vizor_2d 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,144 @@
1
+ # vizor_2d
2
+
3
+
4
+ Lib template for the VIZOR ENGINE PLATFORM
5
+
6
+
7
+
8
+ # VIZOR Collaborator instructions
9
+
10
+
11
+ FIRST TIME :
12
+
13
+
14
+ 1. Clone the project:
15
+
16
+ git clone https://github.com/your-username/your-repository.git
17
+
18
+
19
+
20
+ NOTA : Al clonar el template y crear una nueva libreria
21
+ usar rm -rf .git
22
+ para desvincular el proyecto
23
+ y crear otro repositorio en github.
24
+
25
+
26
+
27
+
28
+ 2. Modify:
29
+
30
+ Make your changes in the codebase.
31
+
32
+ 3. Create a local branch:
33
+
34
+ - NOTA : Como nombre del branch se puede usar la versión,
35
+ ejemplo : release-vX.Y.Z
36
+
37
+ Colocar en CHANGELOG.md el detalle de los cambios realizados:
38
+
39
+ ```bash
40
+ git checkout -b feature-branch-name
41
+ ```
42
+
43
+
44
+
45
+ 4. Add and commit changes:
46
+
47
+ git add .
48
+
49
+ git commit -m "Description of the changes"
50
+
51
+ 5. Push the branch:
52
+
53
+ git push origin feature-branch-name
54
+
55
+ 6. Create a pull request on GitHub.
56
+
57
+ 7. Ask the owner to accept and merge
58
+
59
+
60
+
61
+ NEXT STEPS (Continous Development)
62
+
63
+ 1. pull to have the lastest changes
64
+
65
+ git checkout main
66
+ git pull origin main
67
+
68
+
69
+ 2. create a new branch (use a name that clearly comunicate the featur you ar working on)
70
+
71
+ git checkout -b new-feature-branch
72
+
73
+
74
+ 3. Make your changes in the codebase.
75
+
76
+ 4. push the new changes
77
+
78
+ git add .
79
+ git commit -m "Description of changes"
80
+ git push origin new-feature-branch
81
+
82
+
83
+
84
+
85
+ # Managing Versioning
86
+
87
+ Determine the version update type:
88
+ Decide whether the changes constitute a major, minor, or patch update based on the Semantic
89
+
90
+ Versioning guidelines:
91
+
92
+ Major: Incompatible API changes.
93
+ Minor: Backward-compatible functionality.
94
+ Patch: Backward-compatible bug fixes.
95
+
96
+ Update the version number:
97
+ Update the version number in the relevant files (e.g., package.json for Node.js projects) based on the determined version update type.
98
+
99
+ 1. Create a release branch:
100
+
101
+ git checkout main
102
+ git pull origin main
103
+ git checkout -b release-vX.Y.Z
104
+ Update the changelog:
105
+ Document the changes in a CHANGELOG.md file, outlining the new features, bug fixes, and other relevant information for the release.
106
+
107
+ 2. Commit the version update and changelog:
108
+
109
+ git add .
110
+ git commit -m "Bump version to vX.Y.Z and update changelog"
111
+
112
+ 3. Push the release branch:
113
+
114
+ git push origin release-vX.Y.Z
115
+
116
+ 4. Create a pull request for the release branch:
117
+
118
+ 5. Create a pull request to merge the release branch into the main branch.
119
+
120
+ 6. Merge the pull request:
121
+
122
+ Once reviewed and approved, merge the pull request.
123
+
124
+ 7. Tag the release:
125
+
126
+ 8. After merging, create a tag for the new release:
127
+
128
+ git checkout main
129
+ git pull origin main
130
+ git tag -a vX.Y.Z -m "Release version vX.Y.Z"
131
+ git push origin vX.Y.Z
132
+
133
+
134
+ 9. Create a release on GitHub:
135
+
136
+ Go to the GitHub repository, navigate to the "Releases" section, and create a new release using the created tag. Provide the release notes based on the changelog.
137
+
138
+
139
+ By following these steps, you'll maintain a well-organized versioning system, ensuring that the codebase remains structured and that changes are properly documented and released.
140
+
141
+
142
+
143
+
144
+ # vizor_lib_template
@@ -0,0 +1 @@
1
+ (self.webpackChunkvizor_2d=self.webpackChunkvizor_2d||[]).push([[132],{2067:(e,t,r)=>{r.d(t,{Ls:()=>n,_Q:()=>s,mA:()=>a});const n={name:"local-uniform-bit",vertex:{header:"\n\n struct LocalUniforms {\n uTransformMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uRound:f32,\n }\n\n @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "}},s={...n,vertex:{...n.vertex,header:n.vertex.header.replace("group(1)","group(2)")}},a={name:"local-uniform-bit",vertex:{header:"\n\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix = uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "}}},3391:(e,t,r)=>{r.d(t,{R:()=>n,m:()=>s});const n={name:"texture-bit",vertex:{header:"\n\n struct TextureUniforms {\n uTextureMatrix:mat3x3<f32>,\n }\n\n @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;\n ",main:"\n uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n @group(2) @binding(0) var uTexture: texture_2d<f32>;\n @group(2) @binding(1) var uSampler: sampler;\n\n\n ",main:"\n outColor = textureSample(uTexture, uSampler, vUV);\n "}},s={name:"texture-bit",vertex:{header:"\n uniform mat3 uTextureMatrix;\n ",main:"\n uv = (uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n\n\n ",main:"\n outColor = texture(uTexture, vUV);\n "}}},4132:(e,t,r)=>{r.d(t,{WebGLRenderer:()=>rt});var n=r(8507),s=r(9313),a=r(5611),i=r(4459),o=r(4e3),c=r(2067),u=r(6665),l=r(6040),_=r(8475),f=r(5811);class h{contextChange(e){const t=new f.k({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new s.u,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),r=e.limits.maxBatchableTextures,n=(0,a.I)({name:"graphics",bits:[i.a,(0,o.P)(r),c.mA,u.m]});this.shader=new _.M({glProgram:n,resources:{localUniforms:t,batchSamplers:(0,l.n)(r)}})}execute(e,t){const r=t.context,n=r.customShader||this.shader,s=e.renderer,a=s.graphicsContext,{batcher:i,instructions:o}=a.getContextRenderData(r);n.groups[0]=s.globalUniforms.bindGroup,s.state.set(e.state),s.shader.bind(n),s.geometry.bind(i.geometry,n.glProgram);const c=o.instructions;for(let e=0;e<o.instructionSize;e++){const t=c[e];if(t.size){for(let e=0;e<t.textures.count;e++)s.texture.bind(t.textures.textures[e],e);s.geometry.draw(t.topology,t.size,t.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}h.extension={type:[n.Ag.WebGLPipesAdaptor],name:"graphics"};var d=r(3391),m=r(5589),g=r(268);class E{init(){const e=(0,a.I)({name:"mesh",bits:[c.mA,d.m,u.m]});this._shader=new _.M({glProgram:e,resources:{uTexture:m.g.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new s.u}}}})}execute(e,t){const r=e.renderer;let n=t._shader;if(n){if(!n.glProgram)return void(0,g.R)("Mesh shader has no glProgram",t.shader)}else{n=this._shader;const e=t.texture,r=e.source;n.resources.uTexture=r,n.resources.uSampler=r.style,n.resources.textureUniforms.uniforms.uTextureMatrix=e.textureMatrix.mapCoord}n.groups[100]=r.globalUniforms.bindGroup,n.groups[101]=e.localUniformsBindGroup,r.encoder.draw({geometry:t._geometry,shader:n,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}}E.extension={type:[n.Ag.WebGLPipesAdaptor],name:"mesh"};var v=r(7547);class p{constructor(){this._tempState=v.U.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,r){const n=e.renderer,s=this._didUploadHash[r.uid];n.shader.bind(r,s),s||(this._didUploadHash[r.uid]=!0),n.shader.updateUniformGroup(n.globalUniforms.uniformGroup),n.geometry.bind(t,r.glProgram)}execute(e,t){const r=e.renderer;this._tempState.blendMode=t.blendMode,r.state.set(this._tempState);const n=t.textures.textures;for(let e=0;e<t.textures.count;e++)r.texture.bind(n[e],e);r.geometry.draw(t.topology,t.size,t.start)}}p.extension={type:[n.Ag.WebGLPipesAdaptor],name:"batch"};var x=r(800),T=r(381),b=r(5099),R=r(4334),S=r(1132),A=(e=>(e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e))(A||{});class B{constructor(e,t){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=t}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class y{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new R.s({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){const{_gl:t}=this,r=this.getGlBuffer(e);t.bindBuffer(r.type,r.buffer)}bindBufferBase(e,t){const{_gl:r}=this;this._boundBufferBases[t]!==e&&(this._boundBufferBases[t]=e,e._lastBindBaseLocation=t,r.bindBufferBase(r.UNIFORM_BUFFER,t,e.buffer))}nextBindBase(e){this._bindCallId++,this._minBaseLocation=0,e&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(e){let t=this.getLastBindBaseLocation(e);if(t>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,t;let r=0,n=this._nextBindBaseIndex;for(;r<2;){n>=this._maxBindings&&(n=this._minBaseLocation,r++);const e=this._boundBufferBases[n];if(!e||e._lastBindCallId!==this._bindCallId)break;n++}return t=n,this._nextBindBaseIndex=n+1,r>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[t]=null,t)}getLastBindBaseLocation(e){const t=e._lastBindBaseLocation;return this._boundBufferBases[t]===e?t:-1}bindBufferRange(e,t,r,n){const{_gl:s}=this;r||(r=0),t||(t=0),this._boundBufferBases[t]=null,s.bindBufferRange(s.UNIFORM_BUFFER,t||0,e.buffer,256*r,n||256)}updateBuffer(e){const{_gl:t}=this,r=this.getGlBuffer(e);if(e._updateID===r.updateID)return r;r.updateID=e._updateID,t.bindBuffer(r.type,r.buffer);const n=e.data,s=e.descriptor.usage&S.S.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;return n?r.byteLength>=n.byteLength?t.bufferSubData(r.type,0,n,0,e._updateSize/n.BYTES_PER_ELEMENT):(r.byteLength=n.byteLength,t.bufferData(r.type,n,s)):(r.byteLength=e.descriptor.size,t.bufferData(r.type,r.byteLength,s)),r}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,t=!1){const r=e._gpuData[this._renderer.uid];r&&(t||this._gl.deleteBuffer(r.buffer))}createGLBuffer(e){const{_gl:t}=this;let r=A.ARRAY_BUFFER;e.descriptor.usage&S.S.INDEX?r=A.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&S.S.UNIFORM&&(r=A.UNIFORM_BUFFER);const n=new B(t.createBuffer(),r);return e._gpuData[this._renderer.uid]=n,this._managedBuffers.add(e),n}resetState(){this._boundBufferBases=Object.create(null)}}y.extension={type:[n.Ag.WebGLSystem],name:"buffer"};var C=r(1761);const N=class e{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(t){t={...e.defaultOptions,...t};let r=this.multiView=t.multiView;if(t.context&&r&&((0,g.R)("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),this.canvas=r?C.e.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this._renderer.view.canvas,t.context)this.initFromContext(t.context);else{const e=this._renderer.background.alpha<1,r=t.premultipliedAlpha??!0,n=t.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(t.preferWebGLVersion,{alpha:e,premultipliedAlpha:r,antialias:n,stencil:!0,preserveDrawingBuffer:t.preserveDrawingBuffer,powerPreference:t.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView)return void(e!==this.canvas&&(0,g.R)("multiView is disabled, but targetCanvas is not the main canvas"));const{canvas:t}=this;(t.width<e.width||t.height<e.height)&&(t.width=Math.max(e.width,e.width),t.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof C.e.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const t=this._renderer.view.canvas;t.addEventListener("webglcontextlost",this.handleContextLost,!1),t.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,t){let r;const n=this.canvas;if(2===e&&(r=n.getContext("webgl2",t)),!r&&(r=n.getContext("webgl",t),!r))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=r,this.initFromContext(this.gl)}getExtensions(){const{gl:e}=this,t={anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc"),rgtc:e.getExtension("EXT_texture_compression_rgtc"),loseContext:e.getExtension("WEBGL_lose_context")};if(1===this.webGLVersion)this.extensions={...t,drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:e.getExtension("ANGLE_instanced_arrays"),srgb:e.getExtension("EXT_sRGB")};else{this.extensions={...t,colorBufferFloat:e.getExtension("EXT_color_buffer_float")};const r=e.getExtension("WEBGL_provoking_vertex");r&&r.provokingVertexWEBGL(r.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout((()=>{this.gl.isContextLost()&&this.extensions.loseContext?.restoreContext()}),0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),this.extensions.loseContext?.loseContext()}forceContextLoss(){this.extensions.loseContext?.loseContext(),this._contextLossForced=!0}validateContext(e){const t=e.getContextAttributes();t&&!t.stencil&&(0,g.R)("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const r=this.supports,n=2===this.webGLVersion,s=this.extensions;r.uint32Indices=n||!!s.uint32ElementIndex,r.uniformBufferObject=n,r.vertexArrayObject=n||!!s.vertexArrayObject,r.srgbTextures=n||!!s.srgb,r.nonPowOf2wrapping=n,r.nonPowOf2mipmaps=n,r.msaa=n,r.uint32Indices||(0,g.R)("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};N.extension={type:[n.Ag.WebGLSystem],name:"context"},N.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let G=N;var I=r(8306),U=r(7084),D=(e=>(e[e.RGBA=6408]="RGBA",e[e.RGB=6407]="RGB",e[e.RG=33319]="RG",e[e.RED=6403]="RED",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.ALPHA=6406]="ALPHA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e))(D||{}),F=(e=>(e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e))(F||{}),L=(e=>(e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.BYTE=5120]="BYTE",e[e.SHORT=5122]="SHORT",e[e.INT=5124]="INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.HALF_FLOAT=36193]="HALF_FLOAT",e))(L||{});const M={uint8x2:L.UNSIGNED_BYTE,uint8x4:L.UNSIGNED_BYTE,sint8x2:L.BYTE,sint8x4:L.BYTE,unorm8x2:L.UNSIGNED_BYTE,unorm8x4:L.UNSIGNED_BYTE,snorm8x2:L.BYTE,snorm8x4:L.BYTE,uint16x2:L.UNSIGNED_SHORT,uint16x4:L.UNSIGNED_SHORT,sint16x2:L.SHORT,sint16x4:L.SHORT,unorm16x2:L.UNSIGNED_SHORT,unorm16x4:L.UNSIGNED_SHORT,snorm16x2:L.SHORT,snorm16x4:L.SHORT,float16x2:L.HALF_FLOAT,float16x4:L.HALF_FLOAT,float32:L.FLOAT,float32x2:L.FLOAT,float32x3:L.FLOAT,float32x4:L.FLOAT,uint32:L.UNSIGNED_INT,uint32x2:L.UNSIGNED_INT,uint32x3:L.UNSIGNED_INT,uint32x4:L.UNSIGNED_INT,sint32:L.INT,sint32x2:L.INT,sint32x3:L.INT,sint32x4:L.INT};const O={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class P{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class w{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new R.s({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const t=this._renderer.context.extensions.vertexArrayObject;t&&(e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=e=>t.bindVertexArrayOES(e),e.deleteVertexArray=e=>t.deleteVertexArrayOES(e));const r=this._renderer.context.extensions.vertexAttribDivisorANGLE;r&&(e.drawArraysInstanced=(e,t,n,s)=>{r.drawArraysInstancedANGLE(e,t,n,s)},e.drawElementsInstanced=(e,t,n,s,a)=>{r.drawElementsInstancedANGLE(e,t,n,s,a)},e.vertexAttribDivisor=(e,t)=>r.vertexAttribDivisorANGLE(e,t)),this._activeGeometry=null,this._activeVao=null}bind(e,t){const r=this.gl;this._activeGeometry=e;const n=this.getVao(e,t);this._activeVao!==n&&(this._activeVao=n,r.bindVertexArray(n)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,t=this._renderer.buffer;for(let r=0;r<e.buffers.length;r++){const n=e.buffers[r];t.updateBuffer(n)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,t){const r=e.attributes,n=t._attributeData;for(const e in n)if(!r[e])throw new Error(`shader and geometry incompatible, geometry missing the "${e}" attribute`)}getSignature(e,t){const r=e.attributes,n=t._attributeData,s=["g",e.uid];for(const e in r)n[e]&&s.push(e,n[e].location);return s.join("-")}getVao(e,t){return e._gpuData[this._renderer.uid]?.vaoCache[t._key]||this.initGeometryVao(e,t)}initGeometryVao(e,t,r=!0){const n=this._renderer.gl,s=this._renderer.buffer;this._renderer.shader._getProgramData(t),this.checkCompatibility(e,t);const a=this.getSignature(e,t);let i=e._gpuData[this._renderer.uid];i||(i=new P,e._gpuData[this._renderer.uid]=i,this._managedGeometries.add(e));const o=i.vaoCache;let c=o[a];if(c)return o[t._key]=c,c;(0,U.q)(e,t._attributeData);const u=e.buffers;c=n.createVertexArray(),n.bindVertexArray(c);for(let e=0;e<u.length;e++){const t=u[e];s.bind(t)}return this.activateVao(e,t),o[t._key]=c,o[a]=c,n.bindVertexArray(null),c}onGeometryUnload(e,t=!1){const r=e._gpuData[this._renderer.uid];if(!r)return;const n=r.vaoCache;if(!t)for(const e in n)this._activeVao!==n[e]&&this.resetState(),this.gl.deleteVertexArray(n[e])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,t){const r=this._renderer.gl,n=this._renderer.buffer,s=e.attributes;e.indexBuffer&&n.bind(e.indexBuffer);let a=null;for(const e in s){const o=s[e],c=o.buffer,u=n.getGlBuffer(c),l=t._attributeData[e];if(l){a!==u&&(n.bind(c),a=u);const e=l.location;r.enableVertexAttribArray(e);const t=(0,I.m)(o.format),s=(i=o.format,M[i]??M.float32);if("int"===l.format?.substring(1,4)?r.vertexAttribIPointer(e,t.size,s,o.stride,o.offset):r.vertexAttribPointer(e,t.size,s,t.normalised,o.stride,o.offset),o.instance){if(!this.hasInstance)throw new Error("geometry error, GPU Instancing is not supported on this device");{const t=o.divisor??1;r.vertexAttribDivisor(e,t)}}}}var i}draw(e,t,r,n){const{gl:s}=this._renderer,a=this._activeGeometry,i=O[e||a.topology];if(n??(n=a.instanceCount),a.indexBuffer){const e=a.indexBuffer.data.BYTES_PER_ELEMENT,o=2===e?s.UNSIGNED_SHORT:s.UNSIGNED_INT;1!==n?s.drawElementsInstanced(i,t||a.indexBuffer.data.length,o,(r||0)*e,n):s.drawElements(i,t||a.indexBuffer.data.length,o,(r||0)*e)}else 1!==n?s.drawArraysInstanced(i,r||0,t||a.getSize(),n):s.drawArrays(i,r||0,t||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}w.extension={type:[n.Ag.WebGLSystem],name:"geometry"};var H=r(6011),k=r(583),V=r(9113);const X=new H.V({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),W=class e{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(t={}){const{useBackBuffer:r,antialias:n}={...e.defaultOptions,...t};this.useBackBuffer=r,this._antialias=n,this._renderer.context.supports.msaa||((0,g.R)("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=v.U.for2d();const s=new V.M({vertex:"\n attribute vec2 aPosition;\n out vec2 vUv;\n\n void main() {\n gl_Position = vec4(aPosition, 0.0, 1.0);\n\n vUv = (aPosition + 1.0) / 2.0;\n\n // flip dem UVs\n vUv.y = 1.0 - vUv.y;\n }",fragment:"\n in vec2 vUv;\n out vec4 finalColor;\n\n uniform sampler2D uTexture;\n\n void main() {\n finalColor = texture(uTexture, vUv);\n }",name:"big-triangle"});this._bigTriangleShader=new _.M({glProgram:s,resources:{uTexture:m.g.WHITE.source}})}renderStart(e){const t=this._renderer.renderTarget.getRenderTarget(e.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!t.isRoot,this._useBackBufferThisRender){const t=this._renderer.renderTarget.getRenderTarget(e.target);this._targetTexture=t.colorTexture,e.target=this._getBackBufferTexture(t.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const e=this._renderer;e.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(e.renderTarget.bind(this._targetTexture,!1),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,e.encoder.draw({geometry:X,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(e){return this._backBufferTexture=this._backBufferTexture||new m.g({source:new k.v({width:e.width,height:e.height,resolution:e._resolution,antialias:this._antialias})}),this._backBufferTexture.source.resize(e.width,e.height,e._resolution),this._backBufferTexture}destroy(){this._backBufferTexture&&(this._backBufferTexture.destroy(),this._backBufferTexture=null)}};W.extension={type:[n.Ag.WebGLSystem],name:"backBuffer",priority:1},W.defaultOptions={useBackBuffer:!1};let Y=W;class ${constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.gl.colorMask(!!(8&e),!!(4&e),!!(2&e),!!(1&e)))}}$.extension={type:[n.Ag.WebGLSystem],name:"colorMask"};class K{constructor(e){this.commandFinished=Promise.resolve(),this._renderer=e}setGeometry(e,t){this._renderer.geometry.bind(e,t.glProgram)}finishRenderPass(){}draw(e){const t=this._renderer,{geometry:r,shader:n,state:s,skipSync:a,topology:i,size:o,start:c,instanceCount:u}=e;t.shader.bind(n,a),t.geometry.bind(r,t.shader._activeProgram),s&&t.state.set(s),t.geometry.draw(i,o,c,u??r.instanceCount)}destroy(){this._renderer=null}}K.extension={type:[n.Ag.WebGLSystem],name:"encoder"};var z=r(6512);class j{constructor(e){this._renderer=e}contextChange(){const e=this._renderer.gl;this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=(0,z.u)(this.maxTextures,e);const t=2===this._renderer.context.webGLVersion;this.maxUniformBindings=t?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}j.extension={type:[n.Ag.WebGLSystem],name:"limits"};var q=r(1172),Z=r(1957);class Q{constructor(e){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:Z.K.NONE},this._renderTargetStencilState=Object.create(null),e.renderTarget.onRenderTargetChange.add(this)}contextChange(e){this._gl=e,this._comparisonFuncMapping={always:e.ALWAYS,never:e.NEVER,equal:e.EQUAL,"not-equal":e.NOTEQUAL,less:e.LESS,"less-equal":e.LEQUAL,greater:e.GREATER,"greater-equal":e.GEQUAL},this._stencilOpsMapping={keep:e.KEEP,zero:e.ZERO,replace:e.REPLACE,invert:e.INVERT,"increment-clamp":e.INCR,"decrement-clamp":e.DECR,"increment-wrap":e.INCR_WRAP,"decrement-wrap":e.DECR_WRAP},this.resetState()}onRenderTargetChange(e){if(this._activeRenderTarget===e)return;this._activeRenderTarget=e;let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:Z.K.DISABLED,stencilReference:0}),this.setStencilMode(t.stencilMode,t.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=Z.K.NONE,this._stencilCache.stencilReference=0}setStencilMode(e,t){const r=this._renderTargetStencilState[this._activeRenderTarget.uid],n=this._gl,s=q.g[e],a=this._stencilCache;r.stencilMode=e,r.stencilReference=t,e!==Z.K.DISABLED?(this._stencilCache.enabled||(this._stencilCache.enabled=!0,n.enable(n.STENCIL_TEST)),e===a.stencilMode&&a.stencilReference===t||(a.stencilMode=e,a.stencilReference=t,n.stencilFunc(this._comparisonFuncMapping[s.stencilBack.compare],t,255),n.stencilOp(n.KEEP,n.KEEP,this._stencilOpsMapping[s.stencilBack.passOp]))):this._stencilCache.enabled&&(this._stencilCache.enabled=!1,n.disable(n.STENCIL_TEST))}}Q.extension={type:[n.Ag.WebGLSystem],name:"stencil"};var J=r(7047);const ee={f32:4,i32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"vec2<i32>":8,"vec3<i32>":12,"vec4<i32>":16,"mat2x2<f32>":32,"mat3x3<f32>":48,"mat4x4<f32>":64};function te(e){const t=e.map((e=>({data:e,offset:0,size:0})));let r=0,n=0;for(let e=0;e<t.length;e++){const s=t[e];if(r=ee[s.data.type],!r)throw new Error(`Unknown type ${s.data.type}`);s.data.size>1&&(r=Math.max(r,16)*s.data.size);const a=12===r?16:r;s.size=r;const i=n%16;n+=i>0&&16-i<a?(16-i)%16:(r-i%r)%r,s.offset=n,n+=r}return n=16*Math.ceil(n/16),{uboElements:t,size:n}}var re=r(6423),ne=r(1266);function se(e,t){const r=Math.max(ee[e.data.type]/16,1),n=e.data.value.length/e.data.size,s=(4-n%4)%4,a=e.data.type.indexOf("i32")>=0?"dataInt32":"data";return`\n v = uv.${e.data.name};\n offset += ${t};\n\n arrayOffset = offset;\n\n t = 0;\n\n for(var i=0; i < ${e.data.size*r}; i++)\n {\n for(var j = 0; j < ${n}; j++)\n {\n ${a}[arrayOffset++] = v[t++];\n }\n ${0!==s?`arrayOffset += ${s};`:""}\n }\n `}function ae(e){return(0,re.E)(e,"uboStd40",se,ne.g)}class ie extends J.W{constructor(){super({createUboElements:te,generateUboSync:ae})}}ie.extension={type:[n.Ag.WebGLSystem],name:"ubo"};var oe=r(7238),ce=r(9252),ue=r(4884),le=r(1257);class _e{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[]}}class fe{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ce.M}init(e,t){this._renderer=e,this._renderTargetSystem=t,e.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new ce.M;const e=this._renderer.gl;this._drawBuffersCache=[];for(let t=1;t<=16;t++)this._drawBuffersCache[t]=Array.from({length:t},((t,r)=>e.COLOR_ATTACHMENT0+r))}copyToTexture(e,t,r,n,s){const a=this._renderTargetSystem,i=this._renderer,o=a.getGpuRenderTarget(e),c=i.gl;return this.finishRenderPass(e),c.bindFramebuffer(c.FRAMEBUFFER,o.resolveTargetFramebuffer),i.texture.bind(t,0),c.copyTexSubImage2D(c.TEXTURE_2D,0,s.x,s.y,r.x,r.y,n.width,n.height),t}startRenderPass(e,t=!0,r,n,s=0,a=0){const i=this._renderTargetSystem,o=e.colorTexture,c=i.getGpuRenderTarget(e);if(0!==a&&this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(s>0){if(c.msaa)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to mip levels requires WebGL2.")}let u=n.y;e.isRoot&&(u=o.pixelHeight-n.height-n.y),e.colorTextures.forEach((e=>{this._renderer.texture.unbind(e)}));const l=this._renderer.gl;l.bindFramebuffer(l.FRAMEBUFFER,c.framebuffer),e.isRoot||c._attachedMipLevel===s&&c._attachedLayer===a||(e.colorTextures.forEach(((e,t)=>{const r=this._renderer.texture.getGlSource(e);if(r.target===l.TEXTURE_2D){if(0!==a)throw new Error("[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.");l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0+t,l.TEXTURE_2D,r.texture,s)}else if(r.target===l.TEXTURE_2D_ARRAY){if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to 2D array textures requires WebGL2.");l.framebufferTextureLayer(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0+t,r.texture,s,a)}else{if(r.target!==l.TEXTURE_CUBE_MAP)throw new Error("[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.");if(a<0||a>5)throw new Error("[RenderTargetSystem] Cube map layer must be between 0 and 5.");l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0+t,l.TEXTURE_CUBE_MAP_POSITIVE_X+a,r.texture,s)}})),c._attachedMipLevel=s,c._attachedLayer=a),e.colorTextures.length>1&&this._setDrawBuffers(e,l);const _=this._viewPortCache;_.x===n.x&&_.y===u&&_.width===n.width&&_.height===n.height||(_.x=n.x,_.y=u,_.width=n.width,_.height=n.height,l.viewport(n.x,u,n.width,n.height)),c.depthStencilRenderBuffer||!e.stencil&&!e.depth||this._initStencil(c),this.clear(e,t,r)}finishRenderPass(e){const t=this._renderTargetSystem.getGpuRenderTarget(e);if(!t.msaa)return;const r=this._renderer.gl;r.bindFramebuffer(r.FRAMEBUFFER,t.resolveTargetFramebuffer),r.bindFramebuffer(r.READ_FRAMEBUFFER,t.framebuffer),r.blitFramebuffer(0,0,t.width,t.height,0,0,t.width,t.height,r.COLOR_BUFFER_BIT,r.NEAREST),r.bindFramebuffer(r.FRAMEBUFFER,t.framebuffer)}initGpuRenderTarget(e){const t=this._renderer.gl,r=new _e;r._attachedMipLevel=0,r._attachedLayer=0;return e.colorTexture instanceof ue.q?(this._renderer.context.ensureCanvasSize(e.colorTexture.resource),r.framebuffer=null,r):(this._initColor(e,r),t.bindFramebuffer(t.FRAMEBUFFER,null),r)}destroyGpuRenderTarget(e){const t=this._renderer.gl;e.framebuffer&&(t.deleteFramebuffer(e.framebuffer),e.framebuffer=null),e.resolveTargetFramebuffer&&(t.deleteFramebuffer(e.resolveTargetFramebuffer),e.resolveTargetFramebuffer=null),e.depthStencilRenderBuffer&&(t.deleteRenderbuffer(e.depthStencilRenderBuffer),e.depthStencilRenderBuffer=null),e.msaaRenderBuffer.forEach((e=>{t.deleteRenderbuffer(e)})),e.msaaRenderBuffer=null}clear(e,t,r,n,s=0,a=0){if(!t)return;if(0!==a)throw new Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");const i=this._renderTargetSystem;"boolean"==typeof t&&(t=t?le.u.ALL:le.u.NONE);const o=this._renderer.gl;if(t&le.u.COLOR){r??(r=i.defaultClearColor);const e=this._clearColorCache,t=r;e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]||(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],o.clearColor(t[0],t[1],t[2],t[3]))}o.clear(t)}resizeGpuRenderTarget(e){if(e.isRoot)return;const t=this._renderTargetSystem.getGpuRenderTarget(e);this._resizeColor(e,t),(e.stencil||e.depth)&&this._resizeStencil(t)}_initColor(e,t){const r=this._renderer,n=r.gl,s=n.createFramebuffer();t.resolveTargetFramebuffer=s,n.bindFramebuffer(n.FRAMEBUFFER,s),t.width=e.colorTexture.source.pixelWidth,t.height=e.colorTexture.source.pixelHeight;if(e.colorTextures.forEach(((e,s)=>{const a=e.source;a.antialias&&(r.context.supports.msaa?t.msaa=!0:(0,g.R)("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),r.texture.bindSource(a,0);const i=r.texture.getGlSource(a),o=i.texture;if(i.target===n.TEXTURE_2D)n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+s,n.TEXTURE_2D,o,0);else if(i.target===n.TEXTURE_2D_ARRAY){if(r.context.webGLVersion<2)throw new Error("[RenderTargetSystem] TEXTURE_2D_ARRAY requires WebGL2.");n.framebufferTextureLayer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+s,o,0,0)}else{if(i.target!==n.TEXTURE_CUBE_MAP)throw new Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.");n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+s,n.TEXTURE_CUBE_MAP_POSITIVE_X,o,0)}})),t.msaa){const r=n.createFramebuffer();t.framebuffer=r,n.bindFramebuffer(n.FRAMEBUFFER,r),e.colorTextures.forEach(((e,r)=>{const s=n.createRenderbuffer();t.msaaRenderBuffer[r]=s}))}else t.framebuffer=s;this._resizeColor(e,t)}_resizeColor(e,t){const r=e.colorTexture.source;if(t.width=r.pixelWidth,t.height=r.pixelHeight,t._attachedMipLevel=0,t._attachedLayer=0,e.colorTextures.forEach(((e,t)=>{0!==t&&e.source.resize(r.width,r.height,r._resolution)})),t.msaa){const r=this._renderer,n=r.gl,s=t.framebuffer;n.bindFramebuffer(n.FRAMEBUFFER,s),e.colorTextures.forEach(((e,s)=>{const a=e.source;r.texture.bindSource(a,0);const i=r.texture.getGlSource(a).internalFormat,o=t.msaaRenderBuffer[s];n.bindRenderbuffer(n.RENDERBUFFER,o),n.renderbufferStorageMultisample(n.RENDERBUFFER,4,i,a.pixelWidth,a.pixelHeight),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+s,n.RENDERBUFFER,o)}))}}_initStencil(e){if(null===e.framebuffer)return;const t=this._renderer.gl,r=t.createRenderbuffer();e.depthStencilRenderBuffer=r,t.bindRenderbuffer(t.RENDERBUFFER,r),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,r),this._resizeStencil(e)}_resizeStencil(e){const t=this._renderer.gl;t.bindRenderbuffer(t.RENDERBUFFER,e.depthStencilRenderBuffer),e.msaa?t.renderbufferStorageMultisample(t.RENDERBUFFER,4,t.DEPTH24_STENCIL8,e.width,e.height):t.renderbufferStorage(t.RENDERBUFFER,2===this._renderer.context.webGLVersion?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,e.width,e.height)}prerender(e){const t=e.colorTexture.resource;this._renderer.context.multiView&&ue.q.test(t)&&this._renderer.context.ensureCanvasSize(t)}postrender(e){if(this._renderer.context.multiView&&ue.q.test(e.colorTexture.resource)){const t=this._renderer.context.canvas,r=e.colorTexture;r.context2D.drawImage(t,0,r.pixelHeight-t.height)}}_setDrawBuffers(e,t){const r=e.colorTextures.length,n=this._drawBuffersCache[r];if(1===this._renderer.context.webGLVersion){const e=this._renderer.context.extensions.drawBuffers;e?e.drawBuffersWEBGL(n):(0,g.R)("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else t.drawBuffers(n)}}class he extends oe.l{constructor(e){super(e),this.adaptor=new fe,this.adaptor.init(e,this)}}he.extension={type:[n.Ag.WebGLSystem],name:"renderTarget"};var de=r(581);class me{constructor(e,t){this.program=e,this.uniformData=t,this.uniformGroups={},this.uniformDirtyGroups={},this.uniformBlockBindings={}}destroy(){this.uniformData=null,this.uniformGroups=null,this.uniformDirtyGroups=null,this.uniformBlockBindings=null,this.program=null}}function ge(e,t,r){const n=e.createShader(t);return e.shaderSource(n,r),e.compileShader(n),n}function Ee(e){const t=new Array(e);for(let e=0;e<t.length;e++)t[e]=!1;return t}function ve(e,t){switch(e){case"float":case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"vec2":return new Float32Array(2*t);case"vec3":return new Float32Array(3*t);case"vec4":return new Float32Array(4*t);case"ivec2":return new Int32Array(2*t);case"ivec3":return new Int32Array(3*t);case"ivec4":return new Int32Array(4*t);case"uvec2":return new Uint32Array(2*t);case"uvec3":return new Uint32Array(3*t);case"uvec4":return new Uint32Array(4*t);case"bool":return!1;case"bvec2":return Ee(2*t);case"bvec3":return Ee(3*t);case"bvec4":return Ee(4*t);case"mat2":return new Float32Array([1,0,0,1]);case"mat3":return new Float32Array([1,0,0,0,1,0,0,0,1]);case"mat4":return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}return null}let pe=null;const xe={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",UNSIGNED_INT:"uint",UNSIGNED_INT_VEC2:"uvec2",UNSIGNED_INT_VEC3:"uvec3",UNSIGNED_INT_VEC4:"uvec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",INT_SAMPLER_2D:"sampler2D",UNSIGNED_INT_SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray"},Te={float:"float32",vec2:"float32x2",vec3:"float32x3",vec4:"float32x4",int:"sint32",ivec2:"sint32x2",ivec3:"sint32x3",ivec4:"sint32x4",uint:"uint32",uvec2:"uint32x2",uvec3:"uint32x3",uvec4:"uint32x4",bool:"uint32",bvec2:"uint32x2",bvec3:"uint32x3",bvec4:"uint32x4"};function be(e,t){if(!pe){const t=Object.keys(xe);pe={};for(let r=0;r<t.length;++r){const n=t[r];pe[e[n]]=xe[n]}}return pe[t]}function Re(e,t){const r=be(e,t);return Te[r]||"float32"}function Se(e,t){const r=e.getShaderSource(t).split("\n").map(((e,t)=>`${t}: ${e}`)),n=e.getShaderInfoLog(t),s=n.split("\n"),a={},i=s.map((e=>parseFloat(e.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1")))).filter((e=>!(!e||a[e])&&(a[e]=!0,!0))),o=[""];i.forEach((e=>{r[e-1]=`%c${r[e-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")}));const c=r.join("\n");o[0]=c,console.error(n),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}function Ae(e,t){const r=ge(e,e.VERTEX_SHADER,t.vertex),n=ge(e,e.FRAGMENT_SHADER,t.fragment),s=e.createProgram();e.attachShader(s,r),e.attachShader(s,n);const a=t.transformFeedbackVaryings;a&&("function"!=typeof e.transformFeedbackVaryings?(0,g.R)("TransformFeedback is not supported but TransformFeedbackVaryings are given."):e.transformFeedbackVaryings(s,a.names,"separate"===a.bufferMode?e.SEPARATE_ATTRIBS:e.INTERLEAVED_ATTRIBS)),e.linkProgram(s),e.getProgramParameter(s,e.LINK_STATUS)||function(e,t,r,n){e.getProgramParameter(t,e.LINK_STATUS)||(e.getShaderParameter(r,e.COMPILE_STATUS)||Se(e,r),e.getShaderParameter(n,e.COMPILE_STATUS)||Se(e,n),console.error("PixiJS Error: Could not initialize shader."),""!==e.getProgramInfoLog(t)&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",e.getProgramInfoLog(t)))}(e,s,r,n),t._attributeData=function(e,t,r=!1){const n={},s=t.getProgramParameter(e,t.ACTIVE_ATTRIBUTES);for(let r=0;r<s;r++){const s=t.getActiveAttrib(e,r);if(s.name.startsWith("gl_"))continue;const a=Re(t,s.type);n[s.name]={location:0,format:a,stride:(0,I.m)(a).stride,offset:0,instance:!1,start:0}}const a=Object.keys(n);if(r){a.sort(((e,t)=>e>t?1:-1));for(let r=0;r<a.length;r++)n[a[r]].location=r,t.bindAttribLocation(e,r,a[r]);t.linkProgram(e)}else for(let r=0;r<a.length;r++)n[a[r]].location=t.getAttribLocation(e,a[r]);return n}(s,e,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(t.vertex)),t._uniformData=function(e,t){const r={},n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let s=0;s<n;s++){const n=t.getActiveUniform(e,s),a=n.name.replace(/\[.*?\]$/,""),i=!!n.name.match(/\[.*?\]$/),o=be(t,n.type);r[a]={name:a,index:s,type:o,size:n.size,isArray:i,value:ve(o,n.size)}}return r}(s,e),t._uniformBlockData=function(e,t){if(!t.ACTIVE_UNIFORM_BLOCKS)return{};const r={},n=t.getProgramParameter(e,t.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<n;s++){const n=t.getActiveUniformBlockName(e,s),a=t.getUniformBlockIndex(e,n),i=t.getActiveUniformBlockParameter(e,s,t.UNIFORM_BLOCK_DATA_SIZE);r[n]={name:n,index:a,size:i}}return r}(s,e),e.deleteShader(r),e.deleteShader(n);const i={};for(const r in t._uniformData){const n=t._uniformData[r];i[r]={location:e.getUniformLocation(s,r),value:ve(n.type,n.size)}}return new me(s,i)}const Be={textureCount:0,blockIndex:0};class ye{constructor(e){this._activeProgram=null,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._renderer=e}contextChange(e){this._gl=e,this._programDataHash=Object.create(null),this._shaderSyncFunctions=Object.create(null),this._activeProgram=null}bind(e,t){if(this._setProgram(e.glProgram),t)return;Be.textureCount=0,Be.blockIndex=0;let r=this._shaderSyncFunctions[e.glProgram._key];r||(r=this._shaderSyncFunctions[e.glProgram._key]=this._generateShaderSync(e,this)),this._renderer.buffer.nextBindBase(!!e.glProgram.transformFeedbackVaryings),r(this._renderer,e,Be)}updateUniformGroup(e){this._renderer.uniformGroup.updateUniformGroup(e,this._activeProgram,Be)}bindUniformBlock(e,t,r=0){const n=this._renderer.buffer,s=this._getProgramData(this._activeProgram),a=e._bufferResource;a||this._renderer.ubo.updateUniformGroup(e);const i=e.buffer,o=n.updateBuffer(i),c=n.freeLocationForBufferBase(o);if(a){const{offset:t,size:r}=e;0===t&&r===i.data.byteLength?n.bindBufferBase(o,c):n.bindBufferRange(o,c,t)}else n.getLastBindBaseLocation(o)!==c&&n.bindBufferBase(o,c);const u=this._activeProgram._uniformBlockData[t].index;s.uniformBlockBindings[r]!==c&&(s.uniformBlockBindings[r]=c,this._renderer.gl.uniformBlockBinding(s.program,u,c))}_setProgram(e){if(this._activeProgram===e)return;this._activeProgram=e;const t=this._getProgramData(e);this._gl.useProgram(t.program)}_getProgramData(e){return this._programDataHash[e._key]||this._createProgramData(e)}_createProgramData(e){const t=e._key;return this._programDataHash[t]=Ae(this._gl,e),this._programDataHash[t]}destroy(){for(const e of Object.keys(this._programDataHash))this._programDataHash[e].destroy();this._programDataHash=null,this._shaderSyncFunctions=null,this._activeProgram=null,this._renderer=null,this._gl=null}_generateShaderSync(e,t){return function(e,t){const r=[],n=["\n var g = s.groups;\n var sS = r.shader;\n var p = s.glProgram;\n var ugS = r.uniformGroup;\n var resources;\n "];let s=!1,a=0;const i=t._getProgramData(e.glProgram);for(const o in e.groups){const c=e.groups[o];r.push(`\n resources = g[${o}].resources;\n `);for(const u in c.resources){const l=c.resources[u];if(l instanceof f.k)if(l.ubo){const t=e._uniformBindMap[o][Number(u)];r.push(`\n sS.bindUniformBlock(\n resources[${u}],\n '${t}',\n ${e.glProgram._uniformBlockData[t].index}\n );\n `)}else r.push(`\n ugS.updateUniformGroup(resources[${u}], p, sD);\n `);else if(l instanceof de.d){const t=e._uniformBindMap[o][Number(u)];r.push(`\n sS.bindUniformBlock(\n resources[${u}],\n '${t}',\n ${e.glProgram._uniformBlockData[t].index}\n );\n `)}else if(l instanceof k.v){const c=e._uniformBindMap[o][u],l=i.uniformData[c];l&&(s||(s=!0,n.push("\n var tS = r.texture;\n ")),t._gl.uniform1i(l.location,a),r.push(`\n tS.bind(resources[${u}], ${a});\n `),a++)}}}const o=[...n,...r].join("\n");return new Function("r","s","sD",o)}(e,t)}resetState(){this._activeProgram=null}}ye.extension={type:[n.Ag.WebGLSystem],name:"shader"};var Ce=r(8166);const Ne={f32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1f(location, v);\n }","vec2<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2f(location, v[0], v[1]);\n }","vec3<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3f(location, v[0], v[1], v[2]);\n }","vec4<f32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4f(location, v[0], v[1], v[2], v[3]);\n }",i32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1i(location, v);\n }","vec2<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2i(location, v[0], v[1]);\n }","vec3<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3i(location, v[0], v[1], v[2]);\n }","vec4<i32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }",u32:"if (cv !== v) {\n cu.value = v;\n gl.uniform1ui(location, v);\n }","vec2<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2ui(location, v[0], v[1]);\n }","vec3<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3ui(location, v[0], v[1], v[2]);\n }","vec4<u32>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4ui(location, v[0], v[1], v[2], v[3]);\n }",bool:"if (cv !== v) {\n cu.value = v;\n gl.uniform1i(location, v);\n }","vec2<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1]) {\n cv[0] = v[0];\n cv[1] = v[1];\n gl.uniform2i(location, v[0], v[1]);\n }","vec3<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n gl.uniform3i(location, v[0], v[1], v[2]);\n }","vec4<bool>":"if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {\n cv[0] = v[0];\n cv[1] = v[1];\n cv[2] = v[2];\n cv[3] = v[3];\n gl.uniform4i(location, v[0], v[1], v[2], v[3]);\n }","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},Ge={f32:"gl.uniform1fv(location, v);","vec2<f32>":"gl.uniform2fv(location, v);","vec3<f32>":"gl.uniform3fv(location, v);","vec4<f32>":"gl.uniform4fv(location, v);","mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);",i32:"gl.uniform1iv(location, v);","vec2<i32>":"gl.uniform2iv(location, v);","vec3<i32>":"gl.uniform3iv(location, v);","vec4<i32>":"gl.uniform4iv(location, v);",u32:"gl.uniform1iv(location, v);","vec2<u32>":"gl.uniform2iv(location, v);","vec3<u32>":"gl.uniform3iv(location, v);","vec4<u32>":"gl.uniform4iv(location, v);",bool:"gl.uniform1iv(location, v);","vec2<bool>":"gl.uniform2iv(location, v);","vec3<bool>":"gl.uniform3iv(location, v);","vec4<bool>":"gl.uniform4iv(location, v);"};class Ie{constructor(e){this._cache={},this._uniformGroupSyncHash={},this._renderer=e,this.gl=null,this._cache={}}contextChange(e){this.gl=e}updateUniformGroup(e,t,r){const n=this._renderer.shader._getProgramData(t);if(!e.isStatic||e._dirtyId!==n.uniformDirtyGroups[e.uid]){n.uniformDirtyGroups[e.uid]=e._dirtyId;this._getUniformSyncFunction(e,t)(n.uniformData,e.uniforms,this._renderer,r)}}_getUniformSyncFunction(e,t){return this._uniformGroupSyncHash[e._signature]?.[t._key]||this._createUniformSyncFunction(e,t)}_createUniformSyncFunction(e,t){const r=this._uniformGroupSyncHash[e._signature]||(this._uniformGroupSyncHash[e._signature]={}),n=this._getSignature(e,t._uniformData,"u");return this._cache[n]||(this._cache[n]=this._generateUniformsSync(e,t._uniformData)),r[t._key]=this._cache[n],r[t._key]}_generateUniformsSync(e,t){return function(e,t){const r=["\n var v = null;\n var cv = null;\n var cu = null;\n var t = 0;\n var gl = renderer.gl;\n var name = null;\n "];for(const n in e.uniforms){if(!t[n]){e.uniforms[n]instanceof f.k?e.uniforms[n].ubo?r.push(`\n renderer.shader.bindUniformBlock(uv.${n}, "${n}");\n `):r.push(`\n renderer.shader.updateUniformGroup(uv.${n});\n `):e.uniforms[n]instanceof de.d&&r.push(`\n renderer.shader.bindBufferResource(uv.${n}, "${n}");\n `);continue}const s=e.uniformStructures[n];let a=!1;for(let e=0;e<Ce.$.length;e++){const t=Ce.$[e];if(s.type===t.type&&t.test(s)){r.push(`name = "${n}";`,Ce.$[e].uniform),a=!0;break}}if(!a){const e=(1===s.size?Ne:Ge)[s.type].replace("location",`ud["${n}"].location`);r.push(`\n cu = ud["${n}"];\n cv = cu.value;\n v = uv["${n}"];\n ${e};`)}}return new Function("ud","uv","renderer","syncData",r.join("\n"))}(e,t)}_getSignature(e,t,r){const n=e.uniforms,s=[`${r}-`];for(const e in n)s.push(e),t[e]&&s.push(t[e].type);return s.join("-")}destroy(){this._renderer=null,this._cache=null}}Ie.extension={type:[n.Ag.WebGLSystem],name:"uniformGroup"};const Ue=class e{constructor(e){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[0]=this.setBlend,this.map[1]=this.setOffset,this.map[2]=this.setCullFace,this.map[3]=this.setDepthTest,this.map[4]=this.setFrontFace,this.map[5]=this.setDepthMask,this.checks=[],this.defaultState=v.U.for2d(),e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){this._invertFrontFace=!e.isRoot,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(e){this.gl=e,this.blendModesMap=function(e){const t={};if(t.normal=[e.ONE,e.ONE_MINUS_SRC_ALPHA],t.add=[e.ONE,e.ONE],t.multiply=[e.DST_COLOR,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.screen=[e.ONE,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.none=[0,0],t["normal-npm"]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA],t["add-npm"]=[e.SRC_ALPHA,e.ONE,e.ONE,e.ONE],t["screen-npm"]=[e.SRC_ALPHA,e.ONE_MINUS_SRC_COLOR,e.ONE,e.ONE_MINUS_SRC_ALPHA],t.erase=[e.ZERO,e.ONE_MINUS_SRC_ALPHA],e instanceof C.e.get().getWebGLRenderingContext()){const r=e.getExtension("EXT_blend_minmax");r&&(t.min=[e.ONE,e.ONE,e.ONE,e.ONE,r.MIN_EXT,r.MIN_EXT],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,r.MAX_EXT,r.MAX_EXT])}else t.min=[e.ONE,e.ONE,e.ONE,e.ONE,e.MIN,e.MIN],t.max=[e.ONE,e.ONE,e.ONE,e.ONE,e.MAX,e.MAX];return t}(e),this.resetState()}set(e){if(e||(e=this.defaultState),this.stateId!==e.data){let t=this.stateId^e.data,r=0;for(;t;)1&t&&this.map[r].call(this,!!(e.data&1<<r)),t>>=1,r++;this.stateId=e.data}for(let t=0;t<this.checks.length;t++)this.checks[t](this,e)}forceState(e){e||(e=this.defaultState);for(let t=0;t<this.map.length;t++)this.map[t].call(this,!!(e.data&1<<t));for(let t=0;t<this.checks.length;t++)this.checks[t](this,e);this.stateId=e.data}setBlend(t){this._updateCheck(e._checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this._updateCheck(e._checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(e){this.gl[e?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(e){this.gl.depthMask(e)}setCullFace(e){this._cullFace=e,this.gl[e?"enable":"disable"](this.gl.CULL_FACE),this._cullFace&&this._frontFaceDirty&&this.setFrontFace(this._frontFace)}setFrontFace(e){this._frontFace=e,this._frontFaceDirty=!1;const t=this._invertFrontFace?!e:e;this._glFrontFace!==t&&(this._glFrontFace=t,this.gl.frontFace(this.gl[t?"CW":"CCW"]))}setBlendMode(e){if(this.blendModesMap[e]||(e="normal"),e===this.blendMode)return;this.blendMode=e;const t=this.blendModesMap[e],r=this.gl;2===t.length?r.blendFunc(t[0],t[1]):r.blendFuncSeparate(t[0],t[1],t[2],t[3]),6===t.length?(this._blendEq=!0,r.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,r.blendEquationSeparate(r.FUNC_ADD,r.FUNC_ADD))}setPolygonOffset(e,t){this.gl.polygonOffset(e,t)}resetState(){this._glFrontFace=!1,this._frontFace=!1,this._cullFace=!1,this._frontFaceDirty=!1,this._invertFrontFace=!1,this.gl.frontFace(this.gl.CCW),this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode="",this.setBlendMode("normal")}_updateCheck(e,t){const r=this.checks.indexOf(e);t&&-1===r?this.checks.push(e):t||-1===r||this.checks.splice(r,1)}static _checkBlendMode(e,t){e.setBlendMode(t.blendMode)}static _checkPolygonOffset(e,t){e.setPolygonOffset(1,t.polygonOffset)}destroy(){this.gl=null,this.checks.length=0}};Ue.extension={type:[n.Ag.WebGLSystem],name:"state"};let De=Ue;class Fe{constructor(e){this.target=F.TEXTURE_2D,this._layerInitMask=0,this.texture=e,this.width=-1,this.height=-1,this.type=L.UNSIGNED_BYTE,this.internalFormat=D.RGBA,this.format=D.RGBA,this.samplerType=0}destroy(){}}const Le={id:"buffer",upload(e,t,r,n,s,a=!1){const i=s||t.target;a||t.width!==e.width||t.height!==e.height?r.texImage2D(i,0,t.internalFormat,e.width,e.height,0,t.format,t.type,e.resource):r.texSubImage2D(i,0,0,0,e.width,e.height,t.format,t.type,e.resource),t.width=e.width,t.height=e.height}},Me={"bc1-rgba-unorm":!0,"bc1-rgba-unorm-srgb":!0,"bc2-rgba-unorm":!0,"bc2-rgba-unorm-srgb":!0,"bc3-rgba-unorm":!0,"bc3-rgba-unorm-srgb":!0,"bc4-r-unorm":!0,"bc4-r-snorm":!0,"bc5-rg-unorm":!0,"bc5-rg-snorm":!0,"bc6h-rgb-ufloat":!0,"bc6h-rgb-float":!0,"bc7-rgba-unorm":!0,"bc7-rgba-unorm-srgb":!0,"etc2-rgb8unorm":!0,"etc2-rgb8unorm-srgb":!0,"etc2-rgb8a1unorm":!0,"etc2-rgb8a1unorm-srgb":!0,"etc2-rgba8unorm":!0,"etc2-rgba8unorm-srgb":!0,"eac-r11unorm":!0,"eac-r11snorm":!0,"eac-rg11unorm":!0,"eac-rg11snorm":!0,"astc-4x4-unorm":!0,"astc-4x4-unorm-srgb":!0,"astc-5x4-unorm":!0,"astc-5x4-unorm-srgb":!0,"astc-5x5-unorm":!0,"astc-5x5-unorm-srgb":!0,"astc-6x5-unorm":!0,"astc-6x5-unorm-srgb":!0,"astc-6x6-unorm":!0,"astc-6x6-unorm-srgb":!0,"astc-8x5-unorm":!0,"astc-8x5-unorm-srgb":!0,"astc-8x6-unorm":!0,"astc-8x6-unorm-srgb":!0,"astc-8x8-unorm":!0,"astc-8x8-unorm-srgb":!0,"astc-10x5-unorm":!0,"astc-10x5-unorm-srgb":!0,"astc-10x6-unorm":!0,"astc-10x6-unorm-srgb":!0,"astc-10x8-unorm":!0,"astc-10x8-unorm-srgb":!0,"astc-10x10-unorm":!0,"astc-10x10-unorm-srgb":!0,"astc-12x10-unorm":!0,"astc-12x10-unorm-srgb":!0,"astc-12x12-unorm":!0,"astc-12x12-unorm-srgb":!0},Oe={id:"compressed",upload(e,t,r,n,s,a){const i=s??t.target;r.pixelStorei(r.UNPACK_ALIGNMENT,4);let o=e.pixelWidth,c=e.pixelHeight;const u=!!Me[e.format];for(let n=0;n<e.resource.length;n++){const s=e.resource[n];u?r.compressedTexImage2D(i,n,t.internalFormat,o,c,0,s):r.texImage2D(i,n,t.internalFormat,o,c,0,t.format,t.type,s),o=Math.max(o>>1,1),c=Math.max(c>>1,1)}}},Pe=["right","left","top","bottom","front","back"];const we={id:"image",upload(e,t,r,n,s,a=!1){const i=s||t.target,o=e.pixelWidth,c=e.pixelHeight,u=e.resourceWidth,l=e.resourceHeight,_=2===n,f=a||t.width!==o||t.height!==c,h=u>=o&&l>=c;(_?He:ke)(r,i,t,o,c,u,l,e.resource,f,h),t.width=o,t.height=c}};function He(e,t,r,n,s,a,i,o,c,u){if(!u)return c&&e.texImage2D(t,0,r.internalFormat,n,s,0,r.format,r.type,null),void e.texSubImage2D(t,0,0,0,a,i,r.format,r.type,o);c?e.texImage2D(t,0,r.internalFormat,n,s,0,r.format,r.type,o):e.texSubImage2D(t,0,0,0,r.format,r.type,o)}function ke(e,t,r,n,s,a,i,o,c,u){if(!u)return c&&e.texImage2D(t,0,r.internalFormat,n,s,0,r.format,r.type,null),void e.texSubImage2D(t,0,0,0,r.format,r.type,o);c?e.texImage2D(t,0,r.internalFormat,r.format,r.type,o):e.texSubImage2D(t,0,0,0,r.format,r.type,o)}const Ve=function(){const{userAgent:e}=C.e.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(e)}(),Xe={id:"video",upload(e,t,r,n,s,a=Ve){if(e.isValid)we.upload(e,t,r,n,s,a);else{const e=s??t.target;r.texImage2D(e,0,t.internalFormat,1,1,0,t.format,t.type,null)}}},We={linear:9729,nearest:9728},Ye={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},$e={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Ke={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function ze(e,t,r,n,s,a,i,o){const c=a;if(!o||"repeat"!==e.addressModeU||"repeat"!==e.addressModeV||"repeat"!==e.addressModeW){const r=$e[i?"clamp-to-edge":e.addressModeU],n=$e[i?"clamp-to-edge":e.addressModeV],a=$e[i?"clamp-to-edge":e.addressModeW];t[s](c,t.TEXTURE_WRAP_S,r),t[s](c,t.TEXTURE_WRAP_T,n),t.TEXTURE_WRAP_R&&t[s](c,t.TEXTURE_WRAP_R,a)}if(o&&"linear"===e.magFilter||t[s](c,t.TEXTURE_MAG_FILTER,We[e.magFilter]),r){if(!o||"linear"!==e.mipmapFilter){const r=Ye[e.minFilter][e.mipmapFilter];t[s](c,t.TEXTURE_MIN_FILTER,r)}}else t[s](c,t.TEXTURE_MIN_FILTER,We[e.minFilter]);if(n&&e.maxAnisotropy>1){const r=Math.min(e.maxAnisotropy,t.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));t[s](c,n.TEXTURE_MAX_ANISOTROPY_EXT,r)}e.compare&&t[s](c,t.TEXTURE_COMPARE_FUNC,Ke[e.compare])}class je{constructor(e){this._glSamplers=Object.create(null),this._boundTextures=[],this._activeTextureLocation=-1,this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1,this._useSeparateSamplers=!1,this._renderer=e,this._managedTextures=new R.s({renderer:e,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});const t={image:we,buffer:Le,video:Xe,compressed:Oe};var r;this._uploads={...t,cube:(r=t,{id:"cube",upload(e,t,n,s){const a=e.faces;for(let e=0;e<Pe.length;e++){const i=a[Pe[e]];(r[i.uploadMethodId]||r.image).upload(i,t,n,s,F.TEXTURE_CUBE_MAP_POSITIVE_X+e,!(t._layerInitMask&1<<e)),t._layerInitMask|=1<<e}t.width=e.pixelWidth,t.height=e.pixelHeight}})}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gl=e,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=function(e,t){let r={},n=e.RGBA;return e instanceof C.e.get().getWebGLRenderingContext()?t.srgb&&(r={"rgba8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":t.srgb.SRGB8_ALPHA8_EXT}):(r={"rgba8unorm-srgb":e.SRGB8_ALPHA8,"bgra8unorm-srgb":e.SRGB8_ALPHA8},n=e.RGBA8),{r8unorm:e.R8,r8snorm:e.R8_SNORM,r8uint:e.R8UI,r8sint:e.R8I,r16uint:e.R16UI,r16sint:e.R16I,r16float:e.R16F,rg8unorm:e.RG8,rg8snorm:e.RG8_SNORM,rg8uint:e.RG8UI,rg8sint:e.RG8I,r32uint:e.R32UI,r32sint:e.R32I,r32float:e.R32F,rg16uint:e.RG16UI,rg16sint:e.RG16I,rg16float:e.RG16F,rgba8unorm:e.RGBA,...r,rgba8snorm:e.RGBA8_SNORM,rgba8uint:e.RGBA8UI,rgba8sint:e.RGBA8I,bgra8unorm:n,rgb9e5ufloat:e.RGB9_E5,rgb10a2unorm:e.RGB10_A2,rg11b10ufloat:e.R11F_G11F_B10F,rg32uint:e.RG32UI,rg32sint:e.RG32I,rg32float:e.RG32F,rgba16uint:e.RGBA16UI,rgba16sint:e.RGBA16I,rgba16float:e.RGBA16F,rgba32uint:e.RGBA32UI,rgba32sint:e.RGBA32I,rgba32float:e.RGBA32F,stencil8:e.STENCIL_INDEX8,depth16unorm:e.DEPTH_COMPONENT16,depth24plus:e.DEPTH_COMPONENT24,"depth24plus-stencil8":e.DEPTH24_STENCIL8,depth32float:e.DEPTH_COMPONENT32F,"depth32float-stencil8":e.DEPTH32F_STENCIL8,...t.s3tc?{"bc1-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":t.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...t.s3tc_sRGB?{"bc1-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":t.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...t.rgtc?{"bc4-r-unorm":t.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":t.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":t.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":t.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...t.bptc?{"bc6h-rgb-float":t.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":t.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":t.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":t.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...t.etc?{"etc2-rgb8unorm":t.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":t.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":t.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":t.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":t.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":t.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":t.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":t.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...t.astc?{"astc-4x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":t.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":t.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}(e,this._renderer.context.extensions),this._mapFormatToType=function(e){return{r8unorm:e.UNSIGNED_BYTE,r8snorm:e.BYTE,r8uint:e.UNSIGNED_BYTE,r8sint:e.BYTE,r16uint:e.UNSIGNED_SHORT,r16sint:e.SHORT,r16float:e.HALF_FLOAT,rg8unorm:e.UNSIGNED_BYTE,rg8snorm:e.BYTE,rg8uint:e.UNSIGNED_BYTE,rg8sint:e.BYTE,r32uint:e.UNSIGNED_INT,r32sint:e.INT,r32float:e.FLOAT,rg16uint:e.UNSIGNED_SHORT,rg16sint:e.SHORT,rg16float:e.HALF_FLOAT,rgba8unorm:e.UNSIGNED_BYTE,"rgba8unorm-srgb":e.UNSIGNED_BYTE,rgba8snorm:e.BYTE,rgba8uint:e.UNSIGNED_BYTE,rgba8sint:e.BYTE,bgra8unorm:e.UNSIGNED_BYTE,"bgra8unorm-srgb":e.UNSIGNED_BYTE,rgb9e5ufloat:e.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:e.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:e.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:e.UNSIGNED_INT,rg32sint:e.INT,rg32float:e.FLOAT,rgba16uint:e.UNSIGNED_SHORT,rgba16sint:e.SHORT,rgba16float:e.HALF_FLOAT,rgba32uint:e.UNSIGNED_INT,rgba32sint:e.INT,rgba32float:e.FLOAT,stencil8:e.UNSIGNED_BYTE,depth16unorm:e.UNSIGNED_SHORT,depth24plus:e.UNSIGNED_INT,"depth24plus-stencil8":e.UNSIGNED_INT_24_8,depth32float:e.FLOAT,"depth32float-stencil8":e.FLOAT_32_UNSIGNED_INT_24_8_REV}}(e),this._mapFormatToFormat=function(e){return{r8unorm:e.RED,r8snorm:e.RED,r8uint:e.RED,r8sint:e.RED,r16uint:e.RED,r16sint:e.RED,r16float:e.RED,rg8unorm:e.RG,rg8snorm:e.RG,rg8uint:e.RG,rg8sint:e.RG,r32uint:e.RED,r32sint:e.RED,r32float:e.RED,rg16uint:e.RG,rg16sint:e.RG,rg16float:e.RG,rgba8unorm:e.RGBA,"rgba8unorm-srgb":e.RGBA,rgba8snorm:e.RGBA,rgba8uint:e.RGBA,rgba8sint:e.RGBA,bgra8unorm:e.RGBA,"bgra8unorm-srgb":e.RGBA,rgb9e5ufloat:e.RGB,rgb10a2unorm:e.RGBA,rg11b10ufloat:e.RGB,rg32uint:e.RG,rg32sint:e.RG,rg32float:e.RG,rgba16uint:e.RGBA,rgba16sint:e.RGBA,rgba16float:e.RGBA,rgba32uint:e.RGBA,rgba32sint:e.RGBA,rgba32float:e.RGBA,stencil8:e.STENCIL_INDEX8,depth16unorm:e.DEPTH_COMPONENT,depth24plus:e.DEPTH_COMPONENT,"depth24plus-stencil8":e.DEPTH_STENCIL,depth32float:e.DEPTH_COMPONENT,"depth32float-stencil8":e.DEPTH_STENCIL}}(e),this._mapViewDimensionToGlTarget=function(e){return{"2d":e.TEXTURE_2D,cube:e.TEXTURE_CUBE_MAP,"1d":null,"3d":e?.TEXTURE_3D||null,"2d-array":e?.TEXTURE_2D_ARRAY||null,"cube-array":e?.TEXTURE_CUBE_MAP_ARRAY||null}}(e)),this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let e=0;e<16;e++)this.bind(m.g.EMPTY,e)}initSource(e){this.bind(e)}bind(e,t=0){const r=e.source;e?(this.bindSource(r,t),this._useSeparateSamplers&&this._bindSampler(r.style,t)):(this.bindSource(null,t),this._useSeparateSamplers&&this._bindSampler(null,t))}bindSource(e,t=0){const r=this._gl;if(e._gcLastUsed=this._renderer.gc.now,this._boundTextures[t]!==e){this._boundTextures[t]=e,this._activateLocation(t),e||(e=m.g.EMPTY.source);const n=this.getGlSource(e);r.bindTexture(n.target,n.texture)}}_bindSampler(e,t=0){const r=this._gl;if(!e)return this._boundSamplers[t]=null,void r.bindSampler(t,null);const n=this._getGlSampler(e);this._boundSamplers[t]!==n&&(this._boundSamplers[t]=n,r.bindSampler(t,n))}unbind(e){const t=e.source,r=this._boundTextures,n=this._gl;for(let e=0;e<r.length;e++)if(r[e]===t){this._activateLocation(e);const s=this.getGlSource(t);n.bindTexture(s.target,null),r[e]=null}}_activateLocation(e){this._activeTextureLocation!==e&&(this._activeTextureLocation=e,this._gl.activeTexture(this._gl.TEXTURE0+e))}_initSource(e){const t=this._gl,r=new Fe(t.createTexture());if(r.type=this._mapFormatToType[e.format],r.internalFormat=this._mapFormatToInternalFormat[e.format],r.format=this._mapFormatToFormat[e.format],r.target=this._mapViewDimensionToGlTarget[e.viewDimension],null===r.target)throw new Error(`Unsupported view dimension: ${e.viewDimension} with this webgl version: ${this._renderer.context.webGLVersion}`);if("cube"===e.uploadMethodId&&(r.target=t.TEXTURE_CUBE_MAP),e.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||e.isPowerOfTwo)){const t=Math.max(e.width,e.height);e.mipLevelCount=Math.floor(Math.log2(t))+1}e._gpuData[this._renderer.uid]=r;return this._managedTextures.add(e)&&(e.on("update",this.onSourceUpdate,this),e.on("resize",this.onSourceUpdate,this),e.on("styleChange",this.onStyleChange,this),e.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(e),this.updateStyle(e,!1),r}onStyleChange(e){this.updateStyle(e,!1)}updateStyle(e,t){const r=this._gl,n=this.getGlSource(e);r.bindTexture(n.target,n.texture),this._boundTextures[this._activeTextureLocation]=e,ze(e.style,r,e.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",n.target,!this._renderer.context.supports.nonPowOf2wrapping&&!e.isPowerOfTwo,t)}onSourceUnload(e,t=!1){const r=e._gpuData[this._renderer.uid];r&&(t||(this.unbind(e),this._gl.deleteTexture(r.texture)),e.off("update",this.onSourceUpdate,this),e.off("resize",this.onSourceUpdate,this),e.off("styleChange",this.onStyleChange,this),e.off("updateMipmaps",this.onUpdateMipmaps,this))}onSourceUpdate(e){const t=this._gl,r=this.getGlSource(e);t.bindTexture(r.target,r.texture),this._boundTextures[this._activeTextureLocation]=e;const n="premultiply-alpha-on-upload"===e.alphaMode;if(this._premultiplyAlpha!==n&&(this._premultiplyAlpha=n,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,n)),this._uploads[e.uploadMethodId])this._uploads[e.uploadMethodId].upload(e,r,t,this._renderer.context.webGLVersion);else if(r.target===t.TEXTURE_2D)this._initEmptyTexture2D(r,e);else if(r.target===t.TEXTURE_2D_ARRAY)this._initEmptyTexture2DArray(r,e);else{if(r.target!==t.TEXTURE_CUBE_MAP)throw new Error("[GlTextureSystem] Unsupported texture target for empty allocation.");this._initEmptyTextureCube(r,e)}this._applyMipRange(r,e),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e,!1)}onUpdateMipmaps(e,t=!0){t&&this.bindSource(e,0);const r=this.getGlSource(e);this._gl.generateMipmap(r.target)}_initEmptyTexture2D(e,t){const r=this._gl;r.texImage2D(r.TEXTURE_2D,0,e.internalFormat,t.pixelWidth,t.pixelHeight,0,e.format,e.type,null);let n=Math.max(t.pixelWidth>>1,1),s=Math.max(t.pixelHeight>>1,1);for(let a=1;a<t.mipLevelCount;a++)r.texImage2D(r.TEXTURE_2D,a,e.internalFormat,n,s,0,e.format,e.type,null),n=Math.max(n>>1,1),s=Math.max(s>>1,1)}_initEmptyTexture2DArray(e,t){if(2!==this._renderer.context.webGLVersion)throw new Error("[GlTextureSystem] TEXTURE_2D_ARRAY requires WebGL2.");const r=this._gl,n=Math.max(0|t.arrayLayerCount,1);r.texImage3D(r.TEXTURE_2D_ARRAY,0,e.internalFormat,t.pixelWidth,t.pixelHeight,n,0,e.format,e.type,null);let s=Math.max(t.pixelWidth>>1,1),a=Math.max(t.pixelHeight>>1,1);for(let i=1;i<t.mipLevelCount;i++)r.texImage3D(r.TEXTURE_2D_ARRAY,i,e.internalFormat,s,a,n,0,e.format,e.type,null),s=Math.max(s>>1,1),a=Math.max(a>>1,1)}_initEmptyTextureCube(e,t){const r=this._gl;for(let n=0;n<6;n++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,e.internalFormat,t.pixelWidth,t.pixelHeight,0,e.format,e.type,null);let n=Math.max(t.pixelWidth>>1,1),s=Math.max(t.pixelHeight>>1,1);for(let a=1;a<t.mipLevelCount;a++){for(let t=0;t<6;t++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+t,a,e.internalFormat,n,s,0,e.format,e.type,null);n=Math.max(n>>1,1),s=Math.max(s>>1,1)}}_applyMipRange(e,t){if(2!==this._renderer.context.webGLVersion)return;const r=this._gl,n=Math.max((0|t.mipLevelCount)-1,0);r.texParameteri(e.target,r.TEXTURE_BASE_LEVEL,0),r.texParameteri(e.target,r.TEXTURE_MAX_LEVEL,n)}_initSampler(e){const t=this._gl,r=this._gl.createSampler();return this._glSamplers[e._resourceId]=r,ze(e,t,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",r,!1,!0),this._glSamplers[e._resourceId]}_getGlSampler(e){return this._glSamplers[e._resourceId]||this._initSampler(e)}getGlSource(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this._initSource(e)}generateCanvas(e){const{pixels:t,width:r,height:n}=this.getPixels(e),s=C.e.get().createCanvas();s.width=r,s.height=n;const a=s.getContext("2d");if(a){const e=a.createImageData(r,n);e.data.set(t),a.putImageData(e,0,0)}return s}getPixels(e){const t=e.source.resolution,r=e.frame,n=Math.max(Math.round(r.width*t),1),s=Math.max(Math.round(r.height*t),1),a=new Uint8Array(4*n*s),i=this._renderer,o=i.renderTarget.getRenderTarget(e),c=i.renderTarget.getGpuRenderTarget(o),u=i.gl;return u.bindFramebuffer(u.FRAMEBUFFER,c.resolveTargetFramebuffer),u.readPixels(Math.round(r.x*t),Math.round(r.y*t),n,s,u.RGBA,u.UNSIGNED_BYTE,a),{pixels:new Uint8ClampedArray(a.buffer),width:n,height:s}}destroy(){this._managedTextures.destroy(),this._glSamplers=null,this._boundTextures=null,this._boundSamplers=null,this._mapFormatToInternalFormat=null,this._mapFormatToType=null,this._mapFormatToFormat=null,this._uploads=null,this._renderer=null}resetState(){this._activeTextureLocation=-1,this._boundTextures.fill(m.g.EMPTY.source),this._boundSamplers=Object.create(null);const e=this._gl;this._premultiplyAlpha=!1,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}}je.extension={type:[n.Ag.WebGLSystem],name:"texture"};const qe=[...T.i,ie,Y,G,j,y,je,he,w,Ie,ye,K,De,Q,$],Ze=[...T.f],Qe=[p,E,h],Je=[],et=[],tt=[];n.XO.handleByNamedList(n.Ag.WebGLSystem,Je),n.XO.handleByNamedList(n.Ag.WebGLPipes,et),n.XO.handleByNamedList(n.Ag.WebGLPipesAdaptor,tt),n.XO.add(...qe,...Ze,...Qe);class rt extends x.k{constructor(){super({name:"webgl",type:b.W.WEBGL,systems:Je,renderPipes:et,renderPipeAdaptors:tt})}}},7084:(e,t,r)=>{r.d(t,{q:()=>a});var n=r(268),s=r(8306);function a(e,t){for(const r in e.attributes){const s=e.attributes[r],a=t[r];a?(s.format??(s.format=a.format),s.offset??(s.offset=a.offset),s.instance??(s.instance=a.instance)):(0,n.R)(`Attribute ${r} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}!function(e){const{buffers:t,attributes:r}=e,n={},a={};for(const e in t){const r=t[e];n[r.uid]=0,a[r.uid]=0}for(const e in r){const t=r[e];n[t.buffer.uid]+=(0,s.m)(t.format).stride}for(const e in r){const t=r[e];t.stride??(t.stride=n[t.buffer.uid]),t.start??(t.start=a[t.buffer.uid]),a[t.buffer.uid]+=(0,s.m)(t.format).stride}}(e)}},1172:(e,t,r)=>{r.d(t,{g:()=>s});var n=r(1957);const s=[];s[n.K.NONE]=void 0,s[n.K.DISABLED]={stencilWriteMask:0,stencilReadMask:0},s[n.K.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},s[n.K.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},s[n.K.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},s[n.K.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}}},581:(e,t,r)=>{r.d(t,{d:()=>a});var n=r(8875),s=r(133);class a extends n.A{constructor({buffer:e,offset:t,size:r}){super(),this.uid=(0,s.L)("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=(0,s.L)("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=e,this.offset=0|t,this.size=r,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=(0,s.L)("resource"),this.emit("change",this)}destroy(e=!1){this.destroyed=!0,e&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}},7047:(e,t,r)=>{r.d(t,{W:()=>i});var n=r(4577),s=r(949),a=r(1132);class i{constructor(e){this._syncFunctionHash=Object.create(null),this._adaptor=e,this._systemCheck()}_systemCheck(){if(!(0,n.f)())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(e){const t=this.getUniformGroupData(e);e.buffer||(e.buffer=new s.h({data:new Float32Array(t.layout.size/4),usage:a.S.UNIFORM|a.S.COPY_DST}))}getUniformGroupData(e){return this._syncFunctionHash[e._signature]||this._initUniformGroup(e)}_initUniformGroup(e){const t=e._signature;let r=this._syncFunctionHash[t];if(!r){const n=Object.keys(e.uniformStructures).map((t=>e.uniformStructures[t])),s=this._adaptor.createUboElements(n),a=this._generateUboSync(s.uboElements);r=this._syncFunctionHash[t]={layout:s,syncFunction:a}}return this._syncFunctionHash[t]}_generateUboSync(e){return this._adaptor.generateUboSync(e)}syncUniformGroup(e,t,r){const n=this.getUniformGroupData(e);e.buffer||(e.buffer=new s.h({data:new Float32Array(n.layout.size/4),usage:a.S.UNIFORM|a.S.COPY_DST}));let i=null;return t||(t=e.buffer.data,i=e.buffer.dataInt32),r||(r=0),n.syncFunction(e.uniforms,t,i,r),!0}updateUniformGroup(e){if(e.isStatic&&!e._dirtyId)return!1;e._dirtyId=0;const t=this.syncUniformGroup(e);return e.buffer.update(),t}destroy(){this._syncFunctionHash=null}}},6423:(e,t,r)=>{r.d(t,{E:()=>s});var n=r(8166);function s(e,t,r,s){const a=["\n var v = null;\n var v2 = null;\n var t = 0;\n var index = 0;\n var name = null;\n var arrayOffset = null;\n "];let i=0;for(let o=0;o<e.length;o++){const c=e[o],u=c.data.name;let l=!1,_=0;for(let e=0;e<n.$.length;e++){if(n.$[e].test(c.data)){_=c.offset/4,a.push(`name = "${u}";`,`offset += ${_-i};`,n.$[e][t]||n.$[e].ubo),l=!0;break}}if(!l)if(c.data.size>1)_=c.offset/4,a.push(r(c,_-i));else{const e=s[c.data.type];_=c.offset/4,a.push(`\n v = uv.${u};\n offset += ${_-i};\n ${e};\n `)}i=_}const o=a.join("\n");return new Function("uv","data","dataInt32","offset",o)}},1266:(e,t,r)=>{function n(e,t){return`\n for (let i = 0; i < ${e*t}; i++) {\n data[offset + (((i / ${e})|0) * 4) + (i % ${e})] = v[i];\n }\n `}r.d(t,{_:()=>a,g:()=>s});const s={f32:"\n data[offset] = v;",i32:"\n dataInt32[offset] = v;","vec2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];","vec3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];","vec4<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];","vec2<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];","vec3<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];","vec4<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];\n dataInt32[offset + 3] = v[3];","mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 4] = v[2];\n data[offset + 5] = v[3];","mat3x3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 4] = v[3];\n data[offset + 5] = v[4];\n data[offset + 6] = v[5];\n data[offset + 8] = v[6];\n data[offset + 9] = v[7];\n data[offset + 10] = v[8];","mat4x4<f32>":"\n for (let i = 0; i < 16; i++) {\n data[offset + i] = v[i];\n }","mat3x2<f32>":n(3,2),"mat4x2<f32>":n(4,2),"mat2x3<f32>":n(2,3),"mat4x3<f32>":n(4,3),"mat2x4<f32>":n(2,4),"mat3x4<f32>":n(3,4)},a={...s,"mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];\n "}},8166:(e,t,r)=>{r.d(t,{$:()=>n});const n=[{type:"mat3x3<f32>",test:e=>void 0!==e.value.a,ubo:"\n var matrix = uv[name].toArray(true);\n data[offset] = matrix[0];\n data[offset + 1] = matrix[1];\n data[offset + 2] = matrix[2];\n data[offset + 4] = matrix[3];\n data[offset + 5] = matrix[4];\n data[offset + 6] = matrix[5];\n data[offset + 8] = matrix[6];\n data[offset + 9] = matrix[7];\n data[offset + 10] = matrix[8];\n ",uniform:"\n gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));\n "},{type:"vec4<f32>",test:e=>"vec4<f32>"===e.type&&1===e.size&&void 0!==e.value.width,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n data[offset + 2] = v.width;\n data[offset + 3] = v.height;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {\n cv[0] = v.x;\n cv[1] = v.y;\n cv[2] = v.width;\n cv[3] = v.height;\n gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);\n }\n "},{type:"vec2<f32>",test:e=>"vec2<f32>"===e.type&&1===e.size&&void 0!==e.value.x,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y) {\n cv[0] = v.x;\n cv[1] = v.y;\n gl.uniform2f(ud[name].location, v.x, v.y);\n }\n "},{type:"vec4<f32>",test:e=>"vec4<f32>"===e.type&&1===e.size&&void 0!==e.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n data[offset + 3] = v.alpha;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n cv[3] = v.alpha;\n gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);\n }\n "},{type:"vec3<f32>",test:e=>"vec3<f32>"===e.type&&1===e.size&&void 0!==e.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n gl.uniform3f(ud[name].location, v.red, v.green, v.blue);\n }\n "}]}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunkvizor_2d=self.webpackChunkvizor_2d||[]).push([[162],{2162:(e,k,h)=>{h.r(k);h(6312),h(5753),h(3859)}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunkvizor_2d=self.webpackChunkvizor_2d||[]).push([[337],{2067:(e,t,r)=>{r.d(t,{Ls:()=>n,_Q:()=>s,mA:()=>a});const n={name:"local-uniform-bit",vertex:{header:"\n\n struct LocalUniforms {\n uTransformMatrix:mat3x3<f32>,\n uColor:vec4<f32>,\n uRound:f32,\n }\n\n @group(1) @binding(0) var<uniform> localUniforms : LocalUniforms;\n ",main:"\n vColor *= localUniforms.uColor;\n modelMatrix *= localUniforms.uTransformMatrix;\n ",end:"\n if(localUniforms.uRound == 1)\n {\n vPosition = vec4(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);\n }\n "}},s={...n,vertex:{...n.vertex,header:n.vertex.header.replace("group(1)","group(2)")}},a={name:"local-uniform-bit",vertex:{header:"\n\n uniform mat3 uTransformMatrix;\n uniform vec4 uColor;\n uniform float uRound;\n ",main:"\n vColor *= uColor;\n modelMatrix = uTransformMatrix;\n ",end:"\n if(uRound == 1.)\n {\n gl_Position.xy = roundPixels(gl_Position.xy, uResolution);\n }\n "}}},3391:(e,t,r)=>{r.d(t,{R:()=>n,m:()=>s});const n={name:"texture-bit",vertex:{header:"\n\n struct TextureUniforms {\n uTextureMatrix:mat3x3<f32>,\n }\n\n @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;\n ",main:"\n uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n @group(2) @binding(0) var uTexture: texture_2d<f32>;\n @group(2) @binding(1) var uSampler: sampler;\n\n\n ",main:"\n outColor = textureSample(uTexture, uSampler, vUV);\n "}},s={name:"texture-bit",vertex:{header:"\n uniform mat3 uTextureMatrix;\n ",main:"\n uv = (uTextureMatrix * vec3(uv, 1.0)).xy;\n "},fragment:{header:"\n uniform sampler2D uTexture;\n\n\n ",main:"\n outColor = texture(uTexture, vUV);\n "}}},7084:(e,t,r)=>{r.d(t,{q:()=>a});var n=r(268),s=r(8306);function a(e,t){for(const r in e.attributes){const s=e.attributes[r],a=t[r];a?(s.format??(s.format=a.format),s.offset??(s.offset=a.offset),s.instance??(s.instance=a.instance)):(0,n.R)(`Attribute ${r} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}!function(e){const{buffers:t,attributes:r}=e,n={},a={};for(const e in t){const r=t[e];n[r.uid]=0,a[r.uid]=0}for(const e in r){const t=r[e];n[t.buffer.uid]+=(0,s.m)(t.format).stride}for(const e in r){const t=r[e];t.stride??(t.stride=n[t.buffer.uid]),t.start??(t.start=a[t.buffer.uid]),a[t.buffer.uid]+=(0,s.m)(t.format).stride}}(e)}},1337:(e,t,r)=>{r.d(t,{WebGPURenderer:()=>Re});var n=r(8507),s=r(9313),a=r(341),i=r(5611),o=r(4459),u=r(4e3),c=r(2067),d=r(6665),h=r(8475),l=r(5811);class p{constructor(){this._maxTextures=0}contextChange(e){const t=new l.k({uTransformMatrix:{value:new s.u,type:"mat3x3<f32>"},uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uRound:{value:0,type:"f32"}});this._maxTextures=e.limits.maxBatchableTextures;const r=(0,i.v)({name:"graphics",bits:[o.F,(0,u._)(this._maxTextures),c._Q,d.b]});this.shader=new h.M({gpuProgram:r,resources:{localUniforms:t}})}execute(e,t){const r=t.context,n=r.customShader||this.shader,s=e.renderer,i=s.graphicsContext,{batcher:o,instructions:u}=i.getContextRenderData(r),c=s.encoder;c.setGeometry(o.geometry,n.gpuProgram);const d=s.globalUniforms.bindGroup;c.setBindGroup(0,d,n.gpuProgram);const h=s.renderPipes.uniformBatch.getUniformBindGroup(n.resources.localUniforms,!0);c.setBindGroup(2,h,n.gpuProgram);const l=u.instructions;let p=null;for(let t=0;t<u.instructionSize;t++){const r=l[t];if(r.topology!==p&&(p=r.topology,c.setPipelineFromGeometryProgramAndState(o.geometry,n.gpuProgram,e.state,r.topology)),n.groups[1]=r.bindGroup,!r.gpuBindGroup){const e=r.textures;r.bindGroup=(0,a.w)(e.textures,e.count,this._maxTextures),r.gpuBindGroup=s.bindGroup.getBindGroup(r.bindGroup,n.gpuProgram,1)}c.setBindGroup(1,r.bindGroup,n.gpuProgram),c.renderPassEncoder.drawIndexed(r.size,1,r.start)}}destroy(){this.shader.destroy(!0),this.shader=null}}p.extension={type:[n.Ag.WebGPUPipesAdaptor],name:"graphics"};var f=r(3391),m=r(5589),g=r(268);class _{init(){const e=(0,i.v)({name:"mesh",bits:[c.Ls,f.R,d.b]});this._shader=new h.M({gpuProgram:e,resources:{uTexture:m.g.EMPTY._source,uSampler:m.g.EMPTY._source.style,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new s.u}}}})}execute(e,t){const r=e.renderer;let n=t._shader;if(n){if(!n.gpuProgram)return void(0,g.R)("Mesh shader has no gpuProgram",t.shader)}else n=this._shader,n.groups[2]=r.texture.getTextureBindGroup(t.texture);const s=n.gpuProgram;if(s.autoAssignGlobalUniforms&&(n.groups[0]=r.globalUniforms.bindGroup),s.autoAssignLocalUniforms){const t=e.localUniforms;n.groups[1]=r.renderPipes.uniformBatch.getUniformBindGroup(t,!0)}r.encoder.draw({geometry:t._geometry,shader:n,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}}_.extension={type:[n.Ag.WebGPUPipesAdaptor],name:"mesh"};var v=r(7547);const b=v.U.for2d();class x{start(e,t,r){const n=e.renderer,s=n.encoder,a=r.gpuProgram;this._shader=r,this._geometry=t,s.setGeometry(t,a),b.blendMode="normal",n.pipeline.getPipeline(t,a,b);const i=n.globalUniforms.bindGroup;s.resetBindGroup(1),s.setBindGroup(0,i,a)}execute(e,t){const r=this._shader.gpuProgram,n=e.renderer,s=n.encoder;if(!t.bindGroup){const e=t.textures;t.bindGroup=(0,a.w)(e.textures,e.count,n.limits.maxBatchableTextures)}b.blendMode=t.blendMode;const i=n.bindGroup.getBindGroup(t.bindGroup,r,1),o=n.pipeline.getPipeline(this._geometry,r,b,t.topology);t.bindGroup._touch(n.gc.now,n.tick),s.setPipeline(o),s.renderPassEncoder.setBindGroup(1,i),s.renderPassEncoder.drawIndexed(t.size,1,t.start)}}x.extension={type:[n.Ag.WebGPUPipesAdaptor],name:"batch"};var y=r(800),P=r(381),G=r(5099);class T{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,r){e._updateKey();return this._hash[e._key]||this._createBindGroup(e,t,r)}_createBindGroup(e,t,r){const n=this._gpu.device,s=t.layout[r],a=[],i=this._renderer;for(const t in s){const r=e.resources[t]??e.resources[s[t]];let n;if("uniformGroup"===r._resourceType){const e=r;i.ubo.updateUniformGroup(e);const t=e.buffer;n={buffer:i.buffer.getGPUBuffer(t),offset:0,size:t.descriptor.size}}else if("buffer"===r._resourceType){const e=r;n={buffer:i.buffer.getGPUBuffer(e),offset:0,size:e.descriptor.size}}else if("bufferResource"===r._resourceType){const e=r;n={buffer:i.buffer.getGPUBuffer(e.buffer),offset:e.offset,size:e.size}}else if("textureSampler"===r._resourceType){const e=r;n=i.texture.getGpuSampler(e)}else if("textureSource"===r._resourceType){const e=r;n=i.texture.getTextureView(e)}a.push({binding:s[t],resource:n})}const o=i.shader.getProgramData(t).bindGroups[r],u=n.createBindGroup({layout:o,entries:a});return this._hash[e._key]=u,u}destroy(){this._hash=null,this._renderer=null}}T.extension={type:[n.Ag.WebGPUSystem],name:"bindGroup"};var C=r(4334),S=r(133),B=r(6736);class U{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class w{constructor(e){this._renderer=e,this._managedBuffers=new C.s({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(e){this._gpu=e}getGPUBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]?.gpuBuffer||this.createGPUBuffer(e)}updateBuffer(e){const t=this.getGPUBuffer(e),r=e.data;return e._updateID&&r&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,r.buffer,0,(e._updateSize||r.byteLength)+3&-4)),t}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(e){e.off("update",this.updateBuffer,this),e.off("change",this.onBufferChange,this)}createGPUBuffer(e){const t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e._resourceId=(0,S.L)("resource"),e.data&&((0,B.W)(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new U(t),this._managedBuffers.add(e)&&(e.on("update",this.updateBuffer,this),e.on("change",this.onBufferChange,this)),t}onBufferChange(e){this._managedBuffers.remove(e),e._updateID=0,this.createGPUBuffer(e)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}w.extension={type:[n.Ag.WebGPUSystem],name:"buffer"};class M{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}}M.extension={type:[n.Ag.WebGPUSystem],name:"colorMask"};var A=r(1761);class R{constructor(e){this._renderer=e}async init(e){return this._initPromise||(this._initPromise=(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then((e=>{this.gpu=e,this._renderer.runners.contextChange.emit(this.gpu)}))),this._initPromise}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){const t=await A.e.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter((e=>t.features.has(e))),n=await t.requestDevice({requiredFeatures:r});return{adapter:t,device:n}}destroy(){this.gpu=null,this._renderer=null}}R.extension={type:[n.Ag.WebGPUSystem],name:"device"},R.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class E{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise((e=>{this._resolveCommandFinished=e})),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,r,n){const s=this._renderer.pipeline.getPipeline(e,t,r,n);this.setPipeline(s)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;const t=2===e.data.BYTES_PER_ELEMENT?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,r){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.gc.now,this._renderer.tick);const n=this._renderer.bindGroup.getBindGroup(t,r,e);this.renderPassEncoder.setBindGroup(e,n)}setGeometry(e,t){const r=this._renderer.pipeline.getBufferNamesToBind(e,t);for(const t in r)this._setVertexBuffer(parseInt(t,10),e.attributes[r[t]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(const r in e.groups){const n=e.groups[r];t||this._syncBindGroup(n),this.setBindGroup(r,n,e.gpuProgram)}}_syncBindGroup(e){for(const t in e.resources){const r=e.resources[t];r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(e){const{geometry:t,shader:r,state:n,topology:s,size:a,start:i,instanceCount:o,skipSync:u}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,n,s),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,u),t.indexBuffer?this.renderPassEncoder.drawIndexed(a||t.indexBuffer.data.length,o??t.instanceCount,i||0):this.renderPassEncoder.draw(a||t.getSize(),o??t.instanceCount,i||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const e=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1],this._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e);const t=this._boundPipeline,r={...this._boundVertexBuffer},n=this._boundIndexBuffer,s={...this._boundBindGroup};this._clearCache();const a=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(a.x,a.y,a.width,a.height,0,1),this.setPipeline(t);for(const e in r)this._setVertexBuffer(e,r[e]);for(const e in s)this.setBindGroup(e,s[e],null);this._setIndexBuffer(n)}_clearCache(){for(let e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(e){this._gpu=e}}E.extension={type:[n.Ag.WebGPUSystem],name:"encoder",priority:1};class L{constructor(e){this._renderer=e}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}L.extension={type:[n.Ag.WebGPUSystem],name:"limits"};var k=r(1957);class O{constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:k.K.DISABLED,stencilReference:0}),this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){const r=this._renderTargetStencilState[this._activeRenderTarget.uid];r.stencilMode=e,r.stencilReference=t;const n=this._renderer;n.pipeline.setStencilMode(e),n.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}O.extension={type:[n.Ag.WebGPUSystem],name:"stencil"};var z=r(7047);const F={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function I(e){const t=e.map((e=>({data:e,offset:0,size:0})));let r=0;for(let e=0;e<t.length;e++){const n=t[e];let s=F[n.data.type].size;const a=F[n.data.type].align;if(!F[n.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${n.data.type}`);n.data.size>1&&(s=Math.max(s,a)*n.data.size),r=Math.ceil(r/a)*a,n.size=s,n.offset=r,r+=s}return r=16*Math.ceil(r/16),{uboElements:t,size:r}}var D=r(6423),H=r(1266);function W(e,t){const{size:r,align:n}=F[e.data.type],s=(n-r)/4,a=e.data.type.indexOf("i32")>=0?"dataInt32":"data";return`\n v = uv.${e.data.name};\n ${0!==t?`offset += ${t};`:""}\n\n arrayOffset = offset;\n\n t = 0;\n\n for(var i=0; i < ${e.data.size*(r/4)}; i++)\n {\n for(var j = 0; j < ${r/4}; j++)\n {\n ${a}[arrayOffset++] = v[t++];\n }\n ${0!==s?`arrayOffset += ${s};`:""}\n }\n `}function V(e){return(0,D.E)(e,"uboWgsl",W,H._)}class N extends z.W{constructor(){super({createUboElements:I,generateUboSync:V})}}N.extension={type:[n.Ag.WebGPUSystem],name:"ubo"};var K=r(949),j=r(581),$=r(1132);class q{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw new Error("UniformBufferBatch: array is too large: "+4*e);const t=this.byteIndex;let r=t+4*e;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>4*this.data.length)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,t}addGroup(e){const t=this.addEmptyGroup(e.length);for(let r=0;r<e.length;r++)this.data[t/4+r]=e[r];return t}destroy(){this.data=null}}var Y=r(3513);const X=128;class Q{constructor(e){this._bindGroupHash=Object.create(null),this._buffers=[],this._bindGroups=[],this._bufferResources=[],this._renderer=e,this._batchBuffer=new q({minUniformOffsetAlignment:X});for(let e=0;e<2;e++){let t=$.S.UNIFORM|$.S.COPY_DST;0===e&&(t|=$.S.COPY_SRC),this._buffers.push(new K.h({data:this._batchBuffer.data,usage:t}))}}renderEnd(){this._uploadBindGroups(),this._resetBindGroups()}_resetBindGroups(){this._bindGroupHash=Object.create(null),this._batchBuffer.clear()}getUniformBindGroup(e,t){if(!t&&this._bindGroupHash[e.uid])return this._bindGroupHash[e.uid];this._renderer.ubo.ensureUniformGroup(e);const r=e.buffer.data,n=this._batchBuffer.addEmptyGroup(r.length);return this._renderer.ubo.syncUniformGroup(e,this._batchBuffer.data,n/4),this._bindGroupHash[e.uid]=this._getBindGroup(n/X),this._bindGroupHash[e.uid]}getUboResource(e){this._renderer.ubo.updateUniformGroup(e);const t=e.buffer.data,r=this._batchBuffer.addGroup(t);return this._getBufferResource(r/X)}getArrayBindGroup(e){const t=this._batchBuffer.addGroup(e);return this._getBindGroup(t/X)}getArrayBufferResource(e){const t=this._batchBuffer.addGroup(e)/X;return this._getBufferResource(t)}_getBufferResource(e){if(!this._bufferResources[e]){const t=this._buffers[e%2];this._bufferResources[e]=new j.d({buffer:t,offset:256*(e/2|0),size:X})}return this._bufferResources[e]}_getBindGroup(e){if(!this._bindGroups[e]){const t=new Y.T({0:this._getBufferResource(e)});this._bindGroups[e]=t}return this._bindGroups[e]}_uploadBindGroups(){const e=this._renderer.buffer,t=this._buffers[0];t.update(this._batchBuffer.byteIndex),e.updateBuffer(t);const r=this._renderer.gpu.device.createCommandEncoder();for(let n=1;n<this._buffers.length;n++){const s=this._buffers[n];r.copyBufferToBuffer(e.getGPUBuffer(t),X,e.getGPUBuffer(s),0,this._batchBuffer.byteIndex)}this._renderer.gpu.device.queue.submit([r.finish()])}destroy(){for(let e=0;e<this._bindGroups.length;e++)this._bindGroups[e]?.destroy();this._bindGroups=null,this._bindGroupHash=null;for(let e=0;e<this._buffers.length;e++)this._buffers[e].destroy();this._buffers=null;for(let e=0;e<this._bufferResources.length;e++)this._bufferResources[e].destroy();this._bufferResources=null,this._batchBuffer.destroy(),this._renderer=null}}Q.extension={type:[n.Ag.WebGPUPipes],name:"uniformBatch"};var J=r(7084),Z=r(7952),ee=r(1172);const te={"point-list":0,"line-list":1,"line-strip":2,"triangle-list":3,"triangle-strip":4};class re{constructor(e){this._moduleCache=Object.create(null),this._bufferLayoutsCache=Object.create(null),this._bindingNamesCache=Object.create(null),this._pipeCache=Object.create(null),this._pipeStateCaches=Object.create(null),this._colorMask=15,this._multisampleCount=1,this._colorTargetCount=1,this._renderer=e}contextChange(e){this._gpu=e,this.setStencilMode(k.K.DISABLED),this._updatePipeHash()}setMultisampleCount(e){this._multisampleCount!==e&&(this._multisampleCount=e,this._updatePipeHash())}setRenderTarget(e){this._multisampleCount=e.msaaSamples,this._depthStencilAttachment=e.descriptor.depthStencilAttachment?1:0,this._colorTargetCount=e.colorTargetCount,this._updatePipeHash()}setColorMask(e){this._colorMask!==e&&(this._colorMask=e,this._updatePipeHash())}setStencilMode(e){this._stencilMode!==e&&(this._stencilMode=e,this._stencilState=ee.g[e],this._updatePipeHash())}setPipeline(e,t,r,n){const s=this.getPipeline(e,t,r);n.setPipeline(s)}getPipeline(e,t,r,n){e._layoutKey||((0,J.q)(e,t.attributeData),this._generateBufferKey(e)),n||(n=e.topology);const s=function(e,t,r,n,s){return e<<24|t<<16|r<<10|n<<5|s}(e._layoutKey,t._layoutKey,r.data,r._blendModeId,te[n]);return this._pipeCache[s]||(this._pipeCache[s]=this._createPipeline(e,t,r,n)),this._pipeCache[s]}_createPipeline(e,t,r,n){const s=this._gpu.device,a=this._createVertexBufferLayouts(e,t),i=this._renderer.state.getColorTargets(r,this._colorTargetCount),o=this._stencilMode===k.K.RENDERING_MASK_ADD?0:this._colorMask;for(let e=0;e<i.length;e++)i[e].writeMask=o;const u=this._renderer.shader.getProgramData(t).pipeline,c={vertex:{module:this._getModule(t.vertex.source),entryPoint:t.vertex.entryPoint,buffers:a},fragment:{module:this._getModule(t.fragment.source),entryPoint:t.fragment.entryPoint,targets:i},primitive:{topology:n,cullMode:r.cullMode},layout:u,multisample:{count:this._multisampleCount},label:"PIXI Pipeline"};this._depthStencilAttachment&&(c.depthStencil={...this._stencilState,format:"depth24plus-stencil8",depthWriteEnabled:r.depthTest,depthCompare:r.depthTest?"less":"always"});return s.createRenderPipeline(c)}_getModule(e){return this._moduleCache[e]||this._createModule(e)}_createModule(e){const t=this._gpu.device;return this._moduleCache[e]=t.createShaderModule({code:e}),this._moduleCache[e]}_generateBufferKey(e){const t=[];let r=0;const n=Object.keys(e.attributes).sort();for(let s=0;s<n.length;s++){const a=e.attributes[n[s]];t[r++]=a.offset,t[r++]=a.format,t[r++]=a.stride,t[r++]=a.instance}const s=t.join("|");return e._layoutKey=(0,Z.X)(s,"geometry"),e._layoutKey}_generateAttributeLocationsKey(e){const t=[];let r=0;const n=Object.keys(e.attributeData).sort();for(let s=0;s<n.length;s++){const a=e.attributeData[n[s]];t[r++]=a.location}const s=t.join("|");return e._attributeLocationsKey=(0,Z.X)(s,"programAttributes"),e._attributeLocationsKey}getBufferNamesToBind(e,t){const r=e._layoutKey<<16|t._attributeLocationsKey;if(this._bindingNamesCache[r])return this._bindingNamesCache[r];const n=this._createVertexBufferLayouts(e,t),s=Object.create(null),a=t.attributeData;for(let e=0;e<n.length;e++){const t=Object.values(n[e].attributes)[0].shaderLocation;for(const r in a)if(a[r].location===t){s[e]=r;break}}return this._bindingNamesCache[r]=s,s}_createVertexBufferLayouts(e,t){t._attributeLocationsKey||this._generateAttributeLocationsKey(t);const r=e._layoutKey<<16|t._attributeLocationsKey;if(this._bufferLayoutsCache[r])return this._bufferLayoutsCache[r];const n=[];return e.buffers.forEach((r=>{const s={arrayStride:0,stepMode:"vertex",attributes:[]},a=s.attributes;for(const n in t.attributeData){const i=e.attributes[n];1!==(i.divisor??1)&&(0,g.R)(`Attribute ${n} has an invalid divisor value of '${i.divisor}'. WebGPU only supports a divisor value of 1`),i.buffer===r&&(s.arrayStride=i.stride,s.stepMode=i.instance?"instance":"vertex",a.push({shaderLocation:t.attributeData[n].location,offset:i.offset,format:i.format}))}a.length&&n.push(s)})),this._bufferLayoutsCache[r]=n,n}_updatePipeHash(){const e=(t=this._stencilMode,r=this._multisampleCount,n=this._colorMask,s=this._depthStencilAttachment,a=this._colorTargetCount,n<<8|t<<5|s<<3|a<<1|r);var t,r,n,s,a;this._pipeStateCaches[e]||(this._pipeStateCaches[e]=Object.create(null)),this._pipeCache=this._pipeStateCaches[e]}destroy(){this._renderer=null,this._bufferLayoutsCache=null}}re.extension={type:[n.Ag.WebGPUSystem],name:"pipeline"};var ne=r(7238),se=r(1257),ae=r(4884),ie=r(583);class oe{constructor(){this.contexts=[],this.msaaTextures=[],this.msaaSamples=1}}class ue{init(e,t){this._renderer=e,this._renderTargetSystem=t}copyToTexture(e,t,r,n,s){const a=this._renderer,i=this._getGpuColorTexture(e),o=a.texture.getGpuSource(t.source);return a.encoder.commandEncoder.copyTextureToTexture({texture:i,origin:r},{texture:o,origin:s},n),t}startRenderPass(e,t=!0,r,n,s=0,a=0){const i=this._renderTargetSystem.getGpuRenderTarget(e);if(0!==a&&i.msaaTextures?.length)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported with MSAA render targets.");if(s>0&&i.msaaTextures?.length)throw new Error("[RenderTargetSystem] Rendering to mip levels is not supported with MSAA render targets.");const o=this.getDescriptor(e,t,r,s,a);i.descriptor=o,this._renderer.pipeline.setRenderTarget(i),this._renderer.encoder.beginRenderPass(i),this._renderer.encoder.setViewport(n)}finishRenderPass(){this._renderer.encoder.endRenderPass()}_getGpuColorTexture(e){const t=this._renderTargetSystem.getGpuRenderTarget(e);return t.contexts[0]?t.contexts[0].getCurrentTexture():this._renderer.texture.getGpuSource(e.colorTextures[0].source)}getDescriptor(e,t,r,n=0,s=0){"boolean"==typeof t&&(t=t?se.u.ALL:se.u.NONE);const a=this._renderTargetSystem,i=a.getGpuRenderTarget(e),o=e.colorTextures.map(((e,o)=>{const u=i.contexts[o];let c,d;if(u){if(0!==s)throw new Error("[RenderTargetSystem] Rendering to array layers is not supported for canvas targets.");c=u.getCurrentTexture().createView()}else c=this._renderer.texture.getGpuSource(e).createView({dimension:"2d",baseMipLevel:n,mipLevelCount:1,baseArrayLayer:s,arrayLayerCount:1});i.msaaTextures[o]&&(d=c,c=this._renderer.texture.getTextureView(i.msaaTextures[o]));const h=t&se.u.COLOR?"clear":"load";return r??(r=a.defaultClearColor),{view:c,resolveTarget:d,clearValue:r,storeOp:"store",loadOp:h}}));let u;if(!e.stencil&&!e.depth||e.depthStencilTexture||(e.ensureDepthStencilTexture(),e.depthStencilTexture.source.sampleCount=i.msaa?4:1),e.depthStencilTexture){const r=t&se.u.STENCIL?"clear":"load",a=t&se.u.DEPTH?"clear":"load";u={view:this._renderer.texture.getGpuSource(e.depthStencilTexture.source).createView({dimension:"2d",baseMipLevel:n,mipLevelCount:1,baseArrayLayer:s,arrayLayerCount:1}),stencilStoreOp:"store",stencilLoadOp:r,depthClearValue:1,depthLoadOp:a,depthStoreOp:"store"}}return{colorAttachments:o,depthStencilAttachment:u}}clear(e,t=!0,r,n,s=0,a=0){if(!t)return;const{gpu:i,encoder:o}=this._renderer,u=i.device;if(null===o.commandEncoder){const i=u.createCommandEncoder(),o=this.getDescriptor(e,t,r,s,a),c=i.beginRenderPass(o);c.setViewport(n.x,n.y,n.width,n.height,0,1),c.end();const d=i.finish();u.queue.submit([d])}else this.startRenderPass(e,t,r,n,s,a)}initGpuRenderTarget(e){e.isRoot=!0;const t=new oe;return t.colorTargetCount=e.colorTextures.length,e.colorTextures.forEach(((e,r)=>{if(e instanceof ae.q){const n=e.resource.getContext("webgpu"),s=e.transparent?"premultiplied":"opaque";try{n.configure({device:this._renderer.gpu.device,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,format:"bgra8unorm",alphaMode:s})}catch(e){console.error(e)}t.contexts[r]=n}if(t.msaa=e.source.antialias,e.source.antialias){const n=new ie.v({width:0,height:0,sampleCount:4,arrayLayerCount:e.source.arrayLayerCount});t.msaaTextures[r]=n}})),t.msaa&&(t.msaaSamples=4,e.depthStencilTexture&&(e.depthStencilTexture.source.sampleCount=4)),t}destroyGpuRenderTarget(e){e.contexts.forEach((e=>{e.unconfigure()})),e.msaaTextures.forEach((e=>{e.destroy()})),e.msaaTextures.length=0,e.contexts.length=0}ensureDepthStencilTexture(e){const t=this._renderTargetSystem.getGpuRenderTarget(e);e.depthStencilTexture&&t.msaa&&(e.depthStencilTexture.source.sampleCount=4)}resizeGpuRenderTarget(e){const t=this._renderTargetSystem.getGpuRenderTarget(e);t.width=e.width,t.height=e.height,t.msaa&&e.colorTextures.forEach(((e,r)=>{const n=t.msaaTextures[r];n?.resize(e.source.width,e.source.height,e.source._resolution)}))}}class ce extends ne.l{constructor(e){super(e),this.adaptor=new ue,this.adaptor.init(e,this)}}ce.extension={type:[n.Ag.WebGPUSystem],name:"renderTarget"};class de{constructor(){this._gpuProgramData=Object.create(null)}contextChange(e){this._gpu=e}getProgramData(e){return this._gpuProgramData[e._layoutKey]||this._createGPUProgramData(e)}_createGPUProgramData(e){const t=this._gpu.device,r=e.gpuLayout.map((e=>t.createBindGroupLayout({entries:e}))),n={bindGroupLayouts:r};return this._gpuProgramData[e._layoutKey]={bindGroups:r,pipeline:t.createPipelineLayout(n)},this._gpuProgramData[e._layoutKey]}destroy(){this._gpu=null,this._gpuProgramData=null}}de.extension={type:[n.Ag.WebGPUSystem],name:"shader"};const he={normal:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"}},add:{alpha:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one",operation:"add"}},multiply:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"dst",dstFactor:"one-minus-src-alpha",operation:"add"}},screen:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},overlay:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"one",dstFactor:"one-minus-src",operation:"add"}},none:{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"zero",operation:"add"}},"normal-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src-alpha",operation:"add"}},"add-npm":{alpha:{srcFactor:"one",dstFactor:"one",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one",operation:"add"}},"screen-npm":{alpha:{srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"src-alpha",dstFactor:"one-minus-src",operation:"add"}},erase:{alpha:{srcFactor:"zero",dstFactor:"one-minus-src-alpha",operation:"add"},color:{srcFactor:"zero",dstFactor:"one-minus-src",operation:"add"}},min:{alpha:{srcFactor:"one",dstFactor:"one",operation:"min"},color:{srcFactor:"one",dstFactor:"one",operation:"min"}},max:{alpha:{srcFactor:"one",dstFactor:"one",operation:"max"},color:{srcFactor:"one",dstFactor:"one",operation:"max"}}};class le{constructor(){this.defaultState=new v.U,this.defaultState.blend=!0}contextChange(e){this.gpu=e}getColorTargets(e,t){const r=[],n={format:"bgra8unorm",writeMask:0,blend:he[e.blendMode]||he.normal};for(let e=0;e<t;e++)r[e]=n;return r}destroy(){this.gpu=null}}le.extension={type:[n.Ag.WebGPUSystem],name:"state"};var pe=r(9939),fe=r(6083);const me=new class{constructor(e){this._canvasPool=Object.create(null),this.canvasOptions=e||{},this.enableFullScreen=!1}_createCanvasAndContext(e,t){const r=A.e.get().createCanvas();r.width=e,r.height=t;const n=r.getContext("2d");return{canvas:r,context:n}}getOptimalCanvasAndContext(e,t,r=1){e=Math.ceil(e*r-1e-6),t=Math.ceil(t*r-1e-6);const n=((e=(0,pe.U5)(e))<<17)+((t=(0,pe.U5)(t))<<1);this._canvasPool[n]||(this._canvasPool[n]=[]);let s=this._canvasPool[n].pop();return s||(s=this._createCanvasAndContext(e,t)),s}returnCanvasAndContext(e){const t=e.canvas,{width:r,height:n}=t,s=(r<<17)+(n<<1);e.context.resetTransform(),e.context.clearRect(0,0,r,n),this._canvasPool[s].push(e)}clear(){this._canvasPool={}}};fe.L.register(me);const ge={type:"image",upload(e,t,r,n=0){const s=e.resource,a=(0|e.pixelWidth)*(0|e.pixelHeight),i=s.byteLength/a;r.device.queue.writeTexture({texture:t,origin:{x:0,y:0,z:n}},s,{offset:0,rowsPerImage:e.pixelHeight,bytesPerRow:e.pixelWidth*i},{width:e.pixelWidth,height:e.pixelHeight,depthOrArrayLayers:1})}},_e={"bc1-rgba-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"bc2-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc3-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"bc7-rgba-unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"etc1-rgb-unorm":{blockBytes:8,blockWidth:4,blockHeight:4},"etc2-rgba8unorm":{blockBytes:16,blockWidth:4,blockHeight:4},"astc-4x4-unorm":{blockBytes:16,blockWidth:4,blockHeight:4}},ve={blockBytes:4,blockWidth:1,blockHeight:1},be={type:"compressed",upload(e,t,r,n=0){let s=e.pixelWidth,a=e.pixelHeight;const i=_e[e.format]||ve;for(let o=0;o<e.resource.length;o++){const u=e.resource[o],c=Math.ceil(s/i.blockWidth)*i.blockBytes;r.device.queue.writeTexture({texture:t,mipLevel:o,origin:{x:0,y:0,z:n}},u,{offset:0,bytesPerRow:c},{width:Math.ceil(s/i.blockWidth)*i.blockWidth,height:Math.ceil(a/i.blockHeight)*i.blockHeight,depthOrArrayLayers:1}),s=Math.max(s>>1,1),a=Math.max(a>>1,1)}}},xe=["right","left","top","bottom","front","back"];const ye={type:"image",upload(e,t,r,n=0){const s=e.resource;if(!s)return;if(globalThis.HTMLImageElement&&s instanceof HTMLImageElement){const t=A.e.get().createCanvas(s.width,s.height);t.getContext("2d").drawImage(s,0,0,s.width,s.height),e.resource=t,(0,g.R)("ImageSource: Image element passed, converting to canvas and replacing resource.")}const a=Math.min(t.width,e.resourceWidth||e.pixelWidth),i=Math.min(t.height,e.resourceHeight||e.pixelHeight),o="premultiply-alpha-on-upload"===e.alphaMode;r.device.queue.copyExternalImageToTexture({source:s},{texture:t,origin:{x:0,y:0,z:n},premultipliedAlpha:o},{width:a,height:i})}},Pe={type:"video",upload(e,t,r,n){ye.upload(e,t,r,n)}};class Ge{constructor(e){this.device=e,this.sampler=e.createSampler({minFilter:"linear"}),this.pipelines={}}_getMipmapPipeline(e){let t=this.pipelines[e];return t||(this.mipmapShaderModule||(this.mipmapShaderModule=this.device.createShaderModule({code:"\n var<private> pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(\n vec2<f32>(-1.0, -1.0), vec2<f32>(-1.0, 3.0), vec2<f32>(3.0, -1.0));\n\n struct VertexOutput {\n @builtin(position) position : vec4<f32>,\n @location(0) texCoord : vec2<f32>,\n };\n\n @vertex\n fn vertexMain(@builtin(vertex_index) vertexIndex : u32) -> VertexOutput {\n var output : VertexOutput;\n output.texCoord = pos[vertexIndex] * vec2<f32>(0.5, -0.5) + vec2<f32>(0.5);\n output.position = vec4<f32>(pos[vertexIndex], 0.0, 1.0);\n return output;\n }\n\n @group(0) @binding(0) var imgSampler : sampler;\n @group(0) @binding(1) var img : texture_2d<f32>;\n\n @fragment\n fn fragmentMain(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {\n return textureSample(img, imgSampler, texCoord);\n }\n "})),t=this.device.createRenderPipeline({layout:"auto",vertex:{module:this.mipmapShaderModule,entryPoint:"vertexMain"},fragment:{module:this.mipmapShaderModule,entryPoint:"fragmentMain",targets:[{format:e}]}}),this.pipelines[e]=t),t}generateMipmap(e){const t=this._getMipmapPipeline(e.format);if("3d"===e.dimension||"1d"===e.dimension)throw new Error("Generating mipmaps for non-2d textures is currently unsupported!");let r=e;const n=e.depthOrArrayLayers||1,s=e.usage&GPUTextureUsage.RENDER_ATTACHMENT;if(!s){const t={size:{width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:n},format:e.format,usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_SRC|GPUTextureUsage.RENDER_ATTACHMENT,mipLevelCount:e.mipLevelCount-1};r=this.device.createTexture(t)}const a=this.device.createCommandEncoder({}),i=t.getBindGroupLayout(0);for(let o=0;o<n;++o){let n=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:"2d",baseArrayLayer:o,arrayLayerCount:1}),u=s?1:0;for(let s=1;s<e.mipLevelCount;++s){const e=r.createView({baseMipLevel:u++,mipLevelCount:1,dimension:"2d",baseArrayLayer:o,arrayLayerCount:1}),s=a.beginRenderPass({colorAttachments:[{view:e,storeOp:"store",loadOp:"clear",clearValue:{r:0,g:0,b:0,a:0}}]}),c=this.device.createBindGroup({layout:i,entries:[{binding:0,resource:this.sampler},{binding:1,resource:n}]});s.setPipeline(t),s.setBindGroup(0,c),s.draw(3,1,0,0),s.end(),n=e}}if(!s){const t={width:Math.ceil(e.width/2),height:Math.ceil(e.height/2),depthOrArrayLayers:n};for(let n=1;n<e.mipLevelCount;++n)a.copyTextureToTexture({texture:r,mipLevel:n-1},{texture:e,mipLevel:n},t),t.width=Math.ceil(t.width/2),t.height=Math.ceil(t.height/2)}return this.device.queue.submit([a.finish()]),s||r.destroy(),e}}class Te{constructor(e){this.textureView=null,this.gpuTexture=e}destroy(){this.gpuTexture.destroy(),this.textureView=null,this.gpuTexture=null}}class Ce{constructor(e){this._gpuSamplers=Object.create(null),this._bindGroupHash=Object.create(null),this._renderer=e,e.gc.addCollection(this,"_bindGroupHash","hash"),this._managedTextures=new C.s({renderer:e,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"gpuTextureSource"});const t={image:ye,buffer:ge,video:Pe,compressed:be};var r;this._uploads={...t,cube:(r=t,{type:"cube",upload(e,t,n){const s=e.faces;for(let e=0;e<xe.length;e++){const a=s[xe[e]];(r[a.uploadMethodId]||r.image).upload(a,t,n,e)}}})}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gpu=e}initSource(e){return e._gpuData[this._renderer.uid]?.gpuTexture||this._initSource(e)}_initSource(e){if(e.autoGenerateMipmaps){const t=Math.max(e.pixelWidth,e.pixelHeight);e.mipLevelCount=Math.floor(Math.log2(t))+1}let t=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST;"compressed"!==e.uploadMethodId&&(t|=GPUTextureUsage.RENDER_ATTACHMENT,t|=GPUTextureUsage.COPY_SRC);const r=_e[e.format]||{blockBytes:4,blockWidth:1,blockHeight:1},n=Math.ceil(e.pixelWidth/r.blockWidth)*r.blockWidth,s=Math.ceil(e.pixelHeight/r.blockHeight)*r.blockHeight,a={label:e.label,size:{width:n,height:s,depthOrArrayLayers:e.arrayLayerCount},format:e.format,sampleCount:e.sampleCount,mipLevelCount:e.mipLevelCount,dimension:e.dimension,usage:t},i=this._gpu.device.createTexture(a);e._gpuData[this._renderer.uid]=new Te(i);return this._managedTextures.add(e)&&(e.on("update",this.onSourceUpdate,this),e.on("resize",this.onSourceResize,this),e.on("updateMipmaps",this.onUpdateMipmaps,this)),this.onSourceUpdate(e),i}onSourceUpdate(e){const t=this.getGpuSource(e);t&&(this._uploads[e.uploadMethodId]&&this._uploads[e.uploadMethodId].upload(e,t,this._gpu),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e))}onUpdateMipmaps(e){this._mipmapGenerator||(this._mipmapGenerator=new Ge(this._gpu.device));const t=this.getGpuSource(e);this._mipmapGenerator.generateMipmap(t)}onSourceUnload(e){e.off("update",this.onSourceUpdate,this),e.off("resize",this.onSourceResize,this),e.off("updateMipmaps",this.onUpdateMipmaps,this)}onSourceResize(e){e._gcLastUsed=this._renderer.gc.now;const t=e._gpuData[this._renderer.uid],r=t?.gpuTexture;r?r.width===e.pixelWidth&&r.height===e.pixelHeight||(t.destroy(),this._bindGroupHash[e.uid]=null,e._gpuData[this._renderer.uid]=null,this.initSource(e)):this.initSource(e)}_initSampler(e){return this._gpuSamplers[e._resourceId]=this._gpu.device.createSampler(e),this._gpuSamplers[e._resourceId]}getGpuSampler(e){return this._gpuSamplers[e._resourceId]||this._initSampler(e)}getGpuSource(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]?.gpuTexture||this.initSource(e)}getTextureBindGroup(e){return this._bindGroupHash[e.uid]||this._createTextureBindGroup(e)}_createTextureBindGroup(e){const t=e.source;return this._bindGroupHash[e.uid]=new Y.T({0:t,1:t.style,2:new l.k({uTextureMatrix:{type:"mat3x3<f32>",value:e.textureMatrix.mapCoord}})}),this._bindGroupHash[e.uid]}getTextureView(e){const t=e.source;t._gcLastUsed=this._renderer.gc.now;let r=t._gpuData[this._renderer.uid];return r||(this.initSource(t),r=t._gpuData[this._renderer.uid]),r.textureView||(r.textureView=r.gpuTexture.createView({dimension:t.viewDimension})),r.textureView}generateCanvas(e){const t=this._renderer,r=t.gpu.device.createCommandEncoder(),n=A.e.get().createCanvas();n.width=e.source.pixelWidth,n.height=e.source.pixelHeight;const s=n.getContext("webgpu");return s.configure({device:t.gpu.device,usage:GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC,format:A.e.get().getNavigator().gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),r.copyTextureToTexture({texture:t.texture.getGpuSource(e.source),origin:{x:0,y:0}},{texture:s.getCurrentTexture()},{width:n.width,height:n.height}),t.gpu.device.queue.submit([r.finish()]),n}getPixels(e){const t=this.generateCanvas(e),r=me.getOptimalCanvasAndContext(t.width,t.height),n=r.context;n.drawImage(t,0,0);const{width:s,height:a}=t,i=n.getImageData(0,0,s,a),o=new Uint8ClampedArray(i.data.buffer);return me.returnCanvasAndContext(r),{pixels:o,width:s,height:a}}destroy(){this._managedTextures.destroy();for(const e of Object.keys(this._bindGroupHash)){const t=Number(e),r=this._bindGroupHash[t];r?.destroy()}this._renderer=null,this._gpu=null,this._mipmapGenerator=null,this._gpuSamplers=null,this._bindGroupHash=null}}Ce.extension={type:[n.Ag.WebGPUSystem],name:"texture"};const Se=[...P.i,N,E,R,L,w,Ce,ce,de,le,re,M,O,T],Be=[...P.f,Q],Ue=[x,_,p],we=[],Me=[],Ae=[];n.XO.handleByNamedList(n.Ag.WebGPUSystem,we),n.XO.handleByNamedList(n.Ag.WebGPUPipes,Me),n.XO.handleByNamedList(n.Ag.WebGPUPipesAdaptor,Ae),n.XO.add(...Se,...Be,...Ue);class Re extends y.k{constructor(){super({name:"webgpu",type:G.W.WEBGPU,systems:we,renderPipes:Me,renderPipeAdaptors:Ae})}}},1172:(e,t,r)=>{r.d(t,{g:()=>s});var n=r(1957);const s=[];s[n.K.NONE]=void 0,s[n.K.DISABLED]={stencilWriteMask:0,stencilReadMask:0},s[n.K.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},s[n.K.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},s[n.K.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}},s[n.K.INVERSE_MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"not-equal",passOp:"keep"},stencilBack:{compare:"not-equal",passOp:"keep"}}},581:(e,t,r)=>{r.d(t,{d:()=>a});var n=r(8875),s=r(133);class a extends n.A{constructor({buffer:e,offset:t,size:r}){super(),this.uid=(0,s.L)("buffer"),this._resourceType="bufferResource",this._touched=0,this._resourceId=(0,s.L)("resource"),this._bufferResource=!0,this.destroyed=!1,this.buffer=e,this.offset=0|t,this.size=r,this.buffer.on("change",this.onBufferChange,this)}onBufferChange(){this._resourceId=(0,s.L)("resource"),this.emit("change",this)}destroy(e=!1){this.destroyed=!0,e&&this.buffer.destroy(),this.emit("change",this),this.buffer=null,this.removeAllListeners()}}},7047:(e,t,r)=>{r.d(t,{W:()=>i});var n=r(4577),s=r(949),a=r(1132);class i{constructor(e){this._syncFunctionHash=Object.create(null),this._adaptor=e,this._systemCheck()}_systemCheck(){if(!(0,n.f)())throw new Error("Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.")}ensureUniformGroup(e){const t=this.getUniformGroupData(e);e.buffer||(e.buffer=new s.h({data:new Float32Array(t.layout.size/4),usage:a.S.UNIFORM|a.S.COPY_DST}))}getUniformGroupData(e){return this._syncFunctionHash[e._signature]||this._initUniformGroup(e)}_initUniformGroup(e){const t=e._signature;let r=this._syncFunctionHash[t];if(!r){const n=Object.keys(e.uniformStructures).map((t=>e.uniformStructures[t])),s=this._adaptor.createUboElements(n),a=this._generateUboSync(s.uboElements);r=this._syncFunctionHash[t]={layout:s,syncFunction:a}}return this._syncFunctionHash[t]}_generateUboSync(e){return this._adaptor.generateUboSync(e)}syncUniformGroup(e,t,r){const n=this.getUniformGroupData(e);e.buffer||(e.buffer=new s.h({data:new Float32Array(n.layout.size/4),usage:a.S.UNIFORM|a.S.COPY_DST}));let i=null;return t||(t=e.buffer.data,i=e.buffer.dataInt32),r||(r=0),n.syncFunction(e.uniforms,t,i,r),!0}updateUniformGroup(e){if(e.isStatic&&!e._dirtyId)return!1;e._dirtyId=0;const t=this.syncUniformGroup(e);return e.buffer.update(),t}destroy(){this._syncFunctionHash=null}}},6423:(e,t,r)=>{r.d(t,{E:()=>s});var n=r(8166);function s(e,t,r,s){const a=["\n var v = null;\n var v2 = null;\n var t = 0;\n var index = 0;\n var name = null;\n var arrayOffset = null;\n "];let i=0;for(let o=0;o<e.length;o++){const u=e[o],c=u.data.name;let d=!1,h=0;for(let e=0;e<n.$.length;e++){if(n.$[e].test(u.data)){h=u.offset/4,a.push(`name = "${c}";`,`offset += ${h-i};`,n.$[e][t]||n.$[e].ubo),d=!0;break}}if(!d)if(u.data.size>1)h=u.offset/4,a.push(r(u,h-i));else{const e=s[u.data.type];h=u.offset/4,a.push(`\n v = uv.${c};\n offset += ${h-i};\n ${e};\n `)}i=h}const o=a.join("\n");return new Function("uv","data","dataInt32","offset",o)}},1266:(e,t,r)=>{function n(e,t){return`\n for (let i = 0; i < ${e*t}; i++) {\n data[offset + (((i / ${e})|0) * 4) + (i % ${e})] = v[i];\n }\n `}r.d(t,{_:()=>a,g:()=>s});const s={f32:"\n data[offset] = v;",i32:"\n dataInt32[offset] = v;","vec2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];","vec3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];","vec4<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];","vec2<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];","vec3<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];","vec4<i32>":"\n dataInt32[offset] = v[0];\n dataInt32[offset + 1] = v[1];\n dataInt32[offset + 2] = v[2];\n dataInt32[offset + 3] = v[3];","mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 4] = v[2];\n data[offset + 5] = v[3];","mat3x3<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 4] = v[3];\n data[offset + 5] = v[4];\n data[offset + 6] = v[5];\n data[offset + 8] = v[6];\n data[offset + 9] = v[7];\n data[offset + 10] = v[8];","mat4x4<f32>":"\n for (let i = 0; i < 16; i++) {\n data[offset + i] = v[i];\n }","mat3x2<f32>":n(3,2),"mat4x2<f32>":n(4,2),"mat2x3<f32>":n(2,3),"mat4x3<f32>":n(4,3),"mat2x4<f32>":n(2,4),"mat3x4<f32>":n(3,4)},a={...s,"mat2x2<f32>":"\n data[offset] = v[0];\n data[offset + 1] = v[1];\n data[offset + 2] = v[2];\n data[offset + 3] = v[3];\n "}},8166:(e,t,r)=>{r.d(t,{$:()=>n});const n=[{type:"mat3x3<f32>",test:e=>void 0!==e.value.a,ubo:"\n var matrix = uv[name].toArray(true);\n data[offset] = matrix[0];\n data[offset + 1] = matrix[1];\n data[offset + 2] = matrix[2];\n data[offset + 4] = matrix[3];\n data[offset + 5] = matrix[4];\n data[offset + 6] = matrix[5];\n data[offset + 8] = matrix[6];\n data[offset + 9] = matrix[7];\n data[offset + 10] = matrix[8];\n ",uniform:"\n gl.uniformMatrix3fv(ud[name].location, false, uv[name].toArray(true));\n "},{type:"vec4<f32>",test:e=>"vec4<f32>"===e.type&&1===e.size&&void 0!==e.value.width,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n data[offset + 2] = v.width;\n data[offset + 3] = v.height;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y || cv[2] !== v.width || cv[3] !== v.height) {\n cv[0] = v.x;\n cv[1] = v.y;\n cv[2] = v.width;\n cv[3] = v.height;\n gl.uniform4f(ud[name].location, v.x, v.y, v.width, v.height);\n }\n "},{type:"vec2<f32>",test:e=>"vec2<f32>"===e.type&&1===e.size&&void 0!==e.value.x,ubo:"\n v = uv[name];\n data[offset] = v.x;\n data[offset + 1] = v.y;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.x || cv[1] !== v.y) {\n cv[0] = v.x;\n cv[1] = v.y;\n gl.uniform2f(ud[name].location, v.x, v.y);\n }\n "},{type:"vec4<f32>",test:e=>"vec4<f32>"===e.type&&1===e.size&&void 0!==e.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n data[offset + 3] = v.alpha;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue || cv[3] !== v.alpha) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n cv[3] = v.alpha;\n gl.uniform4f(ud[name].location, v.red, v.green, v.blue, v.alpha);\n }\n "},{type:"vec3<f32>",test:e=>"vec3<f32>"===e.type&&1===e.size&&void 0!==e.value.red,ubo:"\n v = uv[name];\n data[offset] = v.red;\n data[offset + 1] = v.green;\n data[offset + 2] = v.blue;\n ",uniform:"\n cv = ud[name].value;\n v = uv[name];\n if (cv[0] !== v.red || cv[1] !== v.green || cv[2] !== v.blue) {\n cv[0] = v.red;\n cv[1] = v.green;\n cv[2] = v.blue;\n gl.uniform3f(ud[name].location, v.red, v.green, v.blue);\n }\n "}]}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunkvizor_2d=self.webpackChunkvizor_2d||[]).push([[397],{8397:(e,t,i)=>{var n=i(8507),s=i(5559),o=i(4458),r=i(7309);class a{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const e=this._canvas.getBoundingClientRect(),t=this._canvas.width,i=this._canvas.height,n=e.width/t*this._renderer.resolution,s=e.height/i*this._renderer.resolution,o=`translate(${e.left}px, ${e.top}px) scale(${n}, ${s})`;o!==this._lastTransform&&(this._domElement.style.transform=o,this._lastTransform=o)},this._domElement=e.domElement,this._renderer=e.renderer,globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas||(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver((e=>{for(const t of e){if(t.target!==this._canvas)continue;const e=this.canvas.width,i=this.canvas.height,n=t.contentRect.width/e*this._renderer.resolution,s=t.contentRect.height/i*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==s)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=s)}})),this._observer.observe(this._canvas)):this._tickerAttached||r.R.shared.add(this.updateTranslation,this,o.d.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&r.R.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}var h=i(5101);class l{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=l.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new h.b,this.page=new h.b,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return!this.manager||this.path&&this.path[this.path.length-1]===this.target||(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,n,s){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var c=/iPhone/i,d=/iPod/i,p=/iPad/i,u=/\biOS-universal(?:.+)Mac\b/i,v=/\bAndroid(?:.+)Mobile\b/i,m=/Android/i,g=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,_=/Silk/i,y=/Windows Phone/i,b=/\bWindows(?:.+)ARM\b/i,E=/BlackBerry/i,f=/BB10/i,T=/Opera Mini/i,P=/\b(CriOS|Chrome)(?:.+)Mobile/i,w=/Mobile(?:.+)Firefox\b/i,M=function(e){return void 0!==e&&"MacIntel"===e.platform&&"number"==typeof e.maxTouchPoints&&e.maxTouchPoints>1&&"undefined"==typeof MSStream};function A(e){var t={userAgent:"",platform:"",maxTouchPoints:0};e||"undefined"==typeof navigator?"string"==typeof e?t.userAgent=e:e&&e.userAgent&&(t={userAgent:e.userAgent,platform:e.platform,maxTouchPoints:e.maxTouchPoints||0}):t={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0};var i=t.userAgent,n=i.split("[FBAN");void 0!==n[1]&&(i=n[0]),void 0!==(n=i.split("Twitter"))[1]&&(i=n[0]);var s=function(e){return function(t){return t.test(e)}}(i),o={apple:{phone:s(c)&&!s(y),ipod:s(d),tablet:!s(c)&&(s(p)||M(t))&&!s(y),universal:s(u),device:(s(c)||s(d)||s(p)||s(u)||M(t))&&!s(y)},amazon:{phone:s(g),tablet:!s(g)&&s(_),device:s(g)||s(_)},android:{phone:!s(y)&&s(g)||!s(y)&&s(v),tablet:!s(y)&&!s(g)&&!s(v)&&(s(_)||s(m)),device:!s(y)&&(s(g)||s(_)||s(v)||s(m))||s(/\bokhttp\b/i)},windows:{phone:s(y),tablet:s(b),device:s(y)||s(b)},other:{blackberry:s(E),blackberry10:s(f),opera:s(T),firefox:s(w),chrome:s(P),device:s(E)||s(f)||s(T)||s(w)||s(P)},any:!1,phone:!1,tablet:!1};return o.any=o.apple.device||o.android.device||o.windows.device||o.other.device,o.phone=o.apple.phone||o.android.phone||o.windows.phone,o.tablet=o.apple.tablet||o.android.tablet||o.windows.tablet,o}const O=(A.default??A)(globalThis.navigator);var D=i(9903);const I=class e{constructor(e,t=O){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const e=document.createElement("button");e.style.width="1px",e.style.height="1px",e.style.position="absolute",e.style.top="-1000px",e.style.left="-1000px",e.style.zIndex=2..toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",(()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()})),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top="0px",this._div.style.left="0px",this._div.style.pointerEvents="none",this._div.style.zIndex=2..toString(),this._canvasObserver=new a({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const t=new MutationObserver((()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())}));t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){if(this._isActive&&!this._isMobileAccessibility){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const e of this._children)e._accessibleDiv?.parentNode&&(e._accessibleDiv.parentNode.removeChild(e._accessibleDiv),e._accessibleDiv=null),e._accessibleActive=!1;for(const e in this._pools){this._pools[e].forEach((e=>{e.parentNode&&e.parentNode.removeChild(e)})),delete this._pools[e]}this._div?.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);const t=e.children;if(t)for(let e=0;e<t.length;e++)this._updateAccessibleObjects(t[e])}init(t){const i={accessibilityOptions:{...e.defaultOptions,...t?.accessibilityOptions||{}}};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount)return;if(this._androidUpdateCount=e+this._androidUpdateFrequency,!(this._renderer.renderingToScreen&&this._renderer.view.canvas||this._isRunningTests))return;const t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const e of this._children)e._renderId===this._renderId&&t.add(this._children.indexOf(e))}for(let e=this._children.length-1;e>=0;e--){const i=this._children[e];if(!t.has(e)){if(i._accessibleDiv&&i._accessibleDiv.parentNode){i._accessibleDiv.parentNode.removeChild(i._accessibleDiv);this._getPool(i.accessibleType).push(i._accessibleDiv),i._accessibleDiv=null}i._accessibleActive=!1,(0,D.d)(this._children,e,1)}}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let e=0;e<this._children.length;e++){const t=this._children[e];if(!t._accessibleActive||!t._accessibleDiv)continue;const i=t._accessibleDiv,n=t.hitArea||t.getBounds().rectangle;if(t.hitArea){const e=t.worldTransform;i.style.left=`${e.tx+n.x*e.a}px`,i.style.top=`${e.ty+n.y*e.d}px`,i.style.width=n.width*e.a+"px",i.style.height=n.height*e.d+"px"}else this._capHitArea(n),i.style.left=`${n.x}px`,i.style.top=`${n.y}px`,i.style.width=`${n.width}px`,i.style.height=`${n.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}_addChild(e){let t=this._getPool(e.accessibleType).pop();t?(t.innerHTML="",t.removeAttribute("title"),t.removeAttribute("aria-label"),t.tabIndex=0):("button"===e.accessibleType?t=document.createElement("button"):(t=document.createElement(e.accessibleType),t.style.cssText="\n color: transparent;\n pointer-events: none;\n padding: 0;\n margin: 0;\n border: 0;\n outline: 0;\n background: transparent;\n box-sizing: border-box;\n user-select: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n ",e.accessibleText&&(t.innerText=e.accessibleText)),t.style.width="100px",t.style.height="100px",t.style.backgroundColor=this.debug?"rgba(255,255,255,0.5)":"transparent",t.style.position="absolute",t.style.zIndex=2..toString(),t.style.borderStyle="none",navigator.userAgent.toLowerCase().includes("chrome")?t.setAttribute("aria-live","off"):t.setAttribute("aria-live","polite"),navigator.userAgent.match(/rv:.*Gecko\//)?t.setAttribute("aria-relevant","additions"):t.setAttribute("aria-relevant","text"),t.addEventListener("click",this._onClick.bind(this)),t.addEventListener("focus",this._onFocus.bind(this)),t.addEventListener("focusout",this._onFocusOut.bind(this))),t.style.pointerEvents=e.accessiblePointerEvents,t.type=e.accessibleType,e.accessibleTitle&&null!==e.accessibleTitle?t.title=e.accessibleTitle:e.accessibleHint&&null!==e.accessibleHint||(t.title=`container ${e.tabIndex}`),e.accessibleHint&&null!==e.accessibleHint&&t.setAttribute("aria-label",e.accessibleHint),e.interactive?t.tabIndex=e.tabIndex:t.tabIndex=0,this.debug&&this._updateDebugHTML(t),e._accessibleActive=!0,e._accessibleDiv=t,t.container=e,this._children.push(e),this._div.appendChild(e._accessibleDiv)}_dispatchEvent(e,t){const{container:i}=e.target,n=this._renderer.events.rootBoundary,s=Object.assign(new l(n),{target:i});n.rootTarget=this._renderer.lastObjectRendered,t.forEach((e=>n.dispatchEvent(s,e)))}_onClick(e){this._dispatchEvent(e,["click","pointertap","tap"])}_onFocus(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","assertive"),this._dispatchEvent(e,["mouseover"])}_onFocusOut(e){e.target.getAttribute("aria-live")||e.target.setAttribute("aria-live","polite"),this._dispatchEvent(e,["mouseout"])}_onKeyDown(e){9===e.keyCode&&this._activateOnTab&&this._activate()}_onMouseMove(e){0===e.movementX&&0===e.movementY||this._deactivate()}destroy(){this._deactivate(),this._destroyTouchHook(),this._canvasObserver?.destroy(),this._canvasObserver=null,this._div=null,this._pools=null,this._children=null,this._renderer=null,this._hookDiv=null,globalThis.removeEventListener("keydown",this._boundOnKeyDown),this._boundOnKeyDown=null,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._boundOnMouseMove=null}setAccessibilityEnabled(e){e?this._activate():this._deactivate()}_getPool(e){return this._pools[e]||(this._pools[e]=[]),this._pools[e]}};I.extension={type:[n.Ag.WebGLSystem,n.Ag.WebGPUSystem],name:"accessibility"},I.defaultOptions={enabledByDefault:!1,debug:!1,activateOnTab:!0,deactivateOnMouseMove:!0};let x=I;n.XO.add(x),n.XO.mixin(s.mc,{accessible:!1,accessibleTitle:null,accessibleHint:null,tabIndex:0,accessibleType:"button",accessibleText:null,accessiblePointerEvents:"auto",accessibleChildren:!0,_accessibleActive:!1,_accessibleDiv:null,_renderId:-1});class k{constructor(e){this._attachedDomElements=[],this._renderer=e,this._renderer.runners.postrender.add(this),this._renderer.runners.init.add(this),this._domElement=document.createElement("div"),this._domElement.style.position="absolute",this._domElement.style.top="0",this._domElement.style.left="0",this._domElement.style.pointerEvents="none",this._domElement.style.zIndex="1000"}init(){this._canvasObserver=new a({domElement:this._domElement,renderer:this._renderer})}addRenderable(e,t){this._attachedDomElements.includes(e)||this._attachedDomElements.push(e)}updateRenderable(e){}validateRenderable(e){return!0}postrender(){const e=this._attachedDomElements;if(0!==e.length){this._canvasObserver.ensureAttached();for(let t=0;t<e.length;t++){const i=e[t],n=i.element;if(!i.parent||i.globalDisplayStatus<7)n?.remove(),e.splice(t,1),t--;else{this._domElement.contains(n)||(n.style.position="absolute",n.style.pointerEvents="auto",this._domElement.appendChild(n));const e=i.worldTransform,t=i._anchor,s=i.width*t.x,o=i.height*t.y;n.style.transformOrigin=`${s}px ${o}px`,n.style.transform=`matrix(${e.a}, ${e.b}, ${e.c}, ${e.d}, ${e.tx-s}, ${e.ty-o})`,n.style.opacity=i.groupAlpha.toString()}}}else this._domElement.remove()}destroy(){this._renderer.runners.postrender.remove(this);for(let e=0;e<this._attachedDomElements.length;e++){const t=this._attachedDomElements[e];t.element?.remove()}this._attachedDomElements.length=0,this._domElement.remove(),this._canvasObserver.destroy(),this._renderer=null}}k.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"dom"},n.XO.add(k);var L=i(8875),B=i(268);const S=new class{constructor(){this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}init(e){this.removeTickerListener(),this.events=e,this.interactionFrequency=10,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}get pauseUpdate(){return this._pauseUpdate}set pauseUpdate(e){this._pauseUpdate=e}addTickerListener(){!this._tickerAdded&&this.domElement&&(r.R.system.add(this._tickerUpdate,this,o.d.INTERACTION),this._tickerAdded=!0)}removeTickerListener(){this._tickerAdded&&(r.R.system.remove(this._tickerUpdate,this),this._tickerAdded=!1)}pointerMoved(){this._didMove=!0}_update(){if(!this.domElement||this._pauseUpdate)return;if(this._didMove)return void(this._didMove=!1);const e=this.events._rootPointerEvent;this.events.supportsTouchEvents&&"touch"===e.pointerType||globalThis.document.dispatchEvent(this.events.supportsPointerEvents?new PointerEvent("pointermove",{clientX:e.clientX,clientY:e.clientY,pointerType:e.pointerType,pointerId:e.pointerId}):new MouseEvent("mousemove",{clientX:e.clientX,clientY:e.clientY}))}_tickerUpdate(e){this._deltaTime+=e.deltaTime,this._deltaTime<this.interactionFrequency||(this._deltaTime=0,this._update())}destroy(){this.removeTickerListener(),this.events=null,this.domElement=null,this._deltaTime=0,this._didMove=!1,this._tickerAdded=!1,this._pauseUpdate=!0}};class C extends l{constructor(){super(...arguments),this.client=new h.b,this.movement=new h.b,this.offset=new h.b,this.global=new h.b,this.screen=new h.b}get clientX(){return this.client.x}get clientY(){return this.client.y}get x(){return this.clientX}get y(){return this.clientY}get movementX(){return this.movement.x}get movementY(){return this.movement.y}get offsetX(){return this.offset.x}get offsetY(){return this.offset.y}get globalX(){return this.global.x}get globalY(){return this.global.y}get screenX(){return this.screen.x}get screenY(){return this.screen.y}getLocalPosition(e,t,i){return e.worldTransform.applyInverse(i||this.global,t)}getModifierState(e){return"getModifierState"in this.nativeEvent&&this.nativeEvent.getModifierState(e)}initMouseEvent(e,t,i,n,s,o,r,a,h,l,c,d,p,u,v){throw new Error("Method not implemented.")}}class R extends C{constructor(){super(...arguments),this.width=0,this.height=0,this.isPrimary=!1}getCoalescedEvents(){return"pointermove"===this.type||"mousemove"===this.type||"touchmove"===this.type?[this]:[]}getPredictedEvents(){throw new Error("getPredictedEvents is not supported!")}}class U extends C{constructor(){super(...arguments),this.DOM_DELTA_PIXEL=0,this.DOM_DELTA_LINE=1,this.DOM_DELTA_PAGE=2}}U.DOM_DELTA_PIXEL=0,U.DOM_DELTA_LINE=1,U.DOM_DELTA_PAGE=2;const X=new h.b,F=new h.b;class Y{constructor(e){this.dispatch=new L.A,this.moveOnAll=!1,this.enableGlobalMoveEvents=!0,this.mappingState={trackingData:{}},this.eventPool=new Map,this._allInteractiveElements=[],this._hitElements=[],this._isPointerMoveEvent=!1,this.rootTarget=e,this.hitPruneFn=this.hitPruneFn.bind(this),this.hitTestFn=this.hitTestFn.bind(this),this.mapPointerDown=this.mapPointerDown.bind(this),this.mapPointerMove=this.mapPointerMove.bind(this),this.mapPointerOut=this.mapPointerOut.bind(this),this.mapPointerOver=this.mapPointerOver.bind(this),this.mapPointerUp=this.mapPointerUp.bind(this),this.mapPointerUpOutside=this.mapPointerUpOutside.bind(this),this.mapWheel=this.mapWheel.bind(this),this.mappingTable={},this.addEventMapping("pointerdown",this.mapPointerDown),this.addEventMapping("pointermove",this.mapPointerMove),this.addEventMapping("pointerout",this.mapPointerOut),this.addEventMapping("pointerleave",this.mapPointerOut),this.addEventMapping("pointerover",this.mapPointerOver),this.addEventMapping("pointerup",this.mapPointerUp),this.addEventMapping("pointerupoutside",this.mapPointerUpOutside),this.addEventMapping("wheel",this.mapWheel)}addEventMapping(e,t){this.mappingTable[e]||(this.mappingTable[e]=[]),this.mappingTable[e].push({fn:t,priority:0}),this.mappingTable[e].sort(((e,t)=>e.priority-t.priority))}dispatchEvent(e,t){e.propagationStopped=!1,e.propagationImmediatelyStopped=!1,this.propagate(e,t),this.dispatch.emit(t||e.type,e)}mapEvent(e){if(!this.rootTarget)return;const t=this.mappingTable[e.type];if(t)for(let i=0,n=t.length;i<n;i++)t[i].fn(e);else(0,B.R)(`[EventBoundary]: Event mapping not defined for ${e.type}`)}hitTest(e,t){S.pauseUpdate=!0;const i=this[this._isPointerMoveEvent&&this.enableGlobalMoveEvents?"hitTestMoveRecursive":"hitTestRecursive"](this.rootTarget,this.rootTarget.eventMode,X.set(e,t),this.hitTestFn,this.hitPruneFn);return i&&i[0]}propagate(e,t){if(!e.target)return;const i=e.composedPath();e.eventPhase=e.CAPTURING_PHASE;for(let n=0,s=i.length-1;n<s;n++)if(e.currentTarget=i[n],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return;if(e.eventPhase=e.AT_TARGET,e.currentTarget=e.target,this.notifyTarget(e,t),!e.propagationStopped&&!e.propagationImmediatelyStopped){e.eventPhase=e.BUBBLING_PHASE;for(let n=i.length-2;n>=0;n--)if(e.currentTarget=i[n],this.notifyTarget(e,t),e.propagationStopped||e.propagationImmediatelyStopped)return}}all(e,t,i=this._allInteractiveElements){if(0===i.length)return;e.eventPhase=e.BUBBLING_PHASE;const n=Array.isArray(t)?t:[t];for(let t=i.length-1;t>=0;t--)n.forEach((n=>{e.currentTarget=i[t],this.notifyTarget(e,n)}))}propagationPath(e){const t=[e];for(let i=0;i<2048&&e!==this.rootTarget&&e.parent;i++){if(!e.parent)throw new Error("Cannot find propagation path to disconnected target");t.push(e.parent),e=e.parent}return t.reverse(),t}hitTestMoveRecursive(e,t,i,n,s,o=!1){let r=!1;if(this._interactivePrune(e))return null;if("dynamic"!==e.eventMode&&"dynamic"!==t||(S.pauseUpdate=!1),e.interactiveChildren&&e.children){const a=e.children;for(let h=a.length-1;h>=0;h--){const l=a[h],c=this.hitTestMoveRecursive(l,this._isInteractive(t)?t:l.eventMode,i,n,s,o||s(e,i));if(c){if(c.length>0&&!c[c.length-1].parent)continue;const t=e.isInteractive();(c.length>0||t)&&(t&&this._allInteractiveElements.push(e),c.push(e)),0===this._hitElements.length&&(this._hitElements=c),r=!0}}}const a=this._isInteractive(t),h=e.isInteractive();return h&&h&&this._allInteractiveElements.push(e),o||this._hitElements.length>0?null:r?this._hitElements:a&&!s(e,i)&&n(e,i)?h?[e]:[]:null}hitTestRecursive(e,t,i,n,s){if(this._interactivePrune(e)||s(e,i))return null;if("dynamic"!==e.eventMode&&"dynamic"!==t||(S.pauseUpdate=!1),e.interactiveChildren&&e.children){const o=e.children,r=i;for(let i=o.length-1;i>=0;i--){const a=o[i],h=this.hitTestRecursive(a,this._isInteractive(t)?t:a.eventMode,r,n,s);if(h){if(h.length>0&&!h[h.length-1].parent)continue;const t=e.isInteractive();return(h.length>0||t)&&h.push(e),h}}}const o=this._isInteractive(t),r=e.isInteractive();return o&&n(e,i)?r?[e]:[]:null}_isInteractive(e){return"static"===e||"dynamic"===e}_interactivePrune(e){return!(e&&e.visible&&e.renderable&&e.measurable)||("none"===e.eventMode||"passive"===e.eventMode&&!e.interactiveChildren)}hitPruneFn(e,t){if(e.hitArea&&(e.worldTransform.applyInverse(t,F),!e.hitArea.contains(F.x,F.y)))return!0;if(e.effects&&e.effects.length)for(let i=0;i<e.effects.length;i++){const n=e.effects[i];if(n.containsPoint){if(!n.containsPoint(t,this.hitTestFn))return!0}}return!1}hitTestFn(e,t){return!!e.hitArea||!!e?.containsPoint&&(e.worldTransform.applyInverse(t,F),e.containsPoint(F))}notifyTarget(e,t){if(!e.currentTarget.isInteractive())return;t??(t=e.type);const i=`on${t}`;e.currentTarget[i]?.(e);const n=e.eventPhase===e.CAPTURING_PHASE||e.eventPhase===e.AT_TARGET?`${t}capture`:t;this._notifyListeners(e,n),e.eventPhase===e.AT_TARGET&&this._notifyListeners(e,t)}mapPointerDown(e){if(!(e instanceof R))return void(0,B.R)("EventBoundary cannot map a non-pointer event as a pointer event");const t=this.createPointerEvent(e);if(this.dispatchEvent(t,"pointerdown"),"touch"===t.pointerType)this.dispatchEvent(t,"touchstart");else if("mouse"===t.pointerType||"pen"===t.pointerType){const e=2===t.button;this.dispatchEvent(t,e?"rightdown":"mousedown")}this.trackingData(e.pointerId).pressTargetsByButton[e.button]=t.composedPath(),this.freeEvent(t)}mapPointerMove(e){if(!(e instanceof R))return void(0,B.R)("EventBoundary cannot map a non-pointer event as a pointer event");this._allInteractiveElements.length=0,this._hitElements.length=0,this._isPointerMoveEvent=!0;const t=this.createPointerEvent(e);this._isPointerMoveEvent=!1;const i="mouse"===t.pointerType||"pen"===t.pointerType,n=this.trackingData(e.pointerId),s=this.findMountedTarget(n.overTargets);if(n.overTargets?.length>0&&s!==t.target){const n="mousemove"===e.type?"mouseout":"pointerout",o=this.createPointerEvent(e,n,s);if(this.dispatchEvent(o,"pointerout"),i&&this.dispatchEvent(o,"mouseout"),!t.composedPath().includes(s)){const n=this.createPointerEvent(e,"pointerleave",s);for(n.eventPhase=n.AT_TARGET;n.target&&!t.composedPath().includes(n.target);)n.currentTarget=n.target,this.notifyTarget(n),i&&this.notifyTarget(n,"mouseleave"),n.target=n.target.parent;this.freeEvent(n)}this.freeEvent(o)}if(s!==t.target){const n="mousemove"===e.type?"mouseover":"pointerover",o=this.clonePointerEvent(t,n);this.dispatchEvent(o,"pointerover"),i&&this.dispatchEvent(o,"mouseover");let r=s?.parent;for(;r&&r!==this.rootTarget.parent&&r!==t.target;)r=r.parent;if(!r||r===this.rootTarget.parent){const e=this.clonePointerEvent(t,"pointerenter");for(e.eventPhase=e.AT_TARGET;e.target&&e.target!==s&&e.target!==this.rootTarget.parent;)e.currentTarget=e.target,this.notifyTarget(e),i&&this.notifyTarget(e,"mouseenter"),e.target=e.target.parent;this.freeEvent(e)}this.freeEvent(o)}const o=[],r=this.enableGlobalMoveEvents??!0;this.moveOnAll?o.push("pointermove"):this.dispatchEvent(t,"pointermove"),r&&o.push("globalpointermove"),"touch"===t.pointerType&&(this.moveOnAll?o.splice(1,0,"touchmove"):this.dispatchEvent(t,"touchmove"),r&&o.push("globaltouchmove")),i&&(this.moveOnAll?o.splice(1,0,"mousemove"):this.dispatchEvent(t,"mousemove"),r&&o.push("globalmousemove"),this.cursor=t.target?.cursor),o.length>0&&this.all(t,o),this._allInteractiveElements.length=0,this._hitElements.length=0,n.overTargets=t.composedPath(),this.freeEvent(t)}mapPointerOver(e){if(!(e instanceof R))return void(0,B.R)("EventBoundary cannot map a non-pointer event as a pointer event");const t=this.trackingData(e.pointerId),i=this.createPointerEvent(e),n="mouse"===i.pointerType||"pen"===i.pointerType;this.dispatchEvent(i,"pointerover"),n&&this.dispatchEvent(i,"mouseover"),"mouse"===i.pointerType&&(this.cursor=i.target?.cursor);const s=this.clonePointerEvent(i,"pointerenter");for(s.eventPhase=s.AT_TARGET;s.target&&s.target!==this.rootTarget.parent;)s.currentTarget=s.target,this.notifyTarget(s),n&&this.notifyTarget(s,"mouseenter"),s.target=s.target.parent;t.overTargets=i.composedPath(),this.freeEvent(i),this.freeEvent(s)}mapPointerOut(e){if(!(e instanceof R))return void(0,B.R)("EventBoundary cannot map a non-pointer event as a pointer event");const t=this.trackingData(e.pointerId);if(t.overTargets){const i="mouse"===e.pointerType||"pen"===e.pointerType,n=this.findMountedTarget(t.overTargets),s=this.createPointerEvent(e,"pointerout",n);this.dispatchEvent(s),i&&this.dispatchEvent(s,"mouseout");const o=this.createPointerEvent(e,"pointerleave",n);for(o.eventPhase=o.AT_TARGET;o.target&&o.target!==this.rootTarget.parent;)o.currentTarget=o.target,this.notifyTarget(o),i&&this.notifyTarget(o,"mouseleave"),o.target=o.target.parent;t.overTargets=null,this.freeEvent(s),this.freeEvent(o)}this.cursor=null}mapPointerUp(e){if(!(e instanceof R))return void(0,B.R)("EventBoundary cannot map a non-pointer event as a pointer event");const t=performance.now(),i=this.createPointerEvent(e);if(this.dispatchEvent(i,"pointerup"),"touch"===i.pointerType)this.dispatchEvent(i,"touchend");else if("mouse"===i.pointerType||"pen"===i.pointerType){const e=2===i.button;this.dispatchEvent(i,e?"rightup":"mouseup")}const n=this.trackingData(e.pointerId),s=this.findMountedTarget(n.pressTargetsByButton[e.button]);let o=s;if(s&&!i.composedPath().includes(s)){let t=s;for(;t&&!i.composedPath().includes(t);){if(i.currentTarget=t,this.notifyTarget(i,"pointerupoutside"),"touch"===i.pointerType)this.notifyTarget(i,"touchendoutside");else if("mouse"===i.pointerType||"pen"===i.pointerType){const e=2===i.button;this.notifyTarget(i,e?"rightupoutside":"mouseupoutside")}t=t.parent}delete n.pressTargetsByButton[e.button],o=t}if(o){const s=this.clonePointerEvent(i,"click");s.target=o,s.path=null,n.clicksByButton[e.button]||(n.clicksByButton[e.button]={clickCount:0,target:s.target,timeStamp:t});const r=n.clicksByButton[e.button];if(r.target===s.target&&t-r.timeStamp<200?++r.clickCount:r.clickCount=1,r.target=s.target,r.timeStamp=t,s.detail=r.clickCount,"mouse"===s.pointerType){const e=2===s.button;this.dispatchEvent(s,e?"rightclick":"click")}else"touch"===s.pointerType&&this.dispatchEvent(s,"tap");this.dispatchEvent(s,"pointertap"),this.freeEvent(s)}this.freeEvent(i)}mapPointerUpOutside(e){if(!(e instanceof R))return void(0,B.R)("EventBoundary cannot map a non-pointer event as a pointer event");const t=this.trackingData(e.pointerId),i=this.findMountedTarget(t.pressTargetsByButton[e.button]),n=this.createPointerEvent(e);if(i){let s=i;for(;s;)n.currentTarget=s,this.notifyTarget(n,"pointerupoutside"),"touch"===n.pointerType?this.notifyTarget(n,"touchendoutside"):"mouse"!==n.pointerType&&"pen"!==n.pointerType||this.notifyTarget(n,2===n.button?"rightupoutside":"mouseupoutside"),s=s.parent;delete t.pressTargetsByButton[e.button]}this.freeEvent(n)}mapWheel(e){if(!(e instanceof U))return void(0,B.R)("EventBoundary cannot map a non-wheel event as a wheel event");const t=this.createWheelEvent(e);this.dispatchEvent(t),this.freeEvent(t)}findMountedTarget(e){if(!e)return null;let t=e[0];for(let i=1;i<e.length&&e[i].parent===t;i++)t=e[i];return t}createPointerEvent(e,t,i){const n=this.allocateEvent(R);return this.copyPointerData(e,n),this.copyMouseData(e,n),this.copyData(e,n),n.nativeEvent=e.nativeEvent,n.originalEvent=e,n.target=i??this.hitTest(n.global.x,n.global.y)??this._hitElements[0],"string"==typeof t&&(n.type=t),n}createWheelEvent(e){const t=this.allocateEvent(U);return this.copyWheelData(e,t),this.copyMouseData(e,t),this.copyData(e,t),t.nativeEvent=e.nativeEvent,t.originalEvent=e,t.target=this.hitTest(t.global.x,t.global.y),t}clonePointerEvent(e,t){const i=this.allocateEvent(R);return i.nativeEvent=e.nativeEvent,i.originalEvent=e.originalEvent,this.copyPointerData(e,i),this.copyMouseData(e,i),this.copyData(e,i),i.target=e.target,i.path=e.composedPath().slice(),i.type=t??i.type,i}copyWheelData(e,t){t.deltaMode=e.deltaMode,t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ}copyPointerData(e,t){e instanceof R&&t instanceof R&&(t.pointerId=e.pointerId,t.width=e.width,t.height=e.height,t.isPrimary=e.isPrimary,t.pointerType=e.pointerType,t.pressure=e.pressure,t.tangentialPressure=e.tangentialPressure,t.tiltX=e.tiltX,t.tiltY=e.tiltY,t.twist=e.twist)}copyMouseData(e,t){e instanceof C&&t instanceof C&&(t.altKey=e.altKey,t.button=e.button,t.buttons=e.buttons,t.client.copyFrom(e.client),t.ctrlKey=e.ctrlKey,t.metaKey=e.metaKey,t.movement.copyFrom(e.movement),t.screen.copyFrom(e.screen),t.shiftKey=e.shiftKey,t.global.copyFrom(e.global))}copyData(e,t){t.isTrusted=e.isTrusted,t.srcElement=e.srcElement,t.timeStamp=performance.now(),t.type=e.type,t.detail=e.detail,t.view=e.view,t.which=e.which,t.layer.copyFrom(e.layer),t.page.copyFrom(e.page)}trackingData(e){return this.mappingState.trackingData[e]||(this.mappingState.trackingData[e]={pressTargetsByButton:{},clicksByButton:{},overTarget:null}),this.mappingState.trackingData[e]}allocateEvent(e){this.eventPool.has(e)||this.eventPool.set(e,[]);const t=this.eventPool.get(e).pop()||new e(this);return t.eventPhase=t.NONE,t.currentTarget=null,t.defaultPrevented=!1,t.path=null,t.target=null,t}freeEvent(e){if(e.manager!==this)throw new Error("It is illegal to free an event not managed by this EventBoundary!");const t=e.constructor;this.eventPool.has(t)||this.eventPool.set(t,[]),this.eventPool.get(t).push(e)}_notifyListeners(e,t){const i=e.currentTarget._events[t];if(i)if("fn"in i)i.once&&e.currentTarget.removeListener(t,i.fn,void 0,!0),i.fn.call(i.context,e);else for(let n=0,s=i.length;n<s&&!e.propagationImmediatelyStopped;n++)i[n].once&&e.currentTarget.removeListener(t,i[n].fn,void 0,!0),i[n].fn.call(i[n].context,e)}}const K={touchstart:"pointerdown",touchend:"pointerup",touchendoutside:"pointerupoutside",touchmove:"pointermove",touchcancel:"pointercancel"},N=class e{constructor(t){this.supportsTouchEvents="ontouchstart"in globalThis,this.supportsPointerEvents=!!globalThis.PointerEvent,this.domElement=null,this.resolution=1,this.renderer=t,this.rootBoundary=new Y(null),S.init(this),this.autoPreventDefault=!0,this._eventsAdded=!1,this._rootPointerEvent=new R(null),this._rootWheelEvent=new U(null),this.cursorStyles={default:"inherit",pointer:"pointer"},this.features=new Proxy({...e.defaultEventFeatures},{set:(e,t,i)=>("globalMove"===t&&(this.rootBoundary.enableGlobalMoveEvents=i),e[t]=i,!0)}),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerUp=this._onPointerUp.bind(this),this._onPointerOverOut=this._onPointerOverOut.bind(this),this.onWheel=this.onWheel.bind(this)}static get defaultEventMode(){return this._defaultEventMode}init(t){const{canvas:i,resolution:n}=this.renderer;this.setTargetElement(i),this.resolution=n,e._defaultEventMode=t.eventMode??"passive",Object.assign(this.features,t.eventFeatures??{}),this.rootBoundary.enableGlobalMoveEvents=this.features.globalMove}resolutionChange(e){this.resolution=e}destroy(){S.destroy(),this.setTargetElement(null),this.renderer=null,this._currentCursor=null}setCursor(e){e||(e="default");let t=!0;if(globalThis.OffscreenCanvas&&this.domElement instanceof OffscreenCanvas&&(t=!1),this._currentCursor===e)return;this._currentCursor=e;const i=this.cursorStyles[e];if(i)switch(typeof i){case"string":t&&(this.domElement.style.cursor=i);break;case"function":i(e);break;case"object":t&&Object.assign(this.domElement.style,i)}else t&&"string"==typeof e&&!Object.prototype.hasOwnProperty.call(this.cursorStyles,e)&&(this.domElement.style.cursor=e)}get pointer(){return this._rootPointerEvent}_onPointerDown(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);if(this.autoPreventDefault&&t[0].isNormalized){(e.cancelable||!("cancelable"in e))&&e.preventDefault()}for(let e=0,i=t.length;e<i;e++){const i=t[e],n=this._bootstrapEvent(this._rootPointerEvent,i);this.rootBoundary.mapEvent(n)}this.setCursor(this.rootBoundary.cursor)}_onPointerMove(e){if(!this.features.move)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,S.pointerMoved();const t=this._normalizeToPointerData(e);for(let e=0,i=t.length;e<i;e++){const i=this._bootstrapEvent(this._rootPointerEvent,t[e]);this.rootBoundary.mapEvent(i)}this.setCursor(this.rootBoundary.cursor)}_onPointerUp(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;let t=e.target;e.composedPath&&e.composedPath().length>0&&(t=e.composedPath()[0]);const i=t!==this.domElement?"outside":"",n=this._normalizeToPointerData(e);for(let e=0,t=n.length;e<t;e++){const t=this._bootstrapEvent(this._rootPointerEvent,n[e]);t.type+=i,this.rootBoundary.mapEvent(t)}this.setCursor(this.rootBoundary.cursor)}_onPointerOverOut(e){if(!this.features.click)return;this.rootBoundary.rootTarget=this.renderer.lastObjectRendered;const t=this._normalizeToPointerData(e);for(let e=0,i=t.length;e<i;e++){const i=this._bootstrapEvent(this._rootPointerEvent,t[e]);this.rootBoundary.mapEvent(i)}this.setCursor(this.rootBoundary.cursor)}onWheel(e){if(!this.features.wheel)return;const t=this.normalizeWheelEvent(e);this.rootBoundary.rootTarget=this.renderer.lastObjectRendered,this.rootBoundary.mapEvent(t)}setTargetElement(e){this._removeEvents(),this.domElement=e,S.domElement=e,this._addEvents()}_addEvents(){if(this._eventsAdded||!this.domElement)return;S.addTickerListener();const e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="none",e.msTouchAction="none"):this.supportsPointerEvents&&(e.touchAction="none")),this.supportsPointerEvents?(globalThis.document.addEventListener("pointermove",this._onPointerMove,!0),this.domElement.addEventListener("pointerdown",this._onPointerDown,!0),this.domElement.addEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.addEventListener("pointerover",this._onPointerOverOut,!0),globalThis.addEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.addEventListener("mousemove",this._onPointerMove,!0),this.domElement.addEventListener("mousedown",this._onPointerDown,!0),this.domElement.addEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.addEventListener("mouseover",this._onPointerOverOut,!0),globalThis.addEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.addEventListener("touchstart",this._onPointerDown,!0),this.domElement.addEventListener("touchend",this._onPointerUp,!0),this.domElement.addEventListener("touchmove",this._onPointerMove,!0))),this.domElement.addEventListener("wheel",this.onWheel,{passive:!0,capture:!0}),this._eventsAdded=!0}_removeEvents(){if(!this._eventsAdded||!this.domElement)return;S.removeTickerListener();const e=this.domElement.style;e&&(globalThis.navigator.msPointerEnabled?(e.msContentZooming="",e.msTouchAction=""):this.supportsPointerEvents&&(e.touchAction="")),this.supportsPointerEvents?(globalThis.document.removeEventListener("pointermove",this._onPointerMove,!0),this.domElement.removeEventListener("pointerdown",this._onPointerDown,!0),this.domElement.removeEventListener("pointerleave",this._onPointerOverOut,!0),this.domElement.removeEventListener("pointerover",this._onPointerOverOut,!0),globalThis.removeEventListener("pointerup",this._onPointerUp,!0)):(globalThis.document.removeEventListener("mousemove",this._onPointerMove,!0),this.domElement.removeEventListener("mousedown",this._onPointerDown,!0),this.domElement.removeEventListener("mouseout",this._onPointerOverOut,!0),this.domElement.removeEventListener("mouseover",this._onPointerOverOut,!0),globalThis.removeEventListener("mouseup",this._onPointerUp,!0),this.supportsTouchEvents&&(this.domElement.removeEventListener("touchstart",this._onPointerDown,!0),this.domElement.removeEventListener("touchend",this._onPointerUp,!0),this.domElement.removeEventListener("touchmove",this._onPointerMove,!0))),this.domElement.removeEventListener("wheel",this.onWheel,!0),this.domElement=null,this._eventsAdded=!1}mapPositionToPoint(e,t,i){const n=this.domElement.isConnected?this.domElement.getBoundingClientRect():{x:0,y:0,width:this.domElement.width,height:this.domElement.height,left:0,top:0},s=1/this.resolution;e.x=(t-n.left)*(this.domElement.width/n.width)*s,e.y=(i-n.top)*(this.domElement.height/n.height)*s}_normalizeToPointerData(e){const t=[];if(this.supportsTouchEvents&&e instanceof TouchEvent)for(let i=0,n=e.changedTouches.length;i<n;i++){const n=e.changedTouches[i];void 0===n.button&&(n.button=0),void 0===n.buttons&&(n.buttons=1),void 0===n.isPrimary&&(n.isPrimary=1===e.touches.length&&"touchstart"===e.type),void 0===n.width&&(n.width=n.radiusX||1),void 0===n.height&&(n.height=n.radiusY||1),void 0===n.tiltX&&(n.tiltX=0),void 0===n.tiltY&&(n.tiltY=0),void 0===n.pointerType&&(n.pointerType="touch"),void 0===n.pointerId&&(n.pointerId=n.identifier||0),void 0===n.pressure&&(n.pressure=n.force||.5),void 0===n.twist&&(n.twist=0),void 0===n.tangentialPressure&&(n.tangentialPressure=0),void 0===n.layerX&&(n.layerX=n.offsetX=n.clientX),void 0===n.layerY&&(n.layerY=n.offsetY=n.clientY),n.isNormalized=!0,n.type=e.type,n.altKey??(n.altKey=e.altKey),n.ctrlKey??(n.ctrlKey=e.ctrlKey),n.metaKey??(n.metaKey=e.metaKey),n.shiftKey??(n.shiftKey=e.shiftKey),t.push(n)}else if(globalThis.MouseEvent&&(!(e instanceof MouseEvent)||this.supportsPointerEvents&&e instanceof globalThis.PointerEvent))t.push(e);else{const i=e;void 0===i.isPrimary&&(i.isPrimary=!0),void 0===i.width&&(i.width=1),void 0===i.height&&(i.height=1),void 0===i.tiltX&&(i.tiltX=0),void 0===i.tiltY&&(i.tiltY=0),void 0===i.pointerType&&(i.pointerType="mouse"),void 0===i.pointerId&&(i.pointerId=1),void 0===i.pressure&&(i.pressure=.5),void 0===i.twist&&(i.twist=0),void 0===i.tangentialPressure&&(i.tangentialPressure=0),i.isNormalized=!0,t.push(i)}return t}normalizeWheelEvent(e){const t=this._rootWheelEvent;return this._transferMouseData(t,e),t.deltaX=e.deltaX,t.deltaY=e.deltaY,t.deltaZ=e.deltaZ,t.deltaMode=e.deltaMode,this.mapPositionToPoint(t.screen,e.clientX,e.clientY),t.global.copyFrom(t.screen),t.offset.copyFrom(t.screen),t.nativeEvent=e,t.type=e.type,t}_bootstrapEvent(e,t){return e.originalEvent=null,e.nativeEvent=t,e.pointerId=t.pointerId,e.width=t.width,e.height=t.height,e.isPrimary=t.isPrimary,e.pointerType=t.pointerType,e.pressure=t.pressure,e.tangentialPressure=t.tangentialPressure,e.tiltX=t.tiltX,e.tiltY=t.tiltY,e.twist=t.twist,this._transferMouseData(e,t),this.mapPositionToPoint(e.screen,t.clientX,t.clientY),e.global.copyFrom(e.screen),e.offset.copyFrom(e.screen),e.isTrusted=t.isTrusted,"pointerleave"===e.type&&(e.type="pointerout"),e.type.startsWith("mouse")&&(e.type=e.type.replace("mouse","pointer")),e.type.startsWith("touch")&&(e.type=K[e.type]||e.type),e}_transferMouseData(e,t){e.isTrusted=t.isTrusted,e.srcElement=t.srcElement,e.timeStamp=performance.now(),e.type=t.type,e.altKey=t.altKey,e.button=t.button,e.buttons=t.buttons,e.client.x=t.clientX,e.client.y=t.clientY,e.ctrlKey=t.ctrlKey,e.metaKey=t.metaKey,e.movement.x=t.movementX,e.movement.y=t.movementY,e.page.x=t.pageX,e.page.y=t.pageY,e.relatedTarget=null,e.shiftKey=t.shiftKey}};N.extension={name:"events",type:[n.Ag.WebGLSystem,n.Ag.CanvasSystem,n.Ag.WebGPUSystem],priority:-1},N.defaultEventFeatures={move:!0,globalMove:!0,click:!0,wheel:!0};let G=N;const W={onclick:null,onmousedown:null,onmouseenter:null,onmouseleave:null,onmousemove:null,onglobalmousemove:null,onmouseout:null,onmouseover:null,onmouseup:null,onmouseupoutside:null,onpointercancel:null,onpointerdown:null,onpointerenter:null,onpointerleave:null,onpointermove:null,onglobalpointermove:null,onpointerout:null,onpointerover:null,onpointertap:null,onpointerup:null,onpointerupoutside:null,onrightclick:null,onrightdown:null,onrightup:null,onrightupoutside:null,ontap:null,ontouchcancel:null,ontouchend:null,ontouchendoutside:null,ontouchmove:null,onglobaltouchmove:null,ontouchstart:null,onwheel:null,get interactive(){return"dynamic"===this.eventMode||"static"===this.eventMode},set interactive(e){this.eventMode=e?"static":"passive"},_internalEventMode:void 0,get eventMode(){return this._internalEventMode??G.defaultEventMode},set eventMode(e){this._internalEventMode=e},isInteractive(){return"static"===this.eventMode||"dynamic"===this.eventMode},interactiveChildren:!0,hitArea:null,addEventListener(e,t,i){const n="boolean"==typeof i&&i||"object"==typeof i&&i.capture,s="object"==typeof i?i.signal:void 0,o="object"==typeof i&&!0===i.once,r="function"==typeof t?void 0:t;e=n?`${e}capture`:e;const a="function"==typeof t?t:t.handleEvent,h=this;s&&s.addEventListener("abort",(()=>{h.off(e,a,r)})),o?h.once(e,a,r):h.on(e,a,r)},removeEventListener(e,t,i){const n="function"==typeof t?void 0:t;e="boolean"==typeof i&&i||"object"==typeof i&&i.capture?`${e}capture`:e,t="function"==typeof t?t:t.handleEvent,this.off(e,t,n)},dispatchEvent(e){if(!(e instanceof l))throw new Error("Container cannot propagate events outside of the Federated Events API");return e.defaultPrevented=!1,e.path=null,e.target=this,e.manager.dispatchEvent(e),!e.defaultPrevented}};n.XO.add(G),n.XO.mixin(s.mc,W);i(6312),i(5753),i(3859)}}]);