(function webpackUniversalModuleDefinition(root, factory) { if (typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if (typeof define === 'function' && define.amd) define([], factory); else if (typeof exports === 'object') exports['luma'] = factory(); else root['luma'] = factory();})(globalThis, function () { var __exports__=(()=>{var ur=Object.create;var de=Object.defineProperty;var Dr=Object.getOwnPropertyDescriptor;var xr=Object.getOwnPropertyNames;var Ur=Object.getPrototypeOf,yr=Object.prototype.hasOwnProperty;var wr=(e,t,r)=>t in e?de(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Xr=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),vr=(e,t)=>{for(var r in t)de(e,r,{get:t[r],enumerable:!0})},ye=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of xr(t))!yr.call(e,s)&&s!==r&&de(e,s,{get:()=>t[s],enumerable:!(i=Dr(t,s))||i.enumerable});return e},we=(e,t,r)=>(ye(e,t,"default"),r&&ye(r,t,"default")),d=(e,t,r)=>(r=e!=null?ur(Ur(e)):{},ye(t||!e||!e.__esModule?de(r,"default",{value:e,enumerable:!0}):r,e)),Hr=e=>ye(de({},"__esModule",{value:!0}),e);var L=(e,t,r)=>(wr(e,typeof t!="symbol"?t+"":t,r),r);var A=Xr((es,Ct)=>{Ct.exports=globalThis.luma});var Ue={};vr(Ue,{Accessor:()=>K,WEBGLBuffer:()=>O,WEBGLCommandEncoder:()=>ne,WEBGLFramebuffer:()=>w,WEBGLRenderPass:()=>ae,WEBGLRenderPipeline:()=>_e,WEBGLResource:()=>q,WEBGLSampler:()=>Y,WEBGLShader:()=>oe,WEBGLTexture:()=>I,WEBGLTransformFeedback:()=>ce,WEBGLVertexArray:()=>Z,WebGLCanvasContext:()=>ie,WebGLDevice:()=>De,WebGLResource:()=>q,_TEXTURE_FORMATS:()=>$,_WEBGLRenderbuffer:()=>xe,convertGLToTextureFormat:()=>Wt,getGLParameters:()=>G,getShaderLayout:()=>Le,popContextState:()=>U,pushContextState:()=>X,resetGLParameters:()=>Xe,setDeviceParameters:()=>$e,setGLParameters:()=>D,trackContextState:()=>ge,withDeviceParameters:()=>Qt,withGLParameters:()=>B});we(Ue,d(A(),1));var g=d(A(),1);var Ee=d(A(),1);var m;(function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",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_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",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[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.R16_EXT=33322]="R16_EXT",e[e.RG16_EXT=33324]="RG16_EXT",e[e.RGB16_EXT=32852]="RGB16_EXT",e[e.RGBA16_EXT=32859]="RGBA16_EXT",e[e.R16_SNORM_EXT=36760]="R16_SNORM_EXT",e[e.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",e[e.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",e[e.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",e[e.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",e[e.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",e[e.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",e[e.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",e[e.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",e[e.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",e[e.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",e[e.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",e[e.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",e[e.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",e[e.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",e[e.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",e[e.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",e[e.LINE_WEBGL=6913]="LINE_WEBGL",e[e.FILL_WEBGL=6914]="FILL_WEBGL",e[e.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",e[e.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",e[e.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",e[e.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",e[e.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",e[e.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",e[e.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",e[e.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",e[e.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",e[e.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",e[e.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",e[e.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",e[e.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",e[e.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",e[e.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",e[e.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",e[e.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",e[e.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",e[e.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",e[e.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",e[e.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",e[e.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",e[e.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",e[e.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(m||(m={}));var Se={[3042]:!1,[32773]:new Float32Array([0,0,0,0]),[32777]:32774,[34877]:32774,[32969]:1,[32968]:0,[32971]:1,[32970]:0,[3106]:new Float32Array([0,0,0,0]),[3107]:[!0,!0,!0,!0],[2884]:!1,[2885]:1029,[2929]:!1,[2931]:1,[2932]:513,[2928]:new Float32Array([0,1]),[2930]:!0,[3024]:!0,[35725]:null,[36006]:null,[36007]:null,[34229]:null,[34964]:null,[2886]:2305,[33170]:4352,[2849]:1,[32823]:!1,[32824]:0,[10752]:0,[32926]:!1,[32928]:!1,[32938]:1,[32939]:!1,[3089]:!1,[3088]:new Int32Array([0,0,1024,1024]),[2960]:!1,[2961]:0,[2968]:4294967295,[36005]:4294967295,[2962]:519,[2967]:0,[2963]:4294967295,[34816]:519,[36003]:0,[36004]:4294967295,[2964]:7680,[2965]:7680,[2966]:7680,[34817]:7680,[34818]:7680,[34819]:7680,[2978]:[0,0,1024,1024],[36389]:null,[36662]:null,[36663]:null,[35053]:null,[35055]:null,[35723]:4352,[36010]:null,[35977]:!1,[3333]:4,[3317]:4,[37440]:!1,[37441]:!1,[37443]:37444,[3330]:0,[3332]:0,[3331]:0,[3314]:0,[32878]:0,[3316]:0,[3315]:0,[32877]:0},C=(e,t,r)=>t?e.enable(r):e.disable(r),It=(e,t,r)=>e.hint(r,t),u=(e,t,r)=>e.pixelStorei(r,t),Nt=(e,t,r)=>{let i=r===36006?36009:36008;return e.bindFramebuffer(i,t)},he=(e,t,r)=>{let s={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[r];e.bindBuffer(s,t)};function it(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}var Ft={[3042]:C,[32773]:(e,t)=>e.blendColor(...t),[32777]:"blendEquation",[34877]:"blendEquation",[32969]:"blendFunc",[32968]:"blendFunc",[32971]:"blendFunc",[32970]:"blendFunc",[3106]:(e,t)=>e.clearColor(...t),[3107]:(e,t)=>e.colorMask(...t),[2884]:C,[2885]:(e,t)=>e.cullFace(t),[2929]:C,[2931]:(e,t)=>e.clearDepth(t),[2932]:(e,t)=>e.depthFunc(t),[2928]:(e,t)=>e.depthRange(...t),[2930]:(e,t)=>e.depthMask(t),[3024]:C,[35723]:It,[35725]:(e,t)=>e.useProgram(t),[36007]:(e,t)=>e.bindRenderbuffer(36161,t),[36389]:(e,t)=>e.bindTransformFeedback?.(36386,t),[34229]:(e,t)=>e.bindVertexArray(t),[36006]:Nt,[36010]:Nt,[34964]:he,[36662]:he,[36663]:he,[35053]:he,[35055]:he,[2886]:(e,t)=>e.frontFace(t),[33170]:It,[2849]:(e,t)=>e.lineWidth(t),[32823]:C,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:C,[32926]:C,[32928]:C,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:C,[3088]:(e,t)=>e.scissor(...t),[2960]:C,[2961]:(e,t)=>e.clearStencil(t),[2968]:(e,t)=>e.stencilMaskSeparate(1028,t),[36005]:(e,t)=>e.stencilMaskSeparate(1029,t),[2962]:"stencilFuncFront",[2967]:"stencilFuncFront",[2963]:"stencilFuncFront",[34816]:"stencilFuncBack",[36003]:"stencilFuncBack",[36004]:"stencilFuncBack",[2964]:"stencilOpFront",[2965]:"stencilOpFront",[2966]:"stencilOpFront",[34817]:"stencilOpBack",[34818]:"stencilOpBack",[34819]:"stencilOpBack",[2978]:(e,t)=>e.viewport(...t),[34383]:C,[10754]:C,[12288]:C,[12289]:C,[12290]:C,[12291]:C,[12292]:C,[12293]:C,[12294]:C,[12295]:C,[3333]:u,[3317]:u,[37440]:u,[37441]:u,[37443]:u,[3330]:u,[3332]:u,[3331]:u,[3314]:u,[32878]:u,[3316]:u,[3315]:u,[32877]:u,framebuffer:(e,t)=>{let r=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,r)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{let r=typeof t=="number"?[t,t]:t;e.blendEquationSeparate(...r)},blendFunc:(e,t)=>{let r=t?.length===2?[...t,...t]:t;e.blendFuncSeparate(...r)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(...t),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=it(t)?t:[t,t];let[r,i]=t;e.stencilMaskSeparate(1028,r),e.stencilMaskSeparate(1029,i)},stencilFunc:(e,t)=>{t=it(t)&&t.length===3?[...t,...t]:t;let[r,i,s,o,a,_]=t;e.stencilFuncSeparate(1028,r,i,s),e.stencilFuncSeparate(1029,o,a,_)},stencilOp:(e,t)=>{t=it(t)&&t.length===3?[...t,...t]:t;let[r,i,s,o,a,_]=t;e.stencilOpSeparate(1028,r,i,s),e.stencilOpSeparate(1029,o,a,_)},viewport:(e,t)=>e.viewport(...t)};function p(e,t,r){return t[e]!==void 0?t[e]:r[e]}var Ot={blendEquation:(e,t,r)=>e.blendEquationSeparate(p(32777,t,r),p(34877,t,r)),blendFunc:(e,t,r)=>e.blendFuncSeparate(p(32969,t,r),p(32968,t,r),p(32971,t,r),p(32970,t,r)),polygonOffset:(e,t,r)=>e.polygonOffset(p(32824,t,r),p(10752,t,r)),sampleCoverage:(e,t,r)=>e.sampleCoverage(p(32938,t,r),p(32939,t,r)),stencilFuncFront:(e,t,r)=>e.stencilFuncSeparate(1028,p(2962,t,r),p(2967,t,r),p(2963,t,r)),stencilFuncBack:(e,t,r)=>e.stencilFuncSeparate(1029,p(34816,t,r),p(36003,t,r),p(36004,t,r)),stencilOpFront:(e,t,r)=>e.stencilOpSeparate(1028,p(2964,t,r),p(2965,t,r),p(2966,t,r)),stencilOpBack:(e,t,r)=>e.stencilOpSeparate(1029,p(34817,t,r),p(34818,t,r),p(34819,t,r))},st={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,r)=>e({[t]:r}),hint:(e,t,r)=>e({[t]:r}),useProgram:(e,t)=>e({[35725]:t}),bindRenderbuffer:(e,t,r)=>e({[36007]:r}),bindTransformFeedback:(e,t,r)=>e({[36389]:r}),bindVertexArray:(e,t)=>e({[34229]:t}),bindFramebuffer:(e,t,r)=>{switch(t){case 36160:return e({[36006]:r,[36010]:r});case 36009:return e({[36006]:r});case 36008:return e({[36010]:r});default:return null}},bindBuffer:(e,t,r)=>{let i={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[t];return i?e({[i]:r}):{valueChanged:!0}},blendColor:(e,t,r,i,s)=>e({[32773]:new Float32Array([t,r,i,s])}),blendEquation:(e,t)=>e({[32777]:t,[34877]:t}),blendEquationSeparate:(e,t,r)=>e({[32777]:t,[34877]:r}),blendFunc:(e,t,r)=>e({[32969]:t,[32968]:r,[32971]:t,[32970]:r}),blendFuncSeparate:(e,t,r,i,s)=>e({[32969]:t,[32968]:r,[32971]:i,[32970]:s}),clearColor:(e,t,r,i,s)=>e({[3106]:new Float32Array([t,r,i,s])}),clearDepth:(e,t)=>e({[2931]:t}),clearStencil:(e,t)=>e({[2961]:t}),colorMask:(e,t,r,i,s)=>e({[3107]:[t,r,i,s]}),cullFace:(e,t)=>e({[2885]:t}),depthFunc:(e,t)=>e({[2932]:t}),depthRange:(e,t,r)=>e({[2928]:new Float32Array([t,r])}),depthMask:(e,t)=>e({[2930]:t}),frontFace:(e,t)=>e({[2886]:t}),lineWidth:(e,t)=>e({[2849]:t}),polygonOffset:(e,t,r)=>e({[32824]:t,[10752]:r}),sampleCoverage:(e,t,r)=>e({[32938]:t,[32939]:r}),scissor:(e,t,r,i,s)=>e({[3088]:new Int32Array([t,r,i,s])}),stencilMask:(e,t)=>e({[2968]:t,[36005]:t}),stencilMaskSeparate:(e,t,r)=>e({[t===1028?2968:36005]:r}),stencilFunc:(e,t,r,i)=>e({[2962]:t,[2967]:r,[2963]:i,[34816]:t,[36003]:r,[36004]:i}),stencilFuncSeparate:(e,t,r,i,s)=>e({[t===1028?2962:34816]:r,[t===1028?2967:36003]:i,[t===1028?2963:36004]:s}),stencilOp:(e,t,r,i)=>e({[2964]:t,[2965]:r,[2966]:i,[34817]:t,[34818]:r,[34819]:i}),stencilOpSeparate:(e,t,r,i,s)=>e({[t===1028?2964:34817]:r,[t===1028?2965:34818]:i,[t===1028?2966:34819]:s}),viewport:(e,t,r,i,s)=>e({[2978]:[t,r,i,s]})},H=(e,t)=>e.isEnabled(t),ot={[3042]:H,[2884]:H,[2929]:H,[3024]:H,[32823]:H,[32926]:H,[32928]:H,[3089]:H,[2960]:H,[35977]:H},Mt=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function D(e,t){if(Wr(t))return;let r={};for(let s in t){let o=Number(s),a=Ft[s];a&&(typeof a=="string"?r[a]=!0:a(e,t[s],o))}let i=e.state&&e.state.cache;if(i)for(let s in r){let o=Ot[s];o(e,t,i)}}function G(e,t=Se){if(typeof t=="number"){let s=t,o=ot[s];return o?o(e,s):e.getParameter(s)}let r=Array.isArray(t)?t:Object.keys(t),i={};for(let s of r){let o=ot[s];i[s]=o?o(e,Number(s)):e.getParameter(Number(s))}return i}function Xe(e){D(e,Se)}function Wr(e){for(let t in e)return!1;return!0}function Bt(e,t){if(e===t)return!0;let r=Array.isArray(e)||ArrayBuffer.isView(e),i=Array.isArray(t)||ArrayBuffer.isView(t);if(r&&i&&e.length===t.length){for(let s=0;s{}}={}){this.gl=t,this.cache=r?G(t):Object.assign({},Se),this.log=i,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(t={}){this.stateStack.push({})}pop(){(0,Ee.assert)(this.stateStack.length>0);let t=this.stateStack[this.stateStack.length-1];D(this.gl,t),this.stateStack.pop()}_updateCache(t){let r=!1,i,s=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let o in t){(0,Ee.assert)(o!==void 0);let a=t[o],_=this.cache[o];Bt(a,_)||(r=!0,i=_,s&&!(o in s)&&(s[o]=_),this.cache[o]=a)}return{valueChanged:r,oldValue:i}}};function Q(e){return e.state}function ge(e,t){let{enable:r=!0,copyState:i}=t;if((0,Ee.assert)(i!==void 0),!e.state){e.state=new at(e,{copyState:i}),kr(e);for(let o in st){let a=st[o];Vr(e,o,a)}Pt(e,"getParameter"),Pt(e,"isEnabled")}let s=Q(e);return s.enable=r,e}function X(e){let t=Q(e);t||(ge(e,{copyState:!1}),t=Q(e)),t.push()}function U(e){let t=Q(e);(0,Ee.assert)(t),t.pop()}function Pt(e,t){let r=e[t].bind(e);e[t]=function(s){if(s===void 0||Mt.has(s))return r(s);let o=Q(e);return s in o.cache||(o.cache[s]=r(s)),o.enable?o.cache[s]:r(s)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function Vr(e,t,r){if(!e[t])return;let i=e[t].bind(e);e[t]=function(...o){let a=Q(e),{valueChanged:_,oldValue:n}=r(a._updateCache,...o);return _&&i(...o),n},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function kr(e){let t=e.useProgram.bind(e);e.useProgram=function(i){let s=Q(e);s.program!==i&&(t(i),s.program=i)}}var Kr={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function ut(e,t){t={...Kr,...t};let r=null,i=o=>r=o.statusMessage||r;e.addEventListener("webglcontextcreationerror",i,!1);let s=null;if(s||=e.getContext("webgl2",t),e.removeEventListener("webglcontextcreationerror",i,!1),!s)throw new Error(`Failed to create WebGL context: ${r||"Unknown error"}`);if(t.onContextLost){let{onContextLost:o}=t;e.addEventListener("webglcontextlost",a=>o(a),!1)}if(t.onContextRestored){let{onContextRestored:o}=t;e.addEventListener("webglcontextrestored",a=>o(a),!1)}return s}function y(e,t,r){return r[t]===void 0&&(r[t]=e.getExtension(t)||null),r[t]}function Dt(e,t){let r=e.getParameter(7936),i=e.getParameter(7937);y(e,"WEBGL_debug_renderer_info",t);let s=t.WEBGL_debug_renderer_info,o=e.getParameter(s?s.UNMASKED_VENDOR_WEBGL:7936),a=e.getParameter(s?s.UNMASKED_RENDERER_WEBGL:7937),_=o||r,n=a||i,l=e.getParameter(7938),c=xt(_,n),T=Yr(_,n),f=mr(_,n);return{type:"webgl",gpu:c,gpuType:f,gpuBackend:T,vendor:_,renderer:n,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function xt(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function Yr(e,t){return/Metal/i.exec(e)||/Metal/i.exec(t)?"metal":/ANGLE/i.exec(e)||/ANGLE/i.exec(t)?"opengl":"unknown"}function mr(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(xt(e,t)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}var mt=d(A(),1);var ft=d(A(),1);function ve(e){switch(e){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(e))}var F="texture-compression-bc",S="texture-compression-astc",W="texture-compression-etc2",$r="texture-compression-etc1-webgl",He="texture-compression-pvrtc-webgl",_t="texture-compression-atc-webgl",pe="float32-renderable-webgl",nt="float16-renderable-webgl",zr="rgb9e5ufloat_renderable-webgl",lt="snorm8-renderable-webgl",be="norm16-renderable-webgl",ct="snorm16-renderable-webgl",We="float32-filterable",Ut="float16-filterable-webgl",Ce="WEBGL_compressed_texture_s3tc",Ie="WEBGL_compressed_texture_s3tc_srgb",ee="EXT_texture_compression_rgtc",te="EXT_texture_compression_bptc",Zr="WEBGL_compressed_texture_etc",Qr="WEBGL_compressed_texture_astc",jr="WEBGL_compressed_texture_etc1",qr="WEBGL_compressed_texture_pvrtc",Jr="WEBGL_compressed_texture_atc",yt="EXT_texture_norm16",wt="EXT_render_snorm",Lr="EXT_color_buffer_float",Ve={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat_renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[wt],"norm16-renderable-webgl":[yt],"snorm16-renderable-webgl":[yt,wt],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[Ce,Ie,ee,te],"texture-compression-bc5-webgl":[ee],"texture-compression-bc7-webgl":[te],"texture-compression-etc2":[Zr],"texture-compression-astc":[Qr],"texture-compression-etc1-webgl":[jr],"texture-compression-pvrtc-webgl":[qr],"texture-compression-atc-webgl":[Jr]};function Xt(e){return e in Ve}function vt(e,t,r){return(Ve[t]||[]).every(s=>y(e,s,r))}var $={"rgb8unorm-unsized":{gl:6407,b:4,c:2,bpp:4,dataFormat:6407,types:[5121,33635]},"rgba8unorm-unsized":{gl:6408,b:4,c:2,bpp:4,dataFormat:6408,types:[5121,32819,32820]},r8unorm:{gl:33321,b:1,c:1,rb:!0},r8snorm:{gl:36756,b:1,c:1,render:lt},r8uint:{gl:33330,b:1,c:1,rb:!0},r8sint:{gl:33329,b:1,c:1,rb:!0},rg8unorm:{gl:33323,b:2,c:2,rb:!0},rg8snorm:{gl:36757,b:2,c:2,render:lt},rg8uint:{gl:33336,b:2,c:2,rb:!0},rg8sint:{gl:33335,b:2,c:2,rb:!0},r16uint:{gl:33332,b:2,c:1,rb:!0},r16sint:{gl:33331,b:2,c:1,rb:!0},r16float:{gl:33325,b:2,c:1,render:nt,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:be,rb:!0},"r16snorm-webgl":{gl:36760,b:2,c:1,f:ct},"rgba4unorm-webgl":{gl:32854,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:36194,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:32855,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:32849,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:36758,b:3,c:3,wgpu:!1},rgba8unorm:{gl:32856,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:35907,b:4,c:4,bpp:4},rgba8snorm:{gl:36759,b:4,c:4,render:lt},rgba8uint:{gl:36220,b:4,c:4,bpp:4},rgba8sint:{gl:36238,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:33338,b:4,c:1,bpp:4},rg16sint:{gl:33337,b:4,c:2,bpp:4},rg16float:{gl:33327,bpp:4,b:4,c:2,render:nt,filter:Ut,rb:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,render:be},"rg16snorm-webgl":{gl:36761,b:2,c:2,render:ct},r32uint:{gl:33334,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:33333,b:4,c:1,bpp:4,rb:!0},r32float:{gl:33326,bpp:4,b:4,c:1,render:pe,filter:We},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:zr},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:pe,rb:!0},rgb10a2unorm:{gl:32857,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:36975,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:32852,b:2,c:3,f:be},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:be},rg32uint:{gl:33340,b:8,c:2,rb:!0},rg32sint:{gl:33339,b:8,c:2,rb:!0},rg32float:{gl:33328,b:8,c:2,render:pe,filter:We,rb:!0},rgba16uint:{gl:36214,b:8,c:4,rb:!0},rgba16sint:{gl:36232,b:8,c:4,rb:!0},rgba16float:{gl:34842,b:8,c:4,render:nt,filter:Ut},"rgba16unorm-webgl":{gl:32859,b:2,c:4,render:be,rb:!0},"rgba16snorm-webgl":{gl:36763,b:2,c:4,render:ct},"rgb32float-webgl":{gl:34837,render:pe,filter:We,gl2ext:Lr,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,b:16,c:4,rb:!0},rgba32sint:{gl:36226,b:16,c:4,rb:!0},rgba32float:{gl:34836,b:16,c:4,render:pe,filter:We,rb:!0},stencil8:{gl:36168,b:1,c:1,attachment:36128,rb:!0},depth16unorm:{gl:33189,b:2,c:1,attachment:36096,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,b:3,c:1,attachment:36096,dataFormat:6402,types:[5125]},depth32float:{gl:36012,b:4,c:1,attachment:36096,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth24unorm-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,dataFormat:34041,types:[34042],rb:!0},"depth32float-stencil8":{gl:36013,b:5,c:2,p:1,attachment:33306,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Ce,f:F},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Ie,f:F},"bc1-rgba-unorm":{gl:33777,x:Ce,f:F},"bc1-rgba-unorm-srgb":{gl:35916,x:Ie,f:F},"bc2-rgba-unorm":{gl:33778,x:Ce,f:F},"bc2-rgba-unorm-srgb":{gl:35918,x:Ie,f:F},"bc3-rgba-unorm":{gl:33779,x:Ce,f:F},"bc3-rgba-unorm-srgb":{gl:35919,x:Ie,f:F},"bc4-r-unorm":{gl:36283,x:ee,f:F},"bc4-r-snorm":{gl:36284,x:ee,f:F},"bc5-rg-unorm":{gl:36285,x:ee,f:F},"bc5-rg-snorm":{gl:36286,x:ee,f:F},"bc6h-rgb-ufloat":{gl:36495,x:te,f:F},"bc6h-rgb-float":{gl:36494,x:te,f:F},"bc7-rgba-unorm":{gl:36492,x:te,f:F},"bc7-rgba-unorm-srgb":{gl:36493,x:te,f:F},"etc2-rgb8unorm":{gl:37492,f:W},"etc2-rgb8unorm-srgb":{gl:37494,f:W},"etc2-rgb8a1unorm":{gl:37496,f:W},"etc2-rgb8a1unorm-srgb":{gl:37497,f:W},"etc2-rgba8unorm":{gl:37493,f:W},"etc2-rgba8unorm-srgb":{gl:37495,f:W},"eac-r11unorm":{gl:37488,f:W},"eac-r11snorm":{gl:37489,f:W},"eac-rg11unorm":{gl:37490,f:W},"eac-rg11snorm":{gl:37491,f:W},"astc-4x4-unorm":{gl:37808,f:S},"astc-4x4-unorm-srgb":{gl:37840,f:S},"astc-5x4-unorm":{gl:37809,f:S},"astc-5x4-unorm-srgb":{gl:37841,f:S},"astc-5x5-unorm":{gl:37810,f:S},"astc-5x5-unorm-srgb":{gl:37842,f:S},"astc-6x5-unorm":{gl:37811,f:S},"astc-6x5-unorm-srgb":{gl:37843,f:S},"astc-6x6-unorm":{gl:37812,f:S},"astc-6x6-unorm-srgb":{gl:37844,f:S},"astc-8x5-unorm":{gl:37813,f:S},"astc-8x5-unorm-srgb":{gl:37845,f:S},"astc-8x6-unorm":{gl:37814,f:S},"astc-8x6-unorm-srgb":{gl:37846,f:S},"astc-8x8-unorm":{gl:37815,f:S},"astc-8x8-unorm-srgb":{gl:37847,f:S},"astc-10x5-unorm":{gl:37819,f:S},"astc-10x5-unorm-srgb":{gl:37851,f:S},"astc-10x6-unorm":{gl:37817,f:S},"astc-10x6-unorm-srgb":{gl:37849,f:S},"astc-10x8-unorm":{gl:37818,f:S},"astc-10x8-unorm-srgb":{gl:37850,f:S},"astc-10x10-unorm":{gl:37819,f:S},"astc-10x10-unorm-srgb":{gl:37851,f:S},"astc-12x10-unorm":{gl:37820,f:S},"astc-12x10-unorm-srgb":{gl:37852,f:S},"astc-12x12-unorm":{gl:37821,f:S},"astc-12x12-unorm-srgb":{gl:37853,f:S},"pvrtc-rgb4unorm-webgl":{gl:35840,f:He},"pvrtc-rgba4unorm-webgl":{gl:35842,f:He},"pvrtc-rbg2unorm-webgl":{gl:35841,f:He},"pvrtc-rgba2unorm-webgl":{gl:35843,f:He},"etc1-rbg-unorm-webgl":{gl:36196,f:$r},"atc-rgb-unorm-webgl":{gl:35986,f:_t},"atc-rgba-unorm-webgl":{gl:35986,f:_t},"atc-rgbai-unorm-webgl":{gl:34798,f:_t}},Gr={[6403]:1,[36244]:1,[33319]:2,[33320]:2,[6407]:3,[36248]:3,[6408]:4,[36249]:4,[6402]:1,[34041]:1,[6406]:1,[6409]:1,[6410]:2},ei={[5126]:4,[5125]:4,[5124]:4,[5123]:2,[5122]:2,[5131]:2,[5120]:1,[5121]:1};function Ne(e,t,r){let i=$[t];if(!i||i.gl===void 0)return!1;let s=i.x||i.gl2ext;return s?Boolean(y(e,s,r)):!0}function Ht(e,t,r){return Ne(e,t,r)&&$[t]?.rb}function Wt(e){if(typeof e=="string")return e;let t=Object.entries($).find(([,r])=>r.gl===e);if(!t)throw new Error(`Unknown texture format ${e}`);return t[0]}function Fe(e){let r=$[e]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${e}`);return r}function Vt(e,t,r){if(!Ne(e,t,r)||t.startsWith("depth")||t.startsWith("stencil"))return!1;try{if((0,ft.decodeTextureFormat)(t).signed)return!1}catch{return!1}return t.endsWith("32float")?Boolean(y(e,"OES_texture_float_linear, extensions",r)):t.endsWith("16float")?Boolean(y(e,"OES_texture_half_float_linear, extensions",r)):!0}function kt(e,t,r){return!(!Ne(e,t,r)||typeof t=="number")}function re(e){let t=$[e],r=Fe(e),i=(0,ft.decodeTextureFormat)(e);return{format:r,dataFormat:t?.dataFormat||ti(i.format,i.integer,i.normalized,r),type:i.dataType?ve(i.dataType):t?.types?.[0]||5121,compressed:i.compressed}}function Kt(e){let t=$[e];if(!t?.attachment)throw new Error(`${e} is not a depth stencil format`);return t.attachment}function Oe(e){let t=re(e),r=Gr[t.dataFormat]||4,i=ei[t.type]||1;return r*i}function ti(e,t,r,i){if(i===6408||i===6407)return i;switch(e){case"r":return t&&!r?36244:6403;case"rg":return t&&!r?33320:33319;case"rgb":return t&&!r?36248:6407;case"rgba":return t&&!r?36249:6408;default:return 6408}}var Yt={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},ke=class extends mt.DeviceFeatures{gl;extensions;testedFeatures=new Set;constructor(t,r,i){super([],i),this.gl=t,this.extensions=r,y(t,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let t=this.getFeatures();for(let r of t)this.has(r)&&(yield r);return[]}has(t){return this.disabledFeatures[t]?!1:(this.testedFeatures.has(t)||(this.testedFeatures.add(t),Xt(t)&&vt(this.gl,t,this.extensions)&&this.features.add(t),this.getWebGLFeature(t)&&this.features.add(t)),this.features.has(t))}initializeFeatures(){let t=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of t)this.has(r)}getFeatures(){return[...Object.keys(Yt),...Object.keys(Ve)]}getWebGLFeature(t){let r=Yt[t];return Boolean(typeof r=="string"?y(this.gl,r,this.extensions):r)}};var $t=d(A(),1);var Ke=class extends $t.DeviceLimits{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(t){super(),this.gl=t}getParameter(t){return this.limits[t]===void 0&&(this.limits[t]=this.gl.getParameter(t)),this.limits[t]}};var Jt=d(A(),1);var je=d(A(),1);var M=d(A(),1);function B(e,t,r){if(ri(t))return r(e);let{nocatch:i=!0}=t;X(e),D(e,t);let s;if(i)s=r(e),U(e);else try{s=r(e)}finally{U(e)}return s}function ri(e){for(let t in e)return!1;return!0}var Me=d(A(),1);function Zt(e,t,r,i){if((0,Me.isObjectEmpty)(t))return i(e);let s=e;X(s.gl);try{return $e(e,t),D(s.gl,r),i(e)}finally{U(s.gl)}}function Qt(e,t,r){if((0,Me.isObjectEmpty)(t))return r(e);X(e.gl);try{return $e(e,t),r(e)}finally{U(e.gl)}}function $e(e,t){let r=e,{gl:i}=r;if(t.cullMode)switch(t.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(t.frontFace&&i.frontFace(j("frontFace",t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has("depth-clip-control")&&i.enable(34383),t.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0)),t.provokingVertex&&e.features.has("provoking-vertex-webgl")){let o=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,a=j("provokingVertex",t.provokingVertex,{first:36429,last:36430});o?.provokingVertexWEBGL(a)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has("polygon-mode-webgl")){if(t.polygonMode){let o=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,a=j("polygonMode",t.polygonMode,{fill:6914,line:6913});o?.polygonModeWEBGL(1028,a),o?.polygonModeWEBGL(1029,a)}t.polygonOffsetLine&&i.enable(10754)}if(e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&i.enable(12288),t.clipDistance1&&i.enable(12289),t.clipDistance2&&i.enable(12290),t.clipDistance3&&i.enable(12291),t.clipDistance4&&i.enable(12292),t.clipDistance5&&i.enable(12293),t.clipDistance6&&i.enable(12294),t.clipDistance7&&i.enable(12295)),t.depthWriteEnabled!==void 0&&i.depthMask(si("depthWriteEnabled",t.depthWriteEnabled)),t.depthCompare&&(t.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(me("depthCompare",t.depthCompare))),t.stencilWriteMask){let s=t.stencilWriteMask;i.stencilMaskSeparate(1028,s),i.stencilMaskSeparate(1029,s)}if(t.stencilReadMask&&Me.log.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){let s=t.stencilReadMask||4294967295,o=me("depthCompare",t.stencilCompare);t.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,o,0,s),i.stencilFuncSeparate(1029,o,0,s)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){let s=Tt("stencilPassOperation",t.stencilPassOperation),o=Tt("stencilFailOperation",t.stencilFailOperation),a=Tt("stencilDepthFailOperation",t.stencilDepthFailOperation);i.stencilOpSeparate(1028,o,a,s),i.stencilOpSeparate(1029,o,a,s)}if(t.blendColorOperation||t.blendAlphaOperation){i.enable(3042);let s=zt("blendColorOperation",t.blendColorOperation||"add"),o=zt("blendAlphaOperation",t.blendAlphaOperation||"add");i.blendEquationSeparate(s,o);let a=Ye("blendColorSrcFactor",t.blendColorSrcFactor||"one"),_=Ye("blendColorDstFactor",t.blendColorDstFactor||"zero"),n=Ye("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),l=Ye("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");i.blendFuncSeparate(a,_,n,l)}}function me(e,t){return j(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Tt(e,t){return j(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function zt(e,t){return j(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Ye(e,t){return j(e,t,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,"constant-color":32769,"one-minus-constant-color":32770,"constant-alpha":32771,"one-minus-constant-alpha":32772})}function ii(e,t){return`Illegal parameter ${t} for ${e}`}function j(e,t,r){if(!(t in r))throw new Error(ii(e,t));return r[t]}function si(e,t){return t}function ze(e){let t={};return e.addressModeU&&(t[10242]=Rt(e.addressModeU)),e.addressModeV&&(t[10243]=Rt(e.addressModeV)),e.addressModeW&&(t[32882]=Rt(e.addressModeW)),e.magFilter&&(t[10240]=jt(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=oi(e.minFilter||"linear",e.mipmapFilter)),e.lodMinClamp!==void 0&&(t[33082]=e.lodMinClamp),e.lodMaxClamp!==void 0&&(t[33083]=e.lodMaxClamp),e.type==="comparison-sampler"&&(t[34892]=34894),e.compare&&(t[34893]=me("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function Rt(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function jt(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}function oi(e,t){if(!t)return jt(e);switch(e){case"nearest":return t==="nearest"?9984:9986;case"linear":return t==="nearest"?9985:9987}}var V=d(A(),1);var O=class extends V.Buffer{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength;bytesUsed;constructor(t,r={}){super(t,r),this.device=t,this.gl=this.device.gl;let i=typeof r=="object"?r.handle:void 0;this.handle=i||this.gl.createBuffer(),t.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=ai(this.props.usage),this.glUsage=_i(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(t,r=0,i=t.byteLength+r){let s=this.glTarget;this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,i,this.glUsage),this.gl.bufferSubData(s,r,t),this.gl.bindBuffer(s,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(t,r,i),this.trackAllocatedMemory(i)}_initWithByteLength(t){(0,V.assert)(t>=0);let r=t;t===0&&(r=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,r,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=t,this.byteLength=t,this._setDebugData(null,0,t),this.trackAllocatedMemory(t),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(t,r=0){this.gl.bindBuffer(36663,this.handle),this.gl.bufferSubData(36663,r,t),this.gl.bindBuffer(36663,null),this._setDebugData(t,r,t.byteLength)}async readAsync(t=0,r){return this.readSyncWebGL(t,r)}readSyncWebGL(t=0,r){r=r??this.byteLength-t;let i=new Uint8Array(r),s=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,t,i,s,r),this.gl.bindBuffer(36662,null),this._setDebugData(i,t,r),i}};function ai(e){return e&V.Buffer.INDEX?34963:e&V.Buffer.VERTEX?34962:e&V.Buffer.UNIFORM?35345:34962}function _i(e){return e&V.Buffer.INDEX||e&V.Buffer.VERTEX?35044:e&V.Buffer.UNIFORM?35048:35044}var qt=d(A(),1);var Y=class extends qt.Sampler{device;handle;parameters;constructor(t,r){super(t,r),this.device=t,this.parameters=ze(r),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(t){for(let[r,i]of Object.entries(t)){let s=Number(r);switch(s){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,s,i);break;default:this.device.gl.samplerParameteri(this.handle,s,i);break}}}};var Ze=d(A(),1),v=class extends Ze.TextureView{device;gl;handle;texture;constructor(t,r){super(t,{...Ze.Texture.defaultProps,...r}),this.device=t,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}};var ni={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},Qe=class extends M.Texture{MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;view=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(t,r){super(t,{...ni,format:"rgba8unorm",...r}),this.device=t,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=6408,this.target=li(this.props),this.loaded=!1,typeof this.props?.data=="string"&&Object.assign(this.props,{data:(0,M.loadImage)(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}createView(t){return new v(this.device,{...t,texture:this})}initialize(t={}){if(this.props.dimension==="cube")return this.initializeCube(t);let r=t.data;if(r instanceof Promise)return r.then(x=>this.initialize(Object.assign({},t,{pixels:x,data:x}))),this;let i=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(i&&r.readyStatethis.initialize(t)),this;let{parameters:s={}}=t,{pixels:o=null,pixelStore:a={},textureUnit:_=void 0,mipmaps:n=!0}=t;r||(r=o);let{width:l,height:c,dataFormat:T,type:f,compressed:R=!1}=t,{depth:h=0}=t,b=Fe(t.format);return{width:l,height:c,compressed:R,dataFormat:T,type:f}=this._deduceParameters({format:t.format,type:f,dataFormat:T,compressed:R,data:r,width:l,height:c}),this.width=l,this.height=c,this.glFormat=b,this.type=f,this.dataFormat=T,this.textureUnit=_,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=n,this.setImageData({data:r,width:l,height:c,depth:h,format:t.format,type:f,dataFormat:T,parameters:a,compressed:R}),this.setSampler(t.sampler),this._setSamplerParameters(s),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),n&&this.device.isTextureFormatFilterable(t.format)&&this.generateMipmap(),i&&(this._video={video:r,parameters:s,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(t){let{mipmaps:r=!0,parameters:i={}}=t;return this.setCubeMapImageData(t).then(()=>{this.loaded=!0,r&&this.generateMipmap(t),this.setSampler(t.sampler),this._setSamplerParameters(i)}),this}setSampler(t={}){let r;t instanceof Y?(this.sampler=t,r=t.props):(this.sampler=new Y(this.device,t),r=t);let i=ze(r);return this._setSamplerParameters(i),this}resize(t){let{height:r,width:i,mipmaps:s=!1}=t;return i!==this.width||r!==this.height?this.initialize({width:i,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:s}):this}update(){if(this._video){let{video:t,parameters:r,lastTime:i}=this._video;if(i===t.currentTime||t.readyState{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(t){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(t);this.trackDeallocatedMemory("Texture");let{target:r=this.target,pixels:i=null,level:s=0,glFormat:o=this.glFormat,offset:a=0,parameters:_={}}=t,{data:n=null,type:l=this.type,width:c=this.width,height:T=this.height,dataFormat:f=this.dataFormat,compressed:R=!1}=t;n||(n=i),{type:l,dataFormat:f,compressed:R,width:c,height:T}=this._deduceParameters({format:this.props.format,type:l,dataFormat:f,compressed:R,data:n,width:c,height:T});let{gl:h}=this;h.bindTexture(this.target,this.handle);let b=null;if({data:n,dataType:b}=this._getDataType({data:n,compressed:R}),B(this.gl,_,()=>{switch(b){case"null":h.texImage2D(r,s,o,c,T,0,f,l,n);break;case"typed-array":h.texImage2D(r,s,o,c,T,0,f,l,n,a);break;case"buffer":this.device.gl.bindBuffer(35052,n.handle||n),this.device.gl.texImage2D(r,s,o,c,T,0,f,l,a),this.device.gl.bindBuffer(35052,null);break;case"browser-object":h.texImage2D(r,s,o,c,T,0,f,l,n);break;case"compressed":for(let[x,N]of n.entries())h.compressedTexImage2D(r,x,N.format,N.width,N.height,0,N.data);break;default:(0,M.assert)(!1,"Unknown image data type")}}),n&&n.byteLength)this.trackAllocatedMemory(n.byteLength,"Texture");else{let x=Oe(this.props.format);this.trackAllocatedMemory(this.width*this.height*x,"Texture")}return this.loaded=!0,this}setSubImageData({target:t=this.target,pixels:r=null,data:i=null,x:s=0,y:o=0,width:a=this.width,height:_=this.height,level:n=0,glFormat:l=this.glFormat,type:c=this.type,dataFormat:T=this.dataFormat,compressed:f=!1,offset:R=0,parameters:h={}}){if({type:c,dataFormat:T,compressed:f,width:a,height:_}=this._deduceParameters({format:this.props.format,type:c,dataFormat:T,compressed:f,data:i,width:a,height:_}),(0,M.assert)(this.depth===1,"texSubImage not supported for 3D textures"),i||(i=r),i&&i.data){let b=i;i=b.data,a=b.shape[0],_=b.shape[1]}i instanceof O&&(i=i.handle),this.gl.bindTexture(this.target,this.handle),B(this.gl,h,()=>{f?this.gl.compressedTexSubImage2D(t,n,s,o,a,_,l,i):i===null?this.gl.texSubImage2D(t,n,s,o,a,_,T,c,null):ArrayBuffer.isView(i)?this.gl.texSubImage2D(t,n,s,o,a,_,T,c,i,R):typeof WebGLBuffer<"u"&&i instanceof WebGLBuffer?(this.device.gl.bindBuffer(35052,i),this.device.gl.texSubImage2D(t,n,s,o,a,_,T,c,R),this.device.gl.bindBuffer(35052,null)):this.device.gl.texSubImage2D(t,n,s,o,a,_,T,c,i)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(t={}){return M.log.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(t=this.textureUnit){let{gl:r}=this;return t!==void 0&&(this.textureUnit=t,r.activeTexture(33984+t)),r.bindTexture(this.target,this.handle),t}unbind(t=this.textureUnit){let{gl:r}=this;return t!==void 0&&(this.textureUnit=t,r.activeTexture(33984+t)),r.bindTexture(this.target,null),t}_getDataType({data:t,compressed:r=!1}){return r?{data:t,dataType:"compressed"}:t===null?{data:t,dataType:"null"}:ArrayBuffer.isView(t)?{data:t,dataType:"typed-array"}:t instanceof O?{data:t.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&t instanceof WebGLBuffer?{data:t,dataType:"buffer"}:{data:t,dataType:"browser-object"}}_deduceParameters(t){let{format:r,data:i}=t,{width:s,height:o,dataFormat:a,type:_,compressed:n}=t,l=re(r);return a=a||l.dataFormat,_=_||l.type,n=n||l.compressed,{width:s,height:o}=this._deduceImageSize(i,s,o),{dataFormat:a,type:_,compressed:n,width:s,height:o,format:r,data:i}}_deduceImageSize(t,r,i){let s;return typeof ImageData<"u"&&t instanceof ImageData?s={width:t.width,height:t.height}:typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement?s={width:t.naturalWidth,height:t.naturalHeight}:typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement?s={width:t.width,height:t.height}:typeof ImageBitmap<"u"&&t instanceof ImageBitmap?s={width:t.width,height:t.height}:typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?s={width:t.videoWidth,height:t.videoHeight}:t?s={width:r,height:i}:s={width:r>=0?r:1,height:i>=0?i:1},(0,M.assert)(s,"Could not deduced texture size"),(0,M.assert)(r===void 0||s.width===r,"Deduced texture width does not match supplied width"),(0,M.assert)(i===void 0||s.height===i,"Deduced texture height does not match supplied height"),s}async setCubeMapImageData(t){let{gl:r}=this,{width:i,height:s,pixels:o,data:a,format:_=6408,type:n=5121}=t,l=o||a,c=await Promise.all(Qe.FACES.map(T=>{let f=l[T];return Promise.all(Array.isArray(f)?f:[f])}));this.bind(),Qe.FACES.forEach((T,f)=>{c[f].length>1&&this.props.mipmaps!==!1&&M.log.warn(`${this.id} has mipmap and multiple LODs.`)(),c[f].forEach((R,h)=>{i&&s?r.texImage2D(T,h,_,i,s,0,_,n,R):r.texImage2D(T,h,_,_,n,R)})}),this.unbind()}setImageDataForFace(t){let{face:r,width:i,height:s,pixels:o,data:a,format:_=6408,type:n=5121}=t,{gl:l}=this,c=o||a;return this.bind(),c instanceof Promise?c.then(T=>this.setImageDataForFace(Object.assign({},t,{face:r,data:T,pixels:T}))):this.width||this.height?l.texImage2D(r,0,_,i,s,0,_,n,c):l.texImage2D(r,0,_,_,n,c),this}setImageData3D(t){let{level:r=0,dataFormat:i,format:s,type:o,width:a,height:_,depth:n=1,offset:l=0,data:c,parameters:T={}}=t;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);let f=re(s);if(B(this.gl,T,()=>{ArrayBuffer.isView(c)&&this.gl.texImage3D(this.target,r,f.format,a,_,n,0,f.dataFormat,f.type,c),c instanceof O&&(this.gl.bindBuffer(35052,c.handle),this.gl.texImage3D(this.target,r,i,a,_,n,0,s,o,l))}),c&&c.byteLength)this.trackAllocatedMemory(c.byteLength,"Texture");else{let R=Oe(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*R,"Texture")}return this.loaded=!0,this}_setSamplerParameters(t){if(!(0,M.isObjectEmpty)(t)){ci(t),this.gl.bindTexture(this.target,this.handle);for(let[r,i]of Object.entries(t)){let s=Number(r),o=i;switch(s){case 33082:case 33083:this.gl.texParameterf(this.target,s,o);break;default:this.gl.texParameteri(this.target,s,o);break}}this.gl.bindTexture(this.target,null)}}},I=Qe;L(I,"FACES",[34069,34070,34071,34072,34073,34074]);function li(e){switch(e.dimension){case"2d":return 3553;case"cube":return 34067;case"2d-array":return 35866;case"3d":return 32879;case"1d":case"cube-array":default:throw new Error(e.dimension)}}function ci(e){M.log.log(1,"texture sampler parameters",e)()}var w=class extends je.Framebuffer{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(t,r){super(t,r);let i=r.handle===null;if(this.device=t,this.gl=t.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),!i){t.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures();let s=this.gl.bindFramebuffer(36160,this.handle);for(let o=0;ok.log.info("Spector capture started:",t)()),P?.onCapture.add(t=>{k.log.info("Spector capture complete:",t)(),P?.getResultUI(),P?.resultView.display(),P?.resultView.addCapture(t)})),e?.canvas){if(typeof e.spector=="string"&&e.spector!==e.canvas.id)return P;P?.startCapture(e?.canvas,500),new Promise(t=>setTimeout(t,2e3)).then(t=>{k.log.info("Spector capture stopped after 2 seconds")(),P?.stopCapture()})}return P}var z=d(A(),1);var Ls=globalThis.document||{},Gs=globalThis.process||{},eo=globalThis.console,tr=globalThis.navigator||{};function qe(e){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let t=typeof navigator<"u"&&navigator.userAgent,r=e||t;return Boolean(r&&r.indexOf("Electron")>=0)}function Be(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||qe()}function At(e){return!e&&!Be()?"Node":qe(e)?"Electron":(e||tr.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var hi="https://unpkg.com/webgl-debug@2.0.1/index.js";function rr(e){return e.luma=e.luma||{},e.luma}async function ir(){Be()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await(0,z.loadScript)(hi))}function sr(e,t={}){return e?t.debug?Ei(e,t):Si(e):null}function Si(e){let t=rr(e);return t.realContext?t.realContext:e}function Ei(e,t){if(!globalThis.WebGLDebugUtils)return z.log.warn("webgl-debug not loaded")(),e;let r=rr(e);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...m,...e});let i=globalThis.WebGLDebugUtils.makeDebugContext(e,gi.bind(null,t),pi.bind(null,t));for(let a in m)!(a in i)&&typeof m[a]=="number"&&(i[a]=m[a]);class s{}Object.setPrototypeOf(i,Object.getPrototypeOf(e)),Object.setPrototypeOf(s,i);let o=Object.create(s);return r.realContext=e,r.debugContext=o,o.debug=!0,o}function dt(e,t){t=Array.from(t).map(i=>i===void 0?"undefined":i);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${e}(${r})`}function gi(e,t,r,i){i=Array.from(i).map(_=>_===void 0?"undefined":_);let s=globalThis.WebGLDebugUtils.glEnumToString(t),o=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,i),a=`${s} in gl.${r}(${o})`;z.log.error(a)();debugger;if(e.throwOnError)throw new Error(a)}function pi(e,t,r){let i="";if(z.log.level>=1&&(i=dt(t,r),z.log.log(1,i)()),e.break&&e.break.length>0&&(i=i||dt(t,r),e.break.every(o=>i.indexOf(o)!==-1)))debugger;for(let s of r)if(s===void 0){if(i=i||dt(t,r),e.throwOnError)throw new Error(`Undefined argument: ${i}`);z.log.error(`Undefined argument: ${i}`)();debugger}}var se=d(A(),1);function ar(e){let t=e.split(/\r?\n/),r=[];for(let i of t){if(i.length<=1)continue;let s=i.split(":");if(s.length===2){let[T,f]=s;r.push({message:f.trim(),type:or(T),lineNum:0,linePos:0});continue}let[o,a,_,...n]=s,l=parseInt(_,10);isNaN(l)&&(l=0);let c=parseInt(a,10);isNaN(c)&&(c=0),r.push({message:n.join(":").trim(),type:or(o),lineNum:l,linePos:c})}return r}function or(e){let t=["warning","error","info"],r=e.toLowerCase();return t.includes(r)?r:"info"}var oe=class extends se.Shader{device;handle;constructor(t,r){switch(super(t,r),this.device=t,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let t=this.device.gl.getShaderInfoLog(this.handle);return ar(t)}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)}async _compile(t){t=(s=>s.startsWith("#version ")?s:`#version 100 ${s}`)(t);let{gl:i}=this.device;if(i.shaderSource(this.handle,t),i.compileShader(this.handle),se.log.level===0){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}se.log.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),se.log.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let t=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await t(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}};var _r=d(A(),1);var bi=256,Ci=1024,Ii=16384,ht=6144,Ni=[1,2,4,8],ae=class extends _r.RenderPass{device;glParameters;constructor(t,r){super(t,r),this.device=t,X(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){U(this.device.gl)}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}setParameters(t={}){let r={...this.glParameters};this.props.framebuffer&&(r.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,t.viewport&&(t.viewport.length>=6?(r.viewport=t.viewport.slice(0,4),r.depthRange=[t.viewport[4],t.viewport[5]]):r.viewport=t.viewport),t.scissorRect&&(r.scissorTest=!0,r.scissor=t.scissorRect),t.blendConstant&&(r.blendColor=t.blendConstant),t.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),t[2967]=t.stencilReference),t.colorMask&&(r.colorMask=Ni.map(i=>Boolean(i&t.colorMask))),this.glParameters=r,D(this.device.gl,r)}beginOcclusionQuery(t){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let t={...this.glParameters},r=0;this.props.clearColor!==!1&&(r|=Ii,t.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=bi,t.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=Ci,t.clearStencil=this.props.clearStencil),r!==0&&B(this.device.gl,t,()=>{this.device.gl.clear(r)})}clearColorBuffer(t=0,r=[0,0,0,0]){B(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl.clearBufferiv(ht,t,r);break;case Uint32Array:this.device.gl.clearBufferuiv(ht,t,r);break;case Float32Array:default:this.device.gl.clearBufferfv(ht,t,r);break}})}};var E=d(A(),1),hr=d(A(),1);var Je=d(A(),1);var Fi="Failed to deduce GL constant from typed array";function nr(e){switch(ArrayBuffer.isView(e)?e.constructor:e){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:return 5121;case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error(Fi)}}function Pe(e,t){let{clamped:r=!0}=t||{};switch(e){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return r?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}var Oi={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},Mi={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}},K=class{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(t){return Pe(t.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(t){return(0,Je.assert)(t.size),Pe(t.type||5126).BYTES_PER_ELEMENT*t.size}static resolve(...t){return new K(Oi,...t)}constructor(...t){t.forEach(r=>this._assign(r)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return K.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return K.getBytesPerVertex(this)}_assign(t={}){return t=(0,Je.checkProps)("Accessor",t,Mi),t.type!==void 0&&(this.type=t.type,(t.type===5124||t.type===5125)&&(this.integer=!0)),t.size!==void 0&&(this.size=t.size),t.offset!==void 0&&(this.offset=t.offset),t.stride!==void 0&&(this.stride=t.stride),t.normalize!==void 0&&(this.normalized=t.normalize),t.normalized!==void 0&&(this.normalized=t.normalized),t.integer!==void 0&&(this.integer=t.integer),t.divisor!==void 0&&(this.divisor=t.divisor),t.buffer!==void 0&&(this.buffer=t.buffer),t.index!==void 0&&(typeof t.index=="boolean"?this.index=t.index?1:0:this.index=t.index),t.instanced!==void 0&&(this.divisor=t.instanced?1:0),t.isInstanced!==void 0&&(this.divisor=t.isInstanced?1:0),this.offset===void 0&&delete this.offset,this.stride===void 0&&delete this.stride,this.type===void 0&&delete this.type,this.size===void 0&&delete this.size,this.divisor===void 0&&delete this.divisor,this.normalized===void 0&&delete this.normalized,this.integer===void 0&&delete this.integer,this.buffer===void 0&&delete this.buffer,this.index===void 0&&delete this.index,this}};function lr(e){return Bi.includes(e)}var Bi=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],cr={[5126]:[5126,1,"float","f32","float32"],[35664]:[5126,2,"vec2","vec2","float32x2"],[35665]:[5126,3,"vec3","vec3","float32x3"],[35666]:[5126,4,"vec4","vec4","float32x4"],[5124]:[5124,1,"int","i32","sint32"],[35667]:[5124,2,"ivec2","vec2","sint32x2"],[35668]:[5124,3,"ivec3","vec3","sint32x3"],[35669]:[5124,4,"ivec4","vec4","sint32x4"],[5125]:[5125,1,"uint","u32","uint32"],[36294]:[5125,2,"uvec2","vec2","uint32x2"],[36295]:[5125,3,"uvec3","vec3","uint32x3"],[36296]:[5125,4,"uvec4","vec4","uint32x4"],[35670]:[5126,1,"bool","f32","float32"],[35671]:[5126,2,"bvec2","vec2","float32x2"],[35672]:[5126,3,"bvec3","vec3","float32x3"],[35673]:[5126,4,"bvec4","vec4","float32x4"],[35674]:[5126,8,"mat2","mat2x2"],[35685]:[5126,8,"mat2x3","mat2x3"],[35686]:[5126,8,"mat2x4","mat2x4"],[35687]:[5126,12,"mat3x2","mat3x2"],[35675]:[5126,12,"mat3","mat3x3"],[35688]:[5126,12,"mat3x4","mat3x4"],[35689]:[5126,16,"mat4x2","mat4x2"],[35690]:[5126,16,"mat4x3","mat4x3"],[35676]:[5126,16,"mat4","mat4x4"]};function St(e){let t=cr[e];if(!t)throw new Error("uniform");let[r,i,,s]=t;return{format:s,components:i,glType:r}}function fr(e){let t=cr[e];if(!t)throw new Error("attribute");let[,r,,i,s]=t;return{attributeType:i,vertexFormat:s,components:r}}function Le(e,t){let r={attributes:[],bindings:[]};r.attributes=Pi(e,t);let i=xi(e,t);for(let _ of i){let n=_.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));r.bindings.push({type:"uniform",name:_.name,location:_.location,visibility:(_.vertex?1:0)&(_.fragment?2:0),minBindingSize:_.byteLength,uniforms:n})}let s=Di(e,t),o=0;for(let _ of s)if(lr(_.type)){let{viewDimension:n,sampleType:l}=yi(_.type);r.bindings.push({type:"texture",name:_.name,location:o,viewDimension:n,sampleType:l}),_.textureUnit=o,o+=1}s.length&&(r.uniforms=s);let a=ui(e,t);return a?.length&&(r.varyings=a),r}function Pi(e,t){let r=[],i=e.getProgramParameter(t,35721);for(let s=0;s=0){let{attributeType:l}=fr(_),c=/instance/i.test(a)?"instance":"vertex";r.push({name:a,location:n,stepMode:c,type:l})}}return r.sort((s,o)=>s.location-o.location),r}function ui(e,t){let r=[],i=e.getProgramParameter(t,35971);for(let s=0;ss.location-o.location),r}function Di(e,t){let r=[],i=e.getProgramParameter(t,35718);for(let s=0;s1)for(let R=0;Re.getActiveUniformBlockParameter(t,o,a),i=[],s=e.getProgramParameter(t,35382);for(let o=0;oo.location-a.location),i}var Ui={[35678]:["2d","float"],[35680]:["cube","float"],[35679]:["3d","float"],[35682]:["3d","depth"],[36289]:["2d-array","float"],[36292]:["2d-array","depth"],[36293]:["cube","float"],[36298]:["2d","sint"],[36299]:["3d","sint"],[36300]:["cube","sint"],[36303]:["2d-array","uint"],[36306]:["2d","uint"],[36307]:["3d","uint"],[36308]:["cube","uint"],[36311]:["2d-array","uint"]};function yi(e){let t=Ui[e];if(!t)throw new Error("sampler");let[r,i]=t;return{viewDimension:r,sampleType:i}}function wi(e){if(e[e.length-1]!=="]")return{name:e,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(e);if(!r||r.length<2)throw new Error(`Failed to parse GLSL uniform name ${e}`);return{name:r[1],length:r[2]?1:0,isArray:Boolean(r[2])}}function Tr(e,t,r,i){let s=e,o=i;o===!0&&(o=1),o===!1&&(o=0);let a=typeof o=="number"?[o]:o;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return e.uniform1i(t,i);case 5126:return e.uniform1fv(t,a);case 35664:return e.uniform2fv(t,a);case 35665:return e.uniform3fv(t,a);case 35666:return e.uniform4fv(t,a);case 5124:return e.uniform1iv(t,a);case 35667:return e.uniform2iv(t,a);case 35668:return e.uniform3iv(t,a);case 35669:return e.uniform4iv(t,a);case 35670:return e.uniform1iv(t,a);case 35671:return e.uniform2iv(t,a);case 35672:return e.uniform3iv(t,a);case 35673:return e.uniform4iv(t,a);case 5125:return s.uniform1uiv(t,a,1);case 36294:return s.uniform2uiv(t,a,2);case 36295:return s.uniform3uiv(t,a,3);case 36296:return s.uniform4uiv(t,a,4);case 35674:return e.uniformMatrix2fv(t,!1,a);case 35675:return e.uniformMatrix3fv(t,!1,a);case 35676:return e.uniformMatrix4fv(t,!1,a);case 35685:return s.uniformMatrix2x3fv(t,!1,a);case 35686:return s.uniformMatrix2x4fv(t,!1,a);case 35687:return s.uniformMatrix3x2fv(t,!1,a);case 35688:return s.uniformMatrix3x4fv(t,!1,a);case 35689:return s.uniformMatrix4x2fv(t,!1,a);case 35690:return s.uniformMatrix4x3fv(t,!1,a)}throw new Error("Illegal uniform")}function Rr(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"line-loop-webgl":return 2;case"triangle-list":return 4;case"triangle-strip":return 5;case"triangle-fan-webgl":return 6;default:throw new Error(e)}}function Ar(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"line-loop-webgl":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;case"triangle-fan-webgl":return 4;default:throw new Error(e)}}var dr=4,_e=class extends E.RenderPipeline{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(t,r){super(t,r),this.device=t,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=(0,E.cast)(r.vs),this.fs=(0,E.cast)(r.fs);let{varyings:i,bufferMode:s=35981}=r;switch(i&&i.length>0&&(this.varyings=i,this.device.gl.transformFeedbackVaryings(this.handle,i,s)),this._linkShaders(),E.log.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Le(this.device.gl,this.handle),E.log.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=(0,hr.mergeShaderLayout)(this.introspectedLayout,r.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":E.log.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`);break;default:}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(t,r){for(let[i,s]of Object.entries(t)){let o=this.shaderLayout.bindings.find(a=>a.name===i)||this.shaderLayout.bindings.find(a=>a.name===`${i}Uniforms`);if(!o){let a=this.shaderLayout.bindings.map(_=>`"${_.name}"`).join(", ");r?.disableWarnings||E.log.warn(`Unknown binding "${i}" in render pipeline "${this.id}", expected one of ${a}`)();continue}switch(s||E.log.warn(`Unsetting binding "${i}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof O)&&!(s.buffer instanceof O))throw new Error("buffer value");break;case"texture":if(!(s instanceof v||s instanceof I||s instanceof w))throw new Error("texture value");break;case"sampler":E.log.warn(`Ignoring sampler ${i}`)();break;default:throw new Error(o.type)}this.bindings[i]=s}}draw(t){let{renderPass:r,parameters:i=this.props.parameters,topology:s=this.props.topology,vertexArray:o,vertexCount:a,instanceCount:_,isInstanced:n=!1,firstVertex:l=0,transformFeedback:c}=t,T=Rr(s),f=Boolean(o.indexBuffer),R=o.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return E.log.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||a===0)return E.log.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(a===0)return E.log.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),o.bindBeforeRender(r),c&&c.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let h=r;return Zt(this.device,i,h.glParameters,()=>{f&&n?this.device.gl.drawElementsInstanced(T,a||0,R,l,_||0):f?this.device.gl.drawElements(T,a||0,R,l):n?this.device.gl.drawArraysInstanced(T,l,a||0,_||0):this.device.gl.drawArrays(T,l,a||0),c&&c.end()}),o.unbindAfterRender(r),!0}setUniformsWebGL(t){let{bindings:r}=(0,E.splitUniformsAndBindings)(t);Object.keys(r).forEach(i=>{E.log.warn(`Unsupported value "${JSON.stringify(r[i])}" used in setUniforms() for key ${i}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,t)}async _linkShaders(){let{gl:t}=this.device;if(t.attachShader(this.handle,this.vs.handle),t.attachShader(this.handle,this.fs.handle),E.log.time(dr,`linkProgram for ${this.id}`)(),t.linkProgram(this.handle),E.log.timeEnd(dr,`linkProgram for ${this.id}`)(),E.log.level,!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}E.log.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),E.log.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}_reportLinkStatus(t){switch(t){case"success":return;default:throw this.vs.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`)):this.fs?.compilationStatus==="error"?(this.fs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`)):new Error(`Error during ${t}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){let{gl:t}=this.device;return t.getProgramParameter(this.handle,35714)?(t.validateProgram(this.handle),t.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){let t=async s=>await new Promise(o=>setTimeout(o,s));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await t(10)}}_areTexturesRenderable(){let t=!0;for(let[,r]of Object.entries(this.bindings))r instanceof I&&(r.update(),t=t&&r.loaded);return t}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:t}=this.device;t.useProgram(this.handle);let r=0,i=0;for(let s of this.shaderLayout.bindings){let o=this.bindings[s.name]||this.bindings[s.name.replace(/Uniforms$/,"")];if(!o)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":let{name:a}=s,_=t.getUniformBlockIndex(this.handle,a);if(_===4294967295)throw new Error(`Invalid uniform block name ${a}`);t.uniformBlockBinding(this.handle,i,_),o instanceof O?t.bindBufferBase(35345,i,o.handle):t.bindBufferRange(35345,i,o.buffer.handle,o.offset||0,o.size||o.buffer.byteLength-o.offset),i+=1;break;case"texture":if(!(o instanceof v||o instanceof I||o instanceof w))throw new Error("texture");let n;if(o instanceof v)n=o.texture;else if(o instanceof I)n=o;else if(o instanceof w&&o.colorAttachments[0]instanceof v)E.log.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),n=o.colorAttachments[0].texture;else throw new Error("No texture");t.activeTexture(33984+r),t.bindTexture(n.target,n.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(){for(let t of this.shaderLayout.uniforms||[]){let{name:r,location:i,type:s,textureUnit:o}=t,a=this.uniforms[r]??o;a!==void 0&&Tr(this.device.gl,i,s,a)}}};var Er=d(A(),1);var et=d(A(),1);var Ge=class extends et.CommandBuffer{device;commands=[];constructor(t){super(t,{}),this.device=t}submitCommands(t=this.commands){for(let r of t)switch(r.name){case"copy-buffer-to-buffer":Xi(this.device,r.options);break;case"copy-buffer-to-texture":vi(this.device,r.options);break;case"copy-texture-to-buffer":Hi(this.device,r.options);break;case"copy-texture-to-texture":Wi(this.device,r.options);break}}};function Xi(e,t){let r=t.source,i=t.destination;e.gl.bindBuffer(36662,r.handle),e.gl.bindBuffer(36663,i.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function vi(e,t){throw new Error("Not implemented")}function Hi(e,t){let{source:r,mipLevel:i=0,aspect:s="all",width:o=t.source.width,height:a=t.source.height,depthOrArrayLayers:_=0,origin:n=[0,0],destination:l,byteOffset:c=0,bytesPerRow:T,rowsPerImage:f}=t;if(s!=="all")throw new Error("not supported");if(i!==0||_!==0||T||f)throw new Error("not implemented");let{framebuffer:R,destroyFramebuffer:h}=Sr(r),b;try{let x=l,N=o||R.width,J=a||R.height,bt=re(R.texture.props.format),Br=bt.dataFormat,Pr=bt.type;e.gl.bindBuffer(35051,x.handle),b=e.gl.bindFramebuffer(36160,R.handle),e.gl.readPixels(n[0],n[1],N,J,Br,Pr,c)}finally{e.gl.bindBuffer(35051,null),b!==void 0&&e.gl.bindFramebuffer(36160,b),h&&R.destroy()}}function Wi(e,t){let{source:r,destinationMipLevel:i=0,origin:s=[0,0],destinationOrigin:o=[0,0],destination:a}=t,{width:_=t.destination.width,height:n=t.destination.height}=t,{framebuffer:l,destroyFramebuffer:c}=Sr(r),[T,f]=s,[R,h,b]=o,x=e.gl.bindFramebuffer(36160,l.handle),N=null,J;if(a instanceof I)N=a,_=Number.isFinite(_)?_:N.width,n=Number.isFinite(n)?n:N.height,N.bind(0),J=N.target;else throw new Error("invalid destination");switch(J){case 3553:case 34067:e.gl.copyTexSubImage2D(J,i,R,h,T,f,_,n);break;case 35866:case 32879:e.gl.copyTexSubImage3D(J,i,R,h,b,T,f,_,n);break;default:}N&&N.unbind(),e.gl.bindFramebuffer(36160,x),c&&l.destroy()}function Sr(e){if(e instanceof et.Texture){let{width:t,height:r,id:i}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${i}`,width:t,height:r,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}var ne=class extends Er.CommandEncoder{device;commandBuffer;constructor(t,r){super(t,r),this.device=t,this.commandBuffer=new Ge(t)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(t){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:t})}copyBufferToTexture(t){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:t})}copyTextureToBuffer(t){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:t})}copyTextureToTexture(t){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:t})}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}resolveQuerySet(t,r,i){}};var le=d(A(),1);var Z=class extends le.VertexArray{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(t){return At()==="Chrome"}constructor(t,r){super(t,r),this.device=t,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(t){let r=t;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(t,r){let i=r;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:s,type:o,stride:a,offset:_,normalized:n,integer:l,divisor:c}=this._getAccessor(t);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(t,s,o,a,_):this.device.gl.vertexAttribPointer(t,s,o,n,a,_),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(t),this.device.gl.vertexAttribDivisor(t,c||0),this.attributes[t]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(t,r){this._enable(t,!1),this.attributes[t]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let t=0;t{for(let r in t)this.setBuffer(r,t[r])})}setBuffer(t,r){let i=this._getVaryingIndex(t),{buffer:s,byteLength:o,byteOffset:a}=this._getBufferRange(r);if(i<0){this.unusedBuffers[t]=s,tt.log.warn(`${this.id} unusedBuffers varying buffer ${t}`)();return}this.buffers[i]={buffer:s,byteLength:o,byteOffset:a},this.bindOnUse||this._bindBuffer(i,s,a,o)}getBuffer(t){if(gr(t))return this.buffers[t]||null;let r=this._getVaryingIndex(t);return r>=0?this.buffers[r]:null}bind(t=this.handle){if(typeof t!="function")return this.gl.bindTransformFeedback(36386,t),this;let r;return this._bound?r=t():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=t(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(t){if(t instanceof O)return{buffer:t,byteOffset:0,byteLength:t.byteLength};let{buffer:r,byteOffset:i=0,byteLength:s=t.buffer.byteLength}=t;return{buffer:r,byteOffset:i,byteLength:s}}_getVaryingIndex(t){if(gr(t))return Number(t);for(let r of this.layout.varyings)if(t===r.name)return r.location;return-1}_bindBuffers(){for(let t in this.buffers){let{buffer:r,byteLength:i,byteOffset:s}=this._getBufferRange(this.buffers[t]);this._bindBuffer(Number(t),r,s,i)}}_unbindBuffers(){for(let t in this.buffers)this.gl.bindBufferBase(35982,Number(t),null)}_bindBuffer(t,r,i=0,s){let o=r&&r.handle;!o||s===void 0?this.gl.bindBufferBase(35982,t,o):this.gl.bindBufferRange(35982,t,o,i,s)}};function gr(e){return typeof e=="number"?Number.isInteger(e):/^\d+$/.test(e)}var pr=d(A(),1);var rt=class extends pr.QuerySet{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(t,r){if(super(t,r),this.device=t,r.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(t){return this._begin(t?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(t){this._queryPending||(this.target=t,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;let t=this.device.gl.getQueryParameter(this.handle,34919);return t&&(this._queryPending=!1),t}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(t=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let r=0;return this._pollingPromise=new Promise((i,s)=>{let o=()=>{this.isResultAvailable()?(i(this.getResult()),this._pollingPromise=null):r++>t?(s("Timed out"),this._pollingPromise=null):requestAnimationFrame(o)};requestAnimationFrame(o)}),this._pollingPromise}};var fe=d(A(),1);var Et=d(A(),1);function gt(e){switch(e){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return(0,Et.assert)(!1),0}}function br(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return(0,Et.assert)(!1),0}}function Cr(e,t){let{sourceX:r=0,sourceY:i=0,sourceFormat:s=6408,sourceAttachment:o=36064}=t||{},{target:a=null,sourceWidth:_,sourceHeight:n,sourceType:l}=t||{},{framebuffer:c,deleteFramebuffer:T}=Nr(e);(0,fe.assert)(c);let{gl:f,handle:R}=c;_=_||c.width,n=n||c.height;let h=o-36064;l=l||c.colorAttachments[h]?.texture?.type||5121,a=Yi(a,l,s,_,n),l=l||nr(a);let b=f.bindFramebuffer(36160,R);return f.readPixels(r,i,_,n,s,l,a),f.bindFramebuffer(36160,b||null),T&&c.destroy(),a}function Ir(e,t){let{target:r,sourceX:i=0,sourceY:s=0,sourceFormat:o=6408,targetByteOffset:a=0}=t||{},{sourceWidth:_,sourceHeight:n,sourceType:l}=t||{},{framebuffer:c,deleteFramebuffer:T}=Nr(e);(0,fe.assert)(c),_=_||c.width,n=n||c.height;let f=c;l=l||5121;let R=r;if(!R){let b=gt(o),x=br(l),N=a+_*n*b*x;R=f.device.createBuffer({byteLength:N})}let h=e.device.createCommandEncoder();return h.copyTextureToBuffer({source:e,width:_,height:n,origin:[i,s],destination:R,byteOffset:a}),h.destroy(),T&&c.destroy(),R}function Nr(e){return e instanceof fe.Framebuffer?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:Ki(e),deleteFramebuffer:!0}}function Ki(e,t){let{device:r,width:i,height:s,id:o}=e;return r.createFramebuffer({...t,id:`framebuffer-for-${o}`,width:i,height:s,colorAttachments:[e]})}function Yi(e,t,r,i,s){if(e)return e;t=t||5121;let o=Pe(t,{clamped:!1}),a=gt(r);return new o(i*s*a)}var Fr=d(A(),1);var mi=256,$i=1024,zi=16384;var Zi="clear: bad arguments";function Or(e,t){let{framebuffer:r=null,color:i=null,depth:s=null,stencil:o=null}=t||{},a={};r&&(a.framebuffer=r);let _=0;i&&(_|=zi,i!==!0&&(a.clearColor=i)),s&&(_|=mi,s!==!0&&(a.clearDepth=s)),o&&(_|=$i,s!==!0&&(a.clearStencil=s)),(0,Fr.assert)(_!==0,Zi);let n=e.gl;B(n,a,()=>{n.clear(_)})}var ue=1,Te=class extends g.Device{type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return typeof WebGL2RenderingContext<"u"}static attach(t){if(t instanceof Te)return t;if(t?.device instanceof g.Device)return t.device;if(!Qi(t))throw new Error("Invalid WebGL2RenderingContext");return new Te({gl:t})}static async create(t={}){g.log.groupCollapsed(ue,"WebGLDevice created")();let r=[];t.debug&&r.push(ir()),t.spector&&r.push(Gt()),typeof t.canvas=="string"&&r.push(g.CanvasContext.pageLoaded);let i=await Promise.allSettled(r);for(let a of i)a.status==="rejected"&&g.log.error(`Failed to initialize debug libraries ${a.reason}`)();if(g.log.probe(ue+1,"DOM is loaded")(),t.gl?.device)return g.log.warn("reattaching existing device")(),Te.attach(t.gl);let s=new Te(t),o=`Created ${s.type}${s.debug?" debug":""} context: ${s.info.vendor}, ${s.info.renderer} for canvas: ${s.canvasContext.id}`;return g.log.probe(ue,o)(),g.log.table(ue,s.info)(),g.log.groupEnd(ue)(),s}constructor(t){super({...t,id:t.id||(0,g.uid)("webgl-device")});let r=t.gl?.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);let i=t.gl?.canvas||t.canvas;this.canvasContext=new ie(this,{...t,canvas:i}),this.lost=new Promise(_=>{this._resolveContextLost=_});let s=t.gl||null;if(s||=ut(this.canvasContext.canvas,{...t,onContextLost:_=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!s)throw new Error("WebGL context creation failed");this.handle=s,this.gl=s,this.gl.device=this,this.gl._version=2,t.spector&&(this.spectorJS=er({...this.props,canvas:this.handle.canvas})),this.info=Dt(this.gl,this._extensions),this.limits=new Ke(this.gl),this.features=new ke(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),this.canvasContext.resize();let{enable:o=!0,copyState:a=!1}=t;ge(this.gl,{enable:o,copyState:a,log:(..._)=>g.log.log(1,..._)()}),t.debug&&(this.gl=sr(this.gl,{...t,throwOnError:!0}),this.debug=!0,g.log.level=Math.max(g.log.level,1),g.log.warn("WebGL debug mode activated. Performance reduced.")())}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(t){return Ne(this.gl,t,this._extensions)}isTextureFormatFilterable(t){return Vt(this.gl,t,this._extensions)}isTextureFormatRenderable(t){return kt(this.gl,t,this._extensions)}createCanvasContext(t){throw new Error("WebGL only supports a single canvas")}createBuffer(t){let r=this._getBufferProps(t);return new O(this,r)}_createTexture(t){return new I(this,t)}createExternalTexture(t){throw new Error("createExternalTexture() not implemented")}createSampler(t){return new Y(this,t)}createShader(t){return new oe(this,t)}createFramebuffer(t){return new w(this,t)}createVertexArray(t){return new Z(this,t)}createTransformFeedback(t){return new ce(this,t)}createQuerySet(t){return new rt(this,t)}createRenderPipeline(t){return new _e(this,t)}beginRenderPass(t){return new ae(this,t)}createComputePipeline(t){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(t){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(t){return new ne(this,t)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(t,r){return Cr(t,r)}readPixelsToBufferWebGL(t,r){return Ir(t,r)}setParametersWebGL(t){D(this.gl,t)}getParametersWebGL(t){return G(this.gl,t)}withParametersWebGL(t,r){return B(this.gl,t,r)}clearWebGL(t){Or(this,t)}resetWebGL(){g.log.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),Xe(this.gl)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let t=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(t=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),t}pushState(){X(this.gl)}popState(){U(this.gl)}setSpectorMetadata(t,r){t.__SPECTOR_Metadata=r}getGLKey(t,r){r=r||this.gl2||this.gl;let i=Number(t);for(let s in r)if(r[s]===i)return`GL.${s}`;return String(t)}_constants;setConstantAttributeWebGL(t,r){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let s=this._constants[t];switch(s&&Li(s,r)&&g.log.info(1,`setConstantAttributeWebGL(${t}) could have been skipped, value unchanged`)(),this._constants[t]=r,r.constructor){case Float32Array:ji(this,t,r);break;case Int32Array:qi(this,t,r);break;case Uint32Array:Ji(this,t,r);break;default:(0,g.assert)(!1)}}getExtension(t){return y(this.gl,t,this._extensions),this._extensions}},De=Te;L(De,"type","webgl");function Qi(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:Boolean(e&&Number.isFinite(e._version))}function ji(e,t,r){switch(r.length){case 1:e.gl.vertexAttrib1fv(t,r);break;case 2:e.gl.vertexAttrib2fv(t,r);break;case 3:e.gl.vertexAttrib3fv(t,r);break;case 4:e.gl.vertexAttrib4fv(t,r);break;default:(0,g.assert)(!1)}}function qi(e,t,r){e.gl.vertexAttribI4iv(t,r)}function Ji(e,t,r){e.gl.vertexAttribI4uiv(t,r)}function Li(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;ri.destroy()),this}bind(t=this.handle){if(typeof t!="function")return this._bindHandle(t),this;let r;return this._bound?r=t():(this._bindHandle(this.handle),this._bound=!0,r=t(),this._bound=!1,this._bindHandle(null)),r}unbind(){this.bind(null)}stubRemovedMethods(t,r,i){return(0,Ae.stubRemovedMethods)(this,t,r,i)}initialize(t){}_createHandle(){throw new Error(Re)}_deleteHandle(){throw new Error(Re)}_bindHandle(t){throw new Error(Re)}_getOptsFromHandle(){throw new Error(Re)}_getParameter(t,r){throw new Error(Re)}_setParameter(t,r){throw new Error(Re)}};var Mr=d(A(),1);var pt=class extends q{get[Symbol.toStringTag](){return"Renderbuffer"}get width(){return this.props.width}get height(){return this.props.height}get format(){return this.props.format}get samples(){return this.props.samples}get attachment(){}glFormat;static isTextureFormatSupported(t,r){return Ht(t.gl,r,t._extensions)}constructor(t,r){if(typeof r.format=="number")throw new Error("Renderbuffer");super(t,r,pt.defaultProps),this.glFormat=Fe(this.props.format),this._initialize(this.props)}resize(t){(t.width!==this.width||t.height!==this.height)&&(Object.assign(this.props,{...t,format:this.format,samples:this.samples}),this._initialize(this.props))}_initialize(t){let{format:r,width:i,height:s,samples:o}=t;(0,Mr.assert)(r,"Needs format"),this.trackDeallocatedMemory(),this.gl.bindRenderbuffer(36161,this.handle),o!==0?this.gl.renderbufferStorageMultisample(36161,o,this.glFormat,i,s):this.gl.renderbufferStorage(36161,this.glFormat,i,s),this.gl.bindRenderbuffer(36161,null),this.trackAllocatedMemory(i*s*(o||1)*Oe(this.format))}_createHandle(){return this.gl.createRenderbuffer()}_deleteHandle(){this.gl.deleteRenderbuffer(this.handle),this.trackDeallocatedMemory()}_bindHandle(t){this.gl.bindRenderbuffer(36161,t)}},xe=pt;L(xe,"defaultProps",{id:void 0,handle:void 0,userData:void 0,format:void 0,width:1,height:1,samples:0});return Hr(Ue);})(); return __exports__; });