import{D as S,t as d,w as b,a as R,N as Z,R as y,v as C,Q as g,E as De,p as Ne,y as T,M as Q,x as Ie}from"./sprite-view-Br3916N3.js";import{G as M,d as Ge,S as x,e as J,h as Ue,i as ee,j as Fe,k as Me}from"./colorToUniform-DJvpt7jY.js";import{e as Oe,G as Pe,c as Le,b as we,U as He,B as te,d as D,f as re,g as Ve}from"./BufferResource-DONVheyy.js";import{a as O,d as N,g as ne,b as Xe,S as P,f as ke,U as L,j as We,R as je}from"./Geometry-BsDB1n4r.js";import{R as Ke,S as Ye,d as $e}from"./RenderTargetSystem-DwrTnSOw.js";import"./schema-B1NKxfZc.js";import"./BatchableSprite-qOYjpB38.js";import"./Filter-DL3E8wYn.js";function ze(){const{userAgent:r}=S.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}class se{constructor(){this._tempState=O.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,n){const s=e.renderer,i=this._didUploadHash[n.uid];s.shader.bind(n,i),i||(this._didUploadHash[n.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(t,n.glProgram)}execute(e,t){const n=e.renderer;this._tempState.blendMode=t.blendMode,n.state.set(this._tempState);const s=t.textures.textures;for(let i=0;i<t.textures.count;i++)n.texture.bind(s[i],i);n.geometry.draw(t.topology,t.size,t.start)}}se.extension={type:[d.WebGLPipesAdaptor],name:"batch"};var B=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(B||{});class qe{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 ie{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new M({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,n=this.getGlBuffer(e);t.bindBuffer(n.type,n.buffer)}bindBufferBase(e,t){const{_gl:n}=this;this._boundBufferBases[t]!==e&&(this._boundBufferBases[t]=e,e._lastBindBaseLocation=t,n.bindBufferBase(n.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 n=0,s=this._nextBindBaseIndex;for(;n<2;){s>=this._maxBindings&&(s=this._minBaseLocation,n++);const i=this._boundBufferBases[s];if(i&&i._lastBindCallId===this._bindCallId){s++;continue}break}return t=s,this._nextBindBaseIndex=s+1,n>=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,n,s){const{_gl:i}=this;n||(n=0),t||(t=0),this._boundBufferBases[t]=null,i.bindBufferRange(i.UNIFORM_BUFFER,t||0,e.buffer,n*256,s||256)}updateBuffer(e){const{_gl:t}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,t.bindBuffer(n.type,n.buffer);const s=e.data,i=e.descriptor.usage&N.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;return s?n.byteLength>=s.byteLength?t.bufferSubData(n.type,e._updateOffset,s,e._updateOffset/s.BYTES_PER_ELEMENT,(e._updateSize||s.byteLength)/s.BYTES_PER_ELEMENT):(n.byteLength=s.byteLength,t.bufferData(n.type,s,i)):(n.byteLength=e.descriptor.size,t.bufferData(n.type,n.byteLength,i)),n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,t=!1){const n=e._gpuData[this._renderer.uid];n&&(t||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){const{_gl:t}=this;let n=B.ARRAY_BUFFER;e.descriptor.usage&N.INDEX?n=B.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&N.UNIFORM&&(n=B.UNIFORM_BUFFER);const s=new qe(t.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}ie.extension={type:[d.WebGLSystem],name:"buffer"};const w=class ae{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...ae.defaultOptions,...e};let t=this.multiView=e.multiView;if(e.context&&t&&(b("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),t=!1),t?this.canvas=S.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const n=this._renderer.background.alpha<1,s=e.premultipliedAlpha??!0,i=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:n,premultipliedAlpha:s,antialias:i,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&b("multiView is disabled, but targetCanvas is not the main canvas");return}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 S.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 n;const s=this.canvas;if(e===2&&(n=s.getContext("webgl2",t)),!n&&(n=s.getContext("webgl",t),!n))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=n,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(this.webGLVersion===1)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 n=e.getExtension("WEBGL_provoking_vertex");n&&n.provokingVertexWEBGL(n.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&&b("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=this.supports,s=this.webGLVersion===2,i=this.extensions;n.uint32Indices=s||!!i.uint32ElementIndex,n.uniformBufferObject=s,n.vertexArrayObject=s||!!i.vertexArrayObject,n.srgbTextures=s||!!i.srgb,n.nonPowOf2wrapping=s,n.nonPowOf2mipmaps=s,n.msaa=s,n.uint32Indices||b("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};w.extension={type:[d.WebGLSystem],name:"context"};w.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let Ze=w;var U=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(U||{}),H=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(H||{}),f=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(f||{});const k={uint8x2:f.UNSIGNED_BYTE,uint8x4:f.UNSIGNED_BYTE,sint8x2:f.BYTE,sint8x4:f.BYTE,unorm8x2:f.UNSIGNED_BYTE,unorm8x4:f.UNSIGNED_BYTE,snorm8x2:f.BYTE,snorm8x4:f.BYTE,uint16x2:f.UNSIGNED_SHORT,uint16x4:f.UNSIGNED_SHORT,sint16x2:f.SHORT,sint16x4:f.SHORT,unorm16x2:f.UNSIGNED_SHORT,unorm16x4:f.UNSIGNED_SHORT,snorm16x2:f.SHORT,snorm16x4:f.SHORT,float16x2:f.HALF_FLOAT,float16x4:f.HALF_FLOAT,float32:f.FLOAT,float32x2:f.FLOAT,float32x3:f.FLOAT,float32x4:f.FLOAT,uint32:f.UNSIGNED_INT,uint32x2:f.UNSIGNED_INT,uint32x3:f.UNSIGNED_INT,uint32x4:f.UNSIGNED_INT,sint32:f.INT,sint32x2:f.INT,sint32x3:f.INT,sint32x4:f.INT};function Qe(r){return k[r]??k.float32}const Je={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class et{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class oe{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new M({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=s=>t.bindVertexArrayOES(s),e.deleteVertexArray=s=>t.deleteVertexArrayOES(s));const n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(s,i,a,c)=>{n.drawArraysInstancedANGLE(s,i,a,c)},e.drawElementsInstanced=(s,i,a,c,o)=>{n.drawElementsInstancedANGLE(s,i,a,c,o)},e.vertexAttribDivisor=(s,i)=>n.vertexAttribDivisorANGLE(s,i)),this._activeGeometry=null,this._activeVao=null}bind(e,t){const n=this.gl;this._activeGeometry=e;const s=this.getVao(e,t);this._activeVao!==s&&(this._activeVao=s,n.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,t=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){const s=e.buffers[n];t.updateBuffer(s)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,t){const n=e.attributes,s=t._attributeData;for(const i in s)if(!n[i])throw new Error(`shader and geometry incompatible, geometry missing the "${i}" attribute`)}getSignature(e,t){const n=e.attributes,s=t._attributeData,i=["g",e.uid];for(const a in n)s[a]&&i.push(a,s[a].location);return i.join("-")}getVao(e,t){return e._gpuData[this._renderer.uid]?.vaoCache[t._key]||this.initGeometryVao(e,t)}initGeometryVao(e,t,n=!0){const s=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(t),this.checkCompatibility(e,t);const a=this.getSignature(e,t);let c=e._gpuData[this._renderer.uid];c||(c=new et,e._gpuData[this._renderer.uid]=c,this._managedGeometries.add(e));const o=c.vaoCache;let u=o[a];if(u)return o[t._key]=u,u;Oe(e,t._attributeData);const _=e.buffers;u=s.createVertexArray(),s.bindVertexArray(u);for(let h=0;h<_.length;h++){const l=_[h];i.bind(l)}return this.activateVao(e,t),o[t._key]=u,o[a]=u,s.bindVertexArray(null),u}onGeometryUnload(e,t=!1){const n=e._gpuData[this._renderer.uid];if(!n)return;const s=n.vaoCache;if(!t)for(const i in s)this._activeVao!==s[i]&&this.resetState(),this.gl.deleteVertexArray(s[i])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,t){const n=this._renderer.gl,s=this._renderer.buffer,i=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let a=null;for(const c in i){const o=i[c],u=o.buffer,_=s.getGlBuffer(u),h=t._attributeData[c];if(h){a!==_&&(s.bind(u),a=_);const l=h.location;n.enableVertexAttribArray(l);const m=ne(o.format),p=Qe(o.format);if(h.format?.substring(1,4)==="int"?n.vertexAttribIPointer(l,m.size,p,o.stride,o.offset):n.vertexAttribPointer(l,m.size,p,m.normalised,o.stride,o.offset),o.instance)if(this.hasInstance){const E=o.divisor??1;n.vertexAttribDivisor(l,E)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,t,n,s){const{gl:i}=this._renderer,a=this._activeGeometry,c=Je[e||a.topology];if(s??(s=a.instanceCount),a.indexBuffer){const o=a.indexBuffer.data.BYTES_PER_ELEMENT,u=o===2?i.UNSIGNED_SHORT:i.UNSIGNED_INT;s!==1?i.drawElementsInstanced(c,t||a.indexBuffer.data.length,u,(n||0)*o,s):i.drawElements(c,t||a.indexBuffer.data.length,u,(n||0)*o)}else s!==1?i.drawArraysInstanced(c,n||0,t||a.vertexCount,s):i.drawArrays(c,n||0,t||a.vertexCount);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}}oe.extension={type:[d.WebGLSystem],name:"geometry"};const tt=new ke({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),V=class ce{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:t,antialias:n}={...ce.defaultOptions,...e};this.useBackBuffer=t,this._antialias=n,this._renderer.context.supports.msaa||(b("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=O.for2d();const s=new Xe({vertex:`
                attribute vec2 aPosition;
                out vec2 vUv;

                void main() {
                    gl_Position = vec4(aPosition, 0.0, 1.0);

                    vUv = (aPosition + 1.0) / 2.0;

                    // flip dem UVs
                    vUv.y = 1.0 - vUv.y;
                }`,fragment:`
                in vec2 vUv;
                out vec4 finalColor;

                uniform sampler2D uTexture;

                void main() {
                    finalColor = texture(uTexture, vUv);
                }`,name:"big-triangle"});this._bigTriangleShader=new P({glProgram:s,resources:{uTexture:R.WHITE.source}})}renderStart(e){const t=this._renderer.renderTarget.getRenderTarget(e.target);if(this._useBackBufferThisRender=this.useBackBuffer&&!!t.isRoot,this._useBackBufferThisRender){const n=this._renderer.renderTarget.getRenderTarget(e.target);this._targetTexture=n.colorTexture,e.target=this._getBackBufferTexture(n.colorTexture)}}renderEnd(){this._presentBackBuffer()}_presentBackBuffer(){const e=this._renderer;e.renderTarget.finishRenderPass(),this._useBackBufferThisRender&&(e.renderTarget.bind({target:this._targetTexture,clear:!1}),this._bigTriangleShader.resources.uTexture=this._backBufferTexture.source,e.encoder.draw({geometry:tt,shader:this._bigTriangleShader,state:this._state}))}_getBackBufferTexture(e){return this._backBufferTexture=this._backBufferTexture||new R({source:new Z({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)}};V.extension={type:[d.WebGLSystem],name:"backBuffer",priority:1};V.defaultOptions={useBackBuffer:!1};let rt=V;class ue{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.gl.colorMask(!!(e&8),!!(e&4),!!(e&2),!!(e&1)))}}ue.extension={type:[d.WebGLSystem],name:"colorMask"};class _e{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:n,shader:s,state:i,skipSync:a,topology:c,size:o,start:u,instanceCount:_}=e;t.shader.bind(s,a),t.geometry.bind(n,t.shader._activeProgram),i&&t.state.set(i),t.geometry.draw(c,o,u,_??n.instanceCount)}destroy(){this._renderer=null}}_e.extension={type:[d.WebGLSystem],name:"encoder"};class he{constructor(e){this._renderer=e}contextChange(){const e=this._renderer.gl;this.maxTextures=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),this.maxBatchableTextures=Ge(this.maxTextures,e);const t=this._renderer.context.webGLVersion===2;this.maxUniformBindings=t?e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS):0}destroy(){}}he.extension={type:[d.WebGLSystem],name:"limits"};class nt{constructor(){this.width=-1,this.height=-1,this.msaa=!1,this._attachedMipLevel=0,this._attachedLayer=0,this.msaaRenderBuffer=[]}}class fe{constructor(e){this._stencilCache={enabled:!1,stencilReference:0,stencilMode:x.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:x.DISABLED,stencilReference:0}),this.setStencilMode(t.stencilMode,t.stencilReference)}resetState(){this._stencilCache.enabled=!1,this._stencilCache.stencilMode=x.NONE,this._stencilCache.stencilReference=0}setStencilMode(e,t){const n=this._renderTargetStencilState[this._activeRenderTarget.uid],s=this._gl,i=Pe[e],a=this._stencilCache;if(n.stencilMode=e,n.stencilReference=t,e===x.DISABLED){this._stencilCache.enabled&&(this._stencilCache.enabled=!1,s.disable(s.STENCIL_TEST));return}this._stencilCache.enabled||(this._stencilCache.enabled=!0,s.enable(s.STENCIL_TEST)),(e!==a.stencilMode||a.stencilReference!==t)&&(a.stencilMode=e,a.stencilReference=t,s.stencilFunc(this._comparisonFuncMapping[i.stencilBack.compare],t,255),s.stencilOp(s.KEEP,s.KEEP,this._stencilOpsMapping[i.stencilBack.passOp]))}}fe.extension={type:[d.WebGLSystem],name:"stencil"};const le={f32:4,i32:4,"vec2<f32>":8,"vec3<f32>":12,"vec4<f32>":16,"vec2<i32>":8,"vec3<i32>":12,"vec4<i32>":16,u32:4,"vec2<u32>":8,"vec3<u32>":12,"vec4<u32>":16,"mat2x2<f32>":16*2,"mat3x3<f32>":16*3,"mat4x4<f32>":16*4};function st(r){const e=r.map(i=>({data:i,offset:0,size:0})),t=16;let n=0,s=0;for(let i=0;i<e.length;i++){const a=e[i];if(n=le[a.data.type],!n)throw new Error(`Unknown type ${a.data.type}`);a.data.size>1&&(n=Math.max(n,t)*a.data.size);const c=n===12?16:n;a.size=n;const o=s%t;o>0&&t-o<c?s+=(t-o)%16:s+=(n-o%n)%n,a.offset=s,s+=n}return s=Math.ceil(s/16)*16,{uboElements:e,size:s}}function it(r,e){const t=Math.max(le[r.data.type]/16,1),n=r.data.value.length/r.data.size,s=(4-n%4)%4,i=r.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
        v = uv.${r.data.name};
        offset += ${e};

        arrayOffset = offset;

        t = 0;

        for(var i=0; i < ${r.data.size*t}; i++)
        {
            for(var j = 0; j < ${n}; j++)
            {
                ${i}[arrayOffset++] = v[t++];
            }
            ${s!==0?`arrayOffset += ${s};`:""}
        }
    `}function at(r){return Le(r,we,it)}class de extends He{constructor(){super({createUboElements:st,generateUboSync:at})}}de.extension={type:[d.WebGLSystem],name:"ubo"};class ot{constructor(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new y,this._boundFramebuffer=void 0}init(e,t){this._renderer=e,this._renderTargetSystem=t,e.runners.contextChange.add(this)}contextChange(){this._clearColorCache=[0,0,0,0],this._viewPortCache=new y,this._boundFramebuffer=void 0;const e=this._renderer.gl;this._drawBuffersCache=[];for(let t=1;t<=16;t++)this._drawBuffersCache[t]=Array.from({length:t},(n,s)=>e.COLOR_ATTACHMENT0+s)}copyToTexture(e,t,n,s,i){const a=this._renderTargetSystem,c=this._renderer,o=a.getGpuRenderTarget(e),u=c.gl;return this.finishRenderPass(e),u.bindFramebuffer(u.FRAMEBUFFER,o.resolveTargetFramebuffer),this._boundFramebuffer=o.resolveTargetFramebuffer,c.texture.bind(t,0),u.copyTexSubImage2D(u.TEXTURE_2D,0,i.x,i.y,n.x,n.y,s.width,s.height),t}copyDepthTexture(e,t,n,s,i){const a=this._renderTargetSystem,c=this._renderer.gl;this.finishRenderPass(e);const o=a.getRenderTarget(t),u=a.getGpuRenderTarget(e),_=a.getGpuRenderTarget(o);c.bindFramebuffer(c.READ_FRAMEBUFFER,u.framebuffer),c.bindFramebuffer(c.DRAW_FRAMEBUFFER,_.framebuffer),this._boundFramebuffer=void 0,c.blitFramebuffer(n.x,n.y,n.x+s.width,n.y+s.height,i.x,i.y,i.x+s.width,i.y+s.height,c.DEPTH_BUFFER_BIT,c.NEAREST)}startRenderPass(e,t=!0,n,s,i=0,a=0){const o=this._renderTargetSystem.getGpuRenderTarget(e);if(a!==0&&this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to array layers requires WebGL2.");if(i>0){if(o.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.")}e.colorAttachments.forEach(l=>{this._renderer.texture.unbind(l.texture)});const u=this._renderer.gl;this.bindFramebuffer(o.framebuffer),!e.isRoot&&e.colorAttachments.length>0&&(o._attachedMipLevel!==i||o._attachedLayer!==a)&&(e.colorAttachments.forEach((l,m)=>{const p=l.texture,E=this._renderer.texture.getGlSource(p);if(E.target===u.TEXTURE_2D){if(a!==0)throw new Error("[RenderTargetSystem] layer must be 0 when rendering to 2D textures in WebGL.");u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0+m,u.TEXTURE_2D,E.texture,i)}else if(E.target===u.TEXTURE_2D_ARRAY){if(this._renderer.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Rendering to 2D array textures requires WebGL2.");u.framebufferTextureLayer(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0+m,E.texture,i,a)}else if(E.target===u.TEXTURE_CUBE_MAP){if(a<0||a>5)throw new Error("[RenderTargetSystem] Cube map layer must be between 0 and 5.");u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0+m,u.TEXTURE_CUBE_MAP_POSITIVE_X+a,E.texture,i)}else throw new Error("[RenderTargetSystem] Unsupported texture target for render-to-layer in WebGL.")}),o._attachedMipLevel=i,o._attachedLayer=a),o.framebuffer&&(e.depthStencilAttachment?this._attachDepthStencilTexture(e,i,a):!o.depthStencilRenderBuffer&&(e.stencil||e.depth)&&this._initStencil(o)),e.colorAttachments.length>1&&this._setDrawBuffers(e,u);let _=s.y;e.isRoot&&(_=e.pixelHeight-s.height-s.y);const h=this._viewPortCache;(h.x!==s.x||h.y!==_||h.width!==s.width||h.height!==s.height)&&(h.x=s.x,h.y=_,h.width=s.width,h.height=s.height,u.viewport(s.x,_,s.width,s.height)),this.clear(e,t,n)}finishRenderPass(e){const n=this._renderTargetSystem.getGpuRenderTarget(e);if(!n.msaa||e.colorAttachments.length===0)return;const s=this._renderer.gl;s.bindFramebuffer(s.FRAMEBUFFER,n.resolveTargetFramebuffer),s.bindFramebuffer(s.READ_FRAMEBUFFER,n.framebuffer),s.blitFramebuffer(0,0,n.width,n.height,0,0,n.width,n.height,s.COLOR_BUFFER_BIT,s.NEAREST),s.bindFramebuffer(s.FRAMEBUFFER,n.framebuffer),this._boundFramebuffer=n.framebuffer}initGpuRenderTarget(e){const n=this._renderer.gl,s=new nt;s._attachedMipLevel=0,s._attachedLayer=0;const i=e.colorTexture;return i instanceof C?(this._renderer.context.ensureCanvasSize(i.resource),s.framebuffer=null,s):(s.width=e.pixelWidth,s.height=e.pixelHeight,e.colorAttachments.length===0?this._initDepth(e,s):this._initColor(e,s),e.depthStencilAttachment&&this._attachDepthStencilTexture(e,0,0),n.bindFramebuffer(n.FRAMEBUFFER,null),this._boundFramebuffer=null,s)}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(n=>{t.deleteRenderbuffer(n)}),e.msaaRenderBuffer=null}clear(e,t,n,s,i=0,a=0){if(!t)return;if(a!==0)throw new Error("[RenderTargetSystem] Clearing array layers is not supported in WebGL renderer.");const c=this._renderTargetSystem;if(typeof t=="boolean"&&(t=t?g.ALL:g.NONE),e.colorAttachments.length===0&&(t&=~g.COLOR,!t))return;const o=this._renderer.gl,u=!!(t&g.DEPTH)&&!this._renderer.state.depthMaskEnabled;if(t&g.COLOR){n??(n=c.defaultClearColor);const _=this._clearColorCache,h=n;(_[0]!==h[0]||_[1]!==h[1]||_[2]!==h[2]||_[3]!==h[3])&&(_[0]=h[0],_[1]=h[1],_[2]=h[2],_[3]=h[3],o.clearColor(h[0],h[1],h[2],h[3]))}u&&o.depthMask(!0),o.clear(t),u&&o.depthMask(!1)}resizeGpuRenderTarget(e){if(e.isRoot)return;const t=this._renderTargetSystem.getGpuRenderTarget(e);t.width=e.pixelWidth,t.height=e.pixelHeight,e.colorAttachments.length>0&&this._resizeColor(e,t),t.depthStencilRenderBuffer&&this._resizeStencil(t),this._boundFramebuffer=void 0}_initColor(e,t){const n=this._renderer,s=n.gl,i=s.createFramebuffer();if(t.resolveTargetFramebuffer=i,s.bindFramebuffer(s.FRAMEBUFFER,i),e.colorAttachments.forEach((c,o)=>{const u=c.texture;u.antialias&&(n.context.supports.msaa?t.msaa=!0:b("[RenderTexture] Antialiasing on textures is not supported in WebGL1")),n.texture.bindSource(u,0);const _=n.texture.getGlSource(u),h=_.texture;if(_.target===s.TEXTURE_2D)s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+o,s.TEXTURE_2D,h,0);else if(_.target===s.TEXTURE_2D_ARRAY){if(n.context.webGLVersion<2)throw new Error("[RenderTargetSystem] TEXTURE_2D_ARRAY requires WebGL2.");s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+o,h,0,0)}else if(_.target===s.TEXTURE_CUBE_MAP)s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+o,s.TEXTURE_CUBE_MAP_POSITIVE_X,h,0);else throw new Error("[RenderTargetSystem] Unsupported texture target for framebuffer attachment.")}),t.msaa){const c=s.createFramebuffer();t.framebuffer=c,s.bindFramebuffer(s.FRAMEBUFFER,c),e.colorAttachments.forEach((o,u)=>{const _=s.createRenderbuffer();t.msaaRenderBuffer[u]=_})}else t.framebuffer=i;this._resizeColor(e,t)}_initDepth(e,t){const n=this._renderer;if(n.context.webGLVersion<2)throw new Error("[RenderTargetSystem] Depth-only render targets require WebGL2.");const s=n.gl,i=s.createFramebuffer();t.resolveTargetFramebuffer=i,t.framebuffer=i,s.bindFramebuffer(s.FRAMEBUFFER,i),s.drawBuffers([s.NONE]),s.readBuffer(s.NONE)}_resizeColor(e,t){const n=e.colorAttachments[0].texture;if(t._attachedMipLevel=0,t._attachedLayer=0,e.colorAttachments.forEach((s,i)=>{i!==0&&s.texture.resize(n.width,n.height,n._resolution)}),t.msaa){const s=this._renderer,i=s.gl,a=t.framebuffer;i.bindFramebuffer(i.FRAMEBUFFER,a),e.colorAttachments.forEach((c,o)=>{const u=c.texture;s.texture.bindSource(u,0);const h=s.texture.getGlSource(u).internalFormat,l=t.msaaRenderBuffer[o];i.bindRenderbuffer(i.RENDERBUFFER,l),i.renderbufferStorageMultisample(i.RENDERBUFFER,4,h,u.pixelWidth,u.pixelHeight),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+o,i.RENDERBUFFER,l)})}}_attachDepthStencilTexture(e,t,n){const s=this._renderer,i=s.gl,a=e.depthStencilAttachment.texture,c=s.texture.getGlSource(a),o=c.texture,u=a.format;let _;u==="depth24plus-stencil8"||u==="depth32float-stencil8"?_=i.DEPTH_STENCIL_ATTACHMENT:u==="stencil8"?_=i.STENCIL_ATTACHMENT:_=i.DEPTH_ATTACHMENT,c.target===i.TEXTURE_2D?i.framebufferTexture2D(i.FRAMEBUFFER,_,i.TEXTURE_2D,o,t):c.target===i.TEXTURE_2D_ARRAY?i.framebufferTextureLayer(i.FRAMEBUFFER,_,o,t,n):c.target===i.TEXTURE_CUBE_MAP&&i.framebufferTexture2D(i.FRAMEBUFFER,_,i.TEXTURE_CUBE_MAP_POSITIVE_X+n,o,t)}_initStencil(e){if(e.framebuffer===null)return;const t=this._renderer.gl,n=t.createRenderbuffer();e.depthStencilRenderBuffer=n,t.bindRenderbuffer(t.RENDERBUFFER,n),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,t.RENDERBUFFER,n),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,this._renderer.context.webGLVersion===2?t.DEPTH24_STENCIL8:t.DEPTH_STENCIL,e.width,e.height)}prerender(e){if(e.colorAttachments.length===0)return;const t=e.colorAttachments[0].texture.resource;this._renderer.context.multiView&&C.test(t)&&this._renderer.context.ensureCanvasSize(t)}postrender(e){if(!this._renderer.context.multiView||e.colorAttachments.length===0)return;const t=e.colorAttachments[0].texture;if(C.test(t.resource)){const n=this._renderer.context.canvas,s=t;s.context2D.drawImage(n,0,s.pixelHeight-n.height)}}_setDrawBuffers(e,t){const n=e.colorAttachments.length,s=this._drawBuffersCache[n];if(this._renderer.context.webGLVersion===1){const i=this._renderer.context.extensions.drawBuffers;i?i.drawBuffersWEBGL(s):b("[RenderTexture] This WebGL1 context does not support rendering to multiple targets")}else t.drawBuffers(s)}resetState(){this._boundFramebuffer=void 0,this._viewPortCache=new y,this._clearColorCache=[0,0,0,0]}bindFramebuffer(e){this._boundFramebuffer!==e&&(this._boundFramebuffer=e,this._renderer.gl.bindFramebuffer(this._renderer.gl.FRAMEBUFFER,e))}}class me extends Ke{constructor(e){super(e),this.adaptor=new ot,this.adaptor.init(e,this)}resetState(){this.adaptor.resetState()}}me.extension={type:[d.WebGLSystem],name:"renderTarget"};class ct extends De{constructor(e,t){super(),this._resourceType="textureView",this._resourceId=Ne("resource"),this._touched=0,this.source=e,this.viewDescriptor=t,this._onChange=this._onChange.bind(this),this._onDestroy=this._onDestroy.bind(this),this.source.on("change",this._onChange),this.source.on("destroy",this._onDestroy)}_onChange(){this.emit("change",this)}_onDestroy(){this.destroy()}get destroyed(){return this.source.destroyed}destroy(){this.source&&(this.source.off("change",this._onChange),this.source.off("destroy",this._onDestroy)),this.emit("destroy",this),this.removeAllListeners()}}function ut(r,e){const t=[],n=[`
        var g = s.groups;
        var sS = r.shader;
        var p = s.glProgram;
        var ugS = r.uniformGroup;
        var resources;
    `];let s=!1,i=0;const a=e._getProgramData(r.glProgram);for(const o in r.groups){const u=r.groups[o];t.push(`
            resources = g[${o}].resources;
        `);for(const _ in u.resources){const h=u.resources[_];if(h instanceof L)if(h.ubo){const l=r._uniformBindMap[o][Number(_)];t.push(`
                        sS.bindUniformBlock(
                            resources[${_}],
                            '${l}',
                            ${r.glProgram._uniformBlockData[l].index}
                        );
                    `)}else t.push(`
                        ugS.updateUniformGroup(resources[${_}], p, sD);
                    `);else if(h instanceof te){const l=r._uniformBindMap[o][Number(_)];t.push(`
                    sS.bindUniformBlock(
                        resources[${_}],
                        '${l}',
                        ${r.glProgram._uniformBlockData[l].index}
                    );
                `)}else if(h instanceof Z||h instanceof ct){const l=r._uniformBindMap[o][_],m=a.uniformData[l];m&&(s||(s=!0,n.push(`
                        var tS = r.texture;
                        `)),e._gl.uniform1i(m.location,i),t.push(`
                        tS.bind(resources[${_}], ${i});
                    `),i++)}}}const c=[...n,...t].join(`
`);return new Function("r","s","sD",c)}class _t{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 W(r,e,t){const n=r.createShader(e);return r.shaderSource(n,t),r.compileShader(n),n}function I(r){const e=new Array(r);for(let t=0;t<e.length;t++)e[t]=!1;return e}function Ee(r,e){switch(r){case"float":return 0;case"vec2":return new Float32Array(2*e);case"vec3":return new Float32Array(3*e);case"vec4":return new Float32Array(4*e);case"int":case"uint":case"sampler2D":case"sampler2DArray":return 0;case"ivec2":return new Int32Array(2*e);case"ivec3":return new Int32Array(3*e);case"ivec4":return new Int32Array(4*e);case"uvec2":return new Uint32Array(2*e);case"uvec3":return new Uint32Array(3*e);case"uvec4":return new Uint32Array(4*e);case"bool":return!1;case"bvec2":return I(2*e);case"bvec3":return I(3*e);case"bvec4":return I(4*e);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 v=null;const j={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_2D_SHADOW:"sampler2DShadow",SAMPLER_CUBE:"samplerCube",INT_SAMPLER_CUBE:"samplerCube",UNSIGNED_INT_SAMPLER_CUBE:"samplerCube",SAMPLER_CUBE_SHADOW:"samplerCubeShadow",SAMPLER_2D_ARRAY:"sampler2DArray",INT_SAMPLER_2D_ARRAY:"sampler2DArray",UNSIGNED_INT_SAMPLER_2D_ARRAY:"sampler2DArray",SAMPLER_2D_ARRAY_SHADOW:"sampler2DArrayShadow"},ht={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(r,e){if(!v){const t=Object.keys(j);v={};for(let n=0;n<t.length;++n){const s=t[n];v[r[s]]=j[s]}}return v[e]}function ft(r,e){const t=be(r,e);return ht[t]||"float32"}function lt(r,e,t=!1){const n={},s=e.getProgramParameter(r,e.ACTIVE_ATTRIBUTES);for(let a=0;a<s;a++){const c=e.getActiveAttrib(r,a);if(c.name.startsWith("gl_"))continue;const o=ft(e,c.type);n[c.name]={location:0,format:o,stride:ne(o).stride,offset:0,instance:!1,start:0}}const i=Object.keys(n);if(t){i.sort((a,c)=>a>c?1:-1);for(let a=0;a<i.length;a++)n[i[a]].location=a,e.bindAttribLocation(r,a,i[a]);e.linkProgram(r)}else for(let a=0;a<i.length;a++)n[i[a]].location=e.getAttribLocation(r,i[a]);return n}function dt(r,e){if(!e.ACTIVE_UNIFORM_BLOCKS)return{};const t={},n=e.getProgramParameter(r,e.ACTIVE_UNIFORM_BLOCKS);for(let s=0;s<n;s++){const i=e.getActiveUniformBlockName(r,s),a=e.getUniformBlockIndex(r,i),c=e.getActiveUniformBlockParameter(r,s,e.UNIFORM_BLOCK_DATA_SIZE);t[i]={name:i,index:a,size:c}}return t}function mt(r,e){const t={},n=e.getProgramParameter(r,e.ACTIVE_UNIFORMS);for(let s=0;s<n;s++){const i=e.getActiveUniform(r,s),a=i.name.replace(/\[.*?\]$/,""),c=!!i.name.match(/\[.*?\]$/),o=be(e,i.type);t[a]={name:a,index:s,type:o,size:i.size,isArray:c,value:Ee(o,i.size)}}return t}function K(r,e){const t=r.getShaderSource(e);if(t===null){console.error("PixiJS Error: Could not retrieve shader source (WebGL context may be lost).");return}const n=t.split(`
`).map((_,h)=>`${h}: ${_}`),s=r.getShaderInfoLog(e)??"",i=s.split(`
`),a={},c=i.map(_=>parseFloat(_.replace(/^ERROR\: 0\:([\d]+)\:.*$/,"$1"))).filter(_=>_&&!a[_]?(a[_]=!0,!0):!1),o=[""];c.forEach(_=>{n[_-1]=`%c${n[_-1]}%c`,o.push("background: #FF0000; color:#FFFFFF; font-size: 10px","font-size: 10px")});const u=n.join(`
`);o[0]=u,console.error(s),console.groupCollapsed("click to view full shader code"),console.warn(...o),console.groupEnd()}function Et(r,e,t,n){r.getProgramParameter(e,r.LINK_STATUS)||(r.getShaderParameter(t,r.COMPILE_STATUS)||K(r,t),r.getShaderParameter(n,r.COMPILE_STATUS)||K(r,n),console.error("PixiJS Error: Could not initialize shader."),r.getProgramInfoLog(e)!==""&&console.warn("PixiJS Warning: gl.getProgramInfoLog()",r.getProgramInfoLog(e)))}function bt(r,e){const t=W(r,r.VERTEX_SHADER,e.vertex),n=W(r,r.FRAGMENT_SHADER,e.fragment),s=r.createProgram();r.attachShader(s,t),r.attachShader(s,n);const i=e.transformFeedbackVaryings;i&&(typeof r.transformFeedbackVaryings!="function"?b("TransformFeedback is not supported but TransformFeedbackVaryings are given."):r.transformFeedbackVaryings(s,i.names,i.bufferMode==="separate"?r.SEPARATE_ATTRIBS:r.INTERLEAVED_ATTRIBS)),r.linkProgram(s),r.getProgramParameter(s,r.LINK_STATUS)||Et(r,s,t,n),e._attributeData=lt(s,r,!/^[ \t]*#[ \t]*version[ \t]+300[ \t]+es[ \t]*$/m.test(e.vertex)),e._uniformData=mt(s,r),e._uniformBlockData=dt(s,r),r.deleteShader(t),r.deleteShader(n);const a={};for(const o in e._uniformData){const u=e._uniformData[o];a[o]={location:r.getUniformLocation(s,o),value:Ee(u.type,u.size)}}return new _t(s,a)}const A={textureCount:0,blockIndex:0};class pe{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;A.textureCount=0,A.blockIndex=0;let n=this._shaderSyncFunctions[e.glProgram._key];n||(n=this._shaderSyncFunctions[e.glProgram._key]=this._generateShaderSync(e,this)),this._renderer.buffer.nextBindBase(!!e.glProgram.transformFeedbackVaryings),n(this._renderer,e,A)}updateUniformGroup(e){this._renderer.uniformGroup.updateUniformGroup(e,this._activeProgram,A)}bindUniformBlock(e,t,n=0){const s=this._renderer.buffer,i=this._getProgramData(this._activeProgram),a=e._bufferResource;a||this._renderer.ubo.updateUniformGroup(e);const c=e.buffer,o=s.updateBuffer(c),u=s.freeLocationForBufferBase(o);if(a){const{offset:h,size:l}=e;h===0&&l===c.data.byteLength?s.bindBufferBase(o,u):s.bindBufferRange(o,u,h)}else s.getLastBindBaseLocation(o)!==u&&s.bindBufferBase(o,u);const _=this._activeProgram._uniformBlockData[t].index;i.uniformBlockBindings[n]!==u&&(i.uniformBlockBindings[n]=u,this._renderer.gl.uniformBlockBinding(i.program,_,u))}_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]=bt(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 ut(e,t)}resetState(){this._activeProgram=null}}pe.extension={type:[d.WebGLSystem],name:"shader"};const pt={f32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1f(location, v);
        }`,"vec2<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2f(location, v[0], v[1]);
        }`,"vec3<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3f(location, v[0], v[1], v[2]);
        }`,"vec4<f32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4f(location, v[0], v[1], v[2], v[3]);
        }`,i32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1i(location, v);
        }`,"vec2<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2i(location, v[0], v[1]);
        }`,"vec3<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3i(location, v[0], v[1], v[2]);
        }`,"vec4<i32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4i(location, v[0], v[1], v[2], v[3]);
        }`,u32:`if (cv !== v) {
            cu.value = v;
            gl.uniform1ui(location, v);
        }`,"vec2<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2ui(location, v[0], v[1]);
        }`,"vec3<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3ui(location, v[0], v[1], v[2]);
        }`,"vec4<u32>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4ui(location, v[0], v[1], v[2], v[3]);
        }`,bool:`if (cv !== v) {
            cu.value = v;
            gl.uniform1i(location, v);
        }`,"vec2<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1]) {
            cv[0] = v[0];
            cv[1] = v[1];
            gl.uniform2i(location, v[0], v[1]);
        }`,"vec3<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            gl.uniform3i(location, v[0], v[1], v[2]);
        }`,"vec4<bool>":`if (cv[0] !== v[0] || cv[1] !== v[1] || cv[2] !== v[2] || cv[3] !== v[3]) {
            cv[0] = v[0];
            cv[1] = v[1];
            cv[2] = v[2];
            cv[3] = v[3];
            gl.uniform4i(location, v[0], v[1], v[2], v[3]);
        }`,"mat2x2<f32>":"gl.uniformMatrix2fv(location, false, v);","mat3x3<f32>":"gl.uniformMatrix3fv(location, false, v);","mat4x4<f32>":"gl.uniformMatrix4fv(location, false, v);"},Rt={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);"};function St(r,e){const t=[`
        var v = null;
        var cv = null;
        var cu = null;
        var t = 0;
        var gl = renderer.gl;
        var name = null;
    `];for(const n in r.uniforms){if(!e[n]){r.uniforms[n]instanceof L?r.uniforms[n].ubo?t.push(`
                        renderer.shader.bindUniformBlock(uv.${n}, "${n}");
                    `):t.push(`
                        renderer.shader.updateUniformGroup(uv.${n});
                    `):r.uniforms[n]instanceof te&&t.push(`
                        renderer.shader.bindBufferResource(uv.${n}, "${n}");
                    `);continue}const s=r.uniformStructures[n];let i=!1;for(let a=0;a<D.length;a++){const c=D[a];if(s.type===c.type&&c.test(s)){t.push(`name = "${n}";`,D[a].uniform),i=!0;break}}if(!i){const c=(s.size===1?pt:Rt)[s.type].replace("location",`ud["${n}"].location`);t.push(`
            cu = ud["${n}"];
            cv = cu.value;
            v = uv["${n}"];
            ${c};`)}}return new Function("ud","uv","renderer","syncData",t.join(`
`))}class Re{constructor(e){this._cache={},this._uniformGroupSyncHash={},this._renderer=e,this.gl=null,this._cache={}}contextChange(e){this.gl=e}updateUniformGroup(e,t,n){const s=this._renderer.shader._getProgramData(t);(!e.isStatic||e._dirtyId!==s.uniformDirtyGroups[e.uid])&&(s.uniformDirtyGroups[e.uid]=e._dirtyId,this._getUniformSyncFunction(e,t)(s.uniformData,e.uniforms,this._renderer,n))}_getUniformSyncFunction(e,t){return this._uniformGroupSyncHash[e._signature]?.[t._key]||this._createUniformSyncFunction(e,t)}_createUniformSyncFunction(e,t){const n=this._uniformGroupSyncHash[e._signature]||(this._uniformGroupSyncHash[e._signature]={}),s=this._getSignature(e,t._uniformData,"u");return this._cache[s]||(this._cache[s]=this._generateUniformsSync(e,t._uniformData)),n[t._key]=this._cache[s],n[t._key]}_generateUniformsSync(e,t){return St(e,t)}_getSignature(e,t,n){const s=e.uniforms,i=[`${n}-`];for(const a in s)i.push(a),t[a]&&i.push(t[a].type);return i.join("-")}destroy(){this._renderer=null,this._cache=null}}Re.extension={type:[d.WebGLSystem],name:"uniformGroup"};function gt(r){const e={};if(e.normal=[r.ONE,r.ONE_MINUS_SRC_ALPHA],e.add=[r.ONE,r.ONE],e.multiply=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],e.screen=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],e.none=[0,0],e["normal-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],e["add-npm"]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],e["screen-npm"]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],e.erase=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],!(r instanceof S.get().getWebGLRenderingContext()))e.min=[r.ONE,r.ONE,r.ONE,r.ONE,r.MIN,r.MIN],e.max=[r.ONE,r.ONE,r.ONE,r.ONE,r.MAX,r.MAX];else{const n=r.getExtension("EXT_blend_minmax");n&&(e.min=[r.ONE,r.ONE,r.ONE,r.ONE,n.MIN_EXT,n.MIN_EXT],e.max=[r.ONE,r.ONE,r.ONE,r.ONE,n.MAX_EXT,n.MAX_EXT])}return e}const{BLEND:Tt,OFFSET:xt,CULLING:vt,DEPTH_TEST:At,WINDING:Bt,DEPTH_MASK:Y}=We,Se=class F{constructor(e){this._invertFrontFace=!1,this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode="none",this._blendEq=!1,this.map=[],this.map[Tt]=this.setBlend,this.map[xt]=this.setOffset,this.map[vt]=this.setCullFace,this.map[At]=this.setDepthTest,this.map[Bt]=this.setFrontFace,this.map[Y]=this.setDepthMask,this.checks=[],this.defaultState=O.for2d(),e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){this._invertFrontFace=!e.isRoot!=!!e.flipY,this._cullFace?this.setFrontFace(this._frontFace):this._frontFaceDirty=!0}contextChange(e){this.gl=e,this.blendModesMap=gt(e),this.resetState()}set(e){if(e||(e=this.defaultState),this.stateId!==e.data){let t=this.stateId^e.data,n=0;for(;t;)t&1&&this.map[n].call(this,!!(e.data&1<<n)),t>>=1,n++;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(e){this._updateCheck(F._checkBlendMode,e),this.gl[e?"enable":"disable"](this.gl.BLEND)}setOffset(e){this._updateCheck(F._checkPolygonOffset,e),this.gl[e?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(e){this.gl[e?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(e){this.gl.depthMask(e)}get depthMaskEnabled(){return!!(this.stateId&1<<Y)}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],n=this.gl;t.length===2?n.blendFunc(t[0],t[1]):n.blendFuncSeparate(t[0],t[1],t[2],t[3]),t.length===6?(this._blendEq=!0,n.blendEquationSeparate(t[4],t[5])):this._blendEq&&(this._blendEq=!1,n.blendEquationSeparate(n.FUNC_ADD,n.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 n=this.checks.indexOf(e);t&&n===-1?this.checks.push(e):!t&&n!==-1&&this.checks.splice(n,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}};Se.extension={type:[d.WebGLSystem],name:"state"};let yt=Se;class Ct{constructor(e){this.target=H.TEXTURE_2D,this._layerInitMask=0,this.texture=e,this.width=-1,this.height=-1,this.type=f.UNSIGNED_BYTE,this.internalFormat=U.RGBA,this.format=U.RGBA,this.samplerType=0}destroy(){}}const Dt={id:"buffer",upload(r,e,t,n,s,i=!1){const a=s||e.target;!i&&e.width===r.width&&e.height===r.height?t.texSubImage2D(a,0,0,0,r.width,r.height,e.format,e.type,r.resource):t.texImage2D(a,0,e.internalFormat,r.width,r.height,0,e.format,e.type,r.resource),e.width=r.width,e.height=r.height}},Nt={"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},It={id:"compressed",upload(r,e,t,n,s,i){const a=s??e.target;t.pixelStorei(t.UNPACK_ALIGNMENT,4);let c=r.pixelWidth,o=r.pixelHeight;const u=!!Nt[r.format];for(let _=0;_<r.resource.length;_++){const h=r.resource[_];u?t.compressedTexImage2D(a,_,e.internalFormat,c,o,0,h):t.texImage2D(a,_,e.internalFormat,c,o,0,e.format,e.type,h),c=Math.max(c>>1,1),o=Math.max(o>>1,1)}}},$=["right","left","top","bottom","front","back"];function Gt(r){return{id:"cube",upload(e,t,n,s){const i=e.faces;for(let a=0;a<$.length;a++){const c=$[a],o=i[c];if(!o.resource)continue;(r[o.uploadMethodId]||r.image).upload(o,t,n,s,H.TEXTURE_CUBE_MAP_POSITIVE_X+a,(t._layerInitMask&1<<a)===0),t._layerInitMask|=1<<a}t.width=e.pixelWidth,t.height=e.pixelHeight}}}const ge={id:"image",upload(r,e,t,n,s,i=!1){const a=s||e.target,c=r.pixelWidth,o=r.pixelHeight,u=r.resourceWidth,_=r.resourceHeight,h=n===2,l=i||e.width!==c||e.height!==o,m=u>=c&&_>=o,p=r.resource;(h?Ut:Ft)(t,a,e,c,o,u,_,p,l,m),e.width=c,e.height=o}};function Ut(r,e,t,n,s,i,a,c,o,u){if(!u){o&&r.texImage2D(e,0,t.internalFormat,n,s,0,t.format,t.type,null),r.texSubImage2D(e,0,0,0,i,a,t.format,t.type,c);return}if(!o){r.texSubImage2D(e,0,0,0,t.format,t.type,c);return}r.texImage2D(e,0,t.internalFormat,n,s,0,t.format,t.type,c)}function Ft(r,e,t,n,s,i,a,c,o,u){if(!u){o&&r.texImage2D(e,0,t.internalFormat,n,s,0,t.format,t.type,null),r.texSubImage2D(e,0,0,0,t.format,t.type,c);return}if(!o){r.texSubImage2D(e,0,0,0,t.format,t.type,c);return}r.texImage2D(e,0,t.internalFormat,t.format,t.type,c)}const Mt=ze(),Ot={id:"video",upload(r,e,t,n,s,i=Mt){if(!r.isValid){const a=s??e.target;t.texImage2D(a,0,e.internalFormat,1,1,0,e.format,e.type,null);return}ge.upload(r,e,t,n,s,i)}},z={linear:9729,nearest:9728},Pt={linear:{linear:9987,nearest:9985},nearest:{linear:9986,nearest:9984}},G={"clamp-to-edge":33071,repeat:10497,"mirror-repeat":33648},Lt={never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519};function q(r,e,t,n,s,i,a,c){const o=i;if(!c||r.addressModeU!=="repeat"||r.addressModeV!=="repeat"||r.addressModeW!=="repeat"){const u=G[a?"clamp-to-edge":r.addressModeU],_=G[a?"clamp-to-edge":r.addressModeV],h=G[a?"clamp-to-edge":r.addressModeW];e[s](o,e.TEXTURE_WRAP_S,u),e[s](o,e.TEXTURE_WRAP_T,_),e.TEXTURE_WRAP_R&&e[s](o,e.TEXTURE_WRAP_R,h)}if((!c||r.magFilter!=="linear")&&e[s](o,e.TEXTURE_MAG_FILTER,z[r.magFilter]),t){if(!c||r.mipmapFilter!=="linear"){const u=Pt[r.minFilter][r.mipmapFilter];e[s](o,e.TEXTURE_MIN_FILTER,u)}}else e[s](o,e.TEXTURE_MIN_FILTER,z[r.minFilter]);if(n&&r.maxAnisotropy>1){const u=Math.min(r.maxAnisotropy,e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT));e[s](o,n.TEXTURE_MAX_ANISOTROPY_EXT,u)}r.compare?(e[s](o,e.TEXTURE_COMPARE_FUNC,Lt[r.compare]),e[s](o,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE)):c||e[s](o,e.TEXTURE_COMPARE_MODE,e.NONE)}function wt(r){return{r8unorm:r.RED,r8snorm:r.RED,r8uint:r.RED,r8sint:r.RED,r16uint:r.RED,r16sint:r.RED,r16float:r.RED,rg8unorm:r.RG,rg8snorm:r.RG,rg8uint:r.RG,rg8sint:r.RG,r32uint:r.RED,r32sint:r.RED,r32float:r.RED,rg16uint:r.RG,rg16sint:r.RG,rg16float:r.RG,rgba8unorm:r.RGBA,"rgba8unorm-srgb":r.RGBA,rgba8snorm:r.RGBA,rgba8uint:r.RGBA,rgba8sint:r.RGBA,bgra8unorm:r.RGBA,"bgra8unorm-srgb":r.RGBA,rgb9e5ufloat:r.RGB,rgb10a2unorm:r.RGBA,rg11b10ufloat:r.RGB,rg32uint:r.RG,rg32sint:r.RG,rg32float:r.RG,rgba16uint:r.RGBA,rgba16sint:r.RGBA,rgba16float:r.RGBA,rgba32uint:r.RGBA,rgba32sint:r.RGBA,rgba32float:r.RGBA,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT,depth24plus:r.DEPTH_COMPONENT,"depth24plus-stencil8":r.DEPTH_STENCIL,depth32float:r.DEPTH_COMPONENT,"depth32float-stencil8":r.DEPTH_STENCIL}}function Ht(r,e){let t={},n=r.RGBA;return r instanceof S.get().getWebGLRenderingContext()?e.srgb&&(t={"rgba8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT,"bgra8unorm-srgb":e.srgb.SRGB8_ALPHA8_EXT}):(t={"rgba8unorm-srgb":r.SRGB8_ALPHA8,"bgra8unorm-srgb":r.SRGB8_ALPHA8},n=r.RGBA8),{r8unorm:r.R8,r8snorm:r.R8_SNORM,r8uint:r.R8UI,r8sint:r.R8I,r16uint:r.R16UI,r16sint:r.R16I,r16float:r.R16F,rg8unorm:r.RG8,rg8snorm:r.RG8_SNORM,rg8uint:r.RG8UI,rg8sint:r.RG8I,r32uint:r.R32UI,r32sint:r.R32I,r32float:r.R32F,rg16uint:r.RG16UI,rg16sint:r.RG16I,rg16float:r.RG16F,rgba8unorm:r.RGBA,...t,rgba8snorm:r.RGBA8_SNORM,rgba8uint:r.RGBA8UI,rgba8sint:r.RGBA8I,bgra8unorm:n,rgb9e5ufloat:r.RGB9_E5,rgb10a2unorm:r.RGB10_A2,rg11b10ufloat:r.R11F_G11F_B10F,rg32uint:r.RG32UI,rg32sint:r.RG32I,rg32float:r.RG32F,rgba16uint:r.RGBA16UI,rgba16sint:r.RGBA16I,rgba16float:r.RGBA16F,rgba32uint:r.RGBA32UI,rgba32sint:r.RGBA32I,rgba32float:r.RGBA32F,stencil8:r.STENCIL_INDEX8,depth16unorm:r.DEPTH_COMPONENT16,depth24plus:r.DEPTH_COMPONENT24,"depth24plus-stencil8":r.DEPTH24_STENCIL8,depth32float:r.DEPTH_COMPONENT32F,"depth32float-stencil8":r.DEPTH32F_STENCIL8,...e.s3tc?{"bc1-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT1_EXT,"bc2-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT3_EXT,"bc3-rgba-unorm":e.s3tc.COMPRESSED_RGBA_S3TC_DXT5_EXT}:{},...e.s3tc_sRGB?{"bc1-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,"bc2-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,"bc3-rgba-unorm-srgb":e.s3tc_sRGB.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}:{},...e.rgtc?{"bc4-r-unorm":e.rgtc.COMPRESSED_RED_RGTC1_EXT,"bc4-r-snorm":e.rgtc.COMPRESSED_SIGNED_RED_RGTC1_EXT,"bc5-rg-unorm":e.rgtc.COMPRESSED_RED_GREEN_RGTC2_EXT,"bc5-rg-snorm":e.rgtc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}:{},...e.bptc?{"bc6h-rgb-float":e.bptc.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,"bc6h-rgb-ufloat":e.bptc.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,"bc7-rgba-unorm":e.bptc.COMPRESSED_RGBA_BPTC_UNORM_EXT,"bc7-rgba-unorm-srgb":e.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT}:{},...e.etc?{"etc2-rgb8unorm":e.etc.COMPRESSED_RGB8_ETC2,"etc2-rgb8unorm-srgb":e.etc.COMPRESSED_SRGB8_ETC2,"etc2-rgb8a1unorm":e.etc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgb8a1unorm-srgb":e.etc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,"etc2-rgba8unorm":e.etc.COMPRESSED_RGBA8_ETC2_EAC,"etc2-rgba8unorm-srgb":e.etc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,"eac-r11unorm":e.etc.COMPRESSED_R11_EAC,"eac-rg11unorm":e.etc.COMPRESSED_SIGNED_RG11_EAC}:{},...e.astc?{"astc-4x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_4x4_KHR,"astc-4x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,"astc-5x4-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x4_KHR,"astc-5x4-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR,"astc-5x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_5x5_KHR,"astc-5x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,"astc-6x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x5_KHR,"astc-6x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,"astc-6x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_6x6_KHR,"astc-6x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,"astc-8x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x5_KHR,"astc-8x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,"astc-8x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x6_KHR,"astc-8x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,"astc-8x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_8x8_KHR,"astc-8x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,"astc-10x5-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x5_KHR,"astc-10x5-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,"astc-10x6-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x6_KHR,"astc-10x6-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,"astc-10x8-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x8_KHR,"astc-10x8-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,"astc-10x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_10x10_KHR,"astc-10x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,"astc-12x10-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x10_KHR,"astc-12x10-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,"astc-12x12-unorm":e.astc.COMPRESSED_RGBA_ASTC_12x12_KHR,"astc-12x12-unorm-srgb":e.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR}:{}}}function Vt(r){return{r8unorm:r.UNSIGNED_BYTE,r8snorm:r.BYTE,r8uint:r.UNSIGNED_BYTE,r8sint:r.BYTE,r16uint:r.UNSIGNED_SHORT,r16sint:r.SHORT,r16float:r.HALF_FLOAT,rg8unorm:r.UNSIGNED_BYTE,rg8snorm:r.BYTE,rg8uint:r.UNSIGNED_BYTE,rg8sint:r.BYTE,r32uint:r.UNSIGNED_INT,r32sint:r.INT,r32float:r.FLOAT,rg16uint:r.UNSIGNED_SHORT,rg16sint:r.SHORT,rg16float:r.HALF_FLOAT,rgba8unorm:r.UNSIGNED_BYTE,"rgba8unorm-srgb":r.UNSIGNED_BYTE,rgba8snorm:r.BYTE,rgba8uint:r.UNSIGNED_BYTE,rgba8sint:r.BYTE,bgra8unorm:r.UNSIGNED_BYTE,"bgra8unorm-srgb":r.UNSIGNED_BYTE,rgb9e5ufloat:r.UNSIGNED_INT_5_9_9_9_REV,rgb10a2unorm:r.UNSIGNED_INT_2_10_10_10_REV,rg11b10ufloat:r.UNSIGNED_INT_10F_11F_11F_REV,rg32uint:r.UNSIGNED_INT,rg32sint:r.INT,rg32float:r.FLOAT,rgba16uint:r.UNSIGNED_SHORT,rgba16sint:r.SHORT,rgba16float:r.HALF_FLOAT,rgba32uint:r.UNSIGNED_INT,rgba32sint:r.INT,rgba32float:r.FLOAT,stencil8:r.UNSIGNED_BYTE,depth16unorm:r.UNSIGNED_SHORT,depth24plus:r.UNSIGNED_INT,"depth24plus-stencil8":r.UNSIGNED_INT_24_8,depth32float:r.FLOAT,"depth32float-stencil8":r.FLOAT_32_UNSIGNED_INT_24_8_REV}}function Xt(r){return{"2d":r.TEXTURE_2D,cube:r.TEXTURE_CUBE_MAP,"1d":null,"3d":r?.TEXTURE_3D||null,"2d-array":r?.TEXTURE_2D_ARRAY||null,"cube-array":r?.TEXTURE_CUBE_MAP_ARRAY||null}}const kt=4,X=class Te{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 M({renderer:e,type:"resource",onUnload:this.onSourceUnload.bind(this),name:"glTexture"});const t={image:ge,buffer:Dt,video:Ot,compressed:It,...Te.uploadExtensions};this._uploads={...t,cube:Gt(t)}}get managedTextures(){return Object.values(this._managedTextures.items)}contextChange(e){this._gl=e,this._mapFormatToInternalFormat||(this._mapFormatToInternalFormat=Ht(e,this._renderer.context.extensions),this._mapFormatToType=Vt(e),this._mapFormatToFormat=wt(e),this._mapViewDimensionToGlTarget=Xt(e)),this._managedTextures.removeAll(!0),this._glSamplers=Object.create(null),this._boundSamplers=Object.create(null),this._premultiplyAlpha=!1;for(let t=0;t<16;t++)this.bind(R.EMPTY,t)}initSource(e){this.bind(e)}bind(e,t=0){const n=e.source;e?(this.bindSource(n,t),this._useSeparateSamplers&&this._bindSampler(n.style,t)):(this.bindSource(null,t),this._useSeparateSamplers&&this._bindSampler(null,t))}bindSource(e,t=0){const n=this._gl;if(e._gcLastUsed=this._renderer.gc.now,this._boundTextures[t]!==e){this._boundTextures[t]=e,this._activateLocation(t),e||(e=R.EMPTY.source);const s=this.getGlSource(e);n.bindTexture(s.target,s.texture)}}_bindSampler(e,t=0){const n=this._gl;if(!e){this._boundSamplers[t]=null,n.bindSampler(t,null);return}const s=this._getGlSampler(e);this._boundSamplers[t]!==s&&(this._boundSamplers[t]=s,n.bindSampler(t,s))}unbind(e){const t=e.source,n=this._boundTextures,s=this._gl;for(let i=0;i<n.length;i++)if(n[i]===t){this._activateLocation(i);const a=this.getGlSource(t);s.bindTexture(a.target,null),n[i]=null}}_activateLocation(e){this._activeTextureLocation!==e&&(this._activeTextureLocation=e,this._gl.activeTexture(this._gl.TEXTURE0+e))}_initSource(e){const t=this._gl,n=new Ct(t.createTexture());if(n.type=this._mapFormatToType[e.format],n.internalFormat=this._mapFormatToInternalFormat[e.format],n.format=this._mapFormatToFormat[e.format],n.target=this._mapViewDimensionToGlTarget[e.viewDimension],n.target===null)throw new Error(`Unsupported view dimension: ${e.viewDimension} with this webgl version: ${this._renderer.context.webGLVersion}`);if(e.autoGenerateMipmaps&&(this._renderer.context.supports.nonPowOf2mipmaps||e.isPowerOfTwo)){const i=Math.max(e.width,e.height);e.mipLevelCount=Math.floor(Math.log2(i))+1}return e._gpuData[this._renderer.uid]=n,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),n}onStyleChange(e){this.updateStyle(e,!1)}updateStyle(e,t){const n=this._gl,s=this.getGlSource(e);n.bindTexture(s.target,s.texture),this._boundTextures[this._activeTextureLocation]=e,q(e.style,n,e.mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"texParameteri",s.target,!this._renderer.context.supports.nonPowOf2wrapping&&!e.isPowerOfTwo,t)}onSourceUnload(e,t=!1){const n=e._gpuData[this._renderer.uid];n&&(t||(this.unbind(e),this._gl.deleteTexture(n.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,n=this.getGlSource(e);t.bindTexture(n.target,n.texture),this._boundTextures[this._activeTextureLocation]=e;const s=e.alphaMode==="premultiply-alpha-on-upload";if(this._premultiplyAlpha!==s&&(this._premultiplyAlpha=s,t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s)),this._uploads[e.uploadMethodId])this._uploads[e.uploadMethodId].upload(e,n,t,this._renderer.context.webGLVersion);else if(n.target===t.TEXTURE_2D)this._initEmptyTexture2D(n,e);else if(n.target===t.TEXTURE_2D_ARRAY)this._initEmptyTexture2DArray(n,e);else if(n.target===t.TEXTURE_CUBE_MAP)this._initEmptyTextureCube(n,e);else throw new Error("[GlTextureSystem] Unsupported texture target for empty allocation.");this._applyMipRange(n,e),e.autoGenerateMipmaps&&e.mipLevelCount>1&&this.onUpdateMipmaps(e,!1)}onUpdateMipmaps(e,t=!0){t&&this.bindSource(e,0);const n=this.getGlSource(e);this._gl.generateMipmap(n.target)}_initEmptyTexture2D(e,t){const n=this._gl;n.texImage2D(n.TEXTURE_2D,0,e.internalFormat,t.pixelWidth,t.pixelHeight,0,e.format,e.type,null);let s=Math.max(t.pixelWidth>>1,1),i=Math.max(t.pixelHeight>>1,1);for(let a=1;a<t.mipLevelCount;a++)n.texImage2D(n.TEXTURE_2D,a,e.internalFormat,s,i,0,e.format,e.type,null),s=Math.max(s>>1,1),i=Math.max(i>>1,1)}_initEmptyTexture2DArray(e,t){if(this._renderer.context.webGLVersion!==2)throw new Error("[GlTextureSystem] TEXTURE_2D_ARRAY requires WebGL2.");const n=this._gl,s=Math.max(t.arrayLayerCount|0,1);n.texImage3D(n.TEXTURE_2D_ARRAY,0,e.internalFormat,t.pixelWidth,t.pixelHeight,s,0,e.format,e.type,null);let i=Math.max(t.pixelWidth>>1,1),a=Math.max(t.pixelHeight>>1,1);for(let c=1;c<t.mipLevelCount;c++)n.texImage3D(n.TEXTURE_2D_ARRAY,c,e.internalFormat,i,a,s,0,e.format,e.type,null),i=Math.max(i>>1,1),a=Math.max(a>>1,1)}_initEmptyTextureCube(e,t){const n=this._gl,s=6;for(let c=0;c<s;c++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,e.internalFormat,t.pixelWidth,t.pixelHeight,0,e.format,e.type,null);let i=Math.max(t.pixelWidth>>1,1),a=Math.max(t.pixelHeight>>1,1);for(let c=1;c<t.mipLevelCount;c++){for(let o=0;o<s;o++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,c,e.internalFormat,i,a,0,e.format,e.type,null);i=Math.max(i>>1,1),a=Math.max(a>>1,1)}}_applyMipRange(e,t){if(this._renderer.context.webGLVersion!==2||t.mipLevelCount<=1)return;const n=this._gl,s=Math.max((t.mipLevelCount|0)-1,0);n.texParameteri(e.target,n.TEXTURE_BASE_LEVEL,0),n.texParameteri(e.target,n.TEXTURE_MAX_LEVEL,s)}_initSampler(e){const t=this._gl,n=this._gl.createSampler();return this._glSamplers[e._resourceId]=n,q(e,t,this._boundTextures[this._activeTextureLocation].mipLevelCount>1,this._renderer.context.extensions.anisotropicFiltering,"samplerParameteri",n,!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:n,height:s}=this.getPixels(e),i=S.get().createCanvas();i.width=n,i.height=s;const a=i.getContext("2d");if(a){const c=a.createImageData(n,s);c.data.set(t),a.putImageData(c,0,0)}return i}getPixels(e){const t=e.source.resolution,n=e.frame,s=Math.max(Math.round(n.width*t),1),i=Math.max(Math.round(n.height*t),1),a=new Uint8Array(kt*s*i),c=this._renderer,o=c.renderTarget.getRenderTarget(e),u=c.renderTarget.getGpuRenderTarget(o),_=c.gl;return c.renderTarget.adaptor.bindFramebuffer(u.resolveTargetFramebuffer),_.readPixels(Math.round(n.x*t),Math.round(n.y*t),s,i,_.RGBA,_.UNSIGNED_BYTE,a),{pixels:new Uint8ClampedArray(a.buffer),width:s,height:i}}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(R.EMPTY.source),this._boundSamplers=Object.create(null);const e=this._gl;this._premultiplyAlpha=!1,e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._premultiplyAlpha)}};X.extension={type:[d.WebGLSystem],name:"texture"};X.uploadExtensions=Object.create(null);let xe=X;T.handleByMap(d.TextureUploaderWebGL,xe.uploadExtensions);class ve{contextChange(e){const t=new L({uColor:{value:new Float32Array([1,1,1,1]),type:"vec4<f32>"},uTransformMatrix:{value:new Q,type:"mat3x3<f32>"},uRound:{value:0,type:"f32"}}),n=e.limits.maxBatchableTextures,s=J({name:"graphics",bits:[Ue,Fe(n),re,ee]});this.shader=new P({glProgram:s,resources:{localUniforms:t,batchSamplers:Me(n)}})}execute(e,t){const n=t.context,s=n.customShader||this.shader,i=e.renderer,a=i.graphicsContext,{batcher:c,instructions:o}=a.getContextRenderData(n);s.groups[0]=i.globalUniforms.bindGroup,i.state.set(e.state),i.shader.bind(s),i.geometry.bind(c.geometry,s.glProgram);const u=o.instructions;for(let _=0;_<o.instructionSize;_++){const h=u[_];if(h.size){for(let l=0;l<h.textures.count;l++)i.texture.bind(h.textures.textures[l],l);i.geometry.draw(h.topology,h.size,h.start)}}}destroy(){this.shader.destroy(!0),this.shader=null}}ve.extension={type:[d.WebGLPipesAdaptor],name:"graphics"};class Ae{init(){const e=J({name:"mesh",bits:[re,Ve,ee]});this._shader=new P({glProgram:e,resources:{uTexture:R.EMPTY.source,textureUniforms:{uTextureMatrix:{type:"mat3x3<f32>",value:new Q}}}})}execute(e,t){const n=e.renderer;let s=t._shader;if(s){if(!s.glProgram){b("Mesh shader has no glProgram",t.shader);return}}else{s=this._shader;const i=t.texture,a=i.source;s.resources.uTexture=a,s.resources.uSampler=a.style,s.resources.textureUniforms.uniforms.uTextureMatrix=i.textureMatrix.mapCoord}s.groups[100]=n.globalUniforms.bindGroup,s.groups[101]=e.localUniformsBindGroup,n.encoder.draw({geometry:t._geometry,shader:s,state:t.state})}destroy(){this._shader.destroy(!0),this._shader=null}}Ae.extension={type:[d.WebGLPipesAdaptor],name:"mesh"};const Wt=[...Ye,de,rt,Ze,he,ie,xe,me,oe,Re,pe,_e,yt,fe,ue],jt=[...$e],Kt=[se,Ae,ve],Be=[],ye=[],Ce=[];T.handleByNamedList(d.WebGLSystem,Be);T.handleByNamedList(d.WebGLPipes,ye);T.handleByNamedList(d.WebGLPipesAdaptor,Ce);T.add(...Wt,...jt,...Kt);class tr extends Ie{constructor(){const e={name:"webgl",type:je.WEBGL,systems:Be,renderPipes:ye,renderPipeAdaptors:Ce};super(e)}}export{tr as WebGLRenderer};
