1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,695002,509685,504819,740021,25350,912828,374366,81905,706145,69004,3311,760457,109900,388396,825458,831934,7784,145453,144135,96204,749494,466234,685251,965880,553746,e=>{"use strict";let t;var r,i,s,n,a=e.i(247167);function o(){let e;if("u">typeof window&&window.performance)e=window.performance.now();else if(void 0!==a.default&&a.default.hrtime){let t=a.default.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}class l{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=o(),this._timerPending=!0,this}timeEnd(){return this._timerPending&&(this.addTime(o()-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)}}class u{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}_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){let{name:t,type:r}=e,i=this.stats[t];return i||(i=e instanceof l?e:new l(t,r),this.stats[t]=i),i}}e.s(["Stats",()=>u],509685);let c=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","Referenced Buffer Memory","Referenced Texture Memory","Swap Chain Texture"],h=new WeakMap,_=new WeakMap;class d{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new u({id:e}));let t=this.stats.get(e);return"GPU Time and Memory"===e&&function(e,t){let r=e.stats,i=!1;for(let s of t)r[s]||(e.get(s),i=!0);let s=Object.keys(r).length,n=h.get(e);if(!i&&n?.orderedStatNames===t&&n.statCount===s)return;let a={},o=_.get(t);for(let e of(o||(o=new Set(t),_.set(t,o)),t))r[e]&&(a[e]=r[e]);for(let[e,t]of Object.entries(r))o.has(e)||(a[e]=t);for(let e of Object.keys(r))delete r[e];Object.assign(r,a),h.set(e,{orderedStatNames:t,statCount:s})}(t,c),t}}let E=new d;e.s(["lumaStats",0,E],504819);let f="4.1.1";function g(){return"object"==typeof a.default&&"[object process]"===String(a.default),!0}function m(e,t){if(!e)throw Error(t||"Assertion failed")}function p(e){let t;if(!e)return 0;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return m(Number.isFinite(t)&&t>=0),t}e.s(["isBrowser",0,g],740021);let T=()=>{};class R{constructor({level:e=0}={}){this.userData={},this._onceCache=new Set,this._level=e}set level(e){this.setLevel(e)}get level(){return this.getLevel()}setLevel(e){return this._level=e,this}getLevel(){return this._level}warn(e,...t){return this._log("warn",0,e,t,{once:!0})}error(e,...t){return this._log("error",0,e,t)}log(e,t,...r){return this._log("log",e,t,r)}info(e,t,...r){return this._log("info",e,t,r)}once(e,t,...r){return this._log("once",e,t,r,{once:!0})}_log(e,t,r,i,s={}){let n=function(e){let{logLevel:t,message:r}=e;e.logLevel=p(t);let i=e.args?Array.from(e.args):[];for(;i.length&&i.shift()!==r;);switch(typeof t){case"string":case"function":void 0!==r&&i.unshift(r),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());let s=typeof e.message;return m("string"===s||"object"===s),Object.assign(e,{args:i},e.opts)}({logLevel:t,message:r,args:this._buildArgs(t,r,i),opts:s});return this._createLogFunction(e,n,s)}_buildArgs(e,t,r){return[e,t,...r]}_createLogFunction(e,t,r){if(!this._shouldLog(t.logLevel))return T;let i=this._getOnceTag(r.tag??t.tag??t.message);if((r.once||t.once)&&void 0!==i){if(this._onceCache.has(i))return T;this._onceCache.add(i)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=p(e)}_getOnceTag(e){if(void 0!==e)try{return"string"==typeof e?e:String(e)}catch{return}}}class A{constructor(e,t,r="sessionStorage"){this.storage=function(e){try{let t=window[e],r="__storage_test__";return t.setItem(r,r),t.removeItem(r),t}catch(e){return null}}(r),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let e={};
1if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function S(e){return"string"!=typeof e?e:s[e=e.toUpperCase()]||s.WHITE}(r=s||(s={}))[r.BLACK=30]="BLACK",r[r.RED=31]="RED",r[r.GREEN=32]="GREEN",r[r.YELLOW=33]="YELLOW",r[r.BLUE=34]="BLUE",r[r.MAGENTA=35]="MAGENTA",r[r.CYAN=36]="CYAN",r[r.WHITE=37]="WHITE",r[r.BRIGHT_BLACK=90]="BRIGHT_BLACK",r[r.BRIGHT_RED=91]="BRIGHT_RED",r[r.BRIGHT_GREEN=92]="BRIGHT_GREEN",r[r.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",r[r.BRIGHT_BLUE=94]="BRIGHT_BLUE",r[r.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",r[r.BRIGHT_CYAN=96]="BRIGHT_CYAN",r[r.BRIGHT_WHITE=97]="BRIGHT_WHITE";let b=globalThis,C=globalThis.process||{},I=globalThis.navigator||{};function N(){let e;if(g()&&b.performance)e=b?.performance?.now?.();else if("hrtime"in C){let t=C?.hrtime?.();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}let P={debug:g()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},y={enabled:!0,level:0};class L extends R{constructor({id:e}={id:""}){super({level:0}),this.VERSION=f,this._startTs=N(),this._deltaTs=N(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new A(`__probe-${this.id}__`,{[this.id]:y}),this.timeStamp(`${this.id} started`),function(e,t=["constructor"]){for(let r of Object.getOwnPropertyNames(Object.getPrototypeOf(e))){let i=e[r];"function"!=typeof i||t.find(e=>r===e)||(e[r]=i.bind(e))}}(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((N()-this._startTs).toPrecision(10))}getDelta(){return Number((N()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._updateConfiguration({enabled:e}),this}setLevel(e){return this._updateConfiguration({level:e}),this}get(e){return this._getConfiguration()[e]}set(e,t){this._updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw Error(t||"Assertion failed")}warn(e,...t){return this._log("warn",0,e,t,{method:P.warn,once:!0})}error(e,...t){return this._log("error",0,e,t,{method:P.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed \ 2in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...r){return this._log("log",e,t,r,{method:P.log,time:!0,once:!0})}log(e,t,...r){return this._log("log",e,t,r,{method:P.debug})}info(e,t,...r){return this._log("info",e,t,r,{method:console.info})}once(e,t,...r){return this._log("once",e,t,r,{method:P.debug||P.info,once:!0})}table(e,t,r){return t?this._log("table",e,t,r&&[r]||[],{method:console.table||T,tag:function(e){for(let t in e)for(let r in e[t])return r||"untitled";return"empty"}(t)}):T}time(e,t){return this._log("time",e,t,[],{method:console.time?console.time:console.info})}timeEnd(e,t){return this._log("time",e,t,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,t){return this._log("time",e,t,[],{method:console.timeStamp||T})}group(e,t,r={collapsed:!1}){let i=(r.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,t,[],{method:i})}groupCollapsed(e,t,r={}){return this.group(e,t,Object.assign({},r,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||T})}withGroup(e,t,r){this.group(e,t)();try{r()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,t){let r=t.method;m(r),t.total=this.getTotal(),t.delta=this.getDelta(),this._deltaTs=N();let i=function(e,t,r){if("string"==typeof t){var i;let s=r.time?function(e,t=8){let r=Math.max(t-e.length,0);return`${" ".repeat(r)}${e}`}((i=r.total)<10?`${i.toFixed(2)}ms`:i<100?`${i.toFixed(1)}ms`:i<1e3?`${i.toFixed(0)}ms`:`${(i/1e3).toFixed(2)}s`):"";t=function(e,t,r){if(!g&&"string"==typeof e){if(t){let r=S(t);e=`\u001b[${r}m${e}\u001b[39m`}if(r){let t=S(r);e=`\u001b[${t+10}m${e}\u001b[49m`}}return e}(t=r.time?`${e}: ${s} ${t}`:`${e}: ${t}`,r.color,r.background)}return t}(this.id,t.message,t);return r.bind(console,i,...t.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(y),this._storage.config[this.id]}_updateConfiguration(e){let t=this._storage.config[this.id]||{...y};this._storage.setConfiguration({[this.id]:{...t,...e}})}}L.VERSION=f,e.s(["Log",0,L],25350);let O=new L({id:"luma.gl"});e.s(["log",0,O],912828);let M={};function v(e="id"){M[e]=M[e]||1;let t=M[e]++;return`${e}-${t}`}e.s(["uid",0,v],374366);let B="GPU Resource Counts",D="Resource Counts",x="GPU Time and Memory",F=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"].flatMap(e=>[`${e} Created`,`${e} Active`]),U=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"].flatMap(e=>[`${e} Created`,`${e} Active`]),G=new WeakMap,w=new WeakMap;class H{static defaultProps={id:"undefined",handle:void 0,userData:void 0};toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;constructor(e,t,r){if(!e)throw Error("no device");this._device=e,this.props=function(e,t){let r={...t};for(let t in e)void 0!==e[t]&&(r[t]=e[t]);return r}(t,r);const i="undefined"!==this.props.id?this.props.id:v(this[Symbol.toStringTag]);this.props.id=i,this.id=i,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=V(this._device),t=e?k():0,r=[this._device.statsManager.getStats(B),this._device.statsManager.getStats(D)],i=X(this._device);for(let e of r)W(e,i);let s=this.getStatsName();for(let e of r)e.get("Resources Active").decrementCount(),e.get(`${s}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(k()-t))}trackAllocatedMemory(e,t=this.getStatsName()){let r=V(this._device),i=r?k():0,s=this._device.statsManager.getStats(x);this.allocatedBytes>0&&this.allocatedBytesName&&(s.get("GPU Memory").subtractCount(this.allocatedBytes),s.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),s.get("GPU Memory").addCount(e),s.get(`${t} Memory`).addCount(e),r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(k()-i)),this.allocatedBytes=e,this.allocatedBytesName=t}trackReferencedMemory(e,t=this.getStatsName()){this.trackAllocatedMemory(e,`Referenced ${t}`)}trackDeallocatedMemory(e=this.getStatsName()){if(0===this.allocatedBytes){this.allocatedBytesName=null;return}let t=V(this._device),r=t?k():0,i=this._device.statsManager.getStats(x);i.get("GPU Memory").subtractCount(this.allocatedBytes),i.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(k()-r)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),t=V(this._device),r=t?k():0,i=[this._device.statsManager.getStats(B),this._device.statsManager.getStats(D)],s=X(this._device);for(let e of i)W(e,s);for(let t of i)t.get("Resources Created").incrementCount(),t.get("Resources Active").incrementCount(),t.get(`${e}s Created`).incrementCount(),t.get(`${e}s Active`).incrementCount();t&&(t.statsBookkeepingCalls=(t.statsBookkeepingCalls||0)+1,t.statsBookkeepingTimeMs=(t.statsBookkeepingTimeMs||0)+(k()-r)),function(e,t){let r=V(e);if(r&&r.activeDefaultFramebufferAcquireDepth)switch(r.transientCanvasResourceCreates=(r.transientCanvasResourceCreates||0)+1,t){case"Texture":r.transientCanvasTextureCreates=(r.transientCanvasTextureCreates||0)+1;break;case"TextureView":r.transientCanvasTextureViewCreates=(r.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":r.transientCanvasSamplerCreates=(r.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":r.transientCanvasFramebufferCreates=(r.transientCanvasFramebufferCreates||0)+1}}(this._device,e)}getStatsName(){var e=this;let t=Object.getPrototypeOf(e);for(;t;){let r=Object.getPrototypeOf(t);if(!r||r===H.prototype)return function(e){let t=Object.getOwnPropertyDescriptor(e,Symbol.toStringTag);
2return"function"==typeof t?.get?t.get.call(e):"string"==typeof t?.value?t.value:null}(t)||e[Symbol.toStringTag]||e.constructor.name;t=r}return e[Symbol.toStringTag]||e.constructor.name}}function W(e,t){let r=e.stats,i=!1;for(let s of t)r[s]||(e.get(s),i=!0);let s=Object.keys(r).length,n=G.get(e);if(!i&&n?.orderedStatNames===t&&n.statCount===s)return;let a={},o=w.get(t);for(let e of(o||(o=new Set(t),w.set(t,o)),t))r[e]&&(a[e]=r[e]);for(let[e,t]of Object.entries(r))o.has(e)||(a[e]=t);for(let e of Object.keys(r))delete r[e];Object.assign(r,a),G.set(e,{orderedStatNames:t,statCount:s})}function X(e){return"webgl"===e.type?U:F}function V(e){let t=e.userData["cpu-hotspot-profiler"];return t?.enabled?t:null}function k(){return globalThis.performance?.now?.()??Date.now()}e.s(["Resource",0,H],81905);class $ extends H{static INDEX=16;static VERTEX=32;static UNIFORM=64;static STORAGE=128;static INDIRECT=256;static QUERY_RESOLVE=512;static MAP_READ=1;static MAP_WRITE=2;static COPY_SRC=4;static COPY_DST=8;get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){const r={...t};(t.usage||0)&$.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?r.indexType="uint32":t.data instanceof Uint16Array?r.indexType="uint16":t.data instanceof Uint8Array&&(r.indexType="uint8")),delete r.data,super(e,r,$.defaultProps),this.usage=r.usage||0,this.indexType=r.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}static DEBUG_DATA_MAX_LENGTH=32;debugData=new ArrayBuffer(0);_setDebugData(e,t,r){let i,s=null;ArrayBuffer.isView(e)?(s=e,i=e.buffer):i=e;let n=Math.min(e?e.byteLength:r,$.DEBUG_DATA_MAX_LENGTH);if(null===i)this.debugData=new ArrayBuffer(n);else{let e=Math.min(s?.byteOffset||0,i.byteLength),t=Math.min(n,Math.max(0,i.byteLength-e));this.debugData=new Uint8Array(i,e,t).slice().buffer}}static defaultProps={...H.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0}}e.s(["Buffer",0,$],706145);let z=new class{getDataTypeInfo(e){let[t,r,i]=K[e],s=e.includes("norm"),n=!s&&!e.startsWith("float");return{signedType:t,primitiveType:r,byteLength:i,normalized:s,integer:n,signed:e.startsWith("s")}}getNormalizedDataType(e){switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}alignTo(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}getDataType(e){let t=ArrayBuffer.isView(e)?e.constructor:e;if(t===Uint8ClampedArray)return"uint8";let r=Object.values(K).find(e=>t===e[4]);if(!r)throw Error(t.name);return r[0]}getTypedArrayConstructor(e){let[,,,,t]=K[e];return t}},K={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};e.s(["dataTypeDecoder",0,z],69004);let Y=new class{getVertexFormatInfo(e){let t;e.endsWith("-webgl")&&(e.replace("-webgl",""),t=!0);let[r,i]=e.split("x"),s=i?parseInt(i):1,n=z.getDataTypeInfo(r),a={type:r,components:s,byteLength:n.byteLength*s,integer:n.integer,signed:n.signed,normalized:n.normalized};return t&&(a.webglOnly=!0),a}makeVertexFormat(e,t,r){let i=r?z.getNormalizedDataType(e):e;switch(i){case"unorm8":if(1===t)return"unorm8";if(3===t)return"unorm8x3-webgl";return`${i}x${t}`;case"snorm8":if(1===t)return"snorm8";if(3===t)return"snorm8x3-webgl";return`${i}x${t}`;case"uint8":case"sint8":case"float16":if(1===t||3===t)throw Error(`size: ${t}`);return`${i}x${t}`;case"uint16":if(1===t)return"uint16";if(3===t)return"uint16x3-webgl";return`${i}x${t}`;case"sint16":if(1===t)return"sint16";if(3===t)return"sint16x3-webgl";return`${i}x${t}`;case"unorm16":if(1===t)return"unorm16";if(3===t)return"unorm16x3-webgl";return`${i}x${t}`;case"snorm16":if(1===t)return"snorm16";if(3===t)return"snorm16x3-webgl";return`${i}x${t}`;default:return 1===t?i:`${i}x${t}`}}getVertexFormatFromAttribute(e,t,r){if(!t||t>4)throw Error(`size ${t}`);let i=z.getDataType(e);return this.makeVertexFormat(i,t,r)}getCompatibleVertexFormat(e){let t;switch(e.primitiveType){case"f32":t="float32";break;case"i32":t="sint32";break;case"u32":t="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return 1===e.components?t:`${t}x${e.components}`}};e.s(["vertexFormatDecoder",0,Y],3311);let Q="texture-compression-bc",j="texture-compression-astc",Z="texture-compression-etc2",q="texture-compression-pvrtc-webgl",J="texture-compression-atc-webgl",ee="float32-renderable-webgl",et="float16-renderable-webgl",er="snorm8-renderable-webgl",ei="norm16-webgl",es="norm16-renderable-webgl",en="snorm16-renderable-webgl",ea="float32-filterable",eo="float16-filterable-webgl";function el(e){let t=eu[e];if(!t)throw Error(`Unsupported texture format ${e}`);return t}let eu={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:er},rg8snorm:{render:er},"rgb8snorm-webgl":{},rgba8snorm:{render:er},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:ei,render:es},rg16unorm:{f:ei,render:es},"rgb16unorm-webgl":{f:ei,render:!1},rgba16unorm:{f:ei,render:es},r16snorm:{f:ei,render:en},rg16snorm:{f:ei,render:en},"rgb16snorm-webgl":{f:ei,render:!1},rgba16snorm:{f:ei,render:en},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:et,filter:"float16-filterable-webgl"},rg16float:{render:et,filter:eo},rgba16float:{render:et,filter:eo},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:ee,filter:ea},rg32float:{render:!1,filter:ea},"rgb32float-webgl":{render:ee,filter:ea},rgba32float:{render:ee,filter:ea},"rgba4unorm-webgl":{channels:"rgba",bitsPerChannel:[4,4,4,4],packed:!0},"rgb565unorm-webgl":{channels:"rgb",bitsPerChannel:[5,6,5,0],packed:!0},"rgb5a1unorm-webgl":{channels:"rgba",bitsPerChannel:[5,5,5,1],packed:!0},rgb9e5ufloat:{channels:"rgb",packed:!0,render:"rgb9e5ufloat-renderable-webgl"},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:ee},rgb10a2unorm:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},rgb10a2uint:{channels:"rgba",bitsPerChannel:[10,10,10,2],packed:!0,p:1},stencil8:{attachment:"stencil",bitsPerChannel:[8,0,0,0],dataType:"uint8"},depth16unorm:{attachment:"depth",bitsPerChannel:[16,0,0,0],dataType:"uint16"},depth24plus:{attachment:"depth",bitsPerChannel:[24,0,0,0],dataType:"uint32"},depth32float:{attachment:"depth",bitsPerChannel:[32,0,0,0],dataType:"float32"},"depth24plus-stencil8":{attachment:"depth-stencil",bitsPerChannel:[24,8,0,0],packed:!0},"depth32float-stencil8":{attachment:"depth-stencil",bitsPerChannel:[32,8,0,0],packed:!0}
2,"bc1-rgb-unorm-webgl":{f:Q},"bc1-rgb-unorm-srgb-webgl":{f:Q},"bc1-rgba-unorm":{f:Q},"bc1-rgba-unorm-srgb":{f:Q},"bc2-rgba-unorm":{f:Q},"bc2-rgba-unorm-srgb":{f:Q},"bc3-rgba-unorm":{f:Q},"bc3-rgba-unorm-srgb":{f:Q},"bc4-r-unorm":{f:Q},"bc4-r-snorm":{f:Q},"bc5-rg-unorm":{f:Q},"bc5-rg-snorm":{f:Q},"bc6h-rgb-ufloat":{f:Q},"bc6h-rgb-float":{f:Q},"bc7-rgba-unorm":{f:Q},"bc7-rgba-unorm-srgb":{f:Q},"etc2-rgb8unorm":{f:Z},"etc2-rgb8unorm-srgb":{f:Z},"etc2-rgb8a1unorm":{f:Z},"etc2-rgb8a1unorm-srgb":{f:Z},"etc2-rgba8unorm":{f:Z},"etc2-rgba8unorm-srgb":{f:Z},"eac-r11unorm":{f:Z},"eac-r11snorm":{f:Z},"eac-rg11unorm":{f:Z},"eac-rg11snorm":{f:Z},"astc-4x4-unorm":{f:j},"astc-4x4-unorm-srgb":{f:j},"astc-5x4-unorm":{f:j},"astc-5x4-unorm-srgb":{f:j},"astc-5x5-unorm":{f:j},"astc-5x5-unorm-srgb":{f:j},"astc-6x5-unorm":{f:j},"astc-6x5-unorm-srgb":{f:j},"astc-6x6-unorm":{f:j},"astc-6x6-unorm-srgb":{f:j},"astc-8x5-unorm":{f:j},"astc-8x5-unorm-srgb":{f:j},"astc-8x6-unorm":{f:j},"astc-8x6-unorm-srgb":{f:j},"astc-8x8-unorm":{f:j},"astc-8x8-unorm-srgb":{f:j},"astc-10x5-unorm":{f:j},"astc-10x5-unorm-srgb":{f:j},"astc-10x6-unorm":{f:j},"astc-10x6-unorm-srgb":{f:j},"astc-10x8-unorm":{f:j},"astc-10x8-unorm-srgb":{f:j},"astc-10x10-unorm":{f:j},"astc-10x10-unorm-srgb":{f:j},"astc-12x10-unorm":{f:j},"astc-12x10-unorm-srgb":{f:j},"astc-12x12-unorm":{f:j},"astc-12x12-unorm-srgb":{f:j},"pvrtc-rgb4unorm-webgl":{f:q},"pvrtc-rgba4unorm-webgl":{f:q},"pvrtc-rgb2unorm-webgl":{f:q},"pvrtc-rgba2unorm-webgl":{f:q},"etc1-rbg-unorm-webgl":{f:"texture-compression-etc1-webgl"},"atc-rgb-unorm-webgl":{f:J},"atc-rgba-unorm-webgl":{f:J},"atc-rgbai-unorm-webgl":{f:J}},ec=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,eh=["rgb","rgba","bgra"],e_=["depth","stencil"],ed=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],eE=new class{isColor(e){return eh.some(t=>e.startsWith(t))}isDepthStencil(e){return e_.some(t=>e.startsWith(t))}isCompressed(e){return ed.some(t=>e.startsWith(t))}getInfo(e){return ef(e)}getCapabilities(e){var t;let r,i,s,n,a,o,l,u;return r=el(t=e),i={format:t,create:r.f??!0,render:r.render??!0,filter:r.filter??!0,blend:r.blend??!0,store:r.store??!0},s=ef(t),n=t.startsWith("depth")||t.startsWith("stencil"),a=s?.signed,o=s?.integer,l=s?.webgl,u=!!s?.compressed,i.render&&=!n&&!u,i.filter&&=!n&&!a&&!o&&!l,i}computeMemoryLayout(e){return function({format:e,width:t,height:r,depth:i,byteAlignment:s}){let{bytesPerPixel:n,bytesPerBlock:a=n,blockWidth:o=1,blockHeight:l=1,compressed:u=!1}=eE.getInfo(e),c=u?Math.ceil(t/o):t,h=u?Math.ceil(r/l):r,_=Math.ceil(c*a/s)*s;return{bytesPerPixel:n,bytesPerRow:_,rowsPerImage:h,depthOrArrayLayers:i,bytesPerImage:_*h,byteLength:_*h*i}}(e)}};function ef(e){var t,r;let i,s,n,a=(s=(i=el(t=e)).bytesPerPixel||1,n=i.bitsPerChannel||[8,8,8,8],delete i.bitsPerChannel,delete i.bytesPerPixel,delete i.f,delete i.render,delete i.filter,delete i.blend,delete i.store,{...i,format:t,attachment:i.attachment||"color",channels:i.channels||"r",components:i.components||i.channels?.length||1,bytesPerPixel:s,bitsPerChannel:n,dataType:i.dataType||"uint8",srgb:i.srgb??!1,packed:i.packed??!1,webgl:i.webgl??!1,integer:i.integer??!1,signed:i.signed??!1,normalized:i.normalized??!1,compressed:i.compressed??!1});if(eE.isCompressed(e)){a.channels="rgb",a.components=3,a.bytesPerPixel=1,a.srgb=!1,a.compressed=!0,a.bytesPerBlock=(r=e).startsWith("bc1")||r.startsWith("bc4")||r.startsWith("etc1")||r.startsWith("etc2-rgb8")||r.startsWith("etc2-rgb8a1")||r.startsWith("eac-r11")||"atc-rgb-unorm-webgl"===r?8:r.startsWith("bc2")||r.startsWith("bc3")||r.startsWith("bc5")||r.startsWith("bc6h")||r.startsWith("bc7")||r.startsWith("etc2-rgba8")||r.startsWith("eac-rg11")||r.startsWith("astc")||"atc-rgba-unorm-webgl"===r||"atc-rgbai-unorm-webgl"===r?16:r.startsWith("pvrtc")?8:16;let t=function(e){let t=/.*-(\d+)x(\d+)-.*/.exec(e);if(t){let[,e,r]=t;return{blockWidth:Number(e),blockHeight:Number(r)}}return e.startsWith("bc")||e.startsWith("etc1")||e.startsWith("etc2")||e.startsWith("eac")||e.startsWith("atc")||e.startsWith("pvrtc-rgb4")||e.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:e.startsWith("pvrtc-rgb2")||e.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}(e);t&&(a.blockWidth=t.blockWidth,a.blockHeight=t.blockHeight)}let o=a.packed?null:ec.exec(e);if(o){let[,t,r,i,s,n]=o,l=`${i}${r}`,u=z.getDataTypeInfo(l),c=8*u.byteLength,h=t?.length??1;a={format:e,attachment:a.attachment,dataType:u.signedType,components:h,channels:t,integer:u.integer,signed:u.signed,normalized:u.normalized,bitsPerChannel:[c,h>=2?c:0,h>=3?c:0,h>=4?c:0],bytesPerPixel:u.byteLength*h,packed:a.packed,srgb:a.srgb},"-webgl"===n&&(a.webgl=!0),"-srgb"===s&&(a.srgb=!0)}return e.endsWith("-webgl")&&(a.webgl=!0),e.endsWith("-srgb")&&(a.srgb=!0),a}function eg(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}function em(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.naturalWi
2dth,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")}e.s(["getExternalImageSize",0,em,"isExternalImage",0,eg],760457);class ep{}function eT(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(eT);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 eR{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 eA{static defaultProps={id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>
2{let[r,i]=e.getDevicePixelSize();O.log(1,`${e} resized => ${r}x${i}px`)()},onPositionChange:(e,t)=>{let[r,i]=e.getPosition();O.log(1,`${e} repositioned => ${r},${i}`)()},onVisibilityChange:e=>O.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>O.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:function(){var e,t;return e=O.get("debug"),t=function(){let e=globalThis.process;if(e?.env)return e.env.NODE_ENV}(),null!=e?!!e:void 0!==t&&"production"!==t}(),debugGPUTime:!1,debugShaders:O.get("debug-shaders")||void 0,debugFramebuffers:!!O.get("debug-framebuffers"),debugFactories:!!O.get("debug-factories"),debugWebGL:!!O.get("debug-webgl"),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0};get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=E;_factories={};timestamp=0;_reused=!1;_moduleData={};_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...eA.defaultProps,...e},this.id=this.props.id||v(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return Y.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return eE.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 eg(e)}getExternalImageSize(e){return em(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 eE.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let t of Object.keys(eu))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,...r){if(!this.props.onError(e,t)){let i=[eT(t),...r.map(eT).filter(e=>void 0!==e)].filter(e=>void 0!==e);return O.error("webgl"===this.type?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...i)}return()=>{}}debug(){if(this.props.debug);else{let e=`\ 3'Type luma.log.set({debug: true}) in console to enable debug breakpoints', 4or create a device with the 'debug: true' prop.`;O.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)}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=eE.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)&$.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,eA,"DeviceFeatures",0,eR,"DeviceLimits",0,ep],109900);let eS={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},eb=(e,t,r)=>t?e.enable(r):e.disable(r),eC=(e,t,r)=>e.hint(r,t),eI=(e,t,r)=>e.pixelStorei(r,t),eN=(e,t,r)=>e.bindFramebuffer(36006===r?36009:36008,t),eP=(e,t,r)=>{e.bindBuffer({34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[r],t)};function ey(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}let eL={3042:eb,32773:(e,t)=>
4e.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:eb,2885:(e,t)=>e.cullFace(t),2929:eb,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:eb,35723:eC,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:eN,36010:eN,34964:eP,36662:eP,36663:eP,35053:eP,35055:eP,2886:(e,t)=>e.frontFace(t),33170:eC,2849:(e,t)=>e.lineWidth(t),32823:eb,32824:"polygonOffset",10752:"polygonOffset",35977:eb,32926:eb,32928:eb,32938:"sampleCoverage",32939:"sampleCoverage",3089:eb,3088:(e,t)=>e.scissor(...t),2960:eb,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:eb,10754:eb,12288:eb,12289:eb,12290:eb,12291:eb,12292:eb,12293:eb,12294:eb,12295:eb,3333:eI,3317:eI,37440:eI,37441:eI,37443:eI,3330:eI,3332:eI,3331:eI,3314:eI,32878:eI,3316:eI,3315:eI,32877:eI,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)=>
4e.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=ey(t)?t:[t,t];e.stencilMaskSeparate(1028,r),e.stencilMaskSeparate(1029,i)},stencilFunc:(e,t)=>{let[r,i,s,n,a,o]=t=ey(t)&&3===t.length?[...t,...t]:t;e.stencilFuncSeparate(1028,r,i,s),e.stencilFuncSeparate(1029,n,a,o)},stencilOp:(e,t)=>{let[r,i,s,n,a,o]=t=ey(t)&&3===t.length?[...t,...t]:t;e.stencilOpSeparate(1028,r,i,s),e.stencilOpSeparate(1029,n,a,o)},viewport:(e,t)=>e.viewport(...t)};function eO(e,t,r){return void 0!==t[e]?t[e]:r[e]}let eM={blendEquation:(e,t,r)=>e.blendEquationSeparate(eO(32777,t,r),eO(34877,t,r)),blendFunc:(e,t,r)=>e.blendFuncSeparate(eO(32969,t,r),eO(32968,t,r),eO(32971,t,r),eO(32970,t,r)),polygonOffset:(e,t,r)=>e.polygonOffset(eO(32824,t,r),eO(10752,t,r)),sampleCoverage:(e,t,r)=>e.sampleCoverage(eO(32938,t,r),eO(32939,t,r)),stencilFuncFront:(e,t,r)=>e.stencilFuncSeparate(1028,eO(2962,t,r),eO(2967,t,r),eO(2963,t,r)),stencilFuncBack:(e,t,r)=>e.stencilFuncSeparate(1029,eO(34816,t,r),eO(36003,t,r),eO(36004,t,r)),stencilOpFront:(e,t,r)=>e.stencilOpSeparate(1028,eO(2964,t,r),eO(2965,t,r),eO(2966,t,r)),stencilOpBack:(e,t,r)=>e.stencilOpSeparate(1029,eO(34817,t,r),eO(34818,t,r),eO(34819,t,r))},ev={enable:(e,t)=>
4e({[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]})},eB=(e,t)=>e.isEnabled(t),eD={3042:eB,2884:eB,2929:eB,3024:eB,32823:eB,32926:eB,32928:eB,3089:eB,2960:eB,35977:eB},ex=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 eF(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=eL[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,eM[s])(e,t,i)}function eU(e,t=eS){if("number"==typeof t){let r=eD[t];return r?r(e,t):e.getParameter(t)}let r=Array.isArray(t)?t:Object.keys(t),i={};for(let t of r){let r=eD[t];i[t]=r?r(e,Number(t)):e.getParameter(Number(t))}return i}function eG(e){return Array.isArray(e)||ArrayBuffer.isView(e)}class ew{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];eF(this.gl,e),this.stateStack.pop()}trackState(e,t){var r;let i;if(this.cache=t?.copyState?eU(e):Object.assign({},eS),this.initialized)throw Error("WebGLStateTracker");for(let t in this.initialized=!0,this.gl.lumaState=this,i=(r=e).useProgram.bind(r),r.useProgram=function(e){let t=ew.get(r);t.program!==e&&(i(e),t.program=e)},ev){let r=ev[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(ew.get(e)._updateCache,...t);return s&&i(...t),n}
4,Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}(e,t,r)}eH(e,"getParameter"),eH(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(eG(e)&&eG(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 eH(e,t){let r=e[t].bind(e);e[t]=function(t){if(void 0===t||ex.has(t))return r(t);let i=ew.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 eW(e){let t=e.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return t._polyfilled??=!1,t.extensions||={},e.luma=t,t}function eX(e,t,r){return void 0===r[t]&&(r[t]=e.getExtension(t)||null),r[t]}function eV(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function ek(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))}let e$="WEBGL_compressed_texture_s3tc",ez="WEBGL_compressed_texture_s3tc_srgb",eK="EXT_texture_compression_rgtc",eY="EXT_texture_compression_bptc",eQ="EXT_render_snorm",ej="EXT_color_buffer_float",eZ="snorm8-renderable-webgl",eq="norm16-renderable-webgl",eJ="snorm16-renderable-webgl",e3="float16-renderable-webgl",e2="float32-renderable-webgl",e0={"float32-renderable-webgl":{extensions:[ej]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[eQ]},"norm16-webgl":{extensions:["EXT_texture_norm16"]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[eQ]},"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$,ez,eK,eY]},"texture-compression-bc5-webgl":{extensions:[eK]},"texture-compression-bc7-webgl":{extensions:[eY]},"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 e1(e,t,r){return function e(t,r,i,s){let n=e0[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=>!!eX(t,e,i))}(e,t,r,new Set)}let e6={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:eZ},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:eZ},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:e3},r16unorm:{gl:33322,rb:!0,r:eq},r16snorm:{gl:36760,r:eJ},"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:eZ},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:e3},rg16unorm:{gl:33324,r:eq},rg16snorm:{gl:36761,r:eJ},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:e2},rgb9e5ufloat:{gl:35901,r:"rgb9e5ufloat-renderable-webgl"},rg11b10ufloat:{gl:35898,rb:!0}
4,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:e2},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:e3},rgba16unorm:{gl:32859,rb:!0,r:eq},rgba16snorm:{gl:36763,r:eJ},"rgb32float-webgl":{gl:34837,x:ej,r:e2,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:e2},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:ez},"bc1-rgba-unorm":{gl:33777,x:e$},"bc1-rgba-unorm-srgb":{gl:35916,x:ez},"bc2-rgba-unorm":{gl:33778,x:e$},"bc2-rgba-unorm-srgb":{gl:35918,x:ez},"bc3-rgba-unorm":{gl:33779,x:e$},"bc3-rgba-unorm-srgb":{gl:35919,x:ez},"bc4-r-unorm":{gl:36283,x:eK},"bc4-r-snorm":{gl:36284,x:eK},"bc5-rg-unorm":{gl:36285,x:eK},"bc5-rg-snorm":{gl:36286,x:eK},"bc6h-rgb-ufloat":{gl:36495,x:eY},"bc6h-rgb-float":{gl:36494,x:eY},"bc7-rgba-unorm":{gl:36492,x:eY},"bc7-rgba-unorm-srgb":{gl:36493,x:eY},"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 e8(e){let t=e6[e],r=function(e){let t=e6[e],r=t?.gl;if(void 0===r)throw Error(`Unsupported texture format ${e}`);return r}(e),i=eE.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;case"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?ek(i.dataType):t?.types?.[0]||5121,compressed:i.compressed||!1}}let e4={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class e5 extends eR{gl;extensions;testedFeatures=new Set;constructor(e,t,r){super([],r),this.gl=e,this.extensions=t,eX(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),e in e0&&e1(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(e4),...Object.keys(e0)]}getWebGLFeature(e){let t=e4[e];return"string"==typeof t?!!eX(this.gl,t,this.extensions):!!t}}class e7 extends ep{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return void 0===this.limits[e]&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}class e9{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}
4start(){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))}}function te(e,t){return!function e(t,r){if(!t){let t=Error(r??"luma.gl assertion failed.");throw Error.captureStackTrace?.(t,e),t}}(e,t),e}class tt{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",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;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...tt.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,g()?e.canvas?"string"==typeof e.canvas?this.canvas=function(e){let t=document.getElementById(e);if(!tt.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=v("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},tt.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):tt.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.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new e9({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,c,h,_=this.cssToDeviceRatio(),[d,E]=this.getDrawingBufferSize();return r=e,i=_,s=d,n=E,a=t,l=tr(r[0],i,s),u=ti(r[1],i,n,a),h=(c=tr(r[0]+1,i,s))===s-1?c:c-1,c=ti(r[1]+1,i,n,a),a?(c=0===c?c:c+1,o=u,u=c):o=c===n-1?c:c-1,{x:l,y:u,width:Math.max(h-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=te(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
4xelSize: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=te(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(){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,this._configureDevice()))}_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 tr(e,t,r){return Math.min(Math.round(e*t),r-1)}function ti(e,t,r,i){return i?Math.max(0,r-1-Math.round(e*t)):Math.min(Math.round(e*t),r-1)}class ts extends tt{static defaultProps=tt.defaultProps}class tn extends H{static defaultProps={...H.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"none",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=tn.normalizeProps(e,t),super(e,t,tn.defaultProps)}static normalizeProps(e,t){return t}}e.s(["Sampler",0,tn],388396);let ta={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"};class to extends H{static SAMPLE=4;static STORAGE=8;static RENDER=16;static COPY_SRC=1;static COPY_DST=2;static TEXTURE=4;static RENDER_ATTACHMENT=16;dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,t,r){if(t=to.normalizeProps(e,t),super(e,t,to.defaultProps),this.dimension=this.props.dimension,this.baseDimension=ta[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,"cube"===this.dimension&&(this.depth=6),void 0===this.props.width||void 0===this.props.height)if(e.isExternalImage(t.data)){const r=e.getExternalImageSize(t.data);this.width=r?.width||1,this.height=r?.height||1}else this.width=1,this.height=1,(void 0===this.props.width||void 0===this.props.height)&&O.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=r?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof tn?e:this.device.createSampler(e)}copyImageData(e){let{data:t,depth:r,...i}=e;this.writeData(t,{...i,depthOrArrayLayers:i.depthOrArrayLayers??r})}computeMemoryLayout(e={}){let{width:t=this.width,height:r=this.height,depthOrArrayLayers:i=this.depth}=this._normalizeTextureReadOptions(e),{format:s,byteAlignment:n}=this;return eE.computeMemoryLayout({format:s,width:t,height:r,depth:i,byteAlignment:n})}readBuffer(e,t){throw Error("readBuffer not implemented")}readDataAsync(e){throw Error("readBuffer not implemented")}writeBuffer(e,t){throw Error("readBuffer not implemented")}writeData(e,t){throw Error("readBuffer not implemented")}
4readDataSyncWebGL(e){throw Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw Error("generateMipmapsWebGL not available")}static normalizeProps(e,t){let r={...t},{width:i,height:s}=r;return"number"==typeof i&&(r.width=Math.max(1,Math.ceil(i))),"number"==typeof s&&(r.height=Math.max(1,Math.ceil(s))),r}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{data:t,depth:r,...i}=e,s=this._normalizeTextureWriteOptions({...i,depthOrArrayLayers:i.depthOrArrayLayers??r});return{data:t,depth:s.depthOrArrayLayers,...s}}_normalizeCopyExternalImageOptions(e){let t=to._omitUndefined(e),r=t.mipLevel??0,i=this._getMipLevelSize(r),s=this.device.getExternalImageSize(e.image),n={...to.defaultCopyExternalImageOptions,...i,...s,...t};return n.width=Math.min(n.width,i.width-n.x),n.height=Math.min(n.height,i.height-n.y),n.depth=Math.min(n.depth,i.depthOrArrayLayers-n.z),n}_normalizeTextureReadOptions(e){let t=to._omitUndefined(e),r=t.mipLevel??0,i=this._getMipLevelSize(r),s={...to.defaultTextureReadOptions,...i,...t};return s.width=Math.min(s.width,i.width-s.x),s.height=Math.min(s.height,i.height-s.y),s.depthOrArrayLayers=Math.min(s.depthOrArrayLayers,i.depthOrArrayLayers-s.z),s}
4_getSupportedColorReadOptions(e){let t=this._normalizeTextureReadOptions(e),r=eE.getInfo(this.format);switch(this._validateColorReadAspect(t),this._validateColorReadFormat(r),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return t;default:throw Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if("all"!==e.aspect)throw Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){let t=to._omitUndefined(e),r=t.mipLevel??0,i=this._getMipLevelSize(r),s={...to.defaultTextureWriteOptions,...i,...t};s.width=Math.min(s.width,i.width-s.x),s.height=Math.min(s.height,i.height-s.y),s.depthOrArrayLayers=Math.min(s.depthOrArrayLayers,i.depthOrArrayLayers-s.z);let n=eE.computeMemoryLayout({format:this.format,width:s.width,height:s.height,depth:s.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=n.bytesPerPixel*s.width;if(s.bytesPerRow=t.bytesPerRow??n.bytesPerRow,s.rowsPerImage=t.rowsPerImage??s.height,s.bytesPerRow<a)throw Error(`bytesPerRow (${s.bytesPerRow}) must be at least ${a} for ${this.format}`);if(s.rowsPerImage<s.height)throw Error(`rowsPerImage (${s.rowsPerImage}) must be at least ${s.height} for ${this.format}`);let o=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(o&&s.bytesPerRow%o!=0)throw Error(`bytesPerRow (${s.bytesPerRow}) must be a multiple of bytesPerPixel (${o}) for ${this.format}`);return s}_getMipLevelSize(e){let t=Math.max(1,this.width>>e);return{width:t,height:"1d"===this.baseDimension?1:Math.max(1,this.height>>e),depthOrArrayLayers:"3d"===this.dimension?Math.max(1,this.depth>>e):this.depth}}getAllocatedByteLength(){let e=0;for(let t=0;t<this.mipLevels;t++){let{width:r,height:i,depthOrArrayLayers:s}=this._getMipLevelSize(t);e+=eE.computeMemoryLayout({format:this.format,width:r,height:i,depth:s,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>void 0!==e))}static defaultProps={...H.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:to.SAMPLE|to.RENDER|to.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0};static defaultCopyDataOptions={data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"};static defaultCopyExternalImageOptions={image:void 0,sourceX:0,sourceY:0,width:void 0,height:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1};static defaultTextureReadOptions={x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"};static defaultTextureWriteOptions={byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}}e.s(["Texture",0,to],825458);class tl extends H{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,tl.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&&(O.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 to?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 to?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:to.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:to.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}
4resizeAttachments(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={...H.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null}}class tu extends tl{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);const r=null===t.handle;this.device=e,this.gl=e.gl,this.handle=this.props.handle||r?this.props.handle:this.gl.createFramebuffer(),!r&&(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=function(e){switch(eE.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}`)}}(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)}}class tc extends ts{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 tu(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}class th extends tt{}class t_ extends th{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)}}async function td(e,t){let r=document.getElementsByTagName("head")[0];if(!r)throw Error("loadScript");let i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",e),t&&(i.id=t),new Promise((t,s)=>{i.onload=t,i.onerror=t=>s(Error(`Unable to load script '${e}': ${t}`)),r.appendChild(i)})}let tE=null,tf=!1,tg={debugSpectorJS:O.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/[email protected]/dist/spector.bundle.js",gl:void 0};async function tm(e){if(!globalThis.SPECTOR)try{await td(e.debugSpectorJSUrl||tg.debugSpectorJSUrl)}catch(e){O.warn(String(e))}}function tp(e){if(!(e={...tg,...e}).debugSpectorJS)return null;if(!tE&&globalThis.SPECTOR&&!globalThis.luma?.spector){O.probe(1,"SPECTOR foun
4d and initialized. Start with `luma.spector.displayUI()`")();let{Spector:e}=globalThis.SPECTOR;tE=new e,globalThis.luma&&(globalThis.luma.spector=tE)}if(!tE)return null;if(tf||(tf=!0,tE.spyCanvases(),tE?.onCaptureStarted.add(e=>O.info("Spector capture started:",e)()),tE?.onCapture.add(e=>{O.info("Spector capture complete:",e)(),tE?.getResultUI(),tE?.resultView.display(),tE?.resultView.addCapture(e)})),e.gl){let t=eW(e.gl),r=t.device;tE?.startCapture(e.gl,500),t.device=r,new Promise(e=>setTimeout(e,2e3)).then(e=>{O.info("Spector capture stopped after 2 seconds")(),tE?.stopCapture()})}return tE}function tT(e){return e.luma=e.luma||{},e.luma}async function tR(){g()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await td("https://unpkg.com/[email protected]/index.js"))}function tA(e,t={}){var r;let i;return t.debugWebGL||t.traceWebGL?function(e,t){if(!globalThis.WebGLDebugUtils)return O.warn("webgl-debug not loaded")(),e;let r=tT(e);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...n,...e});let i=globalThis.WebGLDebugUtils.makeDebugContext(e,tb.bind(null,t),tC.bind(null,t));for(let e in n)e in i||"number"!=typeof n[e]||(i[e]=n[e]);class s{}Object.setPrototypeOf(i,Object.getPrototypeOf(e)),Object.setPrototypeOf(s,i);let a=Object.create(s);return r.realContext=e,r.debugContext=a,a.luma=r,a.debug=!0,a}(e,t):(i=tT(r=e)).realContext?i.realContext:r}function tS(e,t){t=Array.from(t).map(e=>void 0===e?"undefined":e);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${e}(${r})`}function tb(e,t,r,i){i=Array.from(i).map(e=>void 0===e?"undefined":e);let s=globalThis.WebGLDebugUtils.glEnumToString(t),n=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,i),a=`${s} in gl.${r}(${n})`;throw O.error("%cWebGL","color: white; background: red; padding: 2px 6px; border-radius: 3px;",a)(),Error(a)}function tC(e,t,r){let i="";for(let s of(e.traceWebGL&&O.level>=1&&(i=tS(t,r),O.info(1,"%cWebGL","color: white; background: blue; padding: 2px 6px; border-radius: 3px;",i)()),r))void 0===s&&(i=i||tS(t,r))}e.s(["DEFAULT_SPECTOR_PROPS",0,tg,"initializeSpectorJS",0,tp,"loadSpectorJS",0,tm],831934),(i=n||(n={}))[i.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",i[i.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",i[i.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",i[i.POINTS=0]="POINTS",i[i.LINES=1]="LINES",i[i.LINE_LOOP=2]="LINE_LOOP",i[i.LINE_STRIP=3]="LINE_STRIP",i[i.TRIANGLES=4]="TRIANGLES",i[i.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",i[i.TRIANGLE_FAN=6]="TRIANGLE_FAN",i[i.ZERO=0]="ZERO",i[i.ONE=1]="ONE",i[i.SRC_COLOR=768]="SRC_COLOR",i[i.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",i[i.SRC_ALPHA=770]="SRC_ALPHA",i[i.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",i[i.DST_ALPHA=772]="DST_ALPHA",i[i.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",i[i.DST_COLOR=774]="DST_COLOR",i[i.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",i[i.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",i[i.CONSTANT_COLOR=32769]="CONSTANT_COLOR",i[i.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",i[i.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",i[i.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",i[i.FUNC_ADD=32774]="FUNC_ADD",i[i.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",i[i.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",i[i.BLEND_EQUATION=32777]="BLEND_EQUATION",i[i.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",i[i.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",i[i.BLEND_DST_RGB=32968]="BLEND_DST_RGB",i[i.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",i[i.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",i[i.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",i[i.BLEND_COLOR=32773]="BLEND_COLOR",i[i.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",i[i.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",i[i.LINE_WIDTH=2849]="LINE_WIDTH",i[i.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",i[i.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",i[i.CULL_FACE_MODE=2885]="CULL_FACE_MODE",i[i.FRONT_FACE=2886]="FRONT_FACE",i[i.DEPTH_RANGE=2928]="DEPTH_RANGE",i[i.DEPTH_WRITEMA
4SK=2930]="DEPTH_WRITEMASK",i[i.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",i[i.DEPTH_FUNC=2932]="DEPTH_FUNC",i[i.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",i[i.STENCIL_FUNC=2962]="STENCIL_FUNC",i[i.STENCIL_FAIL=2964]="STENCIL_FAIL",i[i.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",i[i.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",i[i.STENCIL_REF=2967]="STENCIL_REF",i[i.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",i[i.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",i[i.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",i[i.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",i[i.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",i[i.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",i[i.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",i[i.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",i[i.VIEWPORT=2978]="VIEWPORT",i[i.SCISSOR_BOX=3088]="SCISSOR_BOX",i[i.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",i[i.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",i[i.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",i[i.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",i[i.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",i[i.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",i[i.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",i[i.RED_BITS=3410]="RED_BITS",i[i.GREEN_BITS=3411]="GREEN_BITS",i[i.BLUE_BITS=3412]="BLUE_BITS",i[i.ALPHA_BITS=3413]="ALPHA_BITS",
4i[i.DEPTH_BITS=3414]="DEPTH_BITS",i[i.STENCIL_BITS=3415]="STENCIL_BITS",i[i.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",i[i.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",i[i.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",i[i.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",i[i.SAMPLES=32937]="SAMPLES",i[i.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",i[i.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",i[i.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",i[i.VENDOR=7936]="VENDOR",i[i.RENDERER=7937]="RENDERER",i[i.VERSION=7938]="VERSION",i[i.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",i[i.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",i[i.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",i[i.STATIC_DRAW=35044]="STATIC_DRAW",i[i.STREAM_DRAW=35040]="STREAM_DRAW",i[i.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",i[i.BUFFER_SIZE=34660]="BUFFER_SIZE",i[i.BUFFER_USAGE=34661]="BUFFER_USAGE",i[i.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",i[i.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",i[i.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",i[i.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",i[i.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",i[i.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",i[i.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",i[i.CULL_FACE=2884]="CULL_FACE",i[i.FRONT=1028]="FRONT",i[i.BACK=1029]="BACK",i[i.FRONT_AND_BACK=1032]="FRONT_AND_BACK",i[i.BLEND=3042]="BLEND",i[i.DEPTH_TEST=2929]="DEPTH_TEST",i[i.DITHER=3024]="DITHER",i[i.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",i[i.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",i[i.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",i[i.SCISSOR_TEST=3089]="SCISSOR_TEST",i[i.STENCIL_TEST=2960]="STENCIL_TEST",i[i.NO_ERROR=0]="NO_ERROR",i[i.INVALID_ENUM=1280]="INVALID_ENUM",i[i.INVALID_VALUE=1281]="INVALID_VALUE",i[i.INVALID_OPERATION=1282]="INVALID_OPERATION",i[i.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",i[i.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",i[i.CW=2304]="CW",i[i.CCW=2305]="CCW",i[i.DONT_CARE=4352]="DONT_CARE",i[i.FASTEST=4353]="FASTEST",i[i.NICEST=4354]="NICEST",i[i.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",i[i.BYTE=5120]="BYTE",i[i.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",i[i.SHORT=5122]="SHORT",i[i.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",i[i.INT=5124]="INT",i[i.UNSIGNED_INT=5125]="UNSIGNED_INT",i[i.FLOAT=5126]="FLOAT",i[i.DOUBLE=5130]="DOUBLE",i[i.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",i[i.ALPHA=6406]="ALPHA",i[i.RGB=6407]="RGB",i[i.RGBA=6408]="RGBA",i[i.LUMINANCE=6409]="LUMINANCE",i[i.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",i[i.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",i[i.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",i[i.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",i[i.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",i[i.VERTEX_SHADER=35633]="VERTEX_SHADER",i[i.COMPILE_STATUS=35713]="COMPILE_STATUS",i[i.DELETE_STATUS=35712]="DELETE_STATUS",i[i.LINK_STATUS=35714]="LINK_STATUS",i[i.VALIDATE_STATUS=35715]="VALIDATE_STATUS",i[i.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",i[i.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",i[i.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",i[i.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",i[i.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",i[i.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",i[i.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",i[i.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",i[i.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",i[i.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",i[i.SHADER_TYPE=35663]="SHADER_TYPE",i[i.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",i[i.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",i[i.NEVER=512]="NEVER",i[i.LESS=513]="LESS",i[i.EQUAL=514]="EQUAL",i[i.LEQUAL=515]="LEQUAL",i[i.GREATER=516]="GREATER",i[i.NOTEQUAL=517]="NOTEQUAL",i[i.GEQUAL=518]="GEQUAL",i[i.ALWAYS=519]="ALWAYS",i[i.KEEP=7680]="KEEP",i[i.REPLACE=7681]="REPLACE",i[i.INCR=7682]="INCR",i[i.DECR=7683]="DECR",i[i.INVERT=5386]="INVERT",i[i.INCR_WRAP=34055]="INCR_WRAP",i[i.DECR_WRAP=34056]="DECR_WRAP",i[i.NEAREST=9728]="NEAREST",i[i.LINEAR=9729]="LINEAR",i[i.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",i[i.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",i[i.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",i[i.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",i[i.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",i[i.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",i[i.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",i[i.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",i[i.TEXTURE_2D=3553]="TEXTURE_2D",i[i.TEXTURE=5890]="TEXTURE",i[i.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",i[i.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",i[i.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",i[i.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",i[i.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",i[i.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",i[i.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",i[i.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",i[i.TEXTURE0=33984]="TEXTURE0",i[i.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",i[i.REPEAT=10497]="REPEAT",i[i.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",i[i.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",i[i.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",i[i.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",i[i.FLOAT_VEC2=35664]="FLOAT_VEC2",i[i.FLOAT_VEC3=35665]="FLOAT_VEC3",i[i.FLOAT_VEC4=35666]="FLOAT_VEC4",i[i.INT_VEC2=35667]="INT_VEC2",i[i.INT_VEC3=35668]="INT_VEC3",i[i.INT_VEC4=35669]="INT_VEC4",i[i.BOOL=35670]="BOOL",i[i.BOOL_VEC2=35671]="BOOL_VEC2",i[i.BOOL_VEC3=35672]="BOOL_VEC3",i[i.BOOL_VEC4=35673]="BOOL_VEC4",i[i.FLOAT_MAT2=35674]="FLOAT_MAT2",i[i.FLOAT_MAT3=35675]="FLOAT_MAT3",i[i.FLOAT_MAT4=35676]="FLOAT_MAT4",i[i.SAMPLER_2D=35678]="SAMPLER_2D",i[i.SAMPLER_CUBE=35680]="SAMPLER_CUBE",i[i.LOW_FLOAT=36336]="LOW_FLOAT",i[i.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",i[i.HIGH_FLOAT=36338]="HIGH_FLOAT",i[i.LOW_INT=36339]="LOW_INT",i[i.MEDIUM_INT=36340]="MEDIUM_INT",i[i.HIGH_INT=36341]="HIGH_INT",i[i.FRAMEBUFFER=36160]="FRAMEBUFFER",i[i.RENDERBUFFER=36161]="RENDERBUFFER",i[i.RGBA4=32854]="RGBA4",i[i.RGB5_A1=32855]="RGB5_A1",i[i.RGB565=36194]="RGB565",i[i.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",i[i.STENCIL_INDEX=6401]="STENCIL_INDEX",i[i.STENCIL_INDEX8=36168]="STENCIL_INDEX8",i[i.DEPTH_STENCIL=34041]="DEPTH_STENCIL",i[i.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",i[i.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",i[i.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",i[i.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",i[i.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",i[i.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",i[i.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",i[i.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",i[i.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_OBJ
4ECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",i[i.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",i[i.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",i[i.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",i[i.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",i[i.NONE=0]="NONE",i[i.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",i[i.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",i[i.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",i[i.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",i[i.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",i[i.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",i[i.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",i[i.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",i[i.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",i[i.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",i[i.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",i[i.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",i[i.READ_BUFFER=3074]="READ_BUFFER",i[i.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",i[i.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",i[i.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",i[i.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",i[i.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",i[i.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",i[i.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",i[i.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",i[i.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",i[i.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",i[i.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",i[i.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",i[i.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",i[i.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",i[i.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",i[i.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",i[i.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",i[i.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",i[i.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",i[i.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",i[i.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",i[i.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",i[i.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",i[i.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",i[i.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",i[i.RED=6403]="RED",i[i.RGB8=32849]="RGB8",i[i.RGBA8=32856]="RGBA8",i[i.RGB10_A2=32857]="RGB10_A2",i[i.TEXTURE_3D=32879]="TEXTURE_3D",i[i.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",i[i.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",i[i.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",i[i.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",i[i.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",i[i.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",i[i.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",i[i.SRGB=35904]="SRGB",i[i.SRGB8=35905]="SRGB8",i[i.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",i[i.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",i[i.RGBA32F=34836]="RGBA32F",i[i.RGB32F=34837]="RGB32F",i[i.RGBA16F=34842]="RGBA16F",i[i.RGB16F=34843]="RGB16F",i[i.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",i[i.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",i[i.R11F_G11F_B10F=35898]="R11F_G11F_B10F",i[i.RGB9_E5=35901]="RGB9_E5",i[i.RGBA32UI=36208]="RGBA32UI",i[i.RGB32UI=36209]="RGB32UI",i[i.RGBA16UI=36214]="RGBA16UI",i[i.RGB16UI=36215]="RGB16UI",i[i.RGBA8UI=36220]="RGBA8UI",i[i.RGB8UI=36221]="RGB8UI",i[i.RGBA32I=36226]="RGBA32I",i[i.RGB32I=36227]="RGB32I",i[i.RGBA16I=36232]="RGBA16I",i[i.RGB16I=36233]="RGB16I",i[i.RGBA8I=36238]="RGBA8I",i[i.RGB8I=36239]="RGB8I",i[i.RED_INTEGER=36244]="RED_INTEGER",i[i.RGB_INTEGER=36248]="RGB_INTEGER",i[i.RGBA_INTEGER=36249]="RGBA_INTEGER",i[i.R8=33321]="R8",i[i.RG8=33323]="RG8",i[i.R16F=33325]="R16F",i[i.R32F=33326]="R32F",i[i.RG16F=33327]="RG16F",i[i.RG32F=33328]="RG32F",i[i.R8I=33329]="R8I",i[i.R8UI=33330]="R8UI",i[i.R16I=33331]="R16I",i[i.R16UI=33332]="R16UI",i[i.R32I=33333]="R32I",i[i.R32UI=33334]="R32UI",i[i.RG8I=33335]="RG8I",i[i.RG8UI=33336]="RG8UI",i[i.RG16I=33337]="RG16I",i[i.RG16UI=33338]="RG16UI",i[i.RG32I=33339]="RG32I",i[i.RG32UI=33340]="RG32UI",i[i.R8_SNORM=36756]="R8_SNORM",i[i.RG8_SNORM=36757]="RG8_SNORM",i[i.RGB8_SNORM=36758]="RGB8_SNORM",i[i.RGBA8_SNORM=36759]="RGBA8_SNORM",i[i.RGB10_A2UI=36975]="RGB10_A2UI",i[i.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",i[i.TEXTURE_IMMUTABLE_
4LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",i[i.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",i[i.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",i[i.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",i[i.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",i[i.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",i[i.HALF_FLOAT=5131]="HALF_FLOAT",i[i.RG=33319]="RG",i[i.RG_INTEGER=33320]="RG_INTEGER",i[i.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",i[i.CURRENT_QUERY=34917]="CURRENT_QUERY",i[i.QUERY_RESULT=34918]="QUERY_RESULT",i[i.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",i[i.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",i[i.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",i[i.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",i[i.DRAW_BUFFER0=34853]="DRAW_BUFFER0",i[i.DRAW_BUFFER1=34854]="DRAW_BUFFER1",i[i.DRAW_BUFFER2=34855]="DRAW_BUFFER2",i[i.DRAW_BUFFER3=34856]="DRAW_BUFFER3",i[i.DRAW_BUFFER4=34857]="DRAW_BUFFER4",i[i.DRAW_BUFFER5=34858]="DRAW_BUFFER5",i[i.DRAW_BUFFER6=34859]="DRAW_BUFFER6",i[i.DRAW_BUFFER7=34860]="DRAW_BUFFER7",i[i.DRAW_BUFFER8=34861]="DRAW_BUFFER8",i[i.DRAW_BUFFER9=34862]="DRAW_BUFFER9",i[i.DRAW_BUFFER10=34863]="DRAW_BUFFER10",i[i.DRAW_BUFFER11=34864]="DRAW_BUFFER11",i[i.DRAW_BUFFER12=34865]="DRAW_BUFFER12",i[i.DRAW_BUFFER13=34866]="DRAW_BUFFER13",i[i.DRAW_BUFFER14=34867]="DRAW_BUFFER14",i[i.DRAW_BUFFER15=34868]="DRAW_BUFFER15",i[i.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",i[i.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",i[i.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",i[i.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",i[i.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",i[i.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",i[i.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",i[i.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",i[i.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",i[i.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",i[i.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",i[i.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",i[i.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",i[i.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",i[i.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",i[i.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",i[i.SAMPLER_3D=35679]="SAMPLER_3D",i[i.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",i[i.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",i[i.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",i[i.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",i[i.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",i[i.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",i[i.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",i[i.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",i[i.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",i[i.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",i[i.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",i[i.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",i[i.MAX_SAMPLES=36183]="MAX_SAMPLES",i[i.SAMPLER_BINDING=35097]="SAMPLER_BINDING",i[i.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",i[i.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",i[i.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",i[i.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",i[i.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",i[i.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",i[i.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",i[i.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",i[i.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",i[i.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",i[i.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",i[i.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",i[i.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",i[i.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",i[i.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",i[i.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",i[i.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",i[i.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",i[i.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",i[i.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",i[i.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",i[i.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",i[i.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",i[i.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",i[i.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",i[i.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",i[i.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",i[i.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",i[i.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",i[i.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",i[i.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",i[i.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",i[i.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",i[i.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",i[i.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",i[i.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",i[i.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",i[i.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",i[i.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",i[i.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",i[i.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",i[i.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",i[i.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",i[i.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",i[i.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",i[i.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",i[i.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",i[i.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",i[i.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",i[i.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",i[i.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",i[i.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",i[i.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",i[i.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",i[i.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",i[i.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",i[i.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",i[i.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",i[i.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",i[i.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",i[i.UNIFORM_TYPE=35383]="UNIFORM_TYPE",i[i.UNIFORM_SIZE=35384]="UNIFORM_SIZE",i[i.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",i[i.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",i[i.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",i[i.UNIFORM_MATRIX_STRI
4DE=35389]="UNIFORM_MATRIX_STRIDE",i[i.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",i[i.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",i[i.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",i[i.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",i[i.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",i[i.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",i[i.OBJECT_TYPE=37138]="OBJECT_TYPE",i[i.SYNC_CONDITION=37139]="SYNC_CONDITION",i[i.SYNC_STATUS=37140]="SYNC_STATUS",i[i.SYNC_FLAGS=37141]="SYNC_FLAGS",i[i.SYNC_FENCE=37142]="SYNC_FENCE",i[i.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",i[i.UNSIGNALED=37144]="UNSIGNALED",i[i.SIGNALED=37145]="SIGNALED",i[i.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",i[i.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",i[i.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",i[i.WAIT_FAILED=37149]="WAIT_FAILED",i[i.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",i[i.COLOR=6144]="COLOR",i[i.DEPTH=6145]="DEPTH",i[i.STENCIL=6146]="STENCIL",i[i.MIN=32775]="MIN",i[i.MAX=32776]="MAX",i[i.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",i[i.STREAM_READ=35041]="STREAM_READ",i[i.STREAM_COPY=35042]="STREAM_COPY",i[i.STATIC_READ=35045]="STATIC_READ",i[i.STATIC_COPY=35046]="STATIC_COPY",i[i.DYNAMIC_READ=35049]="DYNAMIC_READ",i[i.DYNAMIC_COPY=35050]="DYNAMIC_COPY",i[i.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",i[i.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",i[i.INVALID_INDEX=0xffffffff]="INVALID_INDEX",i[i.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",i[i.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",i[i.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",i[i.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",i[i.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",i[i.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",i[i.R16_EXT=33322]="R16_EXT",i[i.RG16_EXT=33324]="RG16_EXT",i[i.RGB16_EXT=32852]="RGB16_EXT",i[i.RGBA16_EXT=32859]="RGBA16_EXT",i[i.R16_SNORM_EXT=36760]="R16_SNORM_EXT",i[i.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",i[i.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",i[i.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",i[i.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",i[i.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",i[i.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",i[i.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",i[i.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",i[i.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",i[i.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",i[i.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",i[i.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",i[i.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",i[i.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",i[i.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",i[i.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",i[i.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",i[i.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",i[i.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",i[i.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",i[i.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",i[i.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",i[i.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",i[i.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",i[i.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",i[i.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",i[i.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",i[i.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",i[i.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",i[i.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",i[i.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",i[i.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",i[i.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",i[i.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",i[i.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",i[i.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",i[i.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",i[i.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",i[i.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",i[i.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",i[i.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",i[i.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",i[i.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",i[i.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",i[i.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",i[i.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",i[i.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",i[i.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",i[i.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",i[i.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",i[i.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",i[i.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",i[i.LINE_WEBGL=6913]="LINE_WEBGL",i[i.FILL_WEBGL=6914]="FILL_WEBGL",i[i.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",i[i.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",i[i.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",i[i.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",i[i.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",i[i.CLIP_DISTANCE2_WEBGL=12290]="
4CLIP_DISTANCE2_WEBGL",i[i.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",i[i.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",i[i.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",i[i.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",i[i.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",i[i.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",i[i.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",i[i.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",i[i.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",i[i.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",i[i.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",i[i.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",i[i.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",i[i.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",i[i.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",i[i.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",i[i.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",i[i.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT",e.s(["loadWebGLDeveloperTools",0,tR,"makeDebugContext",0,tA],7784);let tI={};class tN extends ${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&$.INDEX?34963:e&$.VERTEX?34962:e&$.UNIFORM?35345:34962}(this.props.usage),this.glUsage=function(e){return e&$.INDEX||e&$.VERTEX?35044:e&$.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}}function tP(e,t,r,i){if(i?.inlineSource){let i=function(e,t){let r="";for(let i=t-2;i<=t;i++){let s=e[i-1];void 0!==s&&(r+=ty(s,t,void 0))}return r}(t,r),s=e.linePos>0?`${" ".repeat(e.linePos+5)}^^^ 5`:"";return` 6${i}${s}${e.type.toUpperCase()}: ${e.message} 7 8`}let s="error"===e.type?"red":"orange";return i?.html?`<div class='luma-compiler-log-${e.type}' style="color:${s};"><b> ${e.type.toUpperCase()}: ${e.message}</b></div>`:`${e.type.toUpperCase()}: ${e.message}`}function ty(e,t,r){let i=r?.html?e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'"):e;return`${function(e){let t="";for(let r=e.length;r<4;++r)t+=" ";return t+e}(String(t))}: ${i}${r?.html?"<br/>":"\n"}`}class tL extends H{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){t={...t,debugShaders:t.debugShaders||e.props.debugShaders||"errors"},super(e,{id:function(e){return function(e,t="unnamed"){let r=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e);return r?.[1]??t}(e.source)||e.id||v(`unnamed ${e.stage}-shader`)}(t),...t},tL.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(){let e=this.props.debugShaders;switch(e){case"never":return;case"errors":if("success"===this.compilationStatus)return}let t=await this.getCompilationInfo();("warnings"!==e||t?.length!==0)&&this._displayShaderLog(t,this.id)}_displayShaderLog(e,t){if("u"<typeof document||!document?.createElement)return;let r=`${this.stage} shader "${t}"`,i=function(e,t,r){let i="",s=t.split(/\r?\n/),n=e.slice().sort((e,t)=>
8e.lineNum-t.lineNum);switch(r?.showSourceCode||"no"){case"all":let a=0;for(let e=1;e<=s.length;e++){let t=s[e-1],o=n[a];for(t&&o&&(i+=ty(t,e,r));n.length>a&&o.lineNum===e;){let e=n[a++];e&&(i+=tP(e,s,e.lineNum,{...r,inlineSource:!1}))}}for(;n.length>a;){let e=n[a++];e&&(i+=tP(e,[],0,{...r,inlineSource:!1}))}return i;case"issues":case"no":for(let t of e)i+=tP(t,s,t.lineNum,{inlineSource:r?.showSourceCode!=="no"});return i}}(e,this.source,{showSourceCode:"all",html:!0}),s=this.getTranslatedSource(),n=document.createElement("div");n.innerHTML=`\ 9<h1>Compilation error in ${r}</h1> 10<div style="display:flex;position:fixed;top:10px;right:20px;gap:2px;"> 11<button id="copy">Copy source</button><br/> 12<button id="close">Close</button> 13</div> 14<code><pre>${i}</pre></code>`,s&&(n.innerHTML+=`<br /><h1>Translated Source</h1><br /><br /><code><pre>${s}</pre></code>`),n.style.top="0",n.style.left="0",n.style.background="white",n.style.position="fixed",n.style.zIndex="9999",n.style.maxWidth="100vw",n.style.maxHeight="100vh",n.style.overflowY="auto",document.body.appendChild(n);let a=n.querySelector(".luma-compiler-log-error");a?.scrollIntoView(),n.querySelector("button#close").onclick=()=>{n.remove()},n.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}static defaultProps={...H.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0}}function tO(e){let t=e.toLowerCase();return["warning","error","info"].includes(t)?t:"info"}e.s(["Shader",0,tL],145453);class tM extends tL{device;handle;constructor(e,t){switch(super(e,t),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props});const r=this._compile(this.source);r&&"function"==typeof r.catch&&r.catch(()=>{this.compilationStatus="error"})}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.de
14stroyed=!0)}get asyncCompilationStatus(){return this._waitForCompilationComplete().then(()=>(this._getCompilationStatus(),this.compilationStatus))}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){let e=this.device.gl.getShaderInfoLog(this.handle);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:tO(s||"info"),lineNum:0,linePos:0});continue}r.push({message:n.trim(),type:tO(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:tO(s||"info"),lineNum:0,linePos:0});continue}let u=parseInt(o,10);Number.isNaN(u)&&(u=0);let c=parseInt(a,10);Number.isNaN(c)&&(c=0),r.push({message:l.join(":").trim(),type:tO(n),lineNum:u,linePos:c})}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 15${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(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}return O.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{O.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"}}function tv(e,t){return tF(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function tB(e,t){return tF(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function tD(e,t){return tF(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function tx(e,t,r="color"){return tF(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 tF(e,t,r){if(!(t in r))throw Error(`Illegal parameter ${t} for ${e}`);return r[t]}function tU(e){let t={};return e.addressModeU&&(t[10242]=tG(e.addressModeU)),e.addressModeV&&(t[10243]=tG(e.addressModeV)),e.addressModeW&&(t[32882]=tG(e.addressModeW)),e.magFilter&&(t[10240]=tw(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=function(e,t="none"){if(!t)return tw(e);switch(t){case"none":return tw(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]=tv("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function tG(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function tw(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}class tH extends tn{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=tU(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)}}}}function tW(e){let[,,,,t]=tX[e];return t}let tX={uint8:["uint8","u32",1,!1,Uint8Array],sint8:["sint8","i32",1,!1,Int8Array],unorm8:["uint8","f32",1,!0,Uint8Array],snorm8:["sint8","f32",1,!0,Int8Array],uint16:["uint16","u32",2,!1,Uint16Array],sint16:["sint16","i32",2,!1,Int16Array],unorm16:["uint16","u32",2,!0,Uint16Array],snorm16:["sint16","i32",2,!0,Int16Array],float16:["float16","f16",2,!1,Uint16Array],float32:["float32","f32",4,!1,Float32Array],uint32:["uint32","u32",4,!1,Uint32Array],sint32:["sint32","i32",4,!1,Int32Array]};function tV(e,t,r){let i;if(function(e){for(let t in e)return!1;return!0}(t))return r(e);let{nocatch:s=!0}=t,n=ew.get(e);if(n.push(),eF(e,t),s)i=r(e),n.pop();else try{i=r(e)}finally{n.pop()}return i}e.s(["alignTo",0,function(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}},"getTypedArrayConstructor",0,tW],144135);class tk extends H{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,tk.defaultProps)}static defaultProps={...H.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0}}e.s(["TextureView",0,tk],96204);class t$ extends tk{device;gl;handle;texture;constructor(e,t){super(e,{...to.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}let tz={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 tK extends to{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;
15const r=e8(this.props.format);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.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.gl.bindTexture(this.glTarget,this.handle);const{dimension:i,width:s,height:n,depth:a,mipLevels:o,glTarget:l,glInternalFormat:u}=this;if(!this.compressed)switch(i){case"2d":case"cube":this.gl.texStorage2D(l,o,u,s,n);break;case"2d-array":case"3d":this.gl.texStorage3D(l,o,u,s,n,a);break;default:throw Error(i)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data),this.props.handle?this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"):this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"),this.setSampler(this.props.sampler),this.view=new t$(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Texture"):(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")),this.destroyed=!0)}createView(e){return new t$(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);let t=tU(this.sampler.props);this._setSamplerParameters(t)}copyExternalImage(e){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:c,height:h}=t,_=tY(this.glTarget,this.dimension,u),d=t.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),tV(this.gl,d,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(_,a,o,l,c,h,r,i,s);break;case"2d-array":case"3d":this.gl.texSubImage3D(_,a,o,l,u,c,h,n,r,i,s)}}),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={}){let r=this._normalizeTextureWriteOptions(t),{width:i,height:s,depthOrArrayLayers:n,mipLevel:a,byteOffset:o,x:l,y:u,z:c}=r,{glFormat:h,glType:_,compressed:d}=this,E=tY(this.glTarget,this.dimension,c);if(d)throw Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:f}=this.device.getTextureFormatInfo(this.format),g=f?r.bytesPerRow/f:void 0,m={3317:this.byteAlignment,...void 0!==g?{3314:g}:{},32878:r.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),tV(this.gl,m,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(E,a,l,u,i,s,h,_,o);break;case"2d-array":case"3d":this.gl.texSubImage3D(E,a,l,u,c,i,s,n,h,_,o)}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,t={}){let r,i=this._normalizeTextureWriteOptions(t),s=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:n,height:a,depthOrArrayLayers:o,mipLevel:l,x:u,y:c,z:h,byteOffset:_}=i,{glFormat:d,glType:E,compressed:f}=this,g=tY(this.glTarget,this.dimension,h);if(!f){let{bytesPerPixel:e}=this.device.getTextureFormatInfo(this.format);e&&(r=i.bytesPerRow/e)}let m=this.compressed?{}:{3317:this.byteAlignment,...void 0!==r?{3314:r}:{},32878:i.rowsPerImage},p=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,_),T=f?function(e,t=0){return t?new e.constructor(e.buffer,e.byteOffset+t,(e.byteLength-t)/e.BYTES_PER_ELEMENT):e}(s,_):s,R=this._getMipLevelSize(l),A=0===u&&0===c&&0===h&&n===R.width&&a===R.height&&o===R.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),tV(this.gl,m,()=>{switch(this.dimension){case"2d":case"cube":f?A?this.gl.compressedTexImage2D(g,l,d,n,a,0,T):this.gl.compressedTexSubImage2D(g,l,u,c,n,a,d,T):this.gl.texSubImage2D(g,l,u,c,n,a,d,E,s,p);break;case"2d-array":case"3d":f?A?this.gl.compressedTexImage3D(g,l,d,n,a,o,0,T):this.gl.compressedTexSubImage3D(g,l,u,c,h,n,a,o,d,T):this.gl.texSubImage3D(g,l,u,c,h,n,a,o,d,E,s,p)}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,t){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({
15id:`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=tW(tz[this.glType]),s=new i(r.byteLength/i.BYTES_PER_ELEMENT);return this._readColorTextureLayers(t,r,e=>{let n=new i(s.buffer,s.byteOffset+e,r.bytesPerImage/i.BYTES_PER_ELEMENT);this.gl.readPixels(t.x,t.y,t.width,t.height,this.glFormat,this.glType,n)}),s.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),tV(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,tY(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.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format)||(O.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){O.warn(`Error generating mipmap for ${this}: ${e.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){for(let[t,r]of(O.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,r);break;case 10240:case 10241:case 10242:case 10243:case 32882:case 34892:case 34893:this.gl.texParameteri(this.glTarget,e,r);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,e,r)}}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}}function tY(e,t,r){return"cube"===t?34069+r:e}class tQ extends H{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return"pending"===this.linkStatus||"pending"===this.vs.compilationStatus||this.fs?.compilationStatus==="pending"}get isErrored(){return"error"===this.linkStatus||"error"===this.vs.compilationStatus||this.fs?.compilationStatus==="error"}constructor(e,t){super(e,t,tQ.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}static defaultProps={...H.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,bindings:void 0,bindGroups:void 0}}function tj(e,t){let r;if(!t)return{};if((r=Object.keys(t)).length>0&&r.every(e=>/^\d+$/.test(e)))return Object.fromEntries(Object.entries(t).map(([e,t])=>[Number(e),{...t}]));let i={};for(let[r,s]of Object.entries(t)){let t=function(e,t){let r=e.bindings.find(e=>e.name===t||`${e.name.toLocaleLowerCase()}uniforms`===t.toLocaleLowerCase());return r||O.warn(`Binding ${t} not set: Not found in shader layout.`)(),r||null}(e,r),n=t?.group??0;i[n]||={},i[n][r]=s}return i}function tZ(e){let t={};for(let r of Object.values(e))Object.assign(t,r);return t}e.s(["RenderPipeline",0,tQ],749494),e.s(["flattenBindingsByGroup",0,tZ,"normalizeBindingsByGroup",0,tj],466234);class tq extends tQ{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 r=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(t);this.sharedRenderPipeline=r,this.handle=r.handle,this.vs=r.vs,this.fs=r.fs,this.linkStatus=r.linkStatus,this.introspectedLayout=r.introspectedLayout,this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=t.shaderLayout?function(e,t){let r={...e,attributes:e.attributes.map(e=>({...e})),bindings:e.bindings.map(e=>({...e}))};for(let e of t?.attributes||[]){let t=r.attributes.find(t=>t.name===e.name);t?(t.type=e.type||t.type,t.stepMode=e.stepMode||t.stepMode):O.warn(`shader layout attribute ${e.name} not present in shader`)}for(let e of t?.bindings||[]){let t=tJ(r,e.name);if(!t){O.warn(`shader layout binding ${e.name} not present in shader`);continue}Object.assign(t,e)}return r}(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,t){for(let[r,i]of Object.entries(tZ(tj(this.shaderLayout,e)))){let e=tJ(this.shaderLayout,r);if(e){switch(!i&&O.warn(`Unsetting binding "${r}" in render pipeline "${this.id}"`)(),e.type){case"uniform":if(!(i instanceof tN)&&!(i.buffer instanceof tN))throw Error("buffer value");break;case"texture":if(!(i instanceof t$||i instanceof tK||i instanceof tu))throw Error(`${this} Bad texture binding for ${r}`);break;case"sampler":O.warn(`Ignoring sampler ${r}`)();break;default:throw Error(e.type)}this.bindings[r]=i}else{let e=this.shaderLayout.bindings.map(e=>`"${e.name}"`).join(", ");t?.disableWarnings||O.warn(`No binding "${r}" in render pipeline "${this.id}", expected one of ${e}`,i)()}}}draw(e){this._syncLinkStatus();let t=e.bindGroups?tZ(e.bindGroups):e.bindings||this.bindings,{renderPass:r,parameters:i=this.props.parameters,topology:s=this.props.topology,vertexArray:n,vertexCount:a,instanceCount:o,isInstanced:l=!1,first
15Vertex:u=0,transformFeedback:c,uniforms:h=this.uniforms}=e,_=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)}}(s),d=!!n.indexBuffer,E=n.indexBuffer?.glIndexType;return"success"!==this.linkStatus?(O.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1):this._areTexturesRenderable(t)?(this.device.gl.useProgram(this.handle),n.bindBeforeRender(r),c&&c.begin(this.props.topology),this._applyBindings(t,{disableWarnings:this.props.disableWarnings}),this._applyUniforms(h),!function(e,t,r,i){if(function(e){let t=!0;for(let r in e){t=!1;break}return t}(t))return i(e);e.pushState();try{return function(e,t){let{gl:r}=e;if(t.cullMode)switch(t.cullMode){case"none":r.disable(2884);break;case"front":r.enable(2884),r.cullFace(1028);break;case"back":r.enable(2884),r.cullFace(1029)}if(t.frontFace&&r.frontFace(tF("frontFace",t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has("depth-clip-control")&&r.enable(34383),void 0!==t.depthBias&&(r.enable(32823),r.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=tF("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=tF("polygonMode",t.polygonMode,{fill:6914,line:6913});r?.polygonModeWEBGL(1028,i),r?.polygonModeWEBGL(1029,i)}t.polygonOffsetLine&&r.enable(10754)}if(e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&r.enable(12288),t.clipDistance1&&r.enable(12289),t.clipDistance2&&r.enable(12290),t.clipDistance3&&r.enable(12291),t.clipDistance4&&r.enable(12292),t.clipDistance5&&r.enable(12293),t.clipDistance6&&r.enable(12294),t.clipDistance7&&r.enable(12295)),void 0!==t.depthWriteEnabled&&r.depthMask(t.depthWriteEnabled),t.depthCompare&&("always"!==t.depthCompare?r.enable(2929):r.disable(2929),r.depthFunc(tv("depthCompare",t.depthCompare))),void 0!==t.clearDepth&&r.clearDepth(t.clearDepth),t.stencilWriteMask){let e=t.stencilWriteMask;r.stencilMaskSeparate(1028,e),r.stencilMaskSeparate(1029,e)}if(t.stencilReadMask&&O.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){let e=t.stencilReadMask||0xffffffff,i=tv("depthCompare",t.stencilCompare);"always"!==t.stencilCompare?r.enable(2960):r.disable(2960),r.stencilFuncSeparate(1028,i,0,e),r.stencilFuncSeparate(1029,i,0,e)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){let e=tB("stencilPassOperation",t.stencilPassOperation),i=tB("stencilFailOperation",t.stencilFailOperation),s=tB("stencilDepthFailOperation",t.stencilDepthFailOperation);r.stencilOpSeparate(1028,i,s,e),r.stencilOpSeparate(1029,i,s,e)}switch(t.blend){case!0:r.enable(3042);break;case!1:r.disable(3042)}if(t.blendColorOperation||t.blendAlphaOperation){let e=tD("blendColorOperation",t.blendColorOperation||"add"),i=tD("blendAlphaOperation",t.blendAlphaOperation||"add");r.blendEquationSeparate(e,i);let s=tx("blendColorSrcFactor",t.blendColorSrcFactor||"one"),n=tx("blendColorDstFactor",t.blendColorDstFactor||"zero"),a=tx("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),o=tx("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");r.blendFuncSeparate(s,n,a,o)}}(e,t),eF(e.gl,r),i(e)}finally{e.popState()}}(this.device,i,r.glParameters,()=>{d&&l?this.device.gl.drawElementsInstanced(_,a||0,E,u,o||0):d?this.device.gl.drawElements(_,a||0,E,u):l?this.device.gl.drawArraysInstanced(_,u,a||0,o||0):this.device.gl.drawArrays(_,u,a||0),c&&c.end()}),n.unbindAfterRender(r),!0):(O.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1)}_areTexturesRenderable(e){let t=!0;for(let r of this.shaderLayout.bindings)t3(e,r.name)||(O.warn(`Binding ${r.name} not found in ${this.id}`)(),t=!1);return t}_applyBindings(e,t){if(this._syncLinkStatus(),"success"!==this.linkStatus)return;let{gl:r}=this.device;r.useProgram(this.handle);let i=0,s=0;for(let t of this.shaderLayout.bindings){let n=t3(e,t.name);if(!n)throw Error(`No value for binding ${t.name} in ${this.id}`);switch(t.type){case"uniform":let{name:a}=t,o=r.getUniformBlockIndex(this.handle,a);if(0xffffffff===o)throw Error(`Invalid uniform block name ${a}`);r.uniformBlockBinding(this.handle,o,s),n instanceof tN?r.bindBufferBase(35345,s,n.handle):r.bindBufferRange(35345,s,n.buffer.handle,n.offset||0,n.size||n.buffer.byteLength-(n.offset||0)),s+=1;break;case"texture":let l;if(!(n instanceof t$||n instanceof tK||n instanceof tu))throw Error("texture");
15if(n instanceof t$)l=n.texture;else if(n instanceof tK)l=n;else if(n instanceof tu&&n.colorAttachments[0]instanceof t$)O.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),l=n.colorAttachments[0].texture;else throw Error("No texture");r.activeTexture(33984+i),r.bindTexture(l.glTarget,l.handle),i+=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);case 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 tJ(e,t){return e.bindings.find(e=>e.name===t||e.name===`${t}Uniforms`||`${e.name}Uniforms`===t)}function t3(e,t){return e[t]||e[`${t}Uniforms`]||e[t.replace(/Uniforms$/,"")]}class t2 extends H{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,t){super(e,t,{...H.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}function t0(e){let t=t5[t1(e)];if(!t)throw Error(`Unsupported variable shader type: ${e}`);return t}function t1(e){return t9[e]||e}let t6=new class{getVariableShaderTypeInfo(e){return t0(e)}getAttributeShaderTypeInfo(e){return function(e){var t;let r=t4[t7[t=e]||t];if(!r)throw Error(`Unsupported attribute shader type: ${e}`);let[i,s]=r,n=t8[i]*s;return{primitiveType:i,components:s,byteLength:n,integer:"i32"===i||"u32"===i,signed:"u32"!==i}}(e)}makeShaderAttributeType(e,t){var r,i;return r=e,1===(i=t)?r:`vec${i}<${r}>`}resolveAttributeShaderTypeAlias(e){var t;return t7[t=e]||t}resolveVariableShaderTypeAlias(e){return t1(e)}},t8={f32:4,f16:2,i32:4,u32:4},t4={f32:["f32",1],"vec2<f32>":["f32",2],"vec3<f32>":["f32",3],"vec4<f32>":["f32",4],f16:["f16",1],"vec2<f16>":["f16",2],"vec3<f16>":["f16",3],"vec4<f16>":["f16",4],i32:["i32",1],"vec2<i32>":["i32",2],"vec3<i32>":["i32",3],"vec4<i32>":["i32",4],u32:["u32",1],"vec2<u32>":["u32",2],"vec3<u32>":["u32",3],"vec4<u32>":["u32",4]},t5={f32:{type:"f32",components:1},f16:{type:"f16",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2<f32>":{type:"f32",components:2},"vec3<f32>":{type:"f32",components:3},"vec4<f32>":{type:"f32",components:4},"vec2<f16>":{type:"f16",components:2},"vec3<f16>":{type:"f16",components:3},"vec4<f16>":{type:"f16",components:4},"vec2<i32>":{type:"i32",components:2},"vec3<i32>":{type:"i32",components:3},"vec4<i32>":{type:"i32",components:4},"vec2<u32>":{type:"u32",components:2},"vec3<u32>":{type:"u32",components:3},"vec4<u32>":{type:"u32",components:4},"mat2x2<f32>":{type:"f32",components:4},"mat2x3<f32>":{type:"f32",components:6},"mat2x4<f32>":{type:"f32",components:8},"mat3x2<f32>":{type:"f32",components:6},"mat3x3<f32>":{type:"f32",components:9},"mat3x4<f32>":{type:"f32",components:12},"mat4x2<f32>":{type:"f32",components:8},"mat4x3<f32>":{type:"f32",components:12},"mat4x4<f32>":{type:"f32",components:16},"mat2x2<f16>":{type:"f16",components:4},"mat2x3<f16>
15":{type:"f16",components:6},"mat2x4<f16>":{type:"f16",components:8},"mat3x2<f16>":{type:"f16",components:6},"mat3x3<f16>":{type:"f16",components:9},"mat3x4<f16>":{type:"f16",components:12},"mat4x2<f16>":{type:"f16",components:8},"mat4x3<f16>":{type:"f16",components:12},"mat4x4<f16>":{type:"f16",components:16},"mat2x2<i32>":{type:"i32",components:4},"mat2x3<i32>":{type:"i32",components:6},"mat2x4<i32>":{type:"i32",components:8},"mat3x2<i32>":{type:"i32",components:6},"mat3x3<i32>":{type:"i32",components:9},"mat3x4<i32>":{type:"i32",components:12},"mat4x2<i32>":{type:"i32",components:8},"mat4x3<i32>":{type:"i32",components:12},"mat4x4<i32>":{type:"i32",components:16},"mat2x2<u32>":{type:"u32",components:4},"mat2x3<u32>":{type:"u32",components:6},"mat2x4<u32>":{type:"u32",components:8},"mat3x2<u32>":{type:"u32",components:6},"mat3x3<u32>":{type:"u32",components:9},"mat3x4<u32>":{type:"u32",components:12},"mat4x2<u32>":{type:"u32",components:8},"mat4x3<u32>":{type:"u32",components:12},"mat4x4<u32>":{type:"u32",components:16}},t7={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>"},t9={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>",mat2x2f:"mat2x2<f32>",mat2x3f:"mat2x3<f32>",mat2x4f:"mat2x4<f32>",mat3x2f:"mat3x2<f32>",mat3x3f:"mat3x3<f32>",mat3x4f:"mat3x4<f32>",mat4x2f:"mat4x2<f32>",mat4x3f:"mat4x3<f32>",mat4x4f:"mat4x4<f32>",mat2x2i:"mat2x2<i32>",mat2x3i:"mat2x3<i32>",mat2x4i:"mat2x4<i32>",mat3x2i:"mat3x2<i32>",mat3x3i:"mat3x3<i32>",mat3x4i:"mat3x4<i32>",mat4x2i:"mat4x2<i32>",mat4x3i:"mat4x3<i32>",mat4x4i:"mat4x4<i32>",mat2x2u:"mat2x2<u32>",mat2x3u:"mat2x3<u32>",mat2x4u:"mat2x4<u32>",mat3x2u:"mat3x2<u32>",mat3x3u:"mat3x3<u32>",mat3x4u:"mat3x4<u32>",mat4x2u:"mat4x2<u32>",mat4x3u:"mat4x3<u32>",mat4x4u:"mat4x4<u32>",mat2x2h:"mat2x2<f16>",mat2x3h:"mat2x3<f16>",mat2x4h:"mat2x4<f16>",mat3x2h:"mat3x2<f16>",mat3x3h:"mat3x3<f16>",mat3x4h:"mat3x4<f16>",mat4x2h:"mat4x2<f16>",mat4x3h:"mat4x3<f16>",mat4x4h:"mat4x4<f16>"};e.s(["getVariableShaderTypeInfo",0,t0,"resolveVariableShaderTypeAlias",0,t1,"shaderTypeDecoder",0,t6],685251);let re={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>"},rt={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"}},rr={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126};class ri extends t2{device;handle;vs;fs;introspectedLayout={attributes:[],bindings:[],uniforms:[]};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(),O.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=function(e,t){let r={attributes:[],bindings:[]};for(let i of(r.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=re[a],t=/instance/i.test(n)?"instance":"vertex";r.push({name:n,location:o,stepMode:t,type:e})}}return r.sort((e,t)=>
15e.location-t.location),r}(e,t),function(e,t){let r=(r,i)=>e.getActiveUniformBlockParameter(t,r,i),i=[],s=e.getProgramParameter(t,35382);for(let n=0;n<s;n++){let s={name:e.getActiveUniformBlockName(t,n)||"",location:r(n,35391),byteLength:r(n,35392),vertex:r(n,35396),fragment:r(n,35398),uniformCount:r(n,35394),uniforms:[]},a=r(n,35395)||[],o=e.getActiveUniforms(t,a,35383),l=e.getActiveUniforms(t,a,35384),u=e.getActiveUniforms(t,a,35387),c=e.getActiveUniforms(t,a,35388);for(let r=0;r<s.uniformCount;++r){let i=a[r];if(void 0!==i){let n=e.getActiveUniform(t,i);if(!n)throw Error("activeInfo");let a=re[o[r]];s.uniforms.push({name:n.name,format:a,type:o[r],arrayLength:l[r],byteOffset:u[r],byteStride:c[r]})}}let h=new Set(s.uniforms.map(e=>e.name.split(".")[0]).filter(e=>!!e)),_=s.name.replace(/Uniforms$/,"");if(1===h.size&&!h.has(s.name)&&!h.has(_)){let[e]=h;O.warn(`Uniform block "${s.name}" uses GLSL instance "${e}". luma.gl binds uniform buffers by block name ("${s.name}") and alias ("${_}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}i.push(s)}return i.sort((e,t)=>e.location-t.location),i}(e,t))){let e=i.uniforms.map(e=>({name:e.name,format:e.format,byteOffset:e.byteOffset,byteStride:e.byteStride,arrayLength:e.arrayLength}));r.bindings.push({type:"uniform",name:i.name,group:0,location:i.location,visibility:!!i.vertex&2*!!i.fragment,minBindingSize:i.byteLength,uniforms:e})}let i=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:te(t?.[1],`Failed to parse GLSL uniform name ${e}`),length:+!!t?.[2],isArray:!!t?.[2]}}(n),c=e.getUniformLocation(t,l),h={location:c,name:l,size:a,type:o,isArray:u};if(r.push(h),h.size>1)for(let i=0;i<h.size;i++){let s=`${l}[${i}]`;c=e.getUniformLocation(t,s);let n={...h,name:s,location:c};r.push(n)}}return r}(e,t),s=0;for(let e of i)if(rt[e.type]){let{viewDimension:t,sampleType:i}=rt[e.type];r.bindings.push({type:"texture",name:e.name,group:0,location:s,viewDimension:t,sampleType:i}),e.textureUnit=s,s+=1}i.length&&(r.uniforms=i);let n=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,{type:l,components:u}=t0(re[a]);r.push({location:s,name:n,type:l,size:o*u})}return r.sort((e,t)=>e.location-t.location),r}(e,t);return n?.length&&(r.varyings=n),r}(this.device.gl,this.handle),O.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.de
15stroyed=!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),O.time(4,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),O.timeEnd(4,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let e=this._getLinkStatus();this._reportLinkStatus(e);return}O.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),O.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&&rt[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)}}}class rs extends H{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,t){super(e,t,rs.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={...H.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0}}class rn extends H{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,rn.defaultProps)}static defaultProps={...H.defaultProps}}class ra extends rn{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":this.device,t.options;throw Error("copyBufferToTexture is not supported in WebGL");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:c,byteOffset:h=0,bytesPerRow:_,rowsPerImage:d}=t;if(i instanceof to)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:h},c);if("all"!==n)throw Error("aspect not supported in WebGL");if(0!==s||void 0!==l||_||d)throw Error("not implemented");let{framebuffer:E,destroyFramebuffer:f}=ro(i);try{let t=a||E.width,i=o||E.height,s=te(E.colorAttachments[0]),n=e8(s.texture.props.format),l=n.format,_=n.type;e.gl.bindBuffer(35051,c.handle),r=e.gl.bindFramebuffer(36160,E.handle),e.gl.readPixels(u[0],u[1],t,i,l,_,h)}finally{e.gl.bindBuffer(35051,null),void 0!==r&&e.gl.bindFramebuffer(36160,r),f&&E.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:c=t.destinationTexture.height}=t,{framebuffer:h,destroyFramebuffer:_}=ro(s),[d=0,E=0]=a,[f,g,m]=o,p=e.gl.bindFramebuffer(36160,h.handle);if(l instanceof tK)r=l,u=Number.isFinite(u)?u:r.width,c=Number.isFinite(c)?c:r.height,r._bind(0),i=r.glTarget;else throw Error("invalid destination");switch(i){case 3553:case 34067:e.gl.copyTexSubImage2D(i,n,f,g,d,E,u,c);break;case 35866:case 32879:e.gl.copyTexSubImage3D(i,n,f,g,m,d,E,u,c)}r&&r._unbind(),e.gl.bindFramebuffer(36160,p),_&&h.destroy()}(this.device,t.options);break;default:throw Error(t.name)}}}function ro(e){if(e instanceof to){let{width:t,height:r,id:i}=e;
15return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${i}`,width:t,height:r,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}class rl extends H{static defaultClearColor=[0,0,0,1];static defaultClearDepth=1;static defaultClearStencil=0;get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){t=rl.normalizeProps(e,t),super(e,t,rl.defaultProps)}static normalizeProps(e,t){return t}static defaultProps={...H.defaultProps,framebuffer:null,parameters:void 0,clearColor:rl.defaultClearColor,clearColors:void 0,clearDepth:rl.defaultClearDepth,clearStencil:rl.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0}}let ru=[1,2,4,8];class rc extends rl{device;handle=null;glParameters={};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){}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=ru.map(t=>!!(t&e.colorMask))),this.glParameters=t,eF(this.device.gl,t)}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&&tV(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){tV(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 rh extends rs{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new ra(e,{id:`${this.props.id}-command-buffer`})}destroy(){this.destroyResource()}finish(e){return e?.id&&this.commandBuffer.id!==e.id&&(this.commandBuffer.id=e.id,this.commandBuffer.props.id=e.id),this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new rc(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)}}function r_(e,t){let r={};for(let i of e.attributes){let s=function(e,t,r){let i=function(e,t){let r=e.attributes.find(e=>e.name===t);return r||O.warn(`shader layout attribute "${t}" not present in shader`),r||null}(e,r),s=function(e,t){var r=e;for(let e of r)(e.attributes&&e.format||!e.attributes&&!e.format)&&O.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`);let i=function(e,t){for(let r of e)if(r.format&&r.name===t)return{attributeName:r.name,bufferName:t,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}(e,t);
15return i||(i=function(e,t){for(let r of e){let e=r.byteStride;if("number"!=typeof r.byteStride)for(let t of r.attributes||[])e+=Y.getVertexFormatInfo(t.format).byteLength;let i=r.attributes?.find(e=>e.attribute===t);if(i)return{attributeName:i.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:i.format,byteOffset:i.byteOffset,byteStride:e}}return null}(e,t))?i:(O.warn(`layout for attribute "${t}" not present in buffer layout`),null)}(t,r);if(!i)return null;let n=t6.getAttributeShaderTypeInfo(i.type),a=Y.getCompatibleVertexFormat(n),o=s?.vertexFormat||a,l=Y.getVertexFormatInfo(o);return{attributeName:s?.attributeName||i.name,bufferName:s?.bufferName||i.name,location:i.location,shaderType:i.type,primitiveType:n.primitiveType,shaderComponents:n.components,vertexFormat:o,bufferDataType:l.type,bufferComponents:l.components,normalized:l.normalized,integer:n.integer,stepMode:s?.stepMode||i.stepMode||"vertex",byteOffset:s?.byteOffset||0,byteStride:s?.byteStride||0}}(e,t,i.name);s&&(r[i.name]=s)}return r}function rd(e,t,r=16){let i=r_(e,t),s=Array(r).fill(null);for(let e of Object.values(i))s[e.location]=e;return s}e.s(["getAttributeInfosByLocation",0,rd,"getAttributeInfosFromLayouts",0,r_],965880);class rE extends H{static defaultProps={...H.defaultProps,shaderLayout:void 0,bufferLayout:[]};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,rE.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=Array(this.maxVertexAttributes).fill(null),this.attributeInfos=rd(t.shaderLayout,t.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){this.device.reportError(Error("constant attributes not supported"),this)()}}function rf(e){return(!t||t.byteLength<e)&&(t=new ArrayBuffer(e)),t}function rg(e,t){let r=rf(e.BYTES_PER_ELEMENT*t);return new e(r,0,t)}e.s(["getScratchArray",0,rg,"getScratchArrayBuffer",0,rf],553746);class rm extends rE{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return"Chrome"===(g()?!function(e){if("u">typeof window&&window.process?.type==="renderer"||void 0!==a.default&&a.default.versions?.electron)return!0;let t="u">typeof navigator&&navigator.userAgent,r=e||t;return!!(r&&r.indexOf("Electron")>=0)}(void 0)?(I.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Electron":"Node")}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(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.attributeInfos[e];if(!t)throw Error(`Unknown attribute location ${e}`);let r=ek(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=rm.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=rg(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;
15o++)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}}class rp extends H{static defaultProps={...H.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,rp.defaultProps)}}class rT extends rp{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 r=this._getVaryingIndex(e),{buffer:i,byteLength:s,byteOffset:n}=this._getBufferRange(t);if(r<0){this.unusedBuffers[e]=i,O.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[r]={buffer:i,byteLength:s,byteOffset:n},this.bindOnUse||this._bindBuffer(r,i,n,s)}getBuffer(e){if(rR(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 tN)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(rR(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 rR(e){return"number"==typeof e?Number.isInteger(e):/^\d+$/.test(e)}class rA extends H{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,rA.defaultProps)}static defaultProps={...H.defaultProps,type:void 0,count:void 0}}class rS extends rA{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}
15Object.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=()=>
15{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)}}class rb extends H{static defaultProps={...H.defaultProps};get[Symbol.toStringTag](){return"Fence"}constructor(e,t={}){super(e,t,rb.defaultProps)}}class rC extends rb{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)}}function rI(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 rN(e){return e instanceof tl?{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}}class rP extends eA{static getDeviceFromContext(e){return e?e.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";
15preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;gl;_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"){tI[e]=tI[e]||1;let t=tI[e]++;return`${e}-${t}`}("webgl-device")});const t=eA._getCanvasContextProps(e);if(!t)throw Error("WebGLDevice requires props.createCanvasContext to be set");const r=t.canvas?.gl??null;let i=rP.getDeviceFromContext(r);if(i)throw Error(`WebGL context already attached to device ${i.id}`);this.canvasContext=new tc(this,t),this.lost=new Promise(e=>{this._resolveContextLost=e});const s={...e.webgl};"premultiplied"===t.alphaMode&&(s.premultipliedAlpha=!0),void 0!==e.powerPreference&&(s.powerPreference=e.powerPreference),void 0!==e.failIfMajorPerformanceCaveat&&(s.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);const n=this.props._handle||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}`);eW(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)}}(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")},s);if(!n)throw Error("WebGL context creation failed");if(i=rP.getDeviceFromContext(n)){if(e._reuseDevices)return O.log(1,`Not creating a new Device, instead returning a reference to Device ${i.id} already attached to WebGL context`,i)(),this.canvasContext.destroy(),i._reused=!0,i;throw Error(`WebGL context already attached to device ${i.id}`)}this.handle=n,this.gl=n,this.spectorJS=tp({...this.props,gl:this.handle});const a=eW(this.handle);a.device=this,a.extensions||(a.extensions={}),this.extensions=a.extensions,this.info=function(e,t){var r,i;let s=e.getParameter(7936),n=e.getParameter(7937);eX(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,c=l||n,h=e.getParameter(7938),_=eV(u,c),d=(r=u,i=c,/Metal/i.exec(r)||/Metal/i.exec(i)?"metal":/ANGLE/i.exec(r)||/ANGLE/i.exec(i)?"opengl":"unknown");return{type:"webgl",gpu:_,gpuType:function(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(eV(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,c),gpuBackend:d,vendor:u,renderer:c,version:h,shadingLanguage:"glsl",shadingLanguageVersion:300}}(this.gl,this.extensions),this.limits=new e7(this.gl),this.features=new e5(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new ew(this.gl,{log:(...e)=>O.log(1,...e)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=tA(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),O.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(O.level=Math.max(O.level,1)),this.commandEncoder=new rh(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){this.commandEncoder?.destroy(),this.props._reuseDevices||this._reused||(eW(this.handle).device=null)}get isLost(){return this.gl.isContextLost()}createCanvasContext(e){throw Error("WebGL only supports a single canvas")}createPresentationContext(e){return new t_(this,e||{})}createBuffer(e){return new tN(this,this._normalizeBufferProps(e))}createTexture(e){return new tK(this,e)}createExternalTexture(e){throw Error("createExternalTexture() not implemented")}createSampler(e){return new tH(this,e)}createShader(e){return new tM(this,e)}createFramebuffer(e){return new tu(this,e)}createVertexArray(e){return new rm(this,e)}createTransformFeedback(e){return new rT(this,e)}createQuerySet(e){return new rS(this,e)}createFence(){return new rC(this)}createRenderPipeline(e){return new tq(this,e)}_createSharedRenderPipelineWebGL(e){return new ri(this,e)}createComputePipeline(e){throw Error("ComputePipeline not supported in WebGL")}createCommandEncoder(e={}){return new rh(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()}}_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||{}
15,{target:n=null,sourceWidth:a,sourceHeight:o,sourceDepth:l,sourceFormat:u,sourceType:c}=t||{},{framebuffer:h,deleteFramebuffer:_}=rN(e),{gl:d,handle:E}=h;a||=h.width,o||=h.height;let f=h.colorAttachments[s]?.texture;if(!f)throw Error(`Invalid framebuffer attachment ${s}`);l=f?.depth||1,u||=f?.glFormat||6408,c||=f?.glType||5121,n=function(e,t,r,i,s){if(e)return e;let n=tz[t||=5121];return new(z.getTypedArrayConstructor(n))(i*s*rI(r))}(n,c,u,a,o);let g=z.getDataType(n);c=c||rr[g];let m=d.bindFramebuffer(36160,E);return d.readBuffer(36064+s),d.readPixels(r,i,a,o,u,c,n),d.readBuffer(36064),d.bindFramebuffer(36160,m||null),_&&h.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:c,deleteFramebuffer:h}=rN(e);o=o||c.width,l=l||c.height,u=u||5121;let _=r;if(!_){let e=a+o*l*rI(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);_=c.device.createBuffer({byteLength:e})}let d=e.device.createCommandEncoder();return d.copyTextureToBuffer({sourceTexture:e,width:o,height:l,origin:[i,s],destinationBuffer:_,byteOffset:a}),d.destroy(),h&&c.destroy(),_}(e,t)}setParametersWebGL(e){eF(this.gl,e)}getParametersWebGL(e){return eU(this.gl,e)}withParametersWebGL(e,t){return tV(this.gl,e,t)}resetWebGL(){O.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),eF(this.gl,eS)}_getDeviceSpecificTextureFormatCapabilities(e){var t,r;let i,s,n,a;return t=this.gl,r=this.extensions,i=e.create,s=e6[e.format],s?.gl===void 0&&(i=!1),s?.x&&(i=i&&!!eX(t,s.x,r)),"stencil8"===e.format&&(i=!1),n=s?.r!==!1&&(s?.r===void 0||e1(t,s.r,r)),a=i&&e.render&&n&&function(e,t,r){let i=e6[t],s=i?.gl;if(void 0===s||i?.x&&!eX(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),c=Number(e.getError());for(;c!==u;)c=e.getError();let h=!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),h=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 h}(t,e.format,r),{format:e.format,create:i&&e.create,render:a,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}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(){ew.get(this.gl).push()}popState(){ew.get(this.gl).pop()}getGLKey(e,t){let r=Number(e);for(let e in this.gl)if(this.gl[e]===r)return`GL.${e}`;return 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),{})}setConstantAttributeWebGL(e,t){let r=this.limits.maxVertexAttributes;this._constants=this._constants||Array(r).fill(null);let i=this._constants[e];switch(i&&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,t)&&O.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:var s,n,a,o,l,u,c=this,h=e,_=t;switch(_.length){case 1:c.gl.vertexAttrib1fv(h,_);break;case 2:c.gl.vertexAttrib2fv(h,_);break;case 3:c.gl.vertexAttrib3fv(h,_);break;case 4:c.gl.vertexAttrib4fv(h,_)}break;case Int32Array:s=this,n=e,a=t,s.gl.vertexAttribI4iv(n,a);break;case Uint32Array:o=this,l=e,u=t,o.gl.vertexAttribI4uiv(l,u);break;default:throw Error("constant")}}getExtension(e){return eX(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,rP],695002)}]);
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.