PageSourceSearch

https://censusmapper.ca/_next/static/chunks/0q-a9-8h2mazh.js

js censusmapper.ca collected 2026-10-02 04:33:29 UTC 126,242 bytes, 5 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,780900,e=>{"use strict";var t,r,i=e.i(912828);let s={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,featureLevel:void 0,optionalFeatures:[],xrCompatible:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{let[r,s]=e.getDevicePixelSize();i.log.log(1,`${e} resized => ${r}x${s}px`)()},onPositionChange:(e,t)=>{let[r,s]=e.getPosition();i.log.log(1,`${e} repositioned => ${r},${s}`)()},onVisibilityChange:e=>i.log.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>i.log.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:(t=i.log.get("debug"),r=function(){let e=globalThis.process;if(e?.env)return e.env.NODE_ENV}(),null!=t?!!t:void 0!==r&&"production"!==r),debugGPUTime:!1,debugShaders:i.log.get("debug-shaders")||void 0,debugFramebuffers:!!i.log.get("debug-framebuffers"),debugFactories:!!i.log.get("debug-factories"),debugWebGL:!!i.log.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0};e.s(["DEVICE_DEFAULT_PROPS",0,s])},25387,e=>{"use strict";var t=e.i(504819),r=e.i(912828),i=e.i(374366),s=e.i(706145),n=e.i(3311),a=e.i(582090),o=e.i(760457),l=e.i(210629),u=e.i(780900);function h(e){if(void 0!==e){if(null===e||"string"==typeof e||"number"==typeof e||"boolean"==typeof e)return e;if(e instanceof Error)return e.message;if(Array.isArray(e))return e.map(h);if("object"==typeof e){var t,r,i;let s,n,a,o,l;if("toString"in(t=e)&&"function"==typeof t.toString&&t.toString!==Object.prototype.toString){let t=String(e);if("[object Object]"!==t)return t}return"message"in(r=e)&&"type"in r?(s="string"==typeof(i=e).type?i.type:"message",n="string"==typeof i.message?i.message:"",a="number"==typeof i.lineNum?i.lineNum:null,o="number"==typeof i.linePos?i.linePos:null,l=null!==a&&null!==o?` @ ${a}:${o}`:null!==a?` @ ${a}`:"",`${s}${l}: ${n}`.trim()):e.constructor?.name||"Object"}return String(e)}}class c{features;disabledFeatures;constructor(e=[],t){this.features=new Set(e),this.disabledFeatures=t||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}}class d{static defaultProps={...u.DEVICE_DEFAULT_PROPS};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}toJSON(){return this.toString()}id;props;userData={};statsManager=t.lumaStats;_factories={};timestamp=0;_reused=!1;_moduleData={};wgslLanguageFeatures=new Set;_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...d.defaultProps,...e},this.id=this.props.id||(0,i.uid)(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return n.vertexFormatDecoder.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return a.textureFormatDecoder.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let r=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(r),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,r=1){return 1+Math.floor(Math.log2(Math.max(e,t,r)))}isExternalImage(e){return(0,o.isExternalImage)(e)}getExternalImageSize(e){return(0,o.getExternalImageSize)(e)}isTextureFormatSupported(e){return this.getTextureFormatCapabilities(e).create}isTextureFormatFilterable(e){return this.getTextureFormatCapabilities(e).filter}isTextureFormatRenderable(e){return this.getTextureFormatCapabilities(e).render}isTextureFormatCompressed(e){return a.textureFormatDecoder.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let t of Object.keys((0,l.getTextureFormatTable)()))this.isTextureFormatCompressed(t)&&this.isTextureFormatSupported(t)&&e.push(t);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,t,...i){if(!this.props.onError(e,t)){let s=[h(t),...i.map(h).filter(e=>void 0!==e)].filter(e=>void 0!==e);return r.log.error("webgl"===this.type?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...s)}return()=>{}}debug(){if(this.props.debug);else{let e=`\
2'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
3or create a device with the 'debug: true' prop.`;r.log.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}writeBufferViaCommandEncoder(e,t,r,i=0){throw Error("writeBufferViaCommandEncoder() not implemented")}generateMipmapsWebGPU(e){throw Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,t){throw Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,t,r,i,s){throw Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&!!(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return null!==this._debugGPUTimeQuery}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw Error("not implemented")}readPixelsToBufferWebGL(e,t){throw Error("not implemented")}setParametersWebGL(e){throw Error("not implemented")}getParametersWebGL(e){throw Error("not implemented")}withParametersWebGL(e,t){throw Error("not implemented")}clearWebGL(e){throw Error("not implemented")}resetWebGL(){throw Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return!0===e.createCanvasContext?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=a.textureFormatDecoder.getCapabilities(e),r=e=>("string"==typeof e?this.features.has(e):e)??!0,i=r(t.create);return{format:e,create:i,render:i&&r(t.render),filter:i&&r(t.filter),blend:i&&r(t.blend),store:i&&r(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&s.Buffer.INDEX&&(!e.indexType&&(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":e.data instanceof Uint8Array&&(t.data=new Uint16Array(e.data),t.indexType="uint16")),!t.indexType))throw Error("indices buffer content must be of type uint16 or uint32");return t}}e.s(["Device",0,d,"DeviceFeatures",0,c,"DeviceLimits",0,class{},"isHTMLInCanvasSupported",0,function(){if("u"<typeof HTMLCanvasElement)return!1;let e=HTMLCanvasElement.prototype;return"layoutSubtree"in e&&"function"==typeof e.requestPaint}])},504819,760457,e=>{"use strict";var t=e.i(509685);let r=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","External Buffer Memory","External Texture Memory","Swap Chain Texture"],i=new WeakMap,s=new WeakMap;
3class n{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new t.Stats({id:e}));let n=this.stats.get(e);return"GPU Time and Memory"===e&&function(e,t){let r=e.stats,n=!1;for(let i of t)r[i]||(e.get(i),n=!0);let a=Object.keys(r).length,o=i.get(e);if(!n&&o?.orderedStatNames===t&&o.statCount===a)return;let l={},u=s.get(t);for(let e of(u||(u=new Set(t),s.set(t,u)),t))r[e]&&(l[e]=r[e]);for(let[e,t]of Object.entries(r))u.has(e)||(l[e]=t);for(let e of Object.keys(r))delete r[e];Object.assign(r,l),i.set(e,{orderedStatNames:t,statCount:a})}(n,r),n}}let a=new n;e.s(["lumaStats",0,a],504819),e.s(["getExternalImageSize",0,function(e){if("u">typeof ImageData&&e instanceof ImageData||"u">typeof ImageBitmap&&e instanceof ImageBitmap||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof OffscreenCanvas&&e instanceof OffscreenCanvas)return{width:e.width,height:e.height};if("u">typeof HTMLImageElement&&e instanceof HTMLImageElement)return{width:e.naturalWidth,height:e.naturalHeight};if("u">typeof HTMLVideoElement&&e instanceof HTMLVideoElement)return{width:e.videoWidth,height:e.videoHeight};if("u">typeof VideoFrame&&e instanceof VideoFrame)return{width:e.displayWidth,height:e.displayHeight};throw Error("Unknown image type")},"isExternalImage",0,function(e){return"u">typeof ImageData&&e instanceof ImageData||"u">typeof ImageBitmap&&e instanceof ImageBitmap||"u">typeof HTMLImageElement&&e instanceof HTMLImageElement||"u">typeof HTMLVideoElement&&e instanceof HTMLVideoElement||"u">typeof VideoFrame&&e instanceof VideoFrame||"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"u">typeof OffscreenCanvas&&e instanceof OffscreenCanvas}],760457)},695002,e=>{"use strict";var t=e.i(25387),r=e.i(912828),i=e.i(941533),s=e.i(988e3),n=e.i(567415),a=e.i(709095),o=e.i(420505),l=e.i(677641),u=e.i(624628),h=e.i(511547),c=e.i(892563),d=e.i(726348);let f={};var g=e.i(706145);class m extends g.Buffer{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;const r="object"==typeof t?t.handle:void 0;this.handle=r||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=function(e){return e&g.Buffer.INDEX?34963:e&g.Buffer.VERTEX?34962:e&g.Buffer.UNIFORM?35345:34962}(this.props.usage),this.glUsage=function(e){return e&g.Buffer.INDEX||e&g.Buffer.VERTEX?35044:e&g.Buffer.UNIFORM?35048:35044}(this.props.usage),this.glIndexType="uint32"===this.props.indexType?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,r=e.byteLength+t){let i=this.glTarget;this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,r,this.glUsage),this.gl.bufferSubData(i,t,e),this.gl.bindBuffer(i,null),this.bytesUsed=r,this.byteLength=r,this._setDebugData(e,t,r),this.props.handle?this.trackReferencedMemory(r,"Buffer"):this.trackAllocatedMemory(r)}_initWithByteLength(e){let t=e;0===e&&(t=new Float32Array(0));let r=this.glTarget;return this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,t,this.glUsage),this.gl.bindBuffer(r,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,t=0){let r=ArrayBuffer.isView(e)?e:new Uint8Array(e);this.gl.bindBuffer(36663,this.handle),this.gl.bufferSubData(36663,t,r),this.gl.bindBuffer(36663,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,r=this.byteLength-t){let i=new ArrayBuffer(r);await e(i,"copied"),this.write(i,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,r){let i=await this.readAsync(t,r);return await e(i.buffer,"copied")}readSyncWebGL(e=0,t){let r=new Uint8Array(t=t??this.byteLength-e);return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,r,0,t),this.gl.bindBuffer(36662,null),this._setDebugData(r,e,t),r}}var p=e.i(145453);function b(e){let t=e.toLowerCase();return["warning","error","info"].includes(t)?t:"info"}class y extends p.Shader{device;handle;_compilationInfoLog="";constructor(e,t){super(e,t),this.device=e;const r=this.props.handle;switch(this.props.stage){case"vertex":this.handle=r||this.device.gl.createShader(35633);break;case"fragment":this.handle=r||this.device.gl.createShader(35632);break;default:throw Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});const i=this._compile(this.source);i&&"function"==typeof i.catch&&i.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.de
3stroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this._getCompilationInfoLog();return e?function(e){let t=e.split(/\r?\n/),r=[];for(let e of t){if(e.length<=1)continue;let t=e.trim(),i=e.split(":"),s=i[0]?.trim();if(2===i.length){let[e,n]=i;if(!e||!n){r.push({message:t,type:b(s||"info"),lineNum:0,linePos:0});continue}r.push({message:n.trim(),type:b(e),lineNum:0,linePos:0});continue}let[n,a,o,...l]=i;if(!n||!a||!o){r.push({message:i.slice(1).join(":").trim()||t,type:b(s||"info"),lineNum:0,linePos:0});continue}let u=parseInt(o,10);Number.isNaN(u)&&(u=0);let h=parseInt(a,10);Number.isNaN(h)&&(h=0),r.push({message:l.join(":").trim(),type:b(n),lineNum:u,linePos:h})}return r}(e):[]}getTranslatedSource(){let e=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return e?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es
4${e}`;let{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),!this.device.props.debug){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),"error"===this.compilationStatus)throw Error(this._getCompilationErrorMessage(e));return}return r.log.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{r.log.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void await e(10);let{gl:t}=this.device;for(;;){if(t.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error","error"===this.compilationStatus&&this._getCompilationInfoLog()}_getCompilationErrorMessage(e){var t;let r=`${this.props.stage} shader ${this.props.id}`,i=(t=this._getCompilationInfoLog(),t.split(/\r?\n/).find(e=>e.trim())?.trim()),s=this.getCompilationInfoSync(),n=s.find(e=>"error"===e.type&&e.message.trim())||s.find(e=>e.message.trim())||s.find(e=>"error"===e.type)||s[0];if(!n)return i?`GLSL compilation errors in ${r}: ${i}`:`GLSL compilation errors in ${r}: WebGL did not provide a shader compiler log`;let a=n.lineNum?e.split(/\r?\n/)[n.lineNum-1]?.trim():void 0,o=n.lineNum?` line ${n.lineNum}`:"",l=a?`
5Source: ${a}`:"",u=n.message.trim()||i||"WebGL did not provide a shader compiler log";return`GLSL compilation errors in ${r}:${o}: ${u}${l}`}_getCompilationInfoLog(){let e=this.device.gl.getShaderInfoLog(this.handle)?.trim();return e&&(this._compilationInfoLog=e),this._compilationInfoLog}}var v=e.i(388396),x=e.i(453196);function w(e,t){return P(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function _(e,t){return P(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function S(e,t){return P(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function T(e,t,r="color"){return P(e,t,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant:"color"===r?32769:32771,"one-minus-constant":"color"===r?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function P(e,t,r){if(!(t in r))throw Error(`Illegal parameter ${t} for ${e}`);return r[t]}function E(e){let t={};return e.addressModeU&&(t[10242]=C(e.addressModeU)),e.addressModeV&&(t[10243]=C(e.addressModeV)),e.addressModeW&&(t[32882]=C(e.addressModeW)),e.magFilter&&(t[10240]=L(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=function(e,t="none"){if(!t)return L(e);switch(t){case"none":return L(e);case"nearest":switch(e){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(e){case"nearest":return 9986;case"linear":return 9987}}}(e.minFilter||"linear",e.mipmapFilter)),void 0!==e.lodMinClamp&&(t[33082]=e.lodMinClamp),void 0!==e.lodMaxClamp&&(t[33083]=e.lodMaxClamp),"comparison-sampler"===e.type&&(t[34892]=34894),e.compare&&(t[34893]=w("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function C(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function L(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}class B extends v.Sampler{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=E(t),this.handle=t.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(e){for(let[t,r]of Object.entries(e)){let e=Number(t);switch(e){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,e,r);break;default:this.device.gl.samplerParameteri(this.handle,e,r)}}}}var D=e.i(144135),F=e.i(825458);function A(e,t,r){let s;if(function(e){for(let t in e)return!1;return!0}(t))return r(e);let{nocatch:n=!0}=t,a=i.WebGLStateTracker.get(e);if(a.push(),(0,x.setGLParameters)(e,t),n)s=r(e),a.pop();else try{s=r(e)}finally{a.pop()}return s}var I=e.i(96204);class R extends I.TextureView{device;gl;handle;texture;constructor(e,t){super(e,{...F.Texture.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}let k={5124:"sint32",5125:"uint32",5122:"sint16",5123:"uint16",5120:"sint8",5121:"uint8",5126:"float32",5131:"float16",33635:"uint16",32819:"uint16",32820:"uint16",33640:"uint32",35899:"uint32",35902:"uint32",34042:"uint32",36269:"uint32"};class G extends F.Texture{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,t){super(e,t,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;
5const r=(0,d.getTextureFormatWebGL)(this.props.format);if(this.glTarget=function(e){switch(e){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866}throw Error(e)}(this.props.dimension),this.glInternalFormat=r.internalFormat,this.glFormat=r.format,this.glType=r.type,this.compressed=r.compressed,this.isHandleBorrowed&&void 0===this.props.handle)throw Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);const{dimension:e,width:r,height:i,depth:s,mipLevels:n,glTarget:a,glInternalFormat:o}=this;if(!this.compressed)switch(e){case"2d":case"cube":this.gl.texStorage2D(a,n,o,r,i);break;case"2d-array":case"3d":this.gl.texStorage3D(a,n,o,r,i,s);break;default:throw Error(e)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new R(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(e){return new R(this.device,{...e,texture:this})}clone(e){if(this.isHandleBorrowed&&e&&(e.width!==this.width||e.height!==this.height))throw Error(`Cannot resize borrowed read-only ${this}`);return super.clone(e)}setSampler(e={}){this._assertWritable("set sampler parameters on"),super.setSampler(e);let t=E(this.sampler.props);this._setSamplerParameters(t)}copyExternalImage(e){this._assertWritable("copy external image data into");let t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw Error("WebGL does not support sourceX/sourceY)");let{glFormat:r,glType:i}=this,{image:s,depth:n,mipLevel:a,x:o,y:l,z:u,width:h,height:c}=t,d=W(this.glTarget,this.dimension,u),f=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),A(this.gl,f,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(d,a,o,l,h,c,r,i,s);break;case"2d-array":case"3d":this.gl.texSubImage3D(d,a,o,l,u,h,c,n,r,i,s)}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyElementImage(e){this._assertWritable("copy element image data into");let t=this._normalizeCopyElementImageOptions(e),{glFormat:r}=this,{element:i,depth:s,mipLevel:n,sourceX:a,sourceY:o,sourceWidth:l,sourceHeight:u,x:h,y:c,z:d,width:f,height:g}=t,m=W(this.glTarget,this.dimension,d),p=t.flipY?{37440:!0}:{},b=this.gl;if(1!==s||"2d"!==this.dimension&&"cube"!==this.dimension)throw Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(0!==n||0!==h||0!==c)throw Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if("function"!=typeof b.texElementImage2D)throw Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),A(this.gl,p,()=>{b.texElementImage2D?.(m,r,i,{sx:a,sy:o,swidth:l??f,sheight:u??g,width:f,height:g})}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},t){if(!t)throw Error(`${this} readBuffer requires a destination buffer`);let r=this._getSupportedColorReadOptions(e),i=e.byteOffset??0,s=this.computeMemoryLayout(r);if(t.byteLength<i+s.byteLength)throw Error(`${this} readBuffer target is too small (${t.byteLength} < ${i+s.byteLength})`);this.gl.bindBuffer(35051,t.handle);try{this._readColorTextureLayers(r,s,e=>{this.gl.readPixels(r.x,r.y,r.width,r.height,this.glFormat,this.glType,i+e)})}finally{this.gl.bindBuffer(35051,null)}return t}async readDataAsync(e={}){throw Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,t={}){this._assertWritable("write buffer data into");let r=this._normalizeTextureWriteOptions(t),{width:i,height:s,depthOrArrayLayers:n,mipLevel:a,byteOffset:o,x:l,y:u,z:h}=r,{glFormat:c,glType:d,compressed:f}=this,g=W(this.glTarget,this.dimension,h);if(f)throw Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:m}=this.device.getTextureFormatInfo(this.format),p=m?r.bytesPerRow/m:void 0,b={3317:this.byteAlignment,...void 0!==p?{3314:p}:{},32878:r.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),A(this.gl,b,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(g,a,l,u,i,s,c,d,o);break;case"2d-array":case"3d":this.gl.texSubImage3D(g,a,l,u,h,i,s,n,c,d,o)}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,t={}){let r;this._assertWritable("write data into");let i=this._normalizeTextureWriteOptions(t),s=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:n,height:a,depthOrArrayLayers:o,mipLevel:l,x:u,y:h,z:c,byteOffset:d}=i,{glFormat:f,glType:g,compressed:m}=this,p=W(this.glTarget,this.dimension,c);if(!m){let{bytesPerPixel:e}=this.device.getTextureFormatInfo(this.format);e&&(r=i.bytesPerRow/e)}let b=this.compressed?{}:{3317:this.byteAlignment,...void 0!==r?{3314:r}:{},32878:i.rowsPerImage},y=function(e,t){if(t%e.BYTES_PER_ELEMENT!=0)throw Error(`Texture byteOffset ${t} must align to typed array element size ${e.BYTES_PER_ELEMENT}`);return t/e.BYTES_PER_ELEMENT}(s,d),v=m?function(e,t=0){return t?new e.constructor(e.buffer,e.byteOffset+t,(e.byteLength-t)/e.BYTES_PER_ELEMENT):e}(s,d):s,x=this._getMipLevelSize(l),w=0===u&&0===h&&0===c&&n===x.width&&a===x.height&&o===x.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),A(this.gl,b,()=>{switch(this.dimension){case"2d":case"cube":m?w?this.gl.compressedTexImage2D(p,l,f,n,a,0,v):this.gl.compressedTexSubImage2D(p,l,u,h,n,a,f,v):this.gl.texSubImage2D(p,l,u,h,n,a,f,g,s,y);break;case"2d-array":case"3d":m?w?this.gl.compressedTexImage3D(p,l,f,n,a,o,0,v):this.gl.compressedTexSubImage3D(p,l,u,h,c,n,a,o,f,v):this.gl.texSubImage3D(p,l,u,h,c,n,a,o,f,g,s,y)}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,t){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({
5id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let t=this._getSupportedColorReadOptions(e),r=this.computeMemoryLayout(t),i=k[this.glType],s=(0,D.getTypedArrayConstructor)(i),n=new s(r.byteLength/s.BYTES_PER_ELEMENT);return this._readColorTextureLayers(t,r,e=>{let i=new s(n.buffer,n.byteOffset+e,r.bytesPerImage/s.BYTES_PER_ELEMENT);this.gl.readPixels(t.x,t.y,t.width,t.height,this.glFormat,this.glType,i)}),n.buffer}_readColorTextureLayers(e,t,r){let i=this._getFramebuffer(),s=t.bytesPerRow/t.bytesPerPixel,n={3333:this.byteAlignment,...s!==e.width?{3330:s}:{}},a=this.gl.getParameter(3074),o=this.gl.bindFramebuffer(36160,i.handle);try{this.gl.readBuffer(36064),A(this.gl,n,()=>{for(let s=0;s<e.depthOrArrayLayers;s++)this._attachReadSubresource(i,e.mipLevel,e.z+s),r(s*t.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,o||null),this.gl.readBuffer(a)}}_attachReadSubresource(e,t,r){let i=`${t}:${r}`;if(this._framebufferAttachmentKey!==i){switch(this.dimension){case"2d":this.gl.framebufferTexture2D(36160,36064,3553,this.handle,t);break;case"cube":this.gl.framebufferTexture2D(36160,36064,W(this.glTarget,this.dimension,r),this.handle,t);break;case"2d-array":case"3d":this.gl.framebufferTextureLayer(36160,36064,this.handle,t,r);break;default:throw Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){let t=Number(this.gl.checkFramebufferStatus(36160));if(t!==Number(36053))throw Error(`${e} incomplete for ${this} readback (${t})`)}this._framebufferAttachmentKey=i}}generateMipmapsWebGL(e){if(this._assertWritable("generate mipmaps for"),this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format)||(r.log.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),e?.force))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(e){r.log.warn(`Error generating mipmap for ${this}: ${e.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){for(let[t,i]of(r.log.level>=2&&r.log.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle),Object.entries(e))){let e=Number(t);switch(e){case 33082:case 33083:this.gl.texParameterf(this.glTarget,e,i);break;case 10240:case 10241:case 10242:case 10243:case 32882:case 34892:case 34893:this.gl.texParameteri(this.glTarget,e,i);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,e,i)}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:t}=this;return void 0!==e&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:t}=this;return void 0!==e&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}_assertWritable(e){if(this.isHandleBorrowed)throw Error(`Cannot ${e} borrowed read-only ${this}`)}}function W(e,t,r){return"cube"===t?34069+r:e}var M=e.i(888583),O=e.i(749494),$=e.i(466234),z=e.i(685251),U=e.i(652349),N=e.i(100058);let Q={5126:"f32",35664:"vec2<f32>",35665:"vec3<f32>",35666:"vec4<f32>",5124:"i32",35667:"vec2<i32>",35668:"vec3<i32>",35669:"vec4<i32>",5125:"u32",36294:"vec2<u32>",36295:"vec3<u32>",36296:"vec4<u32>",35670:"f32",35671:"vec2<f32>",35672:"vec3<f32>",35673:"vec4<f32>",35674:"mat2x2<f32>",35685:"mat2x3<f32>",35686:"mat2x4<f32>",35687:"mat3x2<f32>",35675:"mat3x3<f32>",35688:"mat3x4<f32>",35689:"mat4x2<f32>",35690:"mat4x3<f32>",35676:"mat4x4<f32>"},V={35678:{viewDimension:"2d",sampleType:"float"},35680:{viewDimension:"cube",sampleType:"float"},35679:{viewDimension:"3d",sampleType:"float"},35682:{viewDimension:"3d",sampleType:"depth"},36289:{viewDimension:"2d-array",sampleType:"float"},36292:{viewDimension:"2d-array",sampleType:"depth"},36293:{viewDimension:"cube",sampleType:"float"},36298:{viewDimension:"2d",sampleType:"sint"},36299:{viewDimension:"3d",sampleType:"sint"},36300:{viewDimension:"cube",sampleType:"sint"},36303:{viewDimension:"2d-array",sampleType:"uint"},36306:{viewDimension:"2d",sampleType:"uint"},36307:{viewDimension:"3d",sampleType:"uint"},36308:{viewDimension:"cube",sampleType:"uint"},36311:{viewDimension:"2d-array",sampleType:"uint"}},H={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126};function j(e,t,i,s){let n=s||e.getActiveUniformBlockName(t,i);if(!n)throw Error(`Failed to reflect WebGL uniform block at index ${i}: missing block name`);let a=(r,s)=>{let a=e.getActiveUniformBlockParameter(t,i,r);if(null==a)throw Error(`Failed to reflect WebGL uniform block "${n}": ${s} returned null`);return a},o=X(a(35391,"UNIFORM_BLOCK_BINDING"),n,"UNIFORM_BLOCK_BINDING",0),l=X(a(35392,"UNIFORM_BLOCK_DATA_SIZE"),n,"UNIFORM_BLOCK_DATA_SIZE",0),u=X(a(35394,"UNIFORM_BLOCK_ACTIVE_UNIFORMS"),n,"UNIFORM_BLOCK_ACTIVE_UNIFORMS",0),h=K(a(35395,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"),n,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",u),c=q(e,t,h,35383,"UNIFORM_TYPE",n,u),d=q(e,t,h,35384,"UNIFORM_SIZE",n,u),f=q(e,t,h,35386,"UNIFORM_BLOCK_INDEX",n,u),g=q(e,t,h,35387,"UNIFORM_OFFSET",n,u),m=q(e,t,h,35388,"UNIFORM_ARRAY_STRIDE",n,u),p=[];for(let r=0;r<u;r++){if(f[r]!==i)throw Error(`Failed to reflect WebGL uniform block "${n}": active uniform index ${h[r]} belongs to block ${f[r]}, expected ${i}`);let s=h[r],a=e.getActiveUniform(t,s);if(!a)throw Error(`Failed to reflect WebGL uniform block "${n}": getActiveUniform(${s}) returned null`);let o=X(c[r],n,`UNIFORM_TYPE[${r}]`,1),l=X(d[r],n,`UNIFORM_SIZE[${r}]`,1),u=X(g[r],n,`UNIFORM_OFFSET[${r}]`,0),b=X(m[r],n,`UNIFORM_ARRAY_STRIDE[${r}]`,0);if(a.type!==o||a.size!==l)throw Error(`Failed to reflect WebGL uniform block "${n}": getActiveUniform(${s}) disagrees with getActiveUniforms`);p.push({name:a.name,format:Q[o],arrayLength:l,byteOffset:u,byteStride:b})}let b={name:n,location:o,byteLength:l,vertex:!!a(35396,"UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER"),fragment:!!a(35398,"UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER"),uniformCount:u,uniforms:p},y=new Set(b.uniforms.map(e=>e.name.split(".")[0]).filter(e=>!!e)),v=b.name.replace(/Uniforms$/,"");if(1===y.size&&!y.has(b.name)&&!y.has(v)){let[e]=y;r.log.warn(`Uniform block "${b.name}" uses GLSL instance "${e}". luma.gl binds uniform buffers by block name ("${b.name}") and alias ("${v}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}return b}function q(e,t,r,i,s,n,a){let o=e.getActiveUniforms(t,r,i);if(null===o)throw Error(`Failed to reflect WebGL uniform block "${n}": ${s} returned null`);return K(o,n,s,a)}function K(e,t,r,i){if(!Array.isArray(e)&&!ArrayBuffer.isView(e))throw Error(`Failed to reflect WebGL uniform block "${t}": ${r} returned a non-array value`);let s=Array.from(e);if(s.length!==i||s.some(e=>!Number.isInteger(e)))throw Error(`Failed to reflect WebGL uniform block "${t}": ${r} returned ${s.length} invalid values, expected ${i}`);return s}function X(e,t,r,i){if(!Number.isInteger(e)||e<i)throw Error(`Failed to reflect WebGL uniform block "${t}": ${r} returned ${String(e)}`);return e}class Y extends O.RenderPipeline{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,t){super(e,t),this.device=e;const i=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(t);this.sharedRenderPipeline=i,this.handle=i.handle,this.vs=i.vs,this.fs=i.fs,this.linkStatus=i.linkStatus,this.introspectedLayout=function(e,t,i={}){let s={attributes:[],bindings:[]};for(let n of(s.attributes=function(e,t){let r=[],i=e.getProgramParameter(t,35721);for(let s=0;s<i;s++){let i=e.getActiveAttrib(t,s);if(!i)throw Error("activeInfo");let{name:n,type:a}=i,o=e.getAttribLocation(t,n);if(o>=0){let e=Q[a],t=/instance/i.test(n)?"instance":"vertex";r.push({name:n,location:o,stepMode:t,type:e})}}return r.sort((e,t)=>
5e.location-t.location),r}(e,t),function(e,t,i){let s=[],n=function(e,t,r){let i=new Map;for(let e of r.uniformBlockLayouts||[])i.set(e.name,function(e){let t=(0,N.makeShaderBlockLayout)(e.uniformTypes,{layout:"std140"}),r=function(e,t){let r=[],i=(e,n)=>{if("string"==typeof n){let i=t[e];if(!i)throw Error(`Missing std140 layout field ${e}`);r.push({name:e,format:i.shaderType,arrayLength:1,byteOffset:4*i.offset,byteStride:0});return}if(Array.isArray(n))return void s(e,n[0],n[1]);for(let[t,r]of Object.entries(n))i(`${e}.${t}`,r)},s=(e,i,s)=>{if("string"==typeof i){let i=t[`${e}[0]`],n=s>1?t[`${e}[1]`]:void 0;if(!i)throw Error(`Missing std140 array layout field ${e}[0]`);r.push({name:`${e}[0]`,format:i.shaderType,arrayLength:s,byteOffset:4*i.offset,byteStride:n?(n.offset-i.offset)*4:0});return}if(Array.isArray(i))throw Error(`Nested uniform arrays are not supported for ${e}`);for(let[n,a]of Object.entries(i)){if("string"!=typeof a)throw Error(`Composite uniform array members are not supported for ${e}`);let i=`${e}[0].${n}`,o=`${e}[1].${n}`,l=t[i],u=s>1?t[o]:void 0;if(!l)throw Error(`Missing std140 array layout field ${i}`);r.push({name:i,format:l.shaderType,arrayLength:s,byteOffset:4*l.offset,byteStride:u?(u.offset-l.offset)*4:0})}};for(let[t,r]of Object.entries(e))i(t,r);return r}(e.uniformTypes,t.fields);return{type:"uniform",name:e.name,group:0,location:0,minBindingSize:t.byteLength,uniforms:r}}(e));for(let e of r.shaderLayout?.bindings||[]){var s;"uniform"===(s=e).type&&Number.isInteger(s.minBindingSize)&&s.minBindingSize>=0&&Array.isArray(s.uniforms)&&s.uniforms.every(e=>"string"==typeof e.name&&"string"==typeof e.format&&Number.isInteger(e.arrayLength)&&e.arrayLength>0&&Number.isInteger(e.byteOffset)&&e.byteOffset>=0&&Number.isInteger(e.byteStride)&&e.byteStride>=0)&&i.set(e.name,e)}let n=new Map;for(let r of i.values()){let i=function(e,t,r){for(let i of r.endsWith("Uniforms")?[r,r.slice(0,-8)]:[r,`${r}Uniforms`]){let r=e.getUniformBlockIndex(t,i);if(0xffffffff!==r){if(!Number.isInteger(r)||r<0)throw Error(`Failed to resolve WebGL uniform block "${i}": getUniformBlockIndex returned ${String(r)}`);return{blockIndex:r,blockName:i}}}return null}(e,t,r.name);if(!i)continue;let{blockIndex:s,blockName:a}=i;if(n.has(s))throw Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${a}"`);n.set(s,{name:a,location:s,byteLength:r.minBindingSize,vertex:!!(r.visibility&&1&r.visibility),fragment:!!(r.visibility&&2&r.visibility),uniformCount:r.uniforms.length,uniforms:r.uniforms.map(e=>({...e}))})}return n}(e,t,i);for(let[i,l]of n){s.push(l);try{var a=j(e,t,i,l.name),o=l;for(let e of a.uniforms){let t=o.uniforms.find(t=>e.name===t.name||e.name.endsWith(`.${t.name}`));if(!t)throw Error(`Failed to validate WebGL uniform block "${o.name}": reflected unexpected member "${e.name}"`);if(e.format!==t.format||e.arrayLength!==t.arrayLength||e.byteOffset!==t.byteOffset||e.byteStride!==t.byteStride)throw Error(`Failed to validate WebGL uniform block "${o.name}": reflected layout for "${e.name}" does not match supplied std140 metadata`)}}catch(t){let e=t instanceof Error?t.message:String(t);r.log.once(0,`WebGL uniform block reflection failed for "${l.name}"; using supplied std140 metadata. ${e}`)()}}let l=e.getProgramParameter(t,35382);if(!Number.isInteger(l)||l<0)throw Error(`Failed to reflect WebGL uniform blocks: ACTIVE_UNIFORM_BLOCKS returned ${String(l)}`);for(let r=0;r<l;r++)n.has(r)||s.push(j(e,t,r));return s.sort((e,t)=>e.location-t.location),s}(e,t,i))){let e=n.uniforms.map(e=>({name:e.name,format:e.format,byteOffset:e.byteOffset,byteStride:e.byteStride,arrayLength:e.arrayLength}));s.bindings.push({type:"uniform",name:n.name,group:0,location:n.location,visibility:!!n.vertex|2*!!n.fragment,minBindingSize:n.byteLength,uniforms:e})}let n=function(e,t){let r=[],i=e.getProgramParameter(t,35718);for(let s=0;s<i;s++){let i=e.getActiveUniform(t,s);if(!i)throw Error("activeInfo");let{name:n,size:a,type:o}=i,{name:l,isArray:u}=function(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(e);return{name:(0,U.assertDefined)(t?.[1],`Failed to parse GLSL uniform name ${e}`),length:+!!t?.[2],isArray:!!t?.[2]}}(n),h=e.getUniformLocation(t,l),c={location:h,name:l,size:a,type:o,isArray:u};
5if(r.push(c),c.size>1)for(let i=0;i<c.size;i++){let s=`${l}[${i}]`;h=e.getUniformLocation(t,s);let n={...c,name:s,location:h};r.push(n)}}return r}(e,t),a=0;for(let e of n)if(V[e.type]){let{viewDimension:t,sampleType:r}=V[e.type];s.bindings.push({type:"texture",name:e.name,group:0,location:a,viewDimension:t,sampleType:r}),e.textureUnit=a,a+=1}n.length&&(s.uniforms=n);let o=function(e,t){let r=[],i=e.getProgramParameter(t,35971);for(let s=0;s<i;s++){let i=e.getTransformFeedbackVarying(t,s);if(!i)throw Error("activeInfo");let{name:n,type:a,size:o}=i,l=Q[a],{type:u,components:h}=(0,z.getVariableShaderTypeInfo)(l);r.push({location:s,name:n,type:u,size:o*h})}return r.sort((e,t)=>e.location-t.location),r}(e,t);return o?.length&&(s.varyings=o),s}(this.device.gl,this.handle,{uniformBlockLayouts:t._uniformBlockLayouts,shaderLayout:t.shaderLayout}),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=t.shaderLayout?function(e,t){let i={...e,attributes:e.attributes.map(e=>({...e})),bindings:e.bindings.map(e=>({...e}))};for(let e of t?.attributes||[]){let t=i.attributes.find(t=>t.name===e.name);t?(t.type=e.type||t.type,t.stepMode=e.stepMode||t.stepMode):r.log.warn(`shader layout attribute ${e.name} not present in shader`)}for(let e of t?.bindings||[]){let t=J(i,e.name);if(!t){r.log.warn(`shader layout binding ${e.name} not present in shader`);continue}Object.assign(t,e)}return i}(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,t){for(let[i,s]of Object.entries((0,$.flattenBindingsByGroup)((0,$.normalizeBindingsByGroup)(this.shaderLayout,e)))){let e=J(this.shaderLayout,i);if(e){switch(!s&&r.log.warn(`Unsetting binding "${i}" in render pipeline "${this.id}"`)(),e.type){case"uniform":if(!(s instanceof m)&&!(s.buffer instanceof m))throw Error("buffer value");break;case"texture":if(!(s instanceof R||s instanceof G||s instanceof M.WEBGLFramebuffer))throw Error(`${this} Bad texture binding for ${i}`);break;case"sampler":r.log.warn(`Ignoring sampler ${i}`)();break;default:throw Error(e.type)}this.bindings[i]=s}else{let e=this.shaderLayout.bindings.map(e=>`"${e.name}"`).join(", ");t?.disableWarnings||r.log.warn(`No binding "${i}" in render pipeline "${this.id}", expected one of ${e}`,s)()}}}draw(e){let t=e.renderPass,r=e.bindGroups?(0,$.flattenBindingsByGroup)(e.bindGroups):e.bindings||this.bindings;return t.setPipeline(this),t.setBindings(r),t.setVertexArray(e.vertexArray),t.draw({parameters:e.parameters,topology:e.topology,isInstanced:e.isInstanced,vertexCount:e.vertexCount,indexCount:e.indexCount,instanceCount:e.instanceCount,firstVertex:e.firstVertex,firstIndex:e.firstIndex,firstInstance:e.firstInstance,baseVertex:e.baseVertex,transformFeedback:e.transformFeedback,uniforms:e.uniforms})}_areTexturesRenderable(e){let t=!0;for(let i of this.shaderLayout.bindings)Z(e,i.name)||(r.log.warn(`Binding ${i.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(e,t){if(this._syncLinkStatus(),"success"!==this.linkStatus)return;let{gl:i}=this.device;i.useProgram(this.handle);let s=0,n=0;for(let t of this.shaderLayout.bindings){let a=Z(e,t.name);if(!a)throw Error(`No value for binding ${t.name} in ${this.id}`);switch(t.type){case"uniform":let{name:o}=t,l=i.getUniformBlockIndex(this.handle,o);if(0xffffffff===l)throw Error(`Invalid uniform block name ${o}`);i.uniformBlockBinding(this.handle,l,n),a instanceof m?i.bindBufferBase(35345,n,a.handle):i.bindBufferRange(35345,n,a.buffer.handle,a.offset||0,a.size||a.buffer.byteLength-(a.offset||0)),n+=1;break;case"texture":let u;if(!(a instanceof R||a instanceof G||a instanceof M.WEBGLFramebuffer))throw Error("texture");if(a instanceof R)u=a.texture;else if(a instanceof G)u=a;else if(a instanceof M.WEBGLFramebuffer&&a.colorAttachments[0]instanceof R)r.log.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),u=a.colorAttachments[0].texture;else throw Error("No texture");i.activeTexture(33984+s),i.bindTexture(u.glTarget,u.handle),s+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw Error(`binding type '${t.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let t of this.shaderLayout.uniforms||[]){let{name:r,location:i,type:s,textureUnit:n}=t,a=e[r]??n;void 0!==a&&function(e,t,r,i){let s=i;!0===s&&(s=1),!1===s&&(s=0);let n="number"==typeof s?[s]:s;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("number"!=typeof i)throw Error("samplers must be set to integers");return e.uniform1i(t,i);case 5126:return e.uniform1fv(t,n);case 35664:return e.uniform2fv(t,n);case 35665:return e.uniform3fv(t,n);case 35666:return e.uniform4fv(t,n);case 5124:case 35670:return e.uniform1iv(t,n);case 35667:case 35671:return e.uniform2iv(t,n);case 35668:case 35672:return e.uniform3iv(t,n);case 35669:case 35673:return e.uniform4iv(t,n);case 5125:return e.uniform1uiv(t,n,1);case 36294:return e.uniform2uiv(t,n,2);case 36295:return e.uniform3uiv(t,n,3);case 36296:return e.uniform4uiv(t,n,4);case 35674:return e.uniformMatrix2fv(t,!1,n);case 35675:return e.uniformMatrix3fv(t,!1,n);case 35676:return e.uniformMatrix4fv(t,!1,n);
5case 35685:return e.uniformMatrix2x3fv(t,!1,n);case 35686:return e.uniformMatrix2x4fv(t,!1,n);case 35687:return e.uniformMatrix3x2fv(t,!1,n);case 35688:return e.uniformMatrix3x4fv(t,!1,n);case 35689:return e.uniformMatrix4x2fv(t,!1,n);case 35690:return e.uniformMatrix4x3fv(t,!1,n)}throw Error("Illegal uniform")}(this.device.gl,i,s,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}function J(e,t){return e.bindings.find(e=>e.name===t||e.name===`${t}Uniforms`||`${e.name}Uniforms`===t)}function Z(e,t){return e[t]||e[`${t}Uniforms`]||e[t.replace(/Uniforms$/,"")]}var ee=e.i(81905);class et extends ee.Resource{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,t){super(e,t,{...ee.Resource.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}class er extends et{device;handle;vs;fs;linkStatus="pending";constructor(e,t){super(e,t),this.device=e,this.handle=t.handle||this.device.gl.createProgram(),this.vs=t.vs,this.fs=t.fs,t.varyings&&t.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,t.varyings,t.bufferMode||35981),this._linkShaders()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.de
5stroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),r.log.time(4,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),r.log.timeEnd(4,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let e=this._getLinkStatus();this._reportLinkStatus(e);return}r.log.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),r.log.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){if("success"!==e){let t="link-error"===e?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),Error(`${this} ${t} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader()}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),Error(`${this} ${t} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader()}let r=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(Error(`${t} during ${e}: ${r}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715))?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error"):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let t=0,r=e.getProgramParameter(this.handle,35718);for(let i=0;i<r;i++){let r=e.getActiveUniform(this.handle,i);if(r&&V[r.type]){let i=r.name.endsWith("[0]"),s=i?r.name.slice(0,-3):r.name,n=e.getUniformLocation(this.handle,s);null!==n&&(t=this._assignSamplerUniform(n,r,i,t))}}}_assignSamplerUniform(e,t,r,i){let{gl:s}=this.device;if(r&&t.size>1){let r=Int32Array.from({length:t.size},(e,t)=>i+t);return s.uniform1iv(e,r),i+t.size}return s.uniform1i(e,i),i+1}async _waitForLinkComplete(){let e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void await e(10);let{gl:t}=this.device;for(;;){if(t.getProgramParameter(this.handle,37297))return;await e(10)}}}var ei=ee;class es extends ei.Resource{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,t){super(e,t,es.defaultProps),this._timeProfilingQuerySet=t.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let t=2*e,r=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:t}),i=0n;for(let e=0;e<t;e+=2)i+=r[e+1]-r[e];this._gpuTimeMs=Number(i)/1e6}getTimeProfilingSlotCount(){return this._timeProfilingSlotCount}getTimeProfilingQuerySet(){return this._timeProfilingQuerySet}_applyTimeProfilingToPassProps(e){let t=e||{};if(!this._supportsTimestampQueries()||!this._timeProfilingQuerySet||void 0!==t.timestampQuerySet||void 0!==t.beginTimestampIndex||void 0!==t.endTimestampIndex)return t;let r=this._timeProfilingSlotCount;return r+1>=this._timeProfilingQuerySet.props.count?t:(this._timeProfilingSlotCount+=2,{...t,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:r,endTimestampIndex:r+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}static defaultProps={...ei.Resource.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}}var en=ee;class ea extends en.Resource{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,ea.defaultProps)}static defaultProps={...en.Resource.defaultProps}}class eo extends ea{device;handle=null;commands=[];constructor(e,t={}){super(e,t),this.device=e}_executeCommands(e=this.commands){for(let t of e)switch(t.name){case"copy-buffer-to-buffer":!function(e,t){let r=t.sourceBuffer,i=t.destinationBuffer;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)}(this.device,t.options);break;case"copy-buffer-to-texture":!function(e,t){let{sourceBuffer:r,byteOffset:i=0,destinationTexture:s,mipLevel:n=0,origin:a=[0,0,0],aspect:o="all",bytesPerRow:l,rowsPerImage:u,size:h}=t;if("all"!==o)throw Error("copyBufferToTexture aspect is not supported in WebGL");s.writeBuffer(r,{byteOffset:i,bytesPerRow:l,rowsPerImage:u,mipLevel:n,x:a[0]??0,y:a[1]??0,z:a[2]??0,width:h[0],height:h[1],depthOrArrayLayers:h[2]})}(this.device,t.options);break;case"copy-texture-to-buffer":!function(e,t){let r,{sourceTexture:i,mipLevel:s=0,aspect:n="all",width:a=t.sourceTexture.width,height:o=t.sourceTexture.height,depthOrArrayLayers:l,origin:u=[0,0,0],destinationBuffer:h,byteOffset:c=0,bytesPerRow:f,rowsPerImage:g}=t;if(i instanceof F.Texture)return i.readBuffer({x:u[0]??0,y:u[1]??0,z:u[2]??0,width:a,height:o,depthOrArrayLayers:l,mipLevel:s,aspect:n,byteOffset:c},h);if("all"!==n)throw Error("aspect not supported in WebGL");if(0!==s||void 0!==l||f||g)throw Error("not implemented");let{framebuffer:m,destroyFramebuffer:p}=el(i);try{let t=a||m.width,i=o||m.height,s=(0,U.assertDefined)(m.colorAttachments[0]),n=(0,d.getTextureFormatWebGL)(s.texture.props.format),l=n.format,f=n.type;e.gl.bindBuffer(35051,h.handle),r=e.gl.bindFramebuffer(36160,m.handle),e.gl.readPixels(u[0],u[1],t,i,l,f,c)}finally{e.gl.bindBuffer(35051,null),void 0!==r&&e.gl.bindFramebuffer(36160,r),p&&m.destroy()}}(this.device,t.options);break;case"copy-texture-to-texture":!function(e,t){let r,i,{sourceTexture:s,destinationMipLevel:n=0,origin:a=[0,0],destinationOrigin:o=[0,0,0],destinationTexture:l}=t,{width:u=t.destinationTexture.width,height:h=t.destinationTexture.height}=t,{framebuffer:c,destroyFramebuffer:d}=el(s),[f=0,g=0]=a,[m,p,b]=o,y=e.gl.bindFramebuffer(36160,c.handle);if(l instanceof G)r=l,u=Number.isFinite(u)?u:r.width,h=Number.isFinite(h)?h:r.height,r._bind(0),i=r.glTarget;else throw Error("invalid destination");switch(i){case 3553:case 34067:e.gl.copyTexSubImage2D(i,n,m,p,f,g,u,h);break;case 35866:case 32879:e.gl.copyTexSubImage3D(i,n,m,p,b,f,g,u,h)}r&&r._unbind(),e.gl.bindFramebuffer(36160,y),d&&c.destroy()}(this.device,t.options);break;default:throw Error(t.name)}}}function el(e){if(e instanceof F.Texture){let{width:t,height:r,id:i}=e;
5return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${i}`,width:t,height:r,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}var eu=ee;class eh extends eu.Resource{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t,r=eh.defaultProps){t=eh.normalizeProps(e,t),super(e,t,r)}static normalizeProps(e,t){return t}static defaultProps={...eu.Resource.defaultProps,framebuffer:null,resolveTargets:void 0,parameters:void 0,clearColor:eh.defaultClearColor,clearColors:void 0,clearDepth:eh.defaultClearDepth,clearStencil:eh.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}}let ec=[1,2,4,8];class ed extends eh{device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(e,t){let r;super(e,t),this.device=e;const i=this.props.framebuffer,s=!i||null===i.handle;if(s&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded(),!t?.parameters?.viewport)if(!s&&i){const{width:e,height:t}=i;r=[0,0,e,t]}else{const[t,i]=e.getDefaultCanvasContext().getDrawingBufferSize();r=[0,0,t,i]}if(this.device.pushState(),this.setParameters({viewport:r,...this.props.parameters}),!s&&i?.colorAttachments.length){const e=i.colorAttachments.map((e,t)=>36064+t);this.device.gl.drawBuffers(e)}else s&&this.device.gl.drawBuffers([1029]);this.clear(),this.props.timestampQuerySet&&void 0!==this.props.beginTimestampIndex&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&void 0!==this.props.endTimestampIndex&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}executeBundles(e){throw Error("Render bundles are only supported in WebGPU")}setParameters(e={}){let t={...this.glParameters};t.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=+!this.props.stencilReadOnly,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),void 0!==e.stencilReference&&(t[2967]=e.stencilReference,t[36003]=e.stencilReference),"colorMask"in e&&(t.colorMask=ec.map(t=>!!(t&e.colorMask))),this.glParameters=t,(0,x.setGLParameters)(this.device.gl,t)}setPipeline(e){this.pipeline=e}setBindings(e,t){if(!this.pipeline)throw Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=(0,$.flattenBindingsByGroup)((0,$.normalizeBindingsByGroup)(this.pipeline.shaderLayout,e)),this.bindingsPipeline=this.pipeline}setVertexArray(e){this.vertexArray=e}draw(e){let t=this.pipeline,i=this.vertexArray;if(!t)throw Error("RenderPass.setPipeline() must be called before draw()");if(!i)throw Error("RenderPass.setVertexArray() must be called before draw()");if(t.shaderLayout.bindings.length>0&&this.bindingsPipeline!==t)throw Error("RenderPass.setBindings() must be called after setPipeline() before draw()");t._syncLinkStatus();let{parameters:s=t.props.parameters,topology:n=t.props.topology,vertexCount:a,indexCount:o,instanceCount:l,isInstanced:u=!1,firstVertex:h=0,transformFeedback:c,uniforms:d=t.uniforms}=e,f=function(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw Error(e)}}(n),g=!!i.indexBuffer,m=i.indexBuffer?.glIndexType,p=o??a??0;return"success"!==t.linkStatus?(r.log.info(2,`RenderPipeline:${t.id}.draw() aborted - waiting for shader linking`)(),!1):t._areTexturesRenderable(this.bindings)?(this.device.gl.useProgram(t.handle),i.bindBeforeRender(this),c&&c.begin(t.props.topology),t._applyBindings(this.bindings,{disableWarnings:t.props.disableWarnings}),t._applyUniforms(d),!function(e,t,i,s){if(function(e){let t=!0;for(let r in e){t=!1;break}return t}(t))return s(e);e.pushState();try{return function(e,t){let{gl:i}=e;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)}if(t.frontFace&&i.frontFace(P("frontFace",t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has("depth-clip-control")&&i.enable(34383),void 0!==t.depthBias&&(i.enable(32823),i.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0)),t.provokingVertex&&e.features.has("provoking-vertex-webgl")){let r=e.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,i=P("provokingVertex",t.provokingVertex,{first:36429,last:36430});r?.provokingVertexWEBGL(i)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has("polygon-mode-webgl")){if(t.polygonMode){let r=e.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,i=P("polygonMode",t.polygonMode,{fill:6914,line:6913});r?.polygonModeWEBGL(1028,i),r?.polygonModeWEBGL(1029,i)}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.clip
5Distance3&&i.enable(12291),t.clipDistance4&&i.enable(12292),t.clipDistance5&&i.enable(12293),t.clipDistance6&&i.enable(12294),t.clipDistance7&&i.enable(12295)),void 0!==t.depthWriteEnabled&&i.depthMask(t.depthWriteEnabled),t.depthCompare&&("always"!==t.depthCompare?i.enable(2929):i.disable(2929),i.depthFunc(w("depthCompare",t.depthCompare))),void 0!==t.clearDepth&&i.clearDepth(t.clearDepth),t.stencilWriteMask){let e=t.stencilWriteMask;i.stencilMaskSeparate(1028,e),i.stencilMaskSeparate(1029,e)}if(t.stencilReadMask&&r.log.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){let e=t.stencilReadMask||0xffffffff,r=w("depthCompare",t.stencilCompare);"always"!==t.stencilCompare?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,r,0,e),i.stencilFuncSeparate(1029,r,0,e)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){let e=_("stencilPassOperation",t.stencilPassOperation),r=_("stencilFailOperation",t.stencilFailOperation),s=_("stencilDepthFailOperation",t.stencilDepthFailOperation);i.stencilOpSeparate(1028,r,s,e),i.stencilOpSeparate(1029,r,s,e)}switch(t.blend){case!0:i.enable(3042);break;case!1:i.disable(3042)}if(t.blendColorOperation||t.blendAlphaOperation){let e=S("blendColorOperation",t.blendColorOperation||"add"),r=S("blendAlphaOperation",t.blendAlphaOperation||"add");i.blendEquationSeparate(e,r);let s=T("blendColorSrcFactor",t.blendColorSrcFactor||"one"),n=T("blendColorDstFactor",t.blendColorDstFactor||"zero"),a=T("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),o=T("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");i.blendFuncSeparate(s,n,a,o)}}(e,t),(0,x.setGLParameters)(e.gl,i),s(e)}finally{e.popState()}}(this.device,s,this.glParameters,()=>{g&&u?this.device.gl.drawElementsInstanced(f,p,m,h,l||0):g?this.device.gl.drawElements(f,p,m,h):u?this.device.gl.drawArraysInstanced(f,h,a||0,l||0):this.device.gl.drawArrays(f,h,a||0),c&&c.end()}),i.unbindAfterRender(this),!0):(r.log.info(2,`RenderPipeline:${t.id}.draw() aborted - textures not yet loaded`)(),!1)}drawIndirect(e,t=0){throw Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(e,t=0){throw Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(e){let t=this.props.occlusionQuerySet;t?.beginOcclusionQuery()}endOcclusionQuery(){let e=this.props.occlusionQuerySet;e?.endOcclusionQuery()}clear(){let e={...this.glParameters},t=0;this.props.clearColors&&this.props.clearColors.forEach((e,t)=>{e&&this.clearColorBuffer(t,e)}),!1!==this.props.clearColor&&void 0===this.props.clearColors&&(t|=16384,e.clearColor=this.props.clearColor),!1!==this.props.clearDepth&&(t|=256,e.clearDepth=this.props.clearDepth),!1!==this.props.clearStencil&&(t|=1024,e.clearStencil=this.props.clearStencil),0!==t&&A(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){A(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,t);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,t);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,t);break;default:throw Error("clearColorBuffer: color must be typed array")}})}}class ef extends es{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new eo(e,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new ed(this.device,this._applyTimeProfilingToPassProps(e))}beginComputePass(e={}){throw Error("ComputePass not supported in WebGL")}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,r){throw Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(e,t){e.writeTimestamp(t)}}var eg=ee;class em extends eg.Resource{static defaultProps={...eg.Resource.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;indexBuffer=null;attributes;constructor(e,t){super(e,t,em.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=Array(this.maxVertexAttributes).fill(null)}getBufferSlot(e){return null}getDrawValidationError(){return null}setConstantWebGL(e,t){this.device.reportError(Error("constant attributes not supported"),this)()}}var ep=e.i(965880),eb=e.i(553746),ey=e.i(740021),ev=e.i(119045),ex=e.i(799037),ew=e.i(852613);class e_ extends em{get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return"Chrome"===((0,ey.isBrowser)()?(0,ev.isElectron)(void 0)?"Electron":(ex.navigator.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node")}constructor(e,t){for(const r of(super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=Array(this.maxVertexAttributes).fill(null),Object.values((0,ep.getAttributeInfosFromLayouts)(t.shaderLayout,t.bufferLayout))))this.attributeInfosByLocation[r.location]=r}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){if(e&&34963!==e.glTarget)throw Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,e?e.handle:null),this.indexBuffer=e,this.device.gl.bindVertexArray(null)}setBuffer(e,t){if(34963===t.glTarget)throw Error("Use .setIndexBuffer()");let{size:r,type:i,stride:s,offset:n,normalized:a,integer:o,divisor:l}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,t.handle),o?this.device.gl.vertexAttribIPointer(e,r,i,s,n):this.device.gl.vertexAttribPointer(e,r,i,a,s,n),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,l||0),this.attributes[e]=t,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e<this.maxVertexAttributes;++e){let t=this.attributes[e];ArrayBuffer.isView(t)&&this.device.setConstantAttributeWebGL(e,t)}}_getAccessor(e){let t=this.attributeInfosByLocation[e];if(!t)throw Error(`Unknown attribute location ${e}`);let r=(0,ew.getGLFromVertexType)(t.bufferDataType);return{size:t.bufferComponents,type:r,stride:t.byteStride,offset:t.byteOffset,normalized:t.normalized,integer:t.integer,divisor:+("instance"===t.stepMode)}}_enable(e,t=!0){let r=e_.isConstantAttributeZeroSupported(this.device)||0!==e;(t||r)&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),t?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,t){var r;let i=Array.isArray(r=t)?new Float32Array(r):r,s=i.byteLength*e,n=i.length*e;if(this.buffer&&s!==this.buffer.byteLength)throw Error(`Buffer size is immutable, byte length ${s} !== ${this.buffer.byteLength}.`);let a=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:s}),a||=!function(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}(i,this.bufferValue)){let e=(0,eb.getScratchArray)(t.constructor,n);!function(e){let{target:t,source:r,start:i=0,count:s=1}=e,n=r.length,a=s*n,o=0;for(let e=i;o<n;
5o++)t[e++]=r[o]??0;for(;o<a;)o<a-o?(t.copyWithin(i+o,i,i+o),o*=2):(t.copyWithin(i+o,i,i+a-o),o=a);e.target}({target:e,source:i,start:0,count:n}),this.buffer.write(e),this.bufferValue=t}return this.buffer}}var eS=ee;class eT extends eS.Resource{static defaultProps={...eS.Resource.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,eT.defaultProps)}}class eP extends eT{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,t){super(e,t),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,t.buffers&&this.setBuffers(t.buffers),Object.seal(this)}destroy(){this.gl.deleteTransformFeedback(this.handle),super.destroy()}begin(e="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(function(e){switch(e){case"point-list":return 0;case"line-list":case"line-strip":return 1;case"triangle-list":case"triangle-strip":return 4;default:throw Error(e)}}(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[t,r]of Object.entries(e))this.setBuffer(t,r)})}setBuffer(e,t){let i=this._getVaryingIndex(e),{buffer:s,byteLength:n,byteOffset:a}=this._getBufferRange(t);if(i<0){this.unusedBuffers[e]=s,r.log.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:s,byteLength:n,byteOffset:a},this.bindOnUse||this._bindBuffer(i,s,a,n)}getBuffer(e){if(eE(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return this.buffers[t]??null}bind(e=this.handle){let t;return"function"!=typeof e?(this.gl.bindTransformFeedback(36386,e),this):(this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t)}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof m)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:r=0,byteLength:i=e.buffer.byteLength}=e;return{buffer:t,byteOffset:r,byteLength:i}}_getVaryingIndex(e){if(eE(e))return Number(e);for(let t of this.layout.varyings||[])if(e===t.name)return t.location;return -1}_bindBuffers(){for(let[e,t]of Object.entries(this.buffers)){let{buffer:r,byteLength:i,byteOffset:s}=this._getBufferRange(t);this._bindBuffer(Number(e),r,s,i)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,r=0,i){let s=t&&t.handle;s&&void 0!==i?this.gl.bindBufferRange(35982,e,s,r,i):this.gl.bindBufferBase(35982,e,s)}}function eE(e){return"number"==typeof e?Number.isInteger(e):/^\d+$/.test(e)}var eC=ee;class eL extends eC.Resource{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,eL.defaultProps)}static defaultProps={...eC.Resource.defaultProps,type:void 0,count:void 0}}class eB extends eL{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){if(super(e,t),this.device=e,"timestamp"===t.type){if(t.count<2)throw Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=Array(Math.ceil(t.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(t.count>1)throw Error("WebGL occlusion QuerySet can only have one value");const e=this.device.gl.createQuery();if(!e)throw Error("WebGL query not supported");this.handle=e}
5Object.seal(this)}destroy(){if(!this.destroyed){for(let e of(this.handle&&this.device.gl.deleteQuery(this.handle),this._timestampPairs))for(let t of(e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle)),e.completedQueries))this._cancelPendingQuery(t),this.device.gl.deleteQuery(t.handle);for(let e of(this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle)),Array.from(this._pendingReads)))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return"timestamp"===this.props.type?void 0===e?this._timestampPairs.some((e,t)=>this._isTimestampPairAvailable(t)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):!!this._occlusionQuery&&this._pollQueryAvailability(this._occlusionQuery)}async readResults(e){let t=e?.firstQuery||0,r=e?.queryCount||this.props.count-t;if(this._validateRange(t,r),"timestamp"===this.props.type){let e=Array(r).fill(0n),i=Math.floor(t/2),s=Math.floor((t+r-1)/2);for(let n=i;n<=s;n++){let i=await this._consumeTimestampPairResult(n),s=2*n,a=s+1;s>=t&&s<t+r&&(e[s-t]=0n),a>=t&&a<t+r&&(e[a-t]=i)}return e}if(!this._occlusionQuery)throw Error("Occlusion query has not been started");return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(e,t){if("timestamp"!==this.props.type)throw Error("Timestamp durations require a timestamp QuerySet");if(e<0||t>=this.props.count||t<=e)throw Error("Timestamp duration range is out of bounds");if(e%2!=0||t!==e+1)throw Error("WebGL timestamp durations require adjacent even/odd query indices");return Number(await this._consumeTimestampPairResult(this._getTimestampPairIndex(e)))/1e6}beginOcclusionQuery(){if("occlusion"!==this.props.type)throw Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw Error("WebGL occlusion query is not available");if(this._occlusionActive)throw Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if("timestamp"!==this.props.type)throw Error("Timestamp writes require a timestamp QuerySet");let t=this._getTimestampPairIndex(e),r=this._timestampPairs[t];if(e%2==0){if(r.activeQuery)throw Error("Timestamp query pair is already active");let e=this.device.gl.createQuery();if(!e)throw Error("WebGL query not supported");this.device.gl.beginQuery(35007,e),r.activeQuery={handle:e,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};return}if(!r.activeQuery)throw Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),r.completedQueries.push(r.activeQuery),r.activeQuery=null}_validateRange(e,t){if(e<0||t<0||e+t>this.props.count)throw Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){let t=this._timestampPairs[e];return!!t&&0!==t.completedQueries.length&&this._pollQueryAvailability(t.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(null!==e.result||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let t=!!this.device.gl.getParameter(36795);return e.disjoint=t,e.result=t?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let t=this._timestampPairs[e];if(!t||0===t.completedQueries.length)throw Error("Timestamp query pair has no completed result");let r=t.completedQueries.shift();try{return await this._consumeQueryResult(r)}finally{this.device.gl.deleteQuery(r.handle)}}_consumeQueryResult(e){return e.promise||(this._pendingReads.add(e),e.promise=new Promise((t,r)=>{e.resolve=t,e.reject=r;let i=()=>
5{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,t(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(i);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?r(Error("GPU timestamp query was invalidated by a disjoint event")):t(e.result||0n)};i()})),e.promise}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,null!==e.pollRequestId&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let t=e.resolve;e.promise=null,e.resolve=null,e.reject=null,t(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}var eD=ee;class eF extends eD.Resource{static defaultProps={...eD.Resource.defaultProps};get[Symbol.toStringTag](){return"Fence"}constructor(e,t={}){super(e,t,eF.defaultProps)}}class eA extends eF{device;gl;handle;signaled;_signaled=!1;constructor(e,t={}){super(e,{}),this.device=e,this.gl=e.gl;const r=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!r)throw Error("Failed to create WebGL fence");this.handle=r,this.signaled=new Promise(e=>{let t=()=>{let r=this.gl.clientWaitSync(this.handle,0,0);r===this.gl.ALREADY_SIGNALED||r===this.gl.CONDITION_SATISFIED?(this._signaled=!0,e()):setTimeout(t,1)};t()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}var eI=e.i(734237),eR=e.i(69004);function ek(e){switch(e){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function eG(e){return e instanceof eI.Framebuffer?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:function(e){let{device:t,width:r,height:i,id:s}=e;return t.createFramebuffer({...void 0,id:`framebuffer-for-${s}`,width:r,height:i,colorAttachments:[e]})}(e),deleteFramebuffer:!0}}var eW=e.i(777729);class eM extends t.Device{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";
5preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_glKeyByValue=null;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){return"unorm8x4-bgra"!==e}constructor(e){super({...e,id:e.id||function(e="id"){f[e]=f[e]||1;let t=f[e]++;return`${e}-${t}`}("webgl-device")});const h=t.Device._getCanvasContextProps(e);if(!h)throw Error("WebGLDevice requires props.createCanvasContext to be set");const d=h.canvas?.gl??null;let g=eM.getDeviceFromContext(d);if(g)throw Error(`WebGL context already attached to device ${g.id}`);this.canvasContext=new u.WebGLCanvasContext(this,h),this.lost=new Promise(e=>{this._resolveContextLost=e});const m={...e.webgl};"premultiplied"===h.alphaMode&&(m.premultipliedAlpha=!0),void 0!==e.powerPreference&&(m.powerPreference=e.powerPreference),void 0!==e.failIfMajorPerformanceCaveat&&(m.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);const p=this.props._handle||(0,s.createBrowserContext)(this.canvasContext.canvas,{onContextLost:e=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:e=>{console.log("WebGL context restored")}},m);if(!p)throw Error("WebGL context creation failed");if(g=eM.getDeviceFromContext(p)){if(e._reuseDevices)return r.log.log(1,`Not creating a new Device, instead returning a reference to Device ${g.id} already attached to WebGL context`,g)(),this.canvasContext.destroy(),g._reused=!0,g;throw Error(`WebGL context already attached to device ${g.id}`)}this.handle=p,this.gl=p,this.spectorJS=(0,c.initializeRegisteredSpectorJS)({...this.props,gl:this.handle});const b=(0,n.getWebGLContextData)(this.handle);b.device=this,b.extensions||(b.extensions={}),this.extensions=b.extensions,this.info=(0,a.getDeviceInfo)(this.gl,this.extensions),this.limits=new l.WebGLDeviceLimits(this.gl),this.features=new o.WebGLDeviceFeatures(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new i.WebGLStateTracker(this.gl,{log:(...e)=>r.log.log(1,...e)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=(0,c.makeRegisteredDebugContext)(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),r.log.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(r.log.level=Math.max(r.log.level,1)),this.commandEncoder=new ef(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){this.props._reuseDevices||this._reused||(this._isLost=!0,this.commandEncoder?.destroy(),(0,n.getWebGLContextData)(this.handle).device=null)}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(e){throw Error("WebGL only supports a single canvas")}createPresentationContext(e){return new h.WebGLPresentationContext(this,e||{})}createBuffer(e){return new m(this,this._normalizeBufferProps(e))}createTexture(e){return new G(this,e)}createExternalTexture(e){throw Error("ExternalTexture is not available on WebGL")}createSampler(e){return new B(this,e)}createShader(e){return new y(this,e)}createFramebuffer(e){return new M.WEBGLFramebuffer(this,e)}createVertexArray(e){return new e_(this,e)}createTransformFeedback(e){return new eP(this,e)}createQuerySet(e){return new eB(this,e)}createFence(){return new eA(this)}createRenderPipeline(e){return new Y(this,e)}_createSharedRenderPipelineWebGL(e){return new er(this,e)}createComputePipeline(e){throw Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(e){throw Error("Render bundles are only supported in WebGPU")}createCommandEncoder(e={}){return new ef(this,e)}submit(e){let t=null;e||({submittedCommandEncoder:t,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),t&&t.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=t._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}writeBufferViaCommandEncoder(e,t,r,i=0){t.write(r,i)}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,t=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:t}}readPixelsToArrayWebGL(e,t){return function(e,t){let{sourceX:r=0,sourceY:i=0,sourceAttachment:s=0}=t||{}
5,{target:n=null,sourceWidth:a,sourceHeight:o,sourceDepth:l,sourceFormat:u,sourceType:h}=t||{},{framebuffer:c,deleteFramebuffer:d}=eG(e),{gl:f,handle:g}=c;a||=c.width,o||=c.height;let m=c.colorAttachments[s]?.texture;if(!m)throw Error(`Invalid framebuffer attachment ${s}`);l=m?.depth||1,u||=m?.glFormat||6408,h||=m?.glType||5121,n=function(e,t,r,i,s){if(e)return e;let n=k[t||=5121];return new(eR.dataTypeDecoder.getTypedArrayConstructor(n))(i*s*ek(r))}(n,h,u,a,o);let p=eR.dataTypeDecoder.getDataType(n);h=h||H[p];let b=f.bindFramebuffer(36160,g);return f.readBuffer(36064+s),f.readPixels(r,i,a,o,u,h,n),f.readBuffer(36064),f.bindFramebuffer(36160,b||null),d&&c.destroy(),n}(e,t)}readPixelsToBufferWebGL(e,t){return function(e,t){let{target:r,sourceX:i=0,sourceY:s=0,sourceFormat:n=6408,targetByteOffset:a=0}=t||{},{sourceWidth:o,sourceHeight:l,sourceType:u}=t||{},{framebuffer:h,deleteFramebuffer:c}=eG(e);o=o||h.width,l=l||h.height,u=u||5121;let d=r;if(!d){let e=a+o*l*ek(n)*function(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}(u);d=h.device.createBuffer({byteLength:e})}let f=e.device.createCommandEncoder();return f.copyTextureToBuffer({sourceTexture:e,width:o,height:l,origin:[i,s],destinationBuffer:d,byteOffset:a}),f.destroy(),c&&h.destroy(),d}(e,t)}setParametersWebGL(e){(0,x.setGLParameters)(this.gl,e)}getParametersWebGL(e){return(0,x.getGLParameters)(this.gl,e)}withParametersWebGL(e,t){return A(this.gl,e,t)}resetWebGL(){r.log.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),(0,x.resetGLParameters)(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return(0,d.getTextureFormatCapabilitiesWebGL)(this.gl,e,this.extensions)}loseDevice(){let e=!1,t=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return t&&(e=!0,t.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){i.WebGLStateTracker.get(this.gl).push()}popState(){i.WebGLStateTracker.get(this.gl).pop()}getGLKey(e,t){let r=this._getGLKeyByValue().get(Number(e));return r||(t?.emptyIfUnknown?"":String(e))}getGLKeys(e){let t={emptyIfUnknown:!0};return Object.entries(e).reduce((e,[r,i])=>(e[`${r}:${this.getGLKey(r,t)}`]=`${i}:${this.getGLKey(i,t)}`,e),{})}_getGLKeyByValue(){return this._glKeyByValue??=function(e){let t=new Map;for(let r in e){let i=e[r];if(r<"a"){let e=t.get(i);t.set(i,e?`${e}, GL.${r}`:`GL.${r}`)}}return t}(this.gl),this._glKeyByValue}setConstantAttributeWebGL(e,t){let i=this.limits.maxVertexAttributes;this._constants=this._constants||Array(i).fill(null);let s=this._constants[e];switch(s&&function(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}(s,t)&&r.log.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:var n,a,o,l,u,h,c=this,d=e,f=t;switch(f.length){case 1:c.gl.vertexAttrib1fv(d,f);break;case 2:c.gl.vertexAttrib2fv(d,f);break;case 3:c.gl.vertexAttrib3fv(d,f);break;case 4:c.gl.vertexAttrib4fv(d,f)}break;case Int32Array:n=this,a=e,o=t,n.gl.vertexAttribI4iv(a,o);break;case Uint32Array:l=this,u=e,h=t,l.gl.vertexAttribI4uiv(u,h);break;default:throw Error("constant")}}getExtension(e){return(0,eW.getWebGLExtension)(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,t,r){e.luma=t,e.__SPECTOR_Metadata={props:r.spector,id:r.spector.id}}}e.s(["WebGLDevice",0,eM],695002)},892563,e=>{"use strict";var t=e.i(912828);let r=!1;async function i(){n()}async function s(e){n()}function n(){r||(r=!0,t.log.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}e.s(["initializeRegisteredSpectorJS",0,function(e){return null},"loadRegisteredSpectorJS",0,s,"loadRegisteredWebGLDeveloperTools",0,i,"makeRegisteredDebugContext",0,function(e,t){return n(),e}])},941533,453196,567415,988e3,777729,709095,852613,726348,420505,677641,734237,888583,624628,511547,e=>{"use strict";let t={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:0xffffffff,36005:0xffffffff,2962:519,2967:0,2963:0xffffffff,34816:519,36003:0,36004:0xffffffff,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},r=(e,t,r)=>t?e.enable(r):e.disable(r),i=(e,t,r)=>e.hint(r,t),s=(e,t,r)=>e.pixelStorei(r,t),n=(e,t,r)=>e.bindFramebuffer(36006===r?36009:36008,t),a=(e,t,r)=>{e.bindBuffer({34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[r],t)};function o(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}let l={3042:r,32773:(e,t)=>
vendor: 2,073 bytes, line 5
5e.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:r,2885:(e,t)=>e.cullFace(t),2929:r,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:r,35723:i,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:n,36010:n,34964:a,36662:a,36663:a,35053:a,35055:a,2886:(e,t)=>e.frontFace(t),33170:i,2849:(e,t)=>e.lineWidth(t),32823:r,32824:"polygonOffset",10752:"polygonOffset",35977:r,32926:r,32928:r,32938:"sampleCoverage",32939:"sampleCoverage",3089:r,3088:(e,t)=>e.scissor(...t),2960:r,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:r,10754:r,12288:r,12289:r,12290:r,12291:r,12292:r,12293:r,12294:r,12295:r,3333:s,3317:s,37440:s,37441:s,37443:s,3330:s,3332:s,3331:s,3314:s,32878:s,3316:s,3315:s,32877:s,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)=>{e.blendEquationSeparate(..."number"==typeof t?[t,t]:t)},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)=>
5e.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[0],t[1]||!1),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)=>{let[r,i]=t=o(t)?t:[t,t];e.stencilMaskSeparate(1028,r),e.stencilMaskSeparate(1029,i)},stencilFunc:(e,t)=>{let[r,i,s,n,a,l]=t=o(t)&&3===t.length?[...t,...t]:t;e.stencilFuncSeparate(1028,r,i,s),e.stencilFuncSeparate(1029,n,a,l)},stencilOp:(e,t)=>{let[r,i,s,n,a,l]=t=o(t)&&3===t.length?[...t,...t]:t;e.stencilOpSeparate(1028,r,i,s),e.stencilOpSeparate(1029,n,a,l)},viewport:(e,t)=>e.viewport(...t)};function u(e,t,r){return void 0!==t[e]?t[e]:r[e]}let h={blendEquation:(e,t,r)=>e.blendEquationSeparate(u(32777,t,r),u(34877,t,r)),blendFunc:(e,t,r)=>e.blendFuncSeparate(u(32969,t,r),u(32968,t,r),u(32971,t,r),u(32970,t,r)),polygonOffset:(e,t,r)=>e.polygonOffset(u(32824,t,r),u(10752,t,r)),sampleCoverage:(e,t,r)=>e.sampleCoverage(u(32938,t,r),u(32939,t,r)),stencilFuncFront:(e,t,r)=>e.stencilFuncSeparate(1028,u(2962,t,r),u(2967,t,r),u(2963,t,r)),stencilFuncBack:(e,t,r)=>e.stencilFuncSeparate(1029,u(34816,t,r),u(36003,t,r),u(36004,t,r)),stencilOpFront:(e,t,r)=>e.stencilOpSeparate(1028,u(2964,t,r),u(2965,t,r),u(2966,t,r)),stencilOpBack:(e,t,r)=>e.stencilOpSeparate(1029,u(34817,t,r),u(34818,t,r),u(34819,t,r))},c={enable:(e,t)=>
5e({[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({[1028===t?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({[1028===t?2962:34816]:r,[1028===t?2967:36003]:i,[1028===t?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({[1028===t?2964:34817]:r,[1028===t?2965:34818]:i,[1028===t?2966:34819]:s}),viewport:(e,t,r,i,s)=>e({2978:[t,r,i,s]})},d=(e,t)=>e.isEnabled(t),f={3042:d,2884:d,2929:d,3024:d,32823:d,32926:d,32928:d,3089:d,2960:d,35977:d},g=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 m(e,t){if(function(e){for(let t in e)return!1;return!0}(t))return;let r={};for(let i in t){let s=Number(i),n=l[i];n&&("string"==typeof n?r[n]=!0:n(e,t[i],s))}let i=e.lumaState?.cache;if(i)for(let s in r)(0,h[s])(e,t,i)}function p(e,r=t){if("number"==typeof r){let t=f[r];return t?t(e,r):e.getParameter(r)}let i=Array.isArray(r)?r:Object.keys(r),s={};for(let t of i){let r=f[t];s[t]=r?r(e,Number(t)):e.getParameter(Number(t))}return s}function b(e){return Array.isArray(e)||ArrayBuffer.isView(e)}e.s(["getGLParameters",0,p,"resetGLParameters",0,function(e){m(e,t)},"setGLParameters",0,m],453196);class y{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,t){this.gl=e,this.log=t?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];m(this.gl,e),this.stateStack.pop()}trackState(e,r){var i;let s;if(this.cache=r?.copyState?p(e):Object.assign({},t),this.initialized)throw Error("WebGLStateTracker");for(let t in this.initialized=!0,this.gl.lumaState=this,s=(i=e).useProgram.bind(i),i.useProgram=function(e){let t=y.get(i);t.program!==e&&(s(e),t.program=e)},c){let r=c[t];!function(e,t,r){if(!e[t])return;let i=e[t].bind(e);e[t]=function(...t){let{valueChanged:s,oldValue:n}=r(y.get(e)._updateCache,...t);return s&&i(...t),n}
5,Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}(e,t,r)}v(e,"getParameter"),v(e,"isEnabled")}_updateCache(e){let t,r=!1,i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in e){let n=e[s],a=this.cache[s];!function(e,t){if(e===t)return!0;if(b(e)&&b(t)&&e.length===t.length){for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}return!1}(n,a)&&(r=!0,t=a,!i||s in i||(i[s]=a),this.cache[s]=n)}return{valueChanged:r,oldValue:t}}}function v(e,t){let r=e[t].bind(e);e[t]=function(t){if(void 0===t||g.has(t))return r(t);let i=y.get(e);return t in i.cache||(i.cache[t]=r(t)),i.enable?i.cache[t]:r(t)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function x(e){let t=e.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return t._polyfilled??=!1,t.extensions||={},e.luma=t,t}function w(e,t,r){return void 0===r[t]&&(r[t]=e.getExtension(t)||null),r[t]}function _(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"}e.s(["WebGLStateTracker",0,y],941533),e.s(["getWebGLContextData",0,x],567415),e.s(["createBrowserContext",0,function(e,t,r){let i="",s=e=>{let t=e.statusMessage;t&&(i||=t)};e.addEventListener("webglcontextcreationerror",s,!1);let n=!0!==r.failIfMajorPerformanceCaveat,a={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},o=null;try{(o||=e.getContext("webgl2",a))||!a.failIfMajorPerformanceCaveat||(i||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let r=!1;if(!o&&n&&(a.failIfMajorPerformanceCaveat=!1,o=e.getContext("webgl2",a),r=!0),!o&&(o=e.getContext("webgl",{}))&&(o=null,i||="Your browser only supports WebGL1"),!o)throw i||="Your browser does not support WebGL",Error(`Failed to create WebGL context: ${i}`);x(o).softwareRenderer=r;let{onContextLost:s,onContextRestored:l}=t;return e.addEventListener("webglcontextlost",e=>s(e),!1),e.addEventListener("webglcontextrestored",e=>l(e),!1),o}finally{e.removeEventListener("webglcontextcreationerror",s,!1)}}],988e3),e.s(["getWebGLExtension",0,w],777729),e.s(["getDeviceInfo",0,function(e,t){var r,i;let s=e.getParameter(7936),n=e.getParameter(7937);w(e,"WEBGL_debug_renderer_info",t);let a=t.WEBGL_debug_renderer_info,o=e.getParameter(a?a.UNMASKED_VENDOR_WEBGL:7936),l=e.getParameter(a?a.UNMASKED_RENDERER_WEBGL:7937),u=o||s,h=l||n,c=e.getParameter(7938),d=_(u,h),f=(r=u,i=h,/Metal/i.exec(r)||/Metal/i.exec(i)?"metal":/ANGLE/i.exec(r)||/ANGLE/i.exec(i)?"opengl":"unknown");return{type:"webgl",gpu:d,gpuType:function(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(_(e,t)){case"apple":var r,i;return(r=e,i=t,/Apple (M\d|A\d|GPU)/i.test(`${r} ${i}`))?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}(u,h),gpuBackend:f,vendor:u,renderer:h,version:c,shadingLanguage:"glsl",shadingLanguageVersion:300}}],709095);var S=e.i(25387),T=e.i(582090);function P(e){switch(e){case"uint8":case"unorm8":return 5121;case"sint8":case"snorm8":return 5120;case"uint16":case"unorm16":return 5123;case"sint16":case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw Error(String(e))}e.s(["getGLFromVertexType",0,P],852613);let E="WEBGL_compressed_texture_s3tc",C="WEBGL_compressed_texture_s3tc_srgb",L="EXT_texture_compression_rgtc",B="EXT_texture_compression_bptc",D="EXT_render_snorm",F="EXT_color_buffer_float",A="snorm8-renderable-webgl",I="norm16-renderable-webgl",R="snorm16-renderable-webgl",k="float16-renderable-webgl",G="float32-renderable-webgl",W={"float32-renderable-webgl":{extensions:[F]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[D]},"norm16-webgl":{extensions:["EXT_texture_norm16"]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[D]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[E,C,L,B]},"texture-compression-bc5-webgl":{extensions:[L]},"texture-compression-bc7-webgl":{extensions:[B]},"texture-compression-etc2":{extensions:["WEBGL_compressed_texture_etc"]},"texture-compression-astc":{extensions:["WEBGL_compressed_texture_astc"]},"texture-compression-etc1-webgl":{extensions:["WEBGL_compressed_texture_etc1"]},"texture-compression-pvrtc-webgl":{extensions:["WEBGL_compressed_texture_pvrtc"]},"texture-compression-atc-webgl":{extensions:["WEBGL_compressed_texture_atc"]}};function M(e){return e in W}function O(e,t,r){return function e(t,r,i,s){let n=W[r];if(!n||s.has(r))return!1;s.add(r);let a=(n.features||[]).every(r=>e(t,r,i,s));return s.delete(r),!!a&&(n.extensions||[]).every(e=>!!w(t,e,i))}(e,t,r,new Set)}let $={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:A},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:A},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:k},r16unorm:{gl:33322,rb:!0,r:I},r16snorm:{gl:36760,r:R},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:A},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:k},rg16unorm:{gl:33324,r:I},rg16snorm:{gl:36761,r:R},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:G},rgb9e5ufloat:{gl:35901,r:"rgb9e5ufloat-renderable-webgl"},rg11b10ufloat:{gl:35898,rb:!0}
5,rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:G},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:k},rgba16unorm:{gl:32859,rb:!0,r:I},rgba16snorm:{gl:36763,r:R},"rgb32float-webgl":{gl:34837,x:F,r:G,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:G},stencil8:{gl:36168,rb:!0},depth16unorm:{gl:33189,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,dataFormat:6402,types:[5125]},depth32float:{gl:36012,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth32float-stencil8":{gl:36013,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:E},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:C},"bc1-rgba-unorm":{gl:33777,x:E},"bc1-rgba-unorm-srgb":{gl:35916,x:C},"bc2-rgba-unorm":{gl:33778,x:E},"bc2-rgba-unorm-srgb":{gl:35918,x:C},"bc3-rgba-unorm":{gl:33779,x:E},"bc3-rgba-unorm-srgb":{gl:35919,x:C},"bc4-r-unorm":{gl:36283,x:L},"bc4-r-snorm":{gl:36284,x:L},"bc5-rg-unorm":{gl:36285,x:L},"bc5-rg-snorm":{gl:36286,x:L},"bc6h-rgb-ufloat":{gl:36495,x:B},"bc6h-rgb-float":{gl:36494,x:B},"bc7-rgba-unorm":{gl:36492,x:B},"bc7-rgba-unorm-srgb":{gl:36493,x:B},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}};function z(e){switch(T.textureFormatDecoder.getInfo(e).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw Error(`Not a depth stencil format: ${e}`)}}e.s(["TEXTURE_FEATURES",0,W,"checkTextureFeature",0,O,"getDepthStencilAttachmentWebGL",0,z,"getTextureFormatCapabilitiesWebGL",0,function(e,t,r){let i=t.create,s=$[t.format];s?.gl===void 0&&(i=!1),s?.x&&(i=i&&!!w(e,s.x,r)),"stencil8"===t.format&&(i=!1);let n=s?.r!==!1&&(s?.r===void 0||O(e,s.r,r)),a=i&&t.render&&n&&function(e,t,r){let i=$[t],s=i?.gl;if(void 0===s||i?.x&&!w(e,i.x,r))return!1;let n=e.getParameter(32873),a=e.getParameter(36006),o=e.createTexture(),l=e.createFramebuffer();if(!o||!l)return!1;let u=Number(0),h=Number(e.getError());for(;h!==u;)h=e.getError();let c=!1;try{if(e.bindTexture(3553,o),e.texStorage2D(3553,1,s,1,1),Number(e.getError())!==u)return!1;e.bindFramebuffer(36160,l),e.framebufferTexture2D(36160,36064,3553,o,0),c=Number(e.checkFramebufferStatus(36160))===Number(36053)&&Number(e.getError())===u}finally{e.bindFramebuffer(36160,a),e.deleteFramebuffer(l),e.bindTexture(3553,n),e.deleteTexture(o)}return c}(e,t.format,r);return{format:t.format,create:i&&t.create,render:a,filter:i&&t.filter,blend:i&&t.blend,store:i&&t.store}},"getTextureFormatWebGL",0,function(e){let t=$[e],r=function(e){let t=$[e],r=t?.gl;if(void 0===r)throw Error(`Unsupported texture format ${e}`);return r}(e),i=T.textureFormatDecoder.getInfo(e);return i.compressed&&(t.dataFormat=r),{internalFormat:r,format:t?.dataFormat||function(e,t,r,i){if(6408===i||6407===i)return i;switch(e){case"r":return t&&!r?36244:6403;
5case"rg":return t&&!r?33320:33319;case"rgb":return t&&!r?36248:6407;case"rgba":return t&&!r?36249:6408;case"bgra":throw Error("bgra pixels not supported by WebGL");default:return 6408}}(i.channels,i.integer,i.normalized,r),type:i.dataType?P(i.dataType):t?.types?.[0]||5121,compressed:i.compressed||!1}},"isTextureFeature",0,M],726348);let U={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":e=>(0,S.isHTMLInCanvasSupported)()&&"function"==typeof e.texElementImage2D,"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"};class N extends S.DeviceFeatures{gl;extensions;testedFeatures=new Set;constructor(e,t,r){super([],r),this.gl=e,this.extensions=t,w(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){for(let e of this.getFeatures())this.has(e)&&(yield e);return[]}has(e){return!this.disabledFeatures?.[e]&&(!this.testedFeatures.has(e)&&(this.testedFeatures.add(e),M(e)&&O(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){for(let e of this.getFeatures().filter(e=>"polygon-mode-webgl"!==e))this.has(e)}getFeatures(){return[...Object.keys(U),...Object.keys(W)]}getWebGLFeature(e){let t=U[e];return"string"==typeof t?!!w(this.gl,t,this.extensions):"function"==typeof t?t(this.gl):!!t}}e.s(["WebGLDeviceFeatures",0,N],420505);var Q=S;class V extends Q.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 maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){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 maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}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 maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}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(e){super(),this.gl=e}getParameter(e){return void 0===this.limits[e]&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}e.s(["WebGLDeviceLimits",0,V],677641);var H=e.i(740021);
5class j{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(this._started||!this.props.canvas)return;this._started=!0,this._intersectionObserver||=new IntersectionObserver(e=>this.props.onIntersection(e)),this._resizeObserver||=new ResizeObserver(e=>this.props.onResize(e)),this._intersectionObserver.observe(this.props.canvas);let e=this.props.resizeObserverBox;try{this._resizeObserver.observe(this.props.canvas,{box:e})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}var q=e.i(374366),K=e.i(652349);class X{static isHTMLCanvas(e){return"u">typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return"u">typeof OffscreenCanvas&&e instanceof OffscreenCanvas}static defaultProps={id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,pixelSizeSource:"exact",autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",colorFormat:void 0,toneMapping:"standard",trackPosition:!1};id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=(function(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}})();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;_configuredDrawingBufferSize=[0,0];toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...X.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,(0,H.isBrowser)()?e.canvas?"string"==typeof e.canvas?this.canvas=function(e){let t=document.getElementById(e);if(!X.isHTMLCanvas(t))throw Error("Object is not a canvas element");return t}(e.canvas):this.canvas=e.canvas:this.canvas=function(e){let{width:t,height:r}=e,i=document.createElement("canvas");i.id=(0,q.uid)("lumagl-auto-created-canvas"),i.width=t||1,i.height=r||1,i.style.width=Number.isFinite(t)?`${t}px`:"100%",i.style.height=Number.isFinite(r)?`${r}px`:"100%",e?.visible||(i.style.visibility="hidden");let s=function(e){if("string"==typeof e){let t=document.getElementById(e);if(!t)throw Error(`${e} is not an HTML element`);return t}return e||document.body}(e?.container||null);return s.insertBefore(i,s.firstChild),i}(e):this.canvas={width:e.width||1,height:e.height||1},X.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):X.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this._configuredDrawingBufferSize=[this.canvas.width,this.canvas.height],this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new j({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,resizeObserverBox:"css-dpr"===this.props.pixelSizeSource?"content-box":"device-pixel-content-box",onResize:e=>this._handleResize(e),onIntersection:e=>this._handleIntersection(e),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,t){e=Math.floor(e),t=Math.floor(t),(this.drawingBufferWidth!==e||this.drawingBufferHeight!==t)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=t,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return"u">typeof window&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){var r,i,s,n,a;let o,l,u,h,c,d=this.cssToDeviceRatio(),[f,g]=this.getDrawingBufferSize();return r=e,i=d,s=f,n=g,a=t,l=Y(r[0],i,s),u=J(r[1],i,n,a),c=(h=Y(r[0]+1,i,s))===s-1?h:h-1,h=J(r[1]+1,i,n,a),a?(h=0===h?h:h+1,o=u,u=h):o=h===n-1?h:h-1,{x:l,y:u,width:Math.max(c-l+1,1),height:Math.max(o-u+1,1)}}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDrawingBufferSize();return e>0&&t>0?e/t:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[t]=this.getCSSSize();return t?e/t:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let t=e.find(e=>e.target===this.canvas);if(!t)return;let r=t.isIntersecting;this.isVisible!==r&&(this.isVisible=r,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let t=e.find(e=>e.target===this.canvas);if(!t)return;let r=(0,K.assertDefined)(t.contentBoxSize?.[0]);this.cssWidth=r.inlineSize,this.cssHeight=r.blockSize;let i=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromResizeEntry(t)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPi
5xelSize:i})}_updateDrawingBufferSize(){if(this.props.autoResize)if("number"==typeof this.props.useDevicePixels){let e=this.props.useDevicePixels;this.setDrawingBufferSize(this.cssWidth*e,this.cssHeight*e)}else this.props.useDevicePixels?this.setDrawingBufferSize(this.devicePixelWidth,this.devicePixelHeight):this.setDrawingBufferSize(this.cssWidth,this.cssHeight);this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_getDevicePixelSizeFromResizeEntry(e){let t=(0,K.assertDefined)(e.contentBoxSize?.[0]);return"css-dpr"===this.props.pixelSizeSource?this._getDevicePixelSizeFromCSSSize(t.inlineSize,t.blockSize):{devicePixelWidth:e.devicePixelContentBoxSize?.[0]?.inlineSize||t.inlineSize*devicePixelRatio,devicePixelHeight:e.devicePixelContentBoxSize?.[0]?.blockSize||t.blockSize*devicePixelRatio}}_getDevicePixelSizeFromCSSSize(e,t){let r=this.getDevicePixelRatio();return{devicePixelWidth:Math.floor(e*r),devicePixelHeight:Math.floor(t*r)}}_setDevicePixelSize({devicePixelWidth:e,devicePixelHeight:t}){let[r,i]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(e,r)),this.devicePixelHeight=Math.max(1,Math.min(t,i))}_resizeDrawingBufferIfNeeded(){if(this._needsDrawingBufferResize){this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight);let[e,t]=this._configuredDrawingBufferSize;(this.drawingBufferWidth!==e||this.drawingBufferHeight!==t)&&(this._configureDevice(),this._configuredDrawingBufferSize=[this.drawingBufferWidth,this.drawingBufferHeight])}}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;if(this.devicePixelRatio=window.devicePixelRatio,"css-dpr"===this.props.pixelSizeSource){let e=this.getDevicePixelSize();this._setDevicePixelSize(this._getDevicePixelSizeFromCSSSize(this.cssWidth,this.cssHeight)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:e})}this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let t=[e.left,e.top];if(this._position??=t,t[0]!==this._position[0]||t[1]!==this._position[1]){let e=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:e})}}}}function Y(e,t,r){return Math.min(Math.round(e*t),r-1)}function J(e,t,r,i){return i?Math.max(0,r-1-Math.round(e*t)):Math.min(Math.round(e*t),r-1)}class Z extends X{static defaultProps=X.defaultProps}var ee=e.i(81905),et=e.i(825458),er=e.i(912828);class ei extends ee.Resource{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,ei.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(t=>t.texture.clone(e)),r=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:t,depthStencilAttachment:r})}resize(e){let t=!e;if(e){let[r,i]=Array.isArray(e)?e:[e.width,e.height];t=t||i!==this.height||r!==this.width,this.width=r,this.height=i}t&&(er.log.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(0===this.props.colorAttachments.length&&!this.props.depthStencilAttachment)throw Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((e,t)=>{if("string"==typeof e){let r=this.createColorTexture(e,t);return this.attachResource(r),r.view}return e instanceof et.Texture?e.view:e});let e=this.props.depthStencilAttachment;if(e)if("string"==typeof e){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof et.Texture?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:et.Texture.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height,sampler:{magFilter:"linear",minFilter:"linear"}})}createDepthStencilTexture(e){return this.device.createTexture({id:`${this.id}-depth-stencil-attachment`,usage:et.Texture.RENDER_ATTACHMENT|et.Texture.SAMPLE,format:e,width:this.width,height:this.height})}
5resizeAttachments(e,t){if(this.colorAttachments.forEach((r,i)=>{let s=r.texture.clone({width:e,height:t});this.destroyAttachedResource(r),this.colorAttachments[i]=s.view,this.attachResource(s.view)}),this.depthStencilAttachment){let r=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=r.view,this.attachResource(r)}this.updateAttachments()}static defaultProps={...ee.Resource.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}}e.s(["Framebuffer",0,ei],734237);class es extends ei{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);const r=t.handle,i=null===r;this.device=e,this.gl=e.gl,this.handle=r||i?r:this.gl.createFramebuffer(),!i&&(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),t.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),this.destroyed||null===this.handle||this.props.handle||this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let e=0;e<this.colorAttachments.length;++e){let t=this.colorAttachments[e];if(t){let r=36064+e;this._attachTextureView(r,t)}}if(this.depthStencilAttachment){let e=z(this.depthStencilAttachment.props.format);this._attachTextureView(e,this.depthStencilAttachment)}if(this.device.props.debug){let e=this.gl.checkFramebufferStatus(36160);if(36053!==e)throw Error(`Framebuffer ${function(e){switch(e){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${e}`}}(e)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,t){let{gl:r}=this.device,{texture:i}=t,s=t.props.baseMipLevel,n=t.props.baseArrayLayer;switch(r.bindTexture(i.glTarget,i.handle),i.glTarget){case 35866:case 32879:r.framebufferTextureLayer(36160,e,i.handle,s,n);break;case 34067:var a;let o=(a=n)<34069?a+34069:a;r.framebufferTexture2D(36160,e,o,i.handle,s);break;case 3553:r.framebufferTexture2D(36160,e,3553,i.handle,s);break;default:throw Error("Illegal texture type")}r.bindTexture(i.glTarget,null)}resizeAttachments(e,t){if(null===this.handle){this.width=e,this.height=t;return}super.resizeAttachments(e,t)}}e.s(["WEBGLFramebuffer",0,es],888583);class en extends Z{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,t){super(t),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new es(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}e.s(["WebGLCanvasContext",0,en],624628);class ea extends X{}class eo extends ea{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,t={}){super(t),this.device=e;const r=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw Error(`${r}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);const i=this.canvas.getContext("2d");if(!i)throw Error(`${r}: Failed to create 2d presentation context`);this.context2d=i,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[t,r]=e.getDrawingBufferSize();if(0!==this.drawingBufferWidth&&0!==this.drawingBufferHeight&&0!==t&&0!==r&&0!==e.canvas.width&&0!==e.canvas.height){if(t!==this.drawingBufferWidth||r!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${t}x${r} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let t=this.device.getDefaultCanvasContext();return t.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),t.getCurrentFramebuffer(e)}}e.s(["WebGLPresentationContext",0,eo],511547)},509685,e=>{"use strict";var t=e.i(247167);function r(){let e;if("u">typeof window&&window.performance)e=window.performance.now();else if(void 0!==t.default&&t.default.hrtime){let r=t.default.hrtime();e=1e3*r[0]+r[1]/1e6}else e=Date.now();return e}class i{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=r(),this._timerPending=!0,this}timeEnd(){return this._timerPending&&(this.addTime(r()-this._startTime),this._timerPending=!1,this._checkSampling()),this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}e.s(["Stats",0,class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}
5_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){let{name:t,type:r}=e,s=this.stats[t];return s||(s=e instanceof i?e:new i(t,r),this.stats[t]=s),s}}],509685)}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.