@deck.gl/core 9.2.8 → 9.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist.min.js CHANGED
@@ -4,21 +4,21 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['deck'] = factory();
6
6
  else root['deck'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var Po=Object.defineProperty;var ib=Object.getOwnPropertyDescriptor;var ob=Object.getOwnPropertyNames;var ab=Object.prototype.hasOwnProperty;var cb=(r,e,t)=>e in r?Po(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var O=(r,e)=>()=>(r&&(e=r(r=0)),e);var Ht=(r,e)=>{for(var t in e)Po(r,t,{get:e[t],enumerable:!0})},lb=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ob(e))!ab.call(r,s)&&s!==t&&Po(r,s,{get:()=>e[s],enumerable:!(n=ib(e,s))||n.enumerable});return r};var ub=r=>lb(Po({},"__esModule",{value:!0}),r);var L=(r,e,t)=>(cb(r,typeof e!="symbol"?e+"":e,t),t);function Es(){let r;if(typeof window<"u"&&window.performance)r=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var Dl=O(()=>{});var zr,Fl=O(()=>{Dl();zr=class{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=Es(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Es()-this._startTime),this._timerPending=!1,this._checkSampling(),this):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)}}});var Ze,Md=O(()=>{Fl();Ze=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:n}=e,s=this.stats[t];return s||(e instanceof zr?s=e:s=new zr(t,n),this.stats[t]=s),s}}});var Rs=O(()=>{Md();Fl();Dl()});var Bl,Co,Ll=O(()=>{Rs();Bl=class{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new Ze({id:e})),this.stats.get(e)}},Co=new Bl});var Mo,fb,Oo,hb,Od,Ul=O(()=>{Mo=globalThis,fb=globalThis.document||{},Oo=globalThis.process||{},hb=globalThis.console,Od=globalThis.navigator||{}});function ko(r){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=r||e;return Boolean(t&&t.indexOf("Electron")>=0)}var Vl=O(()=>{});function Ie(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||ko()}var zl=O(()=>{Vl()});function Wl(r){return!r&&!Ie()?"Node":ko(r)?"Electron":(r||Od.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var kd=O(()=>{zl();Vl();Ul()});var $l,dr=O(()=>{Ul();zl();kd();$l="4.1.0"});function pb(r){try{let e=window[r],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var No,Nd=O(()=>{No=class{constructor(e,t,n="sessionStorage"){this.storage=pb(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}});function Dd(r){let e;return r<10?e=`${r.toFixed(2)}ms`:r<100?e=`${r.toFixed(1)}ms`:r<1e3?e=`${r.toFixed(0)}ms`:e=`${(r/1e3).toFixed(2)}s`,e}function Fd(r,e=8){let t=Math.max(e-r.length,0);return`${" ".repeat(t)}${r}`}var Bd=O(()=>{});function Ld(r){return typeof r!="string"?r:(r=r.toUpperCase(),Do[r]||Do.WHITE)}function Ud(r,e,t){return!Ie&&typeof r=="string"&&(e&&(r=`\x1B[${Ld(e)}m${r}\x1B[39m`),t&&(r=`\x1B[${Ld(t)+mb}m${r}\x1B[49m`)),r}var Do,mb,Vd=O(()=>{dr();(function(r){r[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"})(Do||(Do={}));mb=10});function zd(r,e=["constructor"]){let t=Object.getPrototypeOf(r),n=Object.getOwnPropertyNames(t),s=r;for(let i of n){let o=s[i];typeof o=="function"&&(e.find(a=>i===a)||(s[i]=o.bind(r)))}}var Wd=O(()=>{});function Is(r,e){if(!r)throw new Error(e||"Assertion failed")}var $d=O(()=>{});function Wr(){let r;if(Ie()&&Mo.performance)r=Mo?.performance?.now?.();else if("hrtime"in Oo){let e=Oo?.hrtime?.();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var jd=O(()=>{dr()});function Mn(){}function qd(r){if(!r)return 0;let e;switch(typeof r){case"number":e=r;break;case"object":e=r.logLevel||r.priority||0;break;default:return 0}return Is(Number.isFinite(e)&&e>=0),e}function Yd(r){let{logLevel:e,message:t}=r;r.logLevel=qd(e);let n=r.args?Array.from(r.args):[];for(;n.length&&n.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&n.unshift(t),r.message=e;break;case"object":Object.assign(r,e);break;default:}typeof r.message=="function"&&(r.message=r.message());let s=typeof r.message;return Is(s==="string"||s==="object"),Object.assign(r,{args:n},r.opts)}function _b(r,e,t){if(typeof e=="string"){let n=t.time?Fd(Dd(t.total)):"";e=t.time?`${r}: ${n} ${e}`:`${r}: ${e}`,e=Ud(e,t.color,t.background)}return e}function yb(r){for(let e in r)for(let t in r[e])return t||"untitled";return"empty"}var Cn,gb,Hd,Xd,Fe,jl=O(()=>{dr();Nd();Bd();Vd();Wd();$d();jd();Cn={debug:Ie()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},gb={enabled:!0,level:0};Hd={},Xd={once:!0},Fe=class{constructor({id:e}={id:""}){this.VERSION=$l,this._startTs=Wr(),this._deltaTs=Wr(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new No(`__probe-${this.id}__`,gb),this.timeStamp(`${this.id} started`),zd(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Wr()-this._startTs).toPrecision(10))}getDelta(){return Number((Wr()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,Cn.warn,arguments,Xd)}error(e){return this._getLogFunction(0,e,Cn.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,Cn.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,Cn.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,Cn.debug||Cn.info,arguments,Xd)}table(e,t,n){return t?this._getLogFunction(e,t,console.table||Mn,n&&[n],{tag:yb(t)}):Mn}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Mn)}group(e,t,n={collapsed:!1}){let s=Yd({logLevel:e,message:t,opts:n}),{collapsed:i}=n;return s.method=(i?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Mn)}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=qd(e)}_getLogFunction(e,t,n,s,i){if(this._shouldLog(e)){i=Yd({logLevel:e,message:t,args:s,opts:i}),n=n||i.method,Is(n),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=Wr();let o=i.tag||i.message;if(i.once&&o)if(!Hd[o])Hd[o]=Wr();else return Mn;return t=_b(this.id,i.message,i),n.bind(console,t,...i.args)}return Mn}};Fe.VERSION=$l});var Kd=O(()=>{globalThis.probe={}});var FR,Ps=O(()=>{jl();jl();Kd();FR=new Fe({id:"@probe.gl/log"})});var I,Xt=O(()=>{Ps();I=new Fe({id:"luma.gl"})});function pr(r="id"){Hl[r]=Hl[r]||1;let e=Hl[r]++;return`${r}-${e}`}var Hl,Cs=O(()=>{Hl={}});function xb(r,e){let t={...e};for(let n in r)r[n]!==void 0&&(t[n]=r[n]);return t}var j,Pe=O(()=>{Cs();j=class{toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(e,t,n){if(!e)throw new Error("no device");this._device=e,this.props=xb(t,n);let s=this.props.id!=="undefined"?this.props.id:pr(this[Symbol.toStringTag]);this.props.id=s,this.id=s,this.userData=this.props.userData||{},this.addStats()}destroy(){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 Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){let n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){let t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}};L(j,"defaultProps",{id:"undefined",handle:void 0,userData:void 0})});var Ms,W,Fo=O(()=>{Pe();Ms=class extends j{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let n={...t};(t.usage||0)&Ms.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?n.indexType="uint32":t.data instanceof Uint16Array?n.indexType="uint16":t.data instanceof Uint8Array&&(n.indexType="uint8")),delete n.data,super(e,n,Ms.defaultProps),this.usage=n.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}debugData=new ArrayBuffer(0);_setDebugData(e,t,n){let s=ArrayBuffer.isView(e)?e.buffer:e,i=Math.min(e?e.byteLength:n,Ms.DEBUG_DATA_MAX_LENGTH);s===null?this.debugData=new ArrayBuffer(i):t===0&&n===s.byteLength?this.debugData=s.slice(0,i):this.debugData=s.slice(t,t+i)}},W=Ms;L(W,"INDEX",16),L(W,"VERTEX",32),L(W,"UNIFORM",64),L(W,"STORAGE",128),L(W,"INDIRECT",256),L(W,"QUERY_RESOLVE",512),L(W,"MAP_READ",1),L(W,"MAP_WRITE",2),L(W,"COPY_SRC",4),L(W,"COPY_DST",8),L(W,"DEBUG_DATA_MAX_LENGTH",32),L(W,"defaultProps",{...j.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0})});function Os(r){let[e,t,n]=Yl[r],s=r.includes("norm"),i=!s&&!r.startsWith("float"),o=r.startsWith("s");return{signedType:e,primitiveType:t,byteLength:n,normalized:s,integer:i,signed:o}}function Xl(r){let e=r;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function Zd(r,e){switch(e){case 1:return r;case 2:return r+r%2;default:return r+(4-r%4)%4}}function $r(r){let e=ArrayBuffer.isView(r)?r.constructor:r;if(e===Uint8ClampedArray)return"uint8";let t=Object.values(Yl).find(n=>e===n[4]);if(!t)throw new Error(e.name);return t[0]}function jr(r){let[,,,,e]=Yl[r];return e}var Yl,ks=O(()=>{Yl={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 On(r){let e;r.endsWith("-webgl")&&(r.replace("-webgl",""),e=!0);let[t,n]=r.split("x"),s=t,i=n?parseInt(n):1,o=Os(s),a={type:s,components:i,byteLength:o.byteLength*i,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(a.webglOnly=!0),a}function Gd(r,e,t){let n=t?Xl(r):r;switch(n){case"unorm8":return e===1?"unorm8":e===3?"unorm8x3-webgl":`${n}x${e}`;case"snorm8":case"uint8":case"sint8":case"uint16":case"sint16":case"unorm16":case"snorm16":case"float16":if(e===1||e===3)throw new Error(`size: ${e}`);return`${n}x${e}`;default:return e===1?n:`${n}x${e}`}}function ql(r,e,t){if(!e||e>4)throw new Error(`size ${e}`);let n=e,s=$r(r);return Gd(s,n,t)}function Qd(r){let e;switch(r.primitiveType){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return r.components<=2?"float16x2":"float16x4"}return r.components===1?e:`${e}x${r.components}`}var Bo=O(()=>{ks()});function Jl(r){let e=Ab[r];if(!e)throw new Error(`Unsupported texture format ${r}`);return e}var Se,se,Rt,bb,Lo,Kl,Uo,Zl,Tb,Gl,Ns,Ql,Vo,Jd,wb,vb,Ab,ep=O(()=>{Se="texture-compression-bc",se="texture-compression-astc",Rt="texture-compression-etc2",bb="texture-compression-etc1-webgl",Lo="texture-compression-pvrtc-webgl",Kl="texture-compression-atc-webgl",Uo="float32-renderable-webgl",Zl="float16-renderable-webgl",Tb="rgb9e5ufloat-renderable-webgl",Gl="snorm8-renderable-webgl",Ns="norm16-renderable-webgl",Ql="snorm16-renderable-webgl",Vo="float32-filterable",Jd="float16-filterable-webgl";wb={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:Gl},rg8snorm:{render:Gl},"rgb8snorm-webgl":{},rgba8snorm:{render:Gl},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:Ns},rg16unorm:{render:Ns},"rgb16unorm-webgl":{f:Ns},rgba16unorm:{render:Ns},r16snorm:{f:Ql},rg16snorm:{render:Ql},"rgb16snorm-webgl":{f:Ns},rgba16snorm:{render:Ql},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:Zl,filter:"float16-filterable-webgl"},rg16float:{render:Zl,filter:Jd},rgba16float:{render:Zl,filter:Jd},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:Uo,filter:Vo},rg32float:{render:!1,filter:Vo},"rgb32float-webgl":{render:Uo,filter:Vo},rgba32float:{render:Uo,filter:Vo},"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:Tb},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:Uo},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}},vb={"bc1-rgb-unorm-webgl":{f:Se},"bc1-rgb-unorm-srgb-webgl":{f:Se},"bc1-rgba-unorm":{f:Se},"bc1-rgba-unorm-srgb":{f:Se},"bc2-rgba-unorm":{f:Se},"bc2-rgba-unorm-srgb":{f:Se},"bc3-rgba-unorm":{f:Se},"bc3-rgba-unorm-srgb":{f:Se},"bc4-r-unorm":{f:Se},"bc4-r-snorm":{f:Se},"bc5-rg-unorm":{f:Se},"bc5-rg-snorm":{f:Se},"bc6h-rgb-ufloat":{f:Se},"bc6h-rgb-float":{f:Se},"bc7-rgba-unorm":{f:Se},"bc7-rgba-unorm-srgb":{f:Se},"etc2-rgb8unorm":{f:Rt},"etc2-rgb8unorm-srgb":{f:Rt},"etc2-rgb8a1unorm":{f:Rt},"etc2-rgb8a1unorm-srgb":{f:Rt},"etc2-rgba8unorm":{f:Rt},"etc2-rgba8unorm-srgb":{f:Rt},"eac-r11unorm":{f:Rt},"eac-r11snorm":{f:Rt},"eac-rg11unorm":{f:Rt},"eac-rg11snorm":{f:Rt},"astc-4x4-unorm":{f:se},"astc-4x4-unorm-srgb":{f:se},"astc-5x4-unorm":{f:se},"astc-5x4-unorm-srgb":{f:se},"astc-5x5-unorm":{f:se},"astc-5x5-unorm-srgb":{f:se},"astc-6x5-unorm":{f:se},"astc-6x5-unorm-srgb":{f:se},"astc-6x6-unorm":{f:se},"astc-6x6-unorm-srgb":{f:se},"astc-8x5-unorm":{f:se},"astc-8x5-unorm-srgb":{f:se},"astc-8x6-unorm":{f:se},"astc-8x6-unorm-srgb":{f:se},"astc-8x8-unorm":{f:se},"astc-8x8-unorm-srgb":{f:se},"astc-10x5-unorm":{f:se},"astc-10x5-unorm-srgb":{f:se},"astc-10x6-unorm":{f:se},"astc-10x6-unorm-srgb":{f:se},"astc-10x8-unorm":{f:se},"astc-10x8-unorm-srgb":{f:se},"astc-10x10-unorm":{f:se},"astc-10x10-unorm-srgb":{f:se},"astc-12x10-unorm":{f:se},"astc-12x10-unorm-srgb":{f:se},"astc-12x12-unorm":{f:se},"astc-12x12-unorm-srgb":{f:se},"pvrtc-rgb4unorm-webgl":{f:Lo},"pvrtc-rgba4unorm-webgl":{f:Lo},"pvrtc-rbg2unorm-webgl":{f:Lo},"pvrtc-rgba2unorm-webgl":{f:Lo},"etc1-rbg-unorm-webgl":{f:bb},"atc-rgb-unorm-webgl":{f:Kl},"atc-rgba-unorm-webgl":{f:Kl},"atc-rgbai-unorm-webgl":{f:Kl}},Ab={...wb,...vb}});function tp(r){let e=Rb(r);if(Yt.isCompressed(r)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;let n=Ib(r);n&&(e.blockWidth=n.blockWidth,e.blockHeight=n.blockHeight)}let t=Eb.exec(r);if(t){let[,n,s,i,o,a]=t,c=`${i}${s}`,l=Os(c),u=l.byteLength*8,f=n.length,h=[u,f>=2?u:0,f>=3?u:0,f>=4?u:0];e={format:r,attachment:e.attachment,dataType:l.signedType,components:f,channels:n,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:h,bytesPerPixel:l.byteLength*n.length,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return r.endsWith("-webgl")&&(e.webgl=!0),r.endsWith("-srgb")&&(e.srgb=!0),e}function Rb(r){let e=Jl(r),t=e.bytesPerPixel||1,n=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,{...e,format:r,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:t,bitsPerChannel:n,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function Ib(r){let t=/.*-(\d+)x(\d+)-.*/.exec(r);if(t){let[,n,s]=t;return{blockWidth:Number(n),blockHeight:Number(s)}}return null}var Sb,Eb,zo,Yt,eu=O(()=>{ks();ep();Sb=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Eb=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,zo=class{getInfo(e){return tp(e)}isColor(e){return e.startsWith("rgba")||e.startsWith("bgra")||e.startsWith("rgb")}isDepthStencil(e){return e.startsWith("depth")||e.startsWith("stencil")}isCompressed(e){return Sb.some(t=>e.startsWith(t))}getCapabilities(e){let t=Jl(e),n={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},s=tp(e),i=e.startsWith("depth")||e.startsWith("stencil"),o=s?.signed,a=s?.integer,c=s?.webgl;return n.render&&=!o,n.filter&&=!i&&!o&&!a&&!c,n}},Yt=new zo});function rp(r){return typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement||typeof VideoFrame<"u"&&r instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas}function np(r){if(typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas)return{width:r.width,height:r.height};if(typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement)return{width:r.naturalWidth,height:r.naturalHeight};if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement)return{width:r.videoWidth,height:r.videoHeight};if(typeof VideoFrame<"u"&&r instanceof VideoFrame)return{width:r.displayWidth,height:r.displayHeight};throw new Error("Unknown image type")}var sp=O(()=>{});var Ds,Fs,tu,Be,ru=O(()=>{Ll();Xt();Cs();Fo();Bo();eu();sp();Ds=class{},Fs=class{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)}},tu=class{get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=Co;timestamp=0;_reused=!1;_lumaData={};_textureCaps={};constructor(e){this.props={...tu.defaultProps,...e},this.id=this.props.id||pr(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return On(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return Yt.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let n=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,n=1){let s=Math.max(e,t,n);return 1+Math.floor(Math.log2(s))}isExternalImage(e){return rp(e)}getExternalImageSize(e){return np(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 Yt.isCompressed(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,...n){return this.props.onError(e,t)?()=>{}:I.error(e.message,t,...n)}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
8
- or create a device with the 'debug: true' prop.`;I.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=Yt.getCapabilities(e),n=i=>(typeof i=="string"?this.features.has(i):i)??!0,s=n(t.create);return{format:e,create:s,render:s&&n(t.render),filter:s&&n(t.filter),blend:s&&n(t.blend),store:s&&n(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&W.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 new Error("indices buffer content must be of type uint16 or uint32");return t}},Be=tu;L(Be,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{let[n,s]=e.getDevicePixelSize();I.log(1,`${e} resized => ${n}x${s}px`)()},onPositionChange:(e,t)=>{let[n,s]=e.getPosition();I.log(1,`${e} repositioned => ${n},${s}`)()},onVisibilityChange:e=>I.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>I.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:I.get("debug")||void 0,debugShaders:I.get("debug-shaders")||void 0,debugFramebuffers:Boolean(I.get("debug-framebuffers")),debugFactories:Boolean(I.get("debug-factories")),debugWebGL:Boolean(I.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!1,_cachePipelines:!1,_cacheDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0})});var Pb,ip,$o,Wo,mr,op=O(()=>{ru();Ll();Xt();Pb="set luma.log.level=1 (or higher) to trace rendering",ip="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",$o=class{stats=Co;log=I;VERSION="9.2.6";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw I.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),I.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");I.error("This version of luma.gl has already been initialized")()}I.log(1,`${this.VERSION} - ${Pb}`)(),globalThis.luma=this}async createDevice(e={}){let t={...$o.defaultProps,...e},n=this.selectAdapter(t.type,t.adapters);if(!n)throw new Error(ip);return t.waitForPageLoad&&await n.pageLoaded,await n.create(t)}async attachDevice(e,t){let n=this._getTypeFromHandle(e,t.adapters),s=n&&this.selectAdapter(n,t.adapters);if(!s)throw new Error(ip);return await s?.attach?.(e,t)}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this._getAdapterMap(e);return Array.from(t).map(([,n])=>n).filter(n=>n.isSupported?.()).map(n=>n.type)}getBestAvailableAdapterType(e=[]){let t=["webgpu","webgl","null"],n=this._getAdapterMap(e);for(let s of t)if(n.get(s)?.isSupported?.())return s;return null}selectAdapter(e,t=[]){let n=e;e==="best-available"&&(n=this.getBestAvailableAdapterType(t));let s=this._getAdapterMap(t);return n&&s.get(n)||null}enforceWebGL2(e=!0,t=[]){let s=this._getAdapterMap(t).get("webgl");s||I.warn("enforceWebGL2: webgl adapter not found")(),s?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign($o.defaultProps,e)}_getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let n of e)t.set(n.type,n);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?I.warn("WebGL1 is not supported",e)():I.warn("Unknown handle type",e)(),null)}},Wo=$o;L(Wo,"defaultProps",{...Be.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});mr=new Wo});function Ob(){return jo||(Mb()||typeof window>"u"?jo=Promise.resolve():jo=new Promise(r=>window.addEventListener("load",()=>r()))),jo}var Bs,Cb,Mb,jo,ap=O(()=>{dr();Bs=class{get pageLoaded(){return Ob()}},Cb=Ie()&&typeof document<"u",Mb=()=>Cb&&document.readyState==="complete",jo=null});function cp(){let r,e;return{promise:new Promise((n,s)=>{r=n,e=s}),resolve:r,reject:e}}var lp=O(()=>{});function kb(r){if(typeof r=="string"){let e=document.getElementById(r);if(!e)throw new Error(`${r} is not an HTML element`);return e}return r||document.body}function Nb(r){let e=document.getElementById(r);if(!Hr.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function Db(r){let{width:e,height:t}=r,n=document.createElement("canvas");n.id=pr("lumagl-auto-created-canvas"),n.width=e||1,n.height=t||1,n.style.width=Number.isFinite(e)?`${e}px`:"100%",n.style.height=Number.isFinite(t)?`${t}px`:"100%",r?.visible||(n.style.visibility="hidden");let s=kb(r?.container||null);return s.insertBefore(n,s.firstChild),n}function Fb(r,e,t,n,s){let i=r,o=up(i[0],e,t),a=fp(i[1],e,n,s),c=up(i[0]+1,e,t),l=c===t-1?c:c-1;c=fp(i[1]+1,e,n,s);let u;return s?(c=c===0?c:c+1,u=a,a=c):u=c===n-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}function up(r,e,t){return Math.min(Math.round(r*e),t-1)}function fp(r,e,t,n){return n?Math.max(0,t-1-Math.round(r*e)):Math.min(Math.round(r*e),t-1)}var kn,Hr,hp=O(()=>{dr();Cs();lp();kn=class{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=cp();_resizeObserver;_intersectionObserver;_position;destroyed=!1;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){if(this.props={...kn.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Ie()?e.canvas?typeof e.canvas=="string"?this.canvas=Nb(e.canvas):this.canvas=e.canvas:this.canvas=Db(e):this.canvas={width:e.width||1,height:e.height||1},kn.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):kn.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],kn.isHTMLCanvas(this.canvas)){this._intersectionObserver=new IntersectionObserver(t=>this._handleIntersection(t)),this._intersectionObserver.observe(this.canvas),this._resizeObserver=new ResizeObserver(t=>this._handleResize(t));try{this._resizeObserver.observe(this.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.canvas,{box:"content-box"})}setTimeout(()=>this._observeDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}destroy(){this.destroyed=!0}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}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){this.canvas.width=e,this.canvas.height=t,this.drawingBufferWidth=e,this.drawingBufferHeight=t}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){let n=this.cssToDeviceRatio(),[s,i]=this.getDrawingBufferSize();return Fb(e,n,s,i,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDevicePixelSize();return e/t}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)}_handleIntersection(e){let t=e.find(s=>s.target===this.canvas);if(!t)return;let n=t.isIntersecting;this.isVisible!==n&&(this.isVisible=n,this.device.props.onVisibilityChange(this))}_handleResize(e){let t=e.find(c=>c.target===this.canvas);if(!t)return;this.cssWidth=t.contentBoxSize[0].inlineSize,this.cssHeight=t.contentBoxSize[0].blockSize;let n=this.getDevicePixelSize(),s=t.devicePixelContentBoxSize?.[0].inlineSize||t.contentBoxSize[0].inlineSize*devicePixelRatio,i=t.devicePixelContentBoxSize?.[0].blockSize||t.contentBoxSize[0].blockSize*devicePixelRatio,[o,a]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(s,o)),this.devicePixelHeight=Math.max(1,Math.min(i,a)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:n})}_updateDrawingBufferSize(){if(this.props.autoResize){if(typeof this.props.useDevicePixels=="number"){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._updateDevice()}this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_observeDevicePixelRatio(){let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange(this,{oldRatio:e}),matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener("change",()=>this._observeDevicePixelRatio(),{once:!0})}_trackPosition(e=100){let t=setInterval(()=>{this.destroyed?clearInterval(t):this.updatePosition()},e)}updatePosition(){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 s=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:s})}}}},Hr=kn;L(Hr,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1})});var Ho,Ge,nu=O(()=>{Pe();Ho=class extends j{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=Ho.normalizeProps(e,t),super(e,t,Ho.defaultProps)}static normalizeProps(e,t){return t}},Ge=Ho;L(Ge,"defaultProps",{...j.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})});var Bb,qt,K,su=O(()=>{Pe();nu();Xt();Bb={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},qt=class extends j{dimension;baseDimension;format;width;height;depth;mipLevels;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,t){if(t=qt.normalizeProps(e,t),super(e,t,qt.defaultProps),this.dimension=this.props.dimension,this.baseDimension=Bb[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.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(t.data)){let n=e.getExternalImageSize(t.data);this.width=n?.width||1,this.height=n?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&I.warn(`${this} created with undefined width or height. This is deprecated. Use AsyncTexture instead.`)();this.updateTimestamp=e.incrementTimestamp()}setSampler(e){this.sampler=e instanceof Ge?e:this.device.createSampler(e)}clone(e){return this.device.createTexture({...this.props,...e})}static normalizeProps(e,t){let n={...t},{width:s,height:i}=n;return typeof s=="number"&&(n.width=Math.max(1,Math.ceil(s))),typeof i=="number"&&(n.height=Math.max(1,Math.ceil(i))),n}_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{width:t,height:n,depth:s}=this,i={...qt.defaultCopyDataOptions,width:t,height:n,depth:s,...e},o=this.device.getTextureFormatInfo(this.format);if(!e.bytesPerRow&&!o.bytesPerPixel)throw new Error(`bytesPerRow must be provided for texture format ${this.format}`);return i.bytesPerRow=e.bytesPerRow||t*(o.bytesPerPixel||4),i.rowsPerImage=e.rowsPerImage||n,i}_normalizeCopyExternalImageOptions(e){let t=this.device.getExternalImageSize(e.image),n={...qt.defaultCopyExternalImageOptions,...t,...e};return n.width=Math.min(n.width,this.width-n.x),n.height=Math.min(n.height,this.height-n.y),n}},K=qt;L(K,"SAMPLE",4),L(K,"STORAGE",8),L(K,"RENDER",16),L(K,"COPY_SRC",1),L(K,"COPY_DST",2),L(K,"TEXTURE",4),L(K,"RENDER_ATTACHMENT",16),L(K,"defaultProps",{...j.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:qt.TEXTURE|qt.RENDER_ATTACHMENT|qt.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),L(K,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),L(K,"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})});var iu,gr,dp=O(()=>{Pe();iu=class extends j{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,iu.defaultProps)}},gr=iu;L(gr,"defaultProps",{...j.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0})});function pp(r,e,t){let n="",s=e.split(/\r?\n/),i=r.slice().sort((o,a)=>o.lineNum-a.lineNum);switch(t?.showSourceCode||"no"){case"all":let o=0;for(let a=1;a<=s.length;a++)for(n+=mp(s[a-1],a,t);i.length>o&&i[o].lineNum===a;){let c=i[o++];n+=ou(c,s,c.lineNum,{...t,inlineSource:!1})}for(;i.length>o;){let a=i[o++];n+=ou(a,[],0,{...t,inlineSource:!1})}return n;case"issues":case"no":for(let a of r)n+=ou(a,s,a.lineNum,{inlineSource:t?.showSourceCode!=="no"});return n}}function ou(r,e,t,n){if(n?.inlineSource){let i=Lb(e,t),o=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^
7
+ "use strict";var __exports__=(()=>{var Oo=Object.defineProperty;var gb=Object.getOwnPropertyDescriptor;var _b=Object.getOwnPropertyNames;var yb=Object.prototype.hasOwnProperty;var xb=(r,e,t)=>e in r?Oo(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var O=(r,e)=>()=>(r&&(e=r(r=0)),e);var $t=(r,e)=>{for(var t in e)Oo(r,t,{get:e[t],enumerable:!0})},bb=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of _b(e))!yb.call(r,s)&&s!==t&&Oo(r,s,{get:()=>e[s],enumerable:!(n=gb(e,s))||n.enumerable});return r};var Tb=r=>bb(Oo({},"__esModule",{value:!0}),r);var L=(r,e,t)=>(xb(r,typeof e!="symbol"?e+"":e,t),t);function Ps(){let r;if(typeof window<"u"&&window.performance)r=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var Vl=O(()=>{});var zr,zl=O(()=>{Vl();zr=class{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=Ps(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Ps()-this._startTime),this._timerPending=!1,this._checkSampling(),this):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)}}});var hr,Ud=O(()=>{zl();hr=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:n}=e,s=this.stats[t];return s||(e instanceof zr?s=e:s=new zr(t,n),this.stats[t]=s),s}}});var Wl=O(()=>{Ud();zl();Vl()});var $l,ko,jl=O(()=>{Wl();$l=class{stats=new Map;getStats(e){return this.get(e)}get(e){return this.stats.has(e)||this.stats.set(e,new hr({id:e})),this.stats.get(e)}},ko=new $l});var No,wb,Do,vb,gR,Vd=O(()=>{No=globalThis,wb=globalThis.document||{},Do=globalThis.process||{},vb=globalThis.console,gR=globalThis.navigator||{}});function zd(r){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=r||e;return Boolean(t&&t.indexOf("Electron")>=0)}var Wd=O(()=>{});function Wr(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||zd()}var $d=O(()=>{Wd()});var Hl,Fo=O(()=>{Vd();$d();Hl="4.1.1"});function On(r,e){if(!r)throw new Error(e||"Assertion failed")}var Xl=O(()=>{});function Yl(r){if(!r)return 0;let e;switch(typeof r){case"number":e=r;break;case"object":e=r.logLevel||r.priority||0;break;default:return 0}return On(Number.isFinite(e)&&e>=0),e}function jd(r){let{logLevel:e,message:t}=r;r.logLevel=Yl(e);let n=r.args?Array.from(r.args):[];for(;n.length&&n.shift()!==t;);switch(typeof e){case"string":case"function":t!==void 0&&n.unshift(t),r.message=e;break;case"object":Object.assign(r,e);break;default:}typeof r.message=="function"&&(r.message=r.message());let s=typeof r.message;return On(s==="string"||s==="object"),Object.assign(r,{args:n},r.opts)}var Hd=O(()=>{Xl()});var $r,Bo,Xd=O(()=>{Hd();$r=()=>{},Bo=class{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,...n){return this._log("log",e,t,n)}info(e,t,...n){return this._log("info",e,t,n)}once(e,t,...n){return this._log("once",e,t,n,{once:!0})}_log(e,t,n,s,i={}){let o=jd({logLevel:t,message:n,args:this._buildArgs(t,n,s),opts:i});return this._createLogFunction(e,o,i)}_buildArgs(e,t,n){return[e,t,...n]}_createLogFunction(e,t,n){if(!this._shouldLog(t.logLevel))return $r;let s=this._getOnceTag(n.tag??t.tag??t.message);if((n.once||t.once)&&s!==void 0){if(this._onceCache.has(s))return $r;this._onceCache.add(s)}return this._emit(e,t)}_shouldLog(e){return this.getLevel()>=Yl(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}});function Sb(r){try{let e=window[r],t="__storage_test__";return e.setItem(t,t),e.removeItem(t),e}catch{return null}}var Lo,Yd=O(()=>{Lo=class{constructor(e,t,n="sessionStorage"){this.storage=Sb(n),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let t=JSON.stringify(this.config);this.storage.setItem(this.id,t)}}_loadConfiguration(){let e={};if(this.storage){let t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}});function qd(r){let e;return r<10?e=`${r.toFixed(2)}ms`:r<100?e=`${r.toFixed(1)}ms`:r<1e3?e=`${r.toFixed(0)}ms`:e=`${(r/1e3).toFixed(2)}s`,e}function Kd(r,e=8){let t=Math.max(e-r.length,0);return`${" ".repeat(t)}${r}`}var Zd=O(()=>{});function Gd(r){return typeof r!="string"?r:(r=r.toUpperCase(),Uo[r]||Uo.WHITE)}function Qd(r,e,t){return!Wr&&typeof r=="string"&&(e&&(r=`\x1B[${Gd(e)}m${r}\x1B[39m`),t&&(r=`\x1B[${Gd(t)+Eb}m${r}\x1B[49m`)),r}var Uo,Eb,Jd=O(()=>{Fo();(function(r){r[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"})(Uo||(Uo={}));Eb=10});function ep(r,e=["constructor"]){let t=Object.getPrototypeOf(r),n=Object.getOwnPropertyNames(t),s=r;for(let i of n){let o=s[i];typeof o=="function"&&(e.find(a=>i===a)||(s[i]=o.bind(r)))}}var tp=O(()=>{});function kn(){let r;if(Wr()&&No.performance)r=No?.performance?.now?.();else if("hrtime"in Do){let e=Do?.hrtime?.();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var rp=O(()=>{Fo()});function Rb(r,e,t){if(typeof e=="string"){let n=t.time?Kd(qd(t.total)):"";e=t.time?`${r}: ${n} ${e}`:`${r}: ${e}`,e=Qd(e,t.color,t.background)}return e}function Ib(r){for(let e in r)for(let t in r[e])return t||"untitled";return"empty"}var Nn,ql,Ie,Kl=O(()=>{Fo();Xd();Yd();Zd();Jd();tp();Xl();rp();Nn={debug:Wr()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},ql={enabled:!0,level:0},Ie=class extends Bo{constructor({id:e}={id:""}){super({level:0}),this.VERSION=Hl,this._startTs=kn(),this._deltaTs=kn(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Lo(`__probe-${this.id}__`,{[this.id]:ql}),this.timeStamp(`${this.id} started`),ep(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((kn()-this._startTs).toPrecision(10))}getDelta(){return Number((kn()-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 new Error(t||"Assertion failed")}warn(e,...t){return this._log("warn",0,e,t,{method:Nn.warn,once:!0})}error(e,...t){return this._log("error",0,e,t,{method:Nn.error})}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t,...n){return this._log("log",e,t,n,{method:Nn.log,time:!0,once:!0})}log(e,t,...n){return this._log("log",e,t,n,{method:Nn.debug})}info(e,t,...n){return this._log("info",e,t,n,{method:console.info})}once(e,t,...n){return this._log("once",e,t,n,{method:Nn.debug||Nn.info,once:!0})}table(e,t,n){return t?this._log("table",e,t,n&&[n]||[],{method:console.table||$r,tag:Ib(t)}):$r}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||$r})}group(e,t,n={collapsed:!1}){let s=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,t,[],{method:s})}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||$r})}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,t){let n=t.method;On(n),t.total=this.getTotal(),t.delta=this.getDelta(),this._deltaTs=kn();let s=Rb(this.id,t.message,t);return n.bind(console,s,...t.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(ql),this._storage.config[this.id]}_updateConfiguration(e){let t=this._storage.config[this.id]||{...ql};this._storage.setConfiguration({[this.id]:{...t,...e}})}};Ie.VERSION=Hl});var np=O(()=>{globalThis.probe={}});var XR,Cs=O(()=>{Kl();Kl();np();XR=new Ie({id:"@probe.gl/log"})});var I,jt=O(()=>{Cs();I=new Ie({id:"luma.gl"})});function dr(r="id"){Zl[r]=Zl[r]||1;let e=Zl[r]++;return`${r}-${e}`}var Zl,Ms=O(()=>{Zl={}});function Pb(r,e){let t={...e};for(let n in r)r[n]!==void 0&&(t[n]=r[n]);return t}var j,Pe=O(()=>{Ms();j=class{toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;_attachedResources=new Set;constructor(e,t,n){if(!e)throw new Error("no device");this._device=e,this.props=Pb(t,n);let s=this.props.id!=="undefined"?this.props.id:dr(this[Symbol.toStringTag]);this.props.id=s,this.id=s,this.userData=this.props.userData||{},this.addStats()}destroy(){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 Object.values(this._attachedResources))e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0}removeStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get(`${t}s Active`).decrementCount()}trackAllocatedMemory(e,t=this[Symbol.toStringTag]){let n=this._device.statsManager.getStats("Resource Counts");n.get("GPU Memory").addCount(e),n.get(`${t} Memory`).addCount(e),this.allocatedBytes=e}trackDeallocatedMemory(e=this[Symbol.toStringTag]){let t=this._device.statsManager.getStats("Resource Counts");t.get("GPU Memory").subtractCount(this.allocatedBytes),t.get(`${e} Memory`).subtractCount(this.allocatedBytes),this.allocatedBytes=0}addStats(){let e=this._device.statsManager.getStats("Resource Counts"),t=this[Symbol.toStringTag];e.get("Resources Created").incrementCount(),e.get(`${t}s Created`).incrementCount(),e.get(`${t}s Active`).incrementCount()}};L(j,"defaultProps",{id:"undefined",handle:void 0,userData:void 0})});var Os,W,Vo=O(()=>{Pe();Os=class extends j{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,t){let n={...t};(t.usage||0)&Os.INDEX&&!t.indexType&&(t.data instanceof Uint32Array?n.indexType="uint32":t.data instanceof Uint16Array?n.indexType="uint16":t.data instanceof Uint8Array&&(n.indexType="uint8")),delete n.data,super(e,n,Os.defaultProps),this.usage=n.usage||0,this.indexType=n.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}debugData=new ArrayBuffer(0);_setDebugData(e,t,n){let s=ArrayBuffer.isView(e)?e.buffer:e,i=Math.min(e?e.byteLength:n,Os.DEBUG_DATA_MAX_LENGTH);s===null?this.debugData=new ArrayBuffer(i):t===0&&n===s.byteLength?this.debugData=s.slice(0,i):this.debugData=s.slice(t,t+i)}},W=Os;L(W,"INDEX",16),L(W,"VERTEX",32),L(W,"UNIFORM",64),L(W,"STORAGE",128),L(W,"INDIRECT",256),L(W,"QUERY_RESOLVE",512),L(W,"MAP_READ",1),L(W,"MAP_WRITE",2),L(W,"COPY_SRC",4),L(W,"COPY_DST",8),L(W,"DEBUG_DATA_MAX_LENGTH",32),L(W,"defaultProps",{...j.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0})});function ks(r){let[e,t,n]=Ql[r],s=r.includes("norm"),i=!s&&!r.startsWith("float"),o=r.startsWith("s");return{signedType:e,primitiveType:t,byteLength:n,normalized:s,integer:i,signed:o}}function Gl(r){let e=r;switch(e){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return e}}function sp(r,e){switch(e){case 1:return r;case 2:return r+r%2;default:return r+(4-r%4)%4}}function jr(r){let e=ArrayBuffer.isView(r)?r.constructor:r;if(e===Uint8ClampedArray)return"uint8";let t=Object.values(Ql).find(n=>e===n[4]);if(!t)throw new Error(e.name);return t[0]}function Hr(r){let[,,,,e]=Ql[r];return e}var Ql,Ns=O(()=>{Ql={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 Dn(r){let e;r.endsWith("-webgl")&&(r.replace("-webgl",""),e=!0);let[t,n]=r.split("x"),s=t,i=n?parseInt(n):1,o=ks(s),a={type:s,components:i,byteLength:o.byteLength*i,integer:o.integer,signed:o.signed,normalized:o.normalized};return e&&(a.webglOnly=!0),a}function ip(r,e,t){let n=t?Gl(r):r;switch(n){case"unorm8":return e===1?"unorm8":e===3?"unorm8x3-webgl":`${n}x${e}`;case"snorm8":case"uint8":case"sint8":case"uint16":case"sint16":case"unorm16":case"snorm16":case"float16":if(e===1||e===3)throw new Error(`size: ${e}`);return`${n}x${e}`;default:return e===1?n:`${n}x${e}`}}function Jl(r,e,t){if(!e||e>4)throw new Error(`size ${e}`);let n=e,s=jr(r);return ip(s,n,t)}function op(r){let e;switch(r.primitiveType){case"f32":e="float32";break;case"i32":e="sint32";break;case"u32":e="uint32";break;case"f16":return r.components<=2?"float16x2":"float16x4"}return r.components===1?e:`${e}x${r.components}`}var zo=O(()=>{Ns()});function su(r){let e=Nb[r];if(!e)throw new Error(`Unsupported texture format ${r}`);return e}var Se,se,St,Cb,Wo,eu,$o,tu,Mb,ru,Ds,nu,jo,ap,Ob,kb,Nb,cp=O(()=>{Se="texture-compression-bc",se="texture-compression-astc",St="texture-compression-etc2",Cb="texture-compression-etc1-webgl",Wo="texture-compression-pvrtc-webgl",eu="texture-compression-atc-webgl",$o="float32-renderable-webgl",tu="float16-renderable-webgl",Mb="rgb9e5ufloat-renderable-webgl",ru="snorm8-renderable-webgl",Ds="norm16-renderable-webgl",nu="snorm16-renderable-webgl",jo="float32-filterable",ap="float16-filterable-webgl";Ob={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:ru},rg8snorm:{render:ru},"rgb8snorm-webgl":{},rgba8snorm:{render:ru},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:Ds},rg16unorm:{render:Ds},"rgb16unorm-webgl":{f:Ds},rgba16unorm:{render:Ds},r16snorm:{f:nu},rg16snorm:{render:nu},"rgb16snorm-webgl":{f:Ds},rgba16snorm:{render:nu},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:tu,filter:"float16-filterable-webgl"},rg16float:{render:tu,filter:ap},rgba16float:{render:tu,filter:ap},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:$o,filter:jo},rg32float:{render:!1,filter:jo},"rgb32float-webgl":{render:$o,filter:jo},rgba32float:{render:$o,filter:jo},"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:Mb},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:$o},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}},kb={"bc1-rgb-unorm-webgl":{f:Se},"bc1-rgb-unorm-srgb-webgl":{f:Se},"bc1-rgba-unorm":{f:Se},"bc1-rgba-unorm-srgb":{f:Se},"bc2-rgba-unorm":{f:Se},"bc2-rgba-unorm-srgb":{f:Se},"bc3-rgba-unorm":{f:Se},"bc3-rgba-unorm-srgb":{f:Se},"bc4-r-unorm":{f:Se},"bc4-r-snorm":{f:Se},"bc5-rg-unorm":{f:Se},"bc5-rg-snorm":{f:Se},"bc6h-rgb-ufloat":{f:Se},"bc6h-rgb-float":{f:Se},"bc7-rgba-unorm":{f:Se},"bc7-rgba-unorm-srgb":{f:Se},"etc2-rgb8unorm":{f:St},"etc2-rgb8unorm-srgb":{f:St},"etc2-rgb8a1unorm":{f:St},"etc2-rgb8a1unorm-srgb":{f:St},"etc2-rgba8unorm":{f:St},"etc2-rgba8unorm-srgb":{f:St},"eac-r11unorm":{f:St},"eac-r11snorm":{f:St},"eac-rg11unorm":{f:St},"eac-rg11snorm":{f:St},"astc-4x4-unorm":{f:se},"astc-4x4-unorm-srgb":{f:se},"astc-5x4-unorm":{f:se},"astc-5x4-unorm-srgb":{f:se},"astc-5x5-unorm":{f:se},"astc-5x5-unorm-srgb":{f:se},"astc-6x5-unorm":{f:se},"astc-6x5-unorm-srgb":{f:se},"astc-6x6-unorm":{f:se},"astc-6x6-unorm-srgb":{f:se},"astc-8x5-unorm":{f:se},"astc-8x5-unorm-srgb":{f:se},"astc-8x6-unorm":{f:se},"astc-8x6-unorm-srgb":{f:se},"astc-8x8-unorm":{f:se},"astc-8x8-unorm-srgb":{f:se},"astc-10x5-unorm":{f:se},"astc-10x5-unorm-srgb":{f:se},"astc-10x6-unorm":{f:se},"astc-10x6-unorm-srgb":{f:se},"astc-10x8-unorm":{f:se},"astc-10x8-unorm-srgb":{f:se},"astc-10x10-unorm":{f:se},"astc-10x10-unorm-srgb":{f:se},"astc-12x10-unorm":{f:se},"astc-12x10-unorm-srgb":{f:se},"astc-12x12-unorm":{f:se},"astc-12x12-unorm-srgb":{f:se},"pvrtc-rgb4unorm-webgl":{f:Wo},"pvrtc-rgba4unorm-webgl":{f:Wo},"pvrtc-rbg2unorm-webgl":{f:Wo},"pvrtc-rgba2unorm-webgl":{f:Wo},"etc1-rbg-unorm-webgl":{f:Cb},"atc-rgb-unorm-webgl":{f:eu},"atc-rgba-unorm-webgl":{f:eu},"atc-rgbai-unorm-webgl":{f:eu}},Nb={...Ob,...kb}});function lp(r){let e=Bb(r);if(Ht.isCompressed(r)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0;let n=Lb(r);n&&(e.blockWidth=n.blockWidth,e.blockHeight=n.blockHeight)}let t=Fb.exec(r);if(t){let[,n,s,i,o,a]=t,c=`${i}${s}`,l=ks(c),u=l.byteLength*8,f=n.length,h=[u,f>=2?u:0,f>=3?u:0,f>=4?u:0];e={format:r,attachment:e.attachment,dataType:l.signedType,components:f,channels:n,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:h,bytesPerPixel:l.byteLength*n.length,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),o==="-srgb"&&(e.srgb=!0)}return r.endsWith("-webgl")&&(e.webgl=!0),r.endsWith("-srgb")&&(e.srgb=!0),e}function Bb(r){let e=su(r),t=e.bytesPerPixel||1,n=e.bitsPerChannel||[8,8,8,8];return delete e.bitsPerChannel,delete e.bytesPerPixel,delete e.f,delete e.render,delete e.filter,delete e.blend,delete e.store,{...e,format:r,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:t,bitsPerChannel:n,dataType:e.dataType||"uint8",srgb:e.srgb??!1,packed:e.packed??!1,webgl:e.webgl??!1,integer:e.integer??!1,signed:e.signed??!1,normalized:e.normalized??!1,compressed:e.compressed??!1}}function Lb(r){let t=/.*-(\d+)x(\d+)-.*/.exec(r);if(t){let[,n,s]=t;return{blockWidth:Number(n),blockHeight:Number(s)}}return null}var Db,Fb,Ho,Ht,iu=O(()=>{Ns();cp();Db=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Fb=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,Ho=class{getInfo(e){return lp(e)}isColor(e){return e.startsWith("rgba")||e.startsWith("bgra")||e.startsWith("rgb")}isDepthStencil(e){return e.startsWith("depth")||e.startsWith("stencil")}isCompressed(e){return Db.some(t=>e.startsWith(t))}getCapabilities(e){let t=su(e),n={format:e,create:t.f??!0,render:t.render??!0,filter:t.filter??!0,blend:t.blend??!0,store:t.store??!0},s=lp(e),i=e.startsWith("depth")||e.startsWith("stencil"),o=s?.signed,a=s?.integer,c=s?.webgl;return n.render&&=!o,n.filter&&=!i&&!o&&!a&&!c,n}},Ht=new Ho});function up(r){return typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement||typeof VideoFrame<"u"&&r instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas}function fp(r){if(typeof ImageData<"u"&&r instanceof ImageData||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas)return{width:r.width,height:r.height};if(typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement)return{width:r.naturalWidth,height:r.naturalHeight};if(typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement)return{width:r.videoWidth,height:r.videoHeight};if(typeof VideoFrame<"u"&&r instanceof VideoFrame)return{width:r.displayWidth,height:r.displayHeight};throw new Error("Unknown image type")}var hp=O(()=>{});var Fs,Bs,ou,Fe,au=O(()=>{jl();jt();Ms();Vo();zo();iu();hp();Fs=class{},Bs=class{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)}},ou=class{get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=ko;timestamp=0;_reused=!1;_lumaData={};_textureCaps={};constructor(e){this.props={...ou.defaultProps,...e},this.id=this.props.id||dr(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return Dn(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return Ht.getInfo(e)}getTextureFormatCapabilities(e){let t=this._textureCaps[e];if(!t){let n=this._getDeviceTextureFormatCapabilities(e);t=this._getDeviceSpecificTextureFormatCapabilities(n),this._textureCaps[e]=t}return t}getMipLevelCount(e,t,n=1){let s=Math.max(e,t,n);return 1+Math.floor(Math.log2(s))}isExternalImage(e){return up(e)}getExternalImageSize(e){return fp(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 Ht.isCompressed(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,...n){return this.props.onError(e,t)?()=>{}:I.error(e.message,t,...n)}debug(){if(this.props.debug)debugger;else{let e=`'Type luma.log.set({debug: true}) in console to enable debug breakpoints',
8
+ or create a device with the 'debug: true' prop.`;I.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let t=Ht.getCapabilities(e),n=i=>(typeof i=="string"?this.features.has(i):i)??!0,s=n(t.create);return{format:e,create:s,render:s&&n(t.render),filter:s&&n(t.filter),blend:s&&n(t.blend),store:s&&n(t.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let t={...e};if((e.usage||0)&W.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 new Error("indices buffer content must be of type uint16 or uint32");return t}},Fe=ou;L(Fe,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,t)=>{},onResize:(e,t)=>{let[n,s]=e.getDevicePixelSize();I.log(1,`${e} resized => ${n}x${s}px`)()},onPositionChange:(e,t)=>{let[n,s]=e.getPosition();I.log(1,`${e} repositioned => ${n},${s}`)()},onVisibilityChange:e=>I.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,t)=>I.log(1,`${e} DPR changed ${t.oldRatio} => ${e.devicePixelRatio}`)(),debug:I.get("debug")||void 0,debugShaders:I.get("debug-shaders")||void 0,debugFramebuffers:Boolean(I.get("debug-framebuffers")),debugFactories:Boolean(I.get("debug-factories")),debugWebGL:Boolean(I.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!1,_cachePipelines:!1,_cacheDestroyPolicy:"unused",_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0})});var Ub,dp,Yo,Xo,pr,pp=O(()=>{au();jl();jt();Ub="set luma.log.level=1 (or higher) to trace rendering",dp="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",Yo=class{stats=ko;log=I;VERSION="9.2.6";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw I.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),I.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");I.error("This version of luma.gl has already been initialized")()}I.log(1,`${this.VERSION} - ${Ub}`)(),globalThis.luma=this}async createDevice(e={}){let t={...Yo.defaultProps,...e},n=this.selectAdapter(t.type,t.adapters);if(!n)throw new Error(dp);return t.waitForPageLoad&&await n.pageLoaded,await n.create(t)}async attachDevice(e,t){let n=this._getTypeFromHandle(e,t.adapters),s=n&&this.selectAdapter(n,t.adapters);if(!s)throw new Error(dp);return await s?.attach?.(e,t)}registerAdapters(e){for(let t of e)this.preregisteredAdapters.set(t.type,t)}getSupportedAdapters(e=[]){let t=this._getAdapterMap(e);return Array.from(t).map(([,n])=>n).filter(n=>n.isSupported?.()).map(n=>n.type)}getBestAvailableAdapterType(e=[]){let t=["webgpu","webgl","null"],n=this._getAdapterMap(e);for(let s of t)if(n.get(s)?.isSupported?.())return s;return null}selectAdapter(e,t=[]){let n=e;e==="best-available"&&(n=this.getBestAvailableAdapterType(t));let s=this._getAdapterMap(t);return n&&s.get(n)||null}enforceWebGL2(e=!0,t=[]){let s=this._getAdapterMap(t).get("webgl");s||I.warn("enforceWebGL2: webgl adapter not found")(),s?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(Yo.defaultProps,e)}_getAdapterMap(e=[]){let t=new Map(this.preregisteredAdapters);for(let n of e)t.set(n.type,n);return t}_getTypeFromHandle(e,t=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?I.warn("WebGL1 is not supported",e)():I.warn("Unknown handle type",e)(),null)}},Xo=Yo;L(Xo,"defaultProps",{...Fe.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});pr=new Xo});var RI,II,PI,mp,gp=O(()=>{RI=globalThis.document||{},II=globalThis.process||{},PI=globalThis.console,mp=globalThis.navigator||{}});function qo(r){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,t=r||e;return Boolean(t&&t.indexOf("Electron")>=0)}var cu=O(()=>{});function Xt(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||qo()}var lu=O(()=>{cu()});function uu(r){return!r&&!Xt()?"Node":qo(r)?"Electron":(r||mp.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var _p=O(()=>{lu();cu();gp()});var Ls=O(()=>{lu();_p()});function Wb(){return Ko||(zb()||typeof window>"u"?Ko=Promise.resolve():Ko=new Promise(r=>window.addEventListener("load",()=>r()))),Ko}var Us,Vb,zb,Ko,yp=O(()=>{Ls();Us=class{get pageLoaded(){return Wb()}},Vb=Xt()&&typeof document<"u",zb=()=>Vb&&document.readyState==="complete",Ko=null});function xp(){let r,e;return{promise:new Promise((n,s)=>{r=n,e=s}),resolve:r,reject:e}}var bp=O(()=>{});function $b(r){if(typeof r=="string"){let e=document.getElementById(r);if(!e)throw new Error(`${r} is not an HTML element`);return e}return r||document.body}function jb(r){let e=document.getElementById(r);if(!Xr.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function Hb(r){let{width:e,height:t}=r,n=document.createElement("canvas");n.id=dr("lumagl-auto-created-canvas"),n.width=e||1,n.height=t||1,n.style.width=Number.isFinite(e)?`${e}px`:"100%",n.style.height=Number.isFinite(t)?`${t}px`:"100%",r?.visible||(n.style.visibility="hidden");let s=$b(r?.container||null);return s.insertBefore(n,s.firstChild),n}function Xb(r,e,t,n,s){let i=r,o=Tp(i[0],e,t),a=wp(i[1],e,n,s),c=Tp(i[0]+1,e,t),l=c===t-1?c:c-1;c=wp(i[1]+1,e,n,s);let u;return s?(c=c===0?c:c+1,u=a,a=c):u=c===n-1?c:c-1,{x:o,y:a,width:Math.max(l-o+1,1),height:Math.max(u-a+1,1)}}function Tp(r,e,t){return Math.min(Math.round(r*e),t-1)}function wp(r,e,t,n){return n?Math.max(0,t-1-Math.round(r*e)):Math.min(Math.round(r*e),t-1)}var Fn,Xr,vp=O(()=>{Ls();Ms();bp();Fn=class{static isHTMLCanvas(e){return typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement}static isOffscreenCanvas(e){return typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas}id;props;canvas;htmlCanvas;offscreenCanvas;type;initialized;isInitialized=!1;isVisible=!0;cssWidth;cssHeight;devicePixelRatio;devicePixelWidth;devicePixelHeight;drawingBufferWidth;drawingBufferHeight;_initializedResolvers=xp();_resizeObserver;_intersectionObserver;_position;destroyed=!1;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){if(this.props={...Fn.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,Xt()?e.canvas?typeof e.canvas=="string"?this.canvas=jb(e.canvas):this.canvas=e.canvas:this.canvas=Hb(e):this.canvas={width:e.width||1,height:e.height||1},Fn.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):Fn.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],Fn.isHTMLCanvas(this.canvas)){this._intersectionObserver=new IntersectionObserver(t=>this._handleIntersection(t)),this._intersectionObserver.observe(this.canvas),this._resizeObserver=new ResizeObserver(t=>this._handleResize(t));try{this._resizeObserver.observe(this.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.canvas,{box:"content-box"})}setTimeout(()=>this._observeDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}destroy(){this.destroyed=!0}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}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){this.canvas.width=e,this.canvas.height=t,this.drawingBufferWidth=e,this.drawingBufferHeight=t}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,t=!0){let n=this.cssToDeviceRatio(),[s,i]=this.getDrawingBufferSize();return Xb(e,n,s,i,t)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,t]=this.getDevicePixelSize();return e/t}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)}_handleIntersection(e){let t=e.find(s=>s.target===this.canvas);if(!t)return;let n=t.isIntersecting;this.isVisible!==n&&(this.isVisible=n,this.device.props.onVisibilityChange(this))}_handleResize(e){let t=e.find(c=>c.target===this.canvas);if(!t)return;this.cssWidth=t.contentBoxSize[0].inlineSize,this.cssHeight=t.contentBoxSize[0].blockSize;let n=this.getDevicePixelSize(),s=t.devicePixelContentBoxSize?.[0].inlineSize||t.contentBoxSize[0].inlineSize*devicePixelRatio,i=t.devicePixelContentBoxSize?.[0].blockSize||t.contentBoxSize[0].blockSize*devicePixelRatio,[o,a]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(s,o)),this.devicePixelHeight=Math.max(1,Math.min(i,a)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:n})}_updateDrawingBufferSize(){if(this.props.autoResize){if(typeof this.props.useDevicePixels=="number"){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._updateDevice()}this._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_observeDevicePixelRatio(){let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange(this,{oldRatio:e}),matchMedia(`(resolution: ${this.devicePixelRatio}dppx)`).addEventListener("change",()=>this._observeDevicePixelRatio(),{once:!0})}_trackPosition(e=100){let t=setInterval(()=>{this.destroyed?clearInterval(t):this.updatePosition()},e)}updatePosition(){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 s=this._position;this._position=t,this.device.props.onPositionChange?.(this,{oldPosition:s})}}}},Xr=Fn;L(Xr,"defaultProps",{id:void 0,canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,alphaMode:"opaque",colorSpace:"srgb",trackPosition:!1})});var Zo,Ke,fu=O(()=>{Pe();Zo=class extends j{get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){t=Zo.normalizeProps(e,t),super(e,t,Zo.defaultProps)}static normalizeProps(e,t){return t}},Ke=Zo;L(Ke,"defaultProps",{...j.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})});var Yb,Yt,K,hu=O(()=>{Pe();fu();jt();Yb={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Yt=class extends j{dimension;baseDimension;format;width;height;depth;mipLevels;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,t){if(t=Yt.normalizeProps(e,t),super(e,t,Yt.defaultProps),this.dimension=this.props.dimension,this.baseDimension=Yb[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.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(t.data)){let n=e.getExternalImageSize(t.data);this.width=n?.width||1,this.height=n?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&I.warn(`${this} created with undefined width or height. This is deprecated. Use AsyncTexture instead.`)();this.updateTimestamp=e.incrementTimestamp()}setSampler(e){this.sampler=e instanceof Ke?e:this.device.createSampler(e)}clone(e){return this.device.createTexture({...this.props,...e})}static normalizeProps(e,t){let n={...t},{width:s,height:i}=n;return typeof s=="number"&&(n.width=Math.max(1,Math.ceil(s))),typeof i=="number"&&(n.height=Math.max(1,Math.ceil(i))),n}_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{width:t,height:n,depth:s}=this,i={...Yt.defaultCopyDataOptions,width:t,height:n,depth:s,...e},o=this.device.getTextureFormatInfo(this.format);if(!e.bytesPerRow&&!o.bytesPerPixel)throw new Error(`bytesPerRow must be provided for texture format ${this.format}`);return i.bytesPerRow=e.bytesPerRow||t*(o.bytesPerPixel||4),i.rowsPerImage=e.rowsPerImage||n,i}_normalizeCopyExternalImageOptions(e){let t=this.device.getExternalImageSize(e.image),n={...Yt.defaultCopyExternalImageOptions,...t,...e};return n.width=Math.min(n.width,this.width-n.x),n.height=Math.min(n.height,this.height-n.y),n}},K=Yt;L(K,"SAMPLE",4),L(K,"STORAGE",8),L(K,"RENDER",16),L(K,"COPY_SRC",1),L(K,"COPY_DST",2),L(K,"TEXTURE",4),L(K,"RENDER_ATTACHMENT",16),L(K,"defaultProps",{...j.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:Yt.TEXTURE|Yt.RENDER_ATTACHMENT|Yt.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),L(K,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),L(K,"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})});var du,mr,Ap=O(()=>{Pe();du=class extends j{get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,du.defaultProps)}},mr=du;L(mr,"defaultProps",{...j.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0})});function Sp(r,e,t){let n="",s=e.split(/\r?\n/),i=r.slice().sort((o,a)=>o.lineNum-a.lineNum);switch(t?.showSourceCode||"no"){case"all":let o=0;for(let a=1;a<=s.length;a++)for(n+=Ep(s[a-1],a,t);i.length>o&&i[o].lineNum===a;){let c=i[o++];n+=pu(c,s,c.lineNum,{...t,inlineSource:!1})}for(;i.length>o;){let a=i[o++];n+=pu(a,[],0,{...t,inlineSource:!1})}return n;case"issues":case"no":for(let a of r)n+=pu(a,s,a.lineNum,{inlineSource:t?.showSourceCode!=="no"});return n}}function pu(r,e,t,n){if(n?.inlineSource){let i=qb(e,t),o=r.linePos>0?`${" ".repeat(r.linePos+5)}^^^
9
9
  `:"";return`
10
10
  ${i}${o}${r.type.toUpperCase()}: ${r.message}
11
11
 
12
- `}let s=r.type==="error"?"red":"#8B4000";return n?.html?`<div class='luma-compiler-log-error' style="color:${s};"><b> ${r.type.toUpperCase()}: ${r.message}</b></div>`:`${r.type.toUpperCase()}: ${r.message}`}function Lb(r,e,t){let n="";for(let s=e-2;s<=e;s++){let i=r[s-1];i!==void 0&&(n+=mp(i,e,t))}return n}function mp(r,e,t){let n=t?.html?Vb(r):r;return`${Ub(String(e),4)}: ${n}${t?.html?"<br/>":`
13
- `}`}function Ub(r,e){let t="";for(let n=r.length;n<e;++n)t+=" ";return t+r}function Vb(r){return r.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}var gp=O(()=>{});function zb(r){return Wb(r.source)||r.id||pr(`unnamed ${r.stage}-shader`)}function Wb(r,e="unnamed"){let n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(r);return n?n[1]:e}var au,_r,_p=O(()=>{Pe();Cs();gp();au=class extends j{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){t={...t,debugShaders:t.debugShaders||e.props.debugShaders||"errors"},super(e,{id:zb(t),...t},au.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(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let t=await this.getCompilationInfo();e==="warnings"&&t?.length===0||this._displayShaderLog(t,this.id)}_displayShaderLog(e,t){if(typeof document>"u"||!document?.createElement)return;let n=t,s=`${this.stage} shader "${n}"`,i=pp(e,this.source,{showSourceCode:"all",html:!0}),o=this.getTranslatedSource();o&&(i+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${o}</pre></code>`);let a=document.createElement("Button");a.innerHTML=`
12
+ `}let s=r.type==="error"?"red":"#8B4000";return n?.html?`<div class='luma-compiler-log-error' style="color:${s};"><b> ${r.type.toUpperCase()}: ${r.message}</b></div>`:`${r.type.toUpperCase()}: ${r.message}`}function qb(r,e,t){let n="";for(let s=e-2;s<=e;s++){let i=r[s-1];i!==void 0&&(n+=Ep(i,e,t))}return n}function Ep(r,e,t){let n=t?.html?Zb(r):r;return`${Kb(String(e),4)}: ${n}${t?.html?"<br/>":`
13
+ `}`}function Kb(r,e){let t="";for(let n=r.length;n<e;++n)t+=" ";return t+r}function Zb(r){return r.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}var Rp=O(()=>{});function Gb(r){return Qb(r.source)||r.id||dr(`unnamed ${r.stage}-shader`)}function Qb(r,e="unnamed"){let n=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(r);return n?n[1]:e}var mu,gr,Ip=O(()=>{Pe();Ms();Rp();mu=class extends j{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){t={...t,debugShaders:t.debugShaders||e.props.debugShaders||"errors"},super(e,{id:Gb(t),...t},mu.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(this.compilationStatus==="success")return;break;case"warnings":case"always":break}let t=await this.getCompilationInfo();e==="warnings"&&t?.length===0||this._displayShaderLog(t,this.id)}_displayShaderLog(e,t){if(typeof document>"u"||!document?.createElement)return;let n=t,s=`${this.stage} shader "${n}"`,i=Sp(e,this.source,{showSourceCode:"all",html:!0}),o=this.getTranslatedSource();o&&(i+=`<br /><br /><h1>Translated Source</h1><br /><br /><code style="user-select:text;"><pre>${o}</pre></code>`);let a=document.createElement("Button");a.innerHTML=`
14
14
  <h1>Compilation error in ${s}</h1><br /><br />
15
15
  <code style="user-select:text;"><pre>
16
16
  ${i}
17
- </pre></code>`,a.style.top="10px",a.style.left="10px",a.style.position="absolute",a.style.zIndex="9999",a.style.width="100%",a.style.textAlign="left",document.body.appendChild(a),document.getElementsByClassName("luma-compiler-log-error")[0]?.scrollIntoView(),a.onclick=()=>{let l=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(l)}}},_r=au;L(_r,"defaultProps",{...j.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0})});var cu,It,yp=O(()=>{Pe();su();Xt();cu=class extends j{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,cu.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(s=>s.texture.clone(e)),n=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,colorAttachments:t,depthStencilAttachment:n})}resize(e){let t=!e;if(e){let[n,s]=Array.isArray(e)?e:[e.width,e.height];t=t||s!==this.height||n!==this.width,this.width=n,this.height=s}t&&(I.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((t,n)=>{if(typeof t=="string"){let s=this.createColorTexture(t,n);return this.attachResource(s),s.view}return t instanceof K?t.view:t});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof K?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:K.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:K.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let n=0;n<this.colorAttachments.length;++n)if(this.colorAttachments[n]){let s=this.colorAttachments[n].texture.clone({width:e,height:t});this.destroyAttachedResource(this.colorAttachments[n]),this.colorAttachments[n]=s.view,this.attachResource(s.view)}if(this.depthStencilAttachment){let n=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}this.updateAttachments()}},It=cu;L(It,"defaultProps",{...j.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null})});var lu,Qe,xp=O(()=>{Pe();lu=class extends j{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(e,t){super(e,t,lu.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}},Qe=lu;L(Qe,"defaultProps",{...j.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}})});var Xr,Kt,bp=O(()=>{Pe();Xr=class extends j{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){t=Xr.normalizeProps(e,t),super(e,t,Xr.defaultProps)}static normalizeProps(e,t){return t}},Kt=Xr;L(Kt,"defaultClearColor",[0,0,0,1]),L(Kt,"defaultClearDepth",1),L(Kt,"defaultClearStencil",0),L(Kt,"defaultProps",{...j.defaultProps,framebuffer:null,parameters:void 0,clearColor:Xr.defaultClearColor,clearColors:void 0,clearDepth:Xr.defaultClearDepth,clearStencil:Xr.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0})});var uu,Yr,Tp=O(()=>{Pe();uu=class extends j{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,uu.defaultProps),this.shaderLayout=t.shaderLayout}},Yr=uu;L(Yr,"defaultProps",{...j.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0})});var fu,Nn,wp=O(()=>{Pe();fu=class extends j{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,fu.defaultProps)}},Nn=fu;L(Nn,"defaultProps",{...j.defaultProps,measureExecutionTime:void 0})});var hu,Dn,vp=O(()=>{Pe();hu=class extends j{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,hu.defaultProps)}},Dn=hu;L(Dn,"defaultProps",{...j.defaultProps})});function Ls(r){return Hb[r]}function du(r){let[e,t]=jb[r],n=e==="i32"||e==="u32",s=e!=="u32",i=$b[e]*t;return{primitiveType:e,components:t,byteLength:i,integer:n,signed:s}}var $b,jb,Hb,Xb,cP,Xo=O(()=>{$b={f32:4,f16:2,i32:4,u32:4},jb={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]},Hb={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>":{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}},Xb={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>"},cP={...Xb,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>"}});function Yo(r,e){let t={};for(let n of r.attributes){let s=Yb(r,e,n.name);s&&(t[n.name]=s)}return t}function Ap(r,e,t=16){let n=Yo(r,e),s=new Array(t).fill(null);for(let i of Object.values(n))s[i.location]=i;return s}function Yb(r,e,t){let n=qb(r,t),s=Kb(e,t);if(!n)return null;let i=du(n.type),o=Qd(i),a=s?.vertexFormat||o,c=On(a);return{attributeName:s?.attributeName||n.name,bufferName:s?.bufferName||n.name,location:n.location,shaderType:n.type,primitiveType:i.primitiveType,shaderComponents:i.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:i.integer,stepMode:s?.stepMode||n.stepMode||"vertex",byteOffset:s?.byteOffset||0,byteStride:s?.byteStride||0}}function qb(r,e){let t=r.attributes.find(n=>n.name===e);return t||I.warn(`shader layout attribute "${e}" not present in shader`),t||null}function Kb(r,e){Zb(r);let t=Gb(r,e);return t||(t=Qb(r,e),t)?t:(I.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function Zb(r){for(let e of r)(e.attributes&&e.format||!e.attributes&&!e.format)&&I.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function Gb(r,e){for(let t of r)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function Qb(r,e){for(let t of r){let n=t.byteStride;if(typeof t.byteStride!="number")for(let i of t.attributes||[]){let o=On(i.format);n+=o.byteLength}let s=t.attributes?.find(i=>i.attribute===e);if(s)return{attributeName:s.attribute,bufferName:t.name,stepMode:t.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:n}}return null}var pu=O(()=>{Xt();Xo();Bo()});var mu,Fn,Sp=O(()=>{pu();Pe();mu=class extends j{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,mu.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=Ap(t.shaderLayout,t.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){this.device.reportError(new Error("constant attributes not supported"),this)()}},Fn=mu;L(Fn,"defaultProps",{...j.defaultProps,shaderLayout:void 0,bufferLayout:[]})});var gu,Bn,Ep=O(()=>{Pe();gu=class extends j{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,gu.defaultProps)}},Bn=gu;L(Bn,"defaultProps",{...j.defaultProps,layout:void 0,buffers:{}})});var _u,Ln,Rp=O(()=>{Pe();_u=class extends j{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,_u.defaultProps)}},Ln=_u;L(Ln,"defaultProps",{...j.defaultProps,type:void 0,count:void 0})});function yu(r){return(!qo||qo.byteLength<r)&&(qo=new ArrayBuffer(r)),qo}function xu(r,e){let t=yu(r.BYTES_PER_ELEMENT*e);return new r(t,0,e)}var qo,bu=O(()=>{});function Jb(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Un(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number":Jb(r)}var Tu=O(()=>{});var e0,Ko,Ip=O(()=>{ks();Xo();bu();Tu();Xt();e0=1024,Ko=class{layout={};byteLength;constructor(e,t={}){let n=0;for(let[i,o]of Object.entries(e)){let a=Ls(o),{type:c,components:l}=a,u=l*(t?.[i]??1);n=Zd(n,u);let f=n;n+=u,this.layout[i]={type:c,size:u,offset:f}}n+=(4-n%4)%4;let s=n*4;this.byteLength=Math.max(s,e0)}getData(e){let t=yu(this.byteLength),n={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)};for(let[s,i]of Object.entries(e)){let o=this.layout[s];if(!o){I.warn(`Supplied uniform value ${s} not present in uniform block layout`)();continue}let{type:a,size:c,offset:l}=o,u=n[a];if(c===1){if(typeof i!="number"&&typeof i!="boolean"){I.warn(`Supplied value for single component uniform ${s} is not a number: ${i}`)();continue}u[l]=Number(i)}else{if(!Un(i)){I.warn(`Supplied value for multi component / array uniform ${s} is not a numeric array: ${i}`)();continue}u.set(i,l)}}return new Uint8Array(t,0,this.byteLength)}has(e){return Boolean(this.layout[e])}get(e){return this.layout[e]}}});function Pp(r,e,t=16){if(r!==e)return!1;let n=r,s=e;if(!Un(n))return!1;if(Un(s)&&n.length===s.length){for(let i=0;i<n.length;++i)if(s[i]!==n[i])return!1}return!0}function Cp(r){return Un(r)?r.slice():r}var Mp=O(()=>{Tu()});var Zo,Op=O(()=>{Mp();Zo=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let t=e?.shaderLayout.bindings?.find(s=>s.type==="uniform"&&s.name===e?.name);if(!t)throw new Error(e?.name);let n=t;for(let s of n.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(e){for(let[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){Pp(this.uniforms[e],t)||(this.uniforms[e]=Cp(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}});var Us,kp=O(()=>{Fo();Xt();Op();Ip();Us=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[t,n]of Object.entries(e)){let s=t,i=new Ko(n.uniformTypes??{},n.uniformSizes??{});this.uniformBufferLayouts.set(s,i);let o=new Zo({name:t});o.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(s,o)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[t,n]of Object.entries(e))this.uniformBlocks.get(t)?.setUniforms(n);this.updateUniformBuffers()}getUniformBufferByteLength(e){return this.uniformBufferLayouts.get(e)?.byteLength||0}getUniformBufferData(e){let t=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.uniformBufferLayouts.get(e)?.getData(t)}createUniformBuffer(e,t,n){n&&this.setUniforms(n);let s=this.getUniformBufferByteLength(t),i=e.createBuffer({usage:W.UNIFORM|W.COPY_DST,byteLength:s}),o=this.getUniformBufferData(t);return i.write(o),i}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){let n=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:W.UNIFORM|W.COPY_DST,byteLength:n});this.uniformBuffers.set(t,s)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(let t of this.uniformBlocks.keys()){let n=this.updateUniformBuffer(t);e||=n}return e&&I.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let t=this.uniformBlocks.get(e),n=this.uniformBuffers.get(e),s=!1;if(n&&t?.needsRedraw){s||=t.needsRedraw;let i=this.getUniformBufferData(e);n=this.uniformBuffers.get(e),n?.write(i);let o=this.uniformBlocks.get(e)?.getAllUniforms();I.log(4,`Writing to uniform buffer ${String(e)}`,i,o)()}return s}}});var H=O(()=>{op();ap();ru();hp();Fo();su();dp();_p();nu();yp();xp();bp();Tp();wp();vp();Sp();Ep();Rp();kp();ks();Xo();Bo();eu();Xt();bu();pu()});var Br,ty=O(()=>{(function(r){r[r.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",r[r.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",r[r.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r[r.ZERO=0]="ZERO",r[r.ONE=1]="ONE",r[r.SRC_COLOR=768]="SRC_COLOR",r[r.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",r[r.SRC_ALPHA=770]="SRC_ALPHA",r[r.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",r[r.DST_ALPHA=772]="DST_ALPHA",r[r.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",r[r.DST_COLOR=774]="DST_COLOR",r[r.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",r[r.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",r[r.CONSTANT_COLOR=32769]="CONSTANT_COLOR",r[r.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",r[r.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",r[r.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",r[r.FUNC_ADD=32774]="FUNC_ADD",r[r.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",r[r.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",r[r.BLEND_EQUATION=32777]="BLEND_EQUATION",r[r.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",r[r.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",r[r.BLEND_DST_RGB=32968]="BLEND_DST_RGB",r[r.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",r[r.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",r[r.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",r[r.BLEND_COLOR=32773]="BLEND_COLOR",r[r.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",r[r.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",r[r.LINE_WIDTH=2849]="LINE_WIDTH",r[r.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",r[r.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",r[r.CULL_FACE_MODE=2885]="CULL_FACE_MODE",r[r.FRONT_FACE=2886]="FRONT_FACE",r[r.DEPTH_RANGE=2928]="DEPTH_RANGE",r[r.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",r[r.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",r[r.DEPTH_FUNC=2932]="DEPTH_FUNC",r[r.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",r[r.STENCIL_FUNC=2962]="STENCIL_FUNC",r[r.STENCIL_FAIL=2964]="STENCIL_FAIL",r[r.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",r[r.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",r[r.STENCIL_REF=2967]="STENCIL_REF",r[r.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",r[r.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",r[r.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",r[r.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",r[r.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",r[r.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",r[r.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",r[r.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",r[r.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",r[r.VIEWPORT=2978]="VIEWPORT",r[r.SCISSOR_BOX=3088]="SCISSOR_BOX",r[r.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",r[r.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",r[r.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",r[r.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",r[r.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",r[r.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",r[r.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",r[r.RED_BITS=3410]="RED_BITS",r[r.GREEN_BITS=3411]="GREEN_BITS",r[r.BLUE_BITS=3412]="BLUE_BITS",r[r.ALPHA_BITS=3413]="ALPHA_BITS",r[r.DEPTH_BITS=3414]="DEPTH_BITS",r[r.STENCIL_BITS=3415]="STENCIL_BITS",r[r.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",r[r.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",r[r.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",r[r.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",r[r.SAMPLES=32937]="SAMPLES",r[r.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",r[r.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",r[r.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",r[r.VENDOR=7936]="VENDOR",r[r.RENDERER=7937]="RENDERER",r[r.VERSION=7938]="VERSION",r[r.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",r[r.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",r[r.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",r[r.STATIC_DRAW=35044]="STATIC_DRAW",r[r.STREAM_DRAW=35040]="STREAM_DRAW",r[r.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.BUFFER_SIZE=34660]="BUFFER_SIZE",r[r.BUFFER_USAGE=34661]="BUFFER_USAGE",r[r.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",r[r.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",r[r.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",r[r.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",r[r.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",r[r.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",r[r.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",r[r.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",r[r.CULL_FACE=2884]="CULL_FACE",r[r.FRONT=1028]="FRONT",r[r.BACK=1029]="BACK",r[r.FRONT_AND_BACK=1032]="FRONT_AND_BACK",r[r.BLEND=3042]="BLEND",r[r.DEPTH_TEST=2929]="DEPTH_TEST",r[r.DITHER=3024]="DITHER",r[r.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",r[r.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",r[r.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",r[r.SCISSOR_TEST=3089]="SCISSOR_TEST",r[r.STENCIL_TEST=2960]="STENCIL_TEST",r[r.NO_ERROR=0]="NO_ERROR",r[r.INVALID_ENUM=1280]="INVALID_ENUM",r[r.INVALID_VALUE=1281]="INVALID_VALUE",r[r.INVALID_OPERATION=1282]="INVALID_OPERATION",r[r.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",r[r.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",r[r.CW=2304]="CW",r[r.CCW=2305]="CCW",r[r.DONT_CARE=4352]="DONT_CARE",r[r.FASTEST=4353]="FASTEST",r[r.NICEST=4354]="NICEST",r[r.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",r[r.BYTE=5120]="BYTE",r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.SHORT=5122]="SHORT",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.INT=5124]="INT",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.FLOAT=5126]="FLOAT",r[r.DOUBLE=5130]="DOUBLE",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.ALPHA=6406]="ALPHA",r[r.RGB=6407]="RGB",r[r.RGBA=6408]="RGBA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",r[r.VERTEX_SHADER=35633]="VERTEX_SHADER",r[r.COMPILE_STATUS=35713]="COMPILE_STATUS",r[r.DELETE_STATUS=35712]="DELETE_STATUS",r[r.LINK_STATUS=35714]="LINK_STATUS",r[r.VALIDATE_STATUS=35715]="VALIDATE_STATUS",r[r.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",r[r.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",r[r.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",r[r.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",r[r.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",r[r.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",r[r.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",r[r.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",r[r.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",r[r.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",r[r.SHADER_TYPE=35663]="SHADER_TYPE",r[r.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",r[r.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",r[r.NEVER=512]="NEVER",r[r.LESS=513]="LESS",r[r.EQUAL=514]="EQUAL",r[r.LEQUAL=515]="LEQUAL",r[r.GREATER=516]="GREATER",r[r.NOTEQUAL=517]="NOTEQUAL",r[r.GEQUAL=518]="GEQUAL",r[r.ALWAYS=519]="ALWAYS",r[r.KEEP=7680]="KEEP",r[r.REPLACE=7681]="REPLACE",r[r.INCR=7682]="INCR",r[r.DECR=7683]="DECR",r[r.INVERT=5386]="INVERT",r[r.INCR_WRAP=34055]="INCR_WRAP",r[r.DECR_WRAP=34056]="DECR_WRAP",r[r.NEAREST=9728]="NEAREST",r[r.LINEAR=9729]="LINEAR",r[r.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",r[r.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",r[r.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",r[r.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",r[r.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",r[r.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",r[r.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",r[r.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE=5890]="TEXTURE",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r[r.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",r[r.TEXTURE0=33984]="TEXTURE0",r[r.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",r[r.REPEAT=10497]="REPEAT",r[r.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r[r.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",r[r.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",r[r.FLOAT_VEC2=35664]="FLOAT_VEC2",r[r.FLOAT_VEC3=35665]="FLOAT_VEC3",r[r.FLOAT_VEC4=35666]="FLOAT_VEC4",r[r.INT_VEC2=35667]="INT_VEC2",r[r.INT_VEC3=35668]="INT_VEC3",r[r.INT_VEC4=35669]="INT_VEC4",r[r.BOOL=35670]="BOOL",r[r.BOOL_VEC2=35671]="BOOL_VEC2",r[r.BOOL_VEC3=35672]="BOOL_VEC3",r[r.BOOL_VEC4=35673]="BOOL_VEC4",r[r.FLOAT_MAT2=35674]="FLOAT_MAT2",r[r.FLOAT_MAT3=35675]="FLOAT_MAT3",r[r.FLOAT_MAT4=35676]="FLOAT_MAT4",r[r.SAMPLER_2D=35678]="SAMPLER_2D",r[r.SAMPLER_CUBE=35680]="SAMPLER_CUBE",r[r.LOW_FLOAT=36336]="LOW_FLOAT",r[r.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",r[r.HIGH_FLOAT=36338]="HIGH_FLOAT",r[r.LOW_INT=36339]="LOW_INT",r[r.MEDIUM_INT=36340]="MEDIUM_INT",r[r.HIGH_INT=36341]="HIGH_INT",r[r.FRAMEBUFFER=36160]="FRAMEBUFFER",r[r.RENDERBUFFER=36161]="RENDERBUFFER",r[r.RGBA4=32854]="RGBA4",r[r.RGB5_A1=32855]="RGB5_A1",r[r.RGB565=36194]="RGB565",r[r.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",r[r.STENCIL_INDEX=6401]="STENCIL_INDEX",r[r.STENCIL_INDEX8=36168]="STENCIL_INDEX8",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r[r.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",r[r.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",r[r.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",r[r.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",r[r.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",r[r.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",r[r.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",r[r.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",r[r.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",r[r.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",r[r.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",r[r.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",r[r.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",r[r.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",r[r.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",r[r.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",r[r.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",r[r.NONE=0]="NONE",r[r.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",r[r.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",r[r.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",r[r.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",r[r.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",r[r.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",r[r.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",r[r.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",r[r.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",r[r.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",r[r.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",r[r.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",r[r.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",r[r.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",r[r.READ_BUFFER=3074]="READ_BUFFER",r[r.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",r[r.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",r[r.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",r[r.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",r[r.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",r[r.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",r[r.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",r[r.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",r[r.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",r[r.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",r[r.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",r[r.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",r[r.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",r[r.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",r[r.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",r[r.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",r[r.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",r[r.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",r[r.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",r[r.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",r[r.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",r[r.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",r[r.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",r[r.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",r[r.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",r[r.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",r[r.RED=6403]="RED",r[r.RGB8=32849]="RGB8",r[r.RGBA8=32856]="RGBA8",r[r.RGB10_A2=32857]="RGB10_A2",r[r.TEXTURE_3D=32879]="TEXTURE_3D",r[r.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",r[r.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",r[r.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",r[r.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",r[r.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",r[r.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",r[r.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",r[r.SRGB=35904]="SRGB",r[r.SRGB8=35905]="SRGB8",r[r.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",r[r.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",r[r.RGBA32F=34836]="RGBA32F",r[r.RGB32F=34837]="RGB32F",r[r.RGBA16F=34842]="RGBA16F",r[r.RGB16F=34843]="RGB16F",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",r[r.R11F_G11F_B10F=35898]="R11F_G11F_B10F",r[r.RGB9_E5=35901]="RGB9_E5",r[r.RGBA32UI=36208]="RGBA32UI",r[r.RGB32UI=36209]="RGB32UI",r[r.RGBA16UI=36214]="RGBA16UI",r[r.RGB16UI=36215]="RGB16UI",r[r.RGBA8UI=36220]="RGBA8UI",r[r.RGB8UI=36221]="RGB8UI",r[r.RGBA32I=36226]="RGBA32I",r[r.RGB32I=36227]="RGB32I",r[r.RGBA16I=36232]="RGBA16I",r[r.RGB16I=36233]="RGB16I",r[r.RGBA8I=36238]="RGBA8I",r[r.RGB8I=36239]="RGB8I",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.R8=33321]="R8",r[r.RG8=33323]="RG8",r[r.R16F=33325]="R16F",r[r.R32F=33326]="R32F",r[r.RG16F=33327]="RG16F",r[r.RG32F=33328]="RG32F",r[r.R8I=33329]="R8I",r[r.R8UI=33330]="R8UI",r[r.R16I=33331]="R16I",r[r.R16UI=33332]="R16UI",r[r.R32I=33333]="R32I",r[r.R32UI=33334]="R32UI",r[r.RG8I=33335]="RG8I",r[r.RG8UI=33336]="RG8UI",r[r.RG16I=33337]="RG16I",r[r.RG16UI=33338]="RG16UI",r[r.RG32I=33339]="RG32I",r[r.RG32UI=33340]="RG32UI",r[r.R8_SNORM=36756]="R8_SNORM",r[r.RG8_SNORM=36757]="RG8_SNORM",r[r.RGB8_SNORM=36758]="RGB8_SNORM",r[r.RGBA8_SNORM=36759]="RGBA8_SNORM",r[r.RGB10_A2UI=36975]="RGB10_A2UI",r[r.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",r[r.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.HALF_FLOAT=5131]="HALF_FLOAT",r[r.RG=33319]="RG",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",r[r.CURRENT_QUERY=34917]="CURRENT_QUERY",r[r.QUERY_RESULT=34918]="QUERY_RESULT",r[r.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",r[r.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",r[r.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",r[r.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",r[r.DRAW_BUFFER0=34853]="DRAW_BUFFER0",r[r.DRAW_BUFFER1=34854]="DRAW_BUFFER1",r[r.DRAW_BUFFER2=34855]="DRAW_BUFFER2",r[r.DRAW_BUFFER3=34856]="DRAW_BUFFER3",r[r.DRAW_BUFFER4=34857]="DRAW_BUFFER4",r[r.DRAW_BUFFER5=34858]="DRAW_BUFFER5",r[r.DRAW_BUFFER6=34859]="DRAW_BUFFER6",r[r.DRAW_BUFFER7=34860]="DRAW_BUFFER7",r[r.DRAW_BUFFER8=34861]="DRAW_BUFFER8",r[r.DRAW_BUFFER9=34862]="DRAW_BUFFER9",r[r.DRAW_BUFFER10=34863]="DRAW_BUFFER10",r[r.DRAW_BUFFER11=34864]="DRAW_BUFFER11",r[r.DRAW_BUFFER12=34865]="DRAW_BUFFER12",r[r.DRAW_BUFFER13=34866]="DRAW_BUFFER13",r[r.DRAW_BUFFER14=34867]="DRAW_BUFFER14",r[r.DRAW_BUFFER15=34868]="DRAW_BUFFER15",r[r.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",r[r.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",r[r.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",r[r.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",r[r.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",r[r.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",r[r.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",r[r.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",r[r.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",r[r.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",r[r.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",r[r.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",r[r.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",r[r.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",r[r.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",r[r.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",r[r.SAMPLER_3D=35679]="SAMPLER_3D",r[r.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",r[r.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",r[r.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",r[r.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",r[r.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",r[r.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",r[r.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",r[r.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",r[r.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",r[r.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",r[r.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",r[r.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",r[r.MAX_SAMPLES=36183]="MAX_SAMPLES",r[r.SAMPLER_BINDING=35097]="SAMPLER_BINDING",r[r.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",r[r.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",r[r.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",r[r.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",r[r.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",r[r.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",r[r.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",r[r.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",r[r.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",r[r.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",r[r.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",r[r.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",r[r.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",r[r.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",r[r.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",r[r.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",r[r.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",r[r.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",r[r.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",r[r.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",r[r.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",r[r.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",r[r.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",r[r.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",r[r.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",r[r.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",r[r.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",r[r.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",r[r.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",r[r.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",r[r.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",r[r.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",r[r.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",r[r.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",r[r.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",r[r.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",r[r.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",r[r.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",r[r.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",r[r.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",r[r.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",r[r.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",r[r.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",r[r.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",r[r.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",r[r.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",r[r.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",r[r.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",r[r.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",r[r.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",r[r.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",r[r.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r[r.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",r[r.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",r[r.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",r[r.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",r[r.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",r[r.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",r[r.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",r[r.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",r[r.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",r[r.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",r[r.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",r[r.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",r[r.UNIFORM_TYPE=35383]="UNIFORM_TYPE",r[r.UNIFORM_SIZE=35384]="UNIFORM_SIZE",r[r.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",r[r.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",r[r.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",r[r.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",r[r.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",r[r.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",r[r.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",r[r.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",r[r.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",r[r.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",r[r.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",r[r.OBJECT_TYPE=37138]="OBJECT_TYPE",r[r.SYNC_CONDITION=37139]="SYNC_CONDITION",r[r.SYNC_STATUS=37140]="SYNC_STATUS",r[r.SYNC_FLAGS=37141]="SYNC_FLAGS",r[r.SYNC_FENCE=37142]="SYNC_FENCE",r[r.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",r[r.UNSIGNALED=37144]="UNSIGNALED",r[r.SIGNALED=37145]="SIGNALED",r[r.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",r[r.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",r[r.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",r[r.WAIT_FAILED=37149]="WAIT_FAILED",r[r.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",r[r.COLOR=6144]="COLOR",r[r.DEPTH=6145]="DEPTH",r[r.STENCIL=6146]="STENCIL",r[r.MIN=32775]="MIN",r[r.MAX=32776]="MAX",r[r.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",r[r.STREAM_READ=35041]="STREAM_READ",r[r.STREAM_COPY=35042]="STREAM_COPY",r[r.STATIC_READ=35045]="STATIC_READ",r[r.STATIC_COPY=35046]="STATIC_COPY",r[r.DYNAMIC_READ=35049]="DYNAMIC_READ",r[r.DYNAMIC_COPY=35050]="DYNAMIC_COPY",r[r.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",r[r.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",r[r.INVALID_INDEX=4294967295]="INVALID_INDEX",r[r.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",r[r.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",r[r.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",r[r.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",r[r.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",r[r.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",r[r.R16_EXT=33322]="R16_EXT",r[r.RG16_EXT=33324]="RG16_EXT",r[r.RGB16_EXT=32852]="RGB16_EXT",r[r.RGBA16_EXT=32859]="RGBA16_EXT",r[r.R16_SNORM_EXT=36760]="R16_SNORM_EXT",r[r.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",r[r.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",r[r.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",r[r.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",r[r.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",r[r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",r[r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",r[r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",r[r.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",r[r.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",r[r.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",r[r.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",r[r.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",r[r.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",r[r.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",r[r.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",r[r.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",r[r.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",r[r.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",r[r.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",r[r.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",r[r.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",r[r.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",r[r.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",r[r.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",r[r.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",r[r.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",r[r.LINE_WEBGL=6913]="LINE_WEBGL",r[r.FILL_WEBGL=6914]="FILL_WEBGL",r[r.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",r[r.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",r[r.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",r[r.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",r[r.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",r[r.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",r[r.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",r[r.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",r[r.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",r[r.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",r[r.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",r[r.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",r[r.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",r[r.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",r[r.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",r[r.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",r[r.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",r[r.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",r[r.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",r[r.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",r[r.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",r[r.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",r[r.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",r[r.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Br||(Br={}))});var ry=O(()=>{ty()});function ny(r=!0){let e=HTMLCanvasElement.prototype;if(!r&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,n){if(t==="webgl"||t==="experimental-webgl"){let s=this.originalGetContext("webgl2",n);return s instanceof HTMLElement&&jA(s),s}return this.originalGetContext(t,n)}}function jA(r){r.getExtension("EXT_color_buffer_float");let e={...VA,WEBGL_disjoint_timer_query:r.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:zA(r),OES_vertex_array_object:WA(r),ANGLE_instanced_arrays:$A(r)},t=r.getExtension;r.getExtension=function(s){let i=t.call(r,s);return i||(s in e?e[s]:null)};let n=r.getSupportedExtensions;r.getSupportedExtensions=function(){return(n.apply(r)||[])?.concat(Object.keys(e))}}var VA,zA,WA,$A,sy=O(()=>{VA={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},zA=r=>({drawBuffersWEBGL(e){return r.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),WA=r=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return r.createVertexArray()},deleteVertexArrayOES(e){return r.deleteVertexArray(e)},isVertexArrayOES(e){return r.isVertexArray(e)},bindVertexArrayOES(e){return r.bindVertexArray(e)}}),$A=r=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return r.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return r.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return r.vertexAttribDivisor(...e)}})});async function Bc(r,e){let t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");let n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",r),e&&(n.id=e),new Promise((s,i)=>{n.onload=s,n.onerror=o=>i(new Error(`Unable to load script '${r}': ${o}`)),t.appendChild(n)})}var Zh=O(()=>{});async function oy(r){if(!globalThis.SPECTOR)try{await Bc(r.debugSpectorJSUrl||Lc.debugSpectorJSUrl)}catch(e){I.warn(String(e))}}function ay(r){if(r={...Lc,...r},!r.debugSpectorJS)return null;if(!qe&&globalThis.SPECTOR&&!globalThis.luma?.spector){I.probe(HA,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();let{Spector:e}=globalThis.SPECTOR;qe=new e,globalThis.luma&&(globalThis.luma.spector=qe)}if(!qe)return null;if(iy||(iy=!0,qe.spyCanvases(),qe?.onCaptureStarted.add(e=>I.info("Spector capture started:",e)()),qe?.onCapture.add(e=>{I.info("Spector capture complete:",e)(),qe?.getResultUI(),qe?.resultView.display(),qe?.resultView.addCapture(e)})),r.gl){let e=r.gl,t=e.device;qe?.startCapture(r.gl,500),e.device=t,new Promise(n=>setTimeout(n,2e3)).then(n=>{I.info("Spector capture stopped after 2 seconds")(),qe?.stopCapture()})}return qe}var HA,qe,iy,Lc,Gh=O(()=>{H();Zh();HA=1,qe=null,iy=!1,Lc={debugSpectorJS:I.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0}});function ly(r){return r.luma=r.luma||{},r.luma}async function uy(){Ie()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await Bc(XA))}function fy(r,e={}){return e.debugWebGL||e.traceWebGL?qA(r,e):YA(r)}function YA(r){let e=ly(r);return e.realContext?e.realContext:r}function qA(r,e){if(!globalThis.WebGLDebugUtils)return I.warn("webgl-debug not loaded")(),r;let t=ly(r);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...Br,...r});let n=globalThis.WebGLDebugUtils.makeDebugContext(r,KA.bind(null,e),ZA.bind(null,e));for(let o in Br)!(o in n)&&typeof Br[o]=="number"&&(n[o]=Br[o]);class s{}Object.setPrototypeOf(n,Object.getPrototypeOf(r)),Object.setPrototypeOf(s,n);let i=Object.create(s);return t.realContext=r,t.debugContext=i,i.debug=!0,i}function cy(r,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${r}(${t})`}function KA(r,e,t,n){n=Array.from(n).map(a=>a===void 0?"undefined":a);let s=globalThis.WebGLDebugUtils.glEnumToString(e),i=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,n),o=`${s} in gl.${t}(${i})`;I.error(o)();debugger}function ZA(r,e,t){let n="";I.level>=1&&(n=cy(e,t),r.traceWebGL&&I.log(1,n)());for(let s of t)if(s===void 0){n=n||cy(e,t);debugger}}var XA,Qh=O(()=>{H();ry();dr();Zh();XA="https://unpkg.com/webgl-debug@2.0.1/index.js"});function Jh(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}function de(r,e,t){return e[r]!==void 0?e[r]:t[r]}var to,be,hy,Ke,dy,eo,py,my,ed,Lt,td,gy,rd=O(()=>{to={[3042]:!1,[32773]:new Float32Array([0,0,0,0]),[32777]:32774,[34877]:32774,[32969]:1,[32968]:0,[32971]:1,[32970]:0,[3106]:new Float32Array([0,0,0,0]),[3107]:[!0,!0,!0,!0],[2884]:!1,[2885]:1029,[2929]:!1,[2931]:1,[2932]:513,[2928]:new Float32Array([0,1]),[2930]:!0,[3024]:!0,[35725]:null,[36006]:null,[36007]:null,[34229]:null,[34964]:null,[2886]:2305,[33170]:4352,[2849]:1,[32823]:!1,[32824]:0,[10752]:0,[32926]:!1,[32928]:!1,[32938]:1,[32939]:!1,[3089]:!1,[3088]:new Int32Array([0,0,1024,1024]),[2960]:!1,[2961]:0,[2968]:4294967295,[36005]:4294967295,[2962]:519,[2967]:0,[2963]:4294967295,[34816]:519,[36003]:0,[36004]:4294967295,[2964]:7680,[2965]:7680,[2966]:7680,[34817]:7680,[34818]:7680,[34819]:7680,[2978]:[0,0,1024,1024],[36389]:null,[36662]:null,[36663]:null,[35053]:null,[35055]:null,[35723]:4352,[36010]:null,[35977]:!1,[3333]:4,[3317]:4,[37440]:!1,[37441]:!1,[37443]:37444,[3330]:0,[3332]:0,[3331]:0,[3314]:0,[32878]:0,[3316]:0,[3315]:0,[32877]:0},be=(r,e,t)=>e?r.enable(t):r.disable(t),hy=(r,e,t)=>r.hint(t,e),Ke=(r,e,t)=>r.pixelStorei(t,e),dy=(r,e,t)=>{let n=t===36006?36009:36008;return r.bindFramebuffer(n,e)},eo=(r,e,t)=>{let s={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[t];r.bindBuffer(s,e)};py={[3042]:be,[32773]:(r,e)=>r.blendColor(...e),[32777]:"blendEquation",[34877]:"blendEquation",[32969]:"blendFunc",[32968]:"blendFunc",[32971]:"blendFunc",[32970]:"blendFunc",[3106]:(r,e)=>r.clearColor(...e),[3107]:(r,e)=>r.colorMask(...e),[2884]:be,[2885]:(r,e)=>r.cullFace(e),[2929]:be,[2931]:(r,e)=>r.clearDepth(e),[2932]:(r,e)=>r.depthFunc(e),[2928]:(r,e)=>r.depthRange(...e),[2930]:(r,e)=>r.depthMask(e),[3024]:be,[35723]:hy,[35725]:(r,e)=>r.useProgram(e),[36007]:(r,e)=>r.bindRenderbuffer(36161,e),[36389]:(r,e)=>r.bindTransformFeedback?.(36386,e),[34229]:(r,e)=>r.bindVertexArray(e),[36006]:dy,[36010]:dy,[34964]:eo,[36662]:eo,[36663]:eo,[35053]:eo,[35055]:eo,[2886]:(r,e)=>r.frontFace(e),[33170]:hy,[2849]:(r,e)=>r.lineWidth(e),[32823]:be,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:be,[32926]:be,[32928]:be,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:be,[3088]:(r,e)=>r.scissor(...e),[2960]:be,[2961]:(r,e)=>r.clearStencil(e),[2968]:(r,e)=>r.stencilMaskSeparate(1028,e),[36005]:(r,e)=>r.stencilMaskSeparate(1029,e),[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]:(r,e)=>r.viewport(...e),[34383]:be,[10754]:be,[12288]:be,[12289]:be,[12290]:be,[12291]:be,[12292]:be,[12293]:be,[12294]:be,[12295]:be,[3333]:Ke,[3317]:Ke,[37440]:Ke,[37441]:Ke,[37443]:Ke,[3330]:Ke,[3332]:Ke,[3331]:Ke,[3314]:Ke,[32878]:Ke,[3316]:Ke,[3315]:Ke,[32877]:Ke,framebuffer:(r,e)=>{let t=e&&"handle"in e?e.handle:e;return r.bindFramebuffer(36160,t)},blend:(r,e)=>e?r.enable(3042):r.disable(3042),blendColor:(r,e)=>r.blendColor(...e),blendEquation:(r,e)=>{let t=typeof e=="number"?[e,e]:e;r.blendEquationSeparate(...t)},blendFunc:(r,e)=>{let t=e?.length===2?[...e,...e]:e;r.blendFuncSeparate(...t)},clearColor:(r,e)=>r.clearColor(...e),clearDepth:(r,e)=>r.clearDepth(e),clearStencil:(r,e)=>r.clearStencil(e),colorMask:(r,e)=>r.colorMask(...e),cull:(r,e)=>e?r.enable(2884):r.disable(2884),cullFace:(r,e)=>r.cullFace(e),depthTest:(r,e)=>e?r.enable(2929):r.disable(2929),depthFunc:(r,e)=>r.depthFunc(e),depthMask:(r,e)=>r.depthMask(e),depthRange:(r,e)=>r.depthRange(...e),dither:(r,e)=>e?r.enable(3024):r.disable(3024),derivativeHint:(r,e)=>{r.hint(35723,e)},frontFace:(r,e)=>r.frontFace(e),mipmapHint:(r,e)=>r.hint(33170,e),lineWidth:(r,e)=>r.lineWidth(e),polygonOffsetFill:(r,e)=>e?r.enable(32823):r.disable(32823),polygonOffset:(r,e)=>r.polygonOffset(...e),sampleCoverage:(r,e)=>r.sampleCoverage(e[0],e[1]||!1),scissorTest:(r,e)=>e?r.enable(3089):r.disable(3089),scissor:(r,e)=>r.scissor(...e),stencilTest:(r,e)=>e?r.enable(2960):r.disable(2960),stencilMask:(r,e)=>{e=Jh(e)?e:[e,e];let[t,n]=e;r.stencilMaskSeparate(1028,t),r.stencilMaskSeparate(1029,n)},stencilFunc:(r,e)=>{e=Jh(e)&&e.length===3?[...e,...e]:e;let[t,n,s,i,o,a]=e;r.stencilFuncSeparate(1028,t,n,s),r.stencilFuncSeparate(1029,i,o,a)},stencilOp:(r,e)=>{e=Jh(e)&&e.length===3?[...e,...e]:e;let[t,n,s,i,o,a]=e;r.stencilOpSeparate(1028,t,n,s),r.stencilOpSeparate(1029,i,o,a)},viewport:(r,e)=>r.viewport(...e)};my={blendEquation:(r,e,t)=>r.blendEquationSeparate(de(32777,e,t),de(34877,e,t)),blendFunc:(r,e,t)=>r.blendFuncSeparate(de(32969,e,t),de(32968,e,t),de(32971,e,t),de(32970,e,t)),polygonOffset:(r,e,t)=>r.polygonOffset(de(32824,e,t),de(10752,e,t)),sampleCoverage:(r,e,t)=>r.sampleCoverage(de(32938,e,t),de(32939,e,t)),stencilFuncFront:(r,e,t)=>r.stencilFuncSeparate(1028,de(2962,e,t),de(2967,e,t),de(2963,e,t)),stencilFuncBack:(r,e,t)=>r.stencilFuncSeparate(1029,de(34816,e,t),de(36003,e,t),de(36004,e,t)),stencilOpFront:(r,e,t)=>r.stencilOpSeparate(1028,de(2964,e,t),de(2965,e,t),de(2966,e,t)),stencilOpBack:(r,e,t)=>r.stencilOpSeparate(1029,de(34817,e,t),de(34818,e,t),de(34819,e,t))},ed={enable:(r,e)=>r({[e]:!0}),disable:(r,e)=>r({[e]:!1}),pixelStorei:(r,e,t)=>r({[e]:t}),hint:(r,e,t)=>r({[e]:t}),useProgram:(r,e)=>r({[35725]:e}),bindRenderbuffer:(r,e,t)=>r({[36007]:t}),bindTransformFeedback:(r,e,t)=>r({[36389]:t}),bindVertexArray:(r,e)=>r({[34229]:e}),bindFramebuffer:(r,e,t)=>{switch(e){case 36160:return r({[36006]:t,[36010]:t});case 36009:return r({[36006]:t});case 36008:return r({[36010]:t});default:return null}},bindBuffer:(r,e,t)=>{let n={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[e];return n?r({[n]:t}):{valueChanged:!0}},blendColor:(r,e,t,n,s)=>r({[32773]:new Float32Array([e,t,n,s])}),blendEquation:(r,e)=>r({[32777]:e,[34877]:e}),blendEquationSeparate:(r,e,t)=>r({[32777]:e,[34877]:t}),blendFunc:(r,e,t)=>r({[32969]:e,[32968]:t,[32971]:e,[32970]:t}),blendFuncSeparate:(r,e,t,n,s)=>r({[32969]:e,[32968]:t,[32971]:n,[32970]:s}),clearColor:(r,e,t,n,s)=>r({[3106]:new Float32Array([e,t,n,s])}),clearDepth:(r,e)=>r({[2931]:e}),clearStencil:(r,e)=>r({[2961]:e}),colorMask:(r,e,t,n,s)=>r({[3107]:[e,t,n,s]}),cullFace:(r,e)=>r({[2885]:e}),depthFunc:(r,e)=>r({[2932]:e}),depthRange:(r,e,t)=>r({[2928]:new Float32Array([e,t])}),depthMask:(r,e)=>r({[2930]:e}),frontFace:(r,e)=>r({[2886]:e}),lineWidth:(r,e)=>r({[2849]:e}),polygonOffset:(r,e,t)=>r({[32824]:e,[10752]:t}),sampleCoverage:(r,e,t)=>r({[32938]:e,[32939]:t}),scissor:(r,e,t,n,s)=>r({[3088]:new Int32Array([e,t,n,s])}),stencilMask:(r,e)=>r({[2968]:e,[36005]:e}),stencilMaskSeparate:(r,e,t)=>r({[e===1028?2968:36005]:t}),stencilFunc:(r,e,t,n)=>r({[2962]:e,[2967]:t,[2963]:n,[34816]:e,[36003]:t,[36004]:n}),stencilFuncSeparate:(r,e,t,n,s)=>r({[e===1028?2962:34816]:t,[e===1028?2967:36003]:n,[e===1028?2963:36004]:s}),stencilOp:(r,e,t,n)=>r({[2964]:e,[2965]:t,[2966]:n,[34817]:e,[34818]:t,[34819]:n}),stencilOpSeparate:(r,e,t,n,s)=>r({[e===1028?2964:34817]:t,[e===1028?2965:34818]:n,[e===1028?2966:34819]:s}),viewport:(r,e,t,n,s)=>r({[2978]:[e,t,n,s]})},Lt=(r,e)=>r.isEnabled(e),td={[3042]:Lt,[2884]:Lt,[2929]:Lt,[3024]:Lt,[32823]:Lt,[32926]:Lt,[32928]:Lt,[3089]:Lt,[2960]:Lt,[35977]:Lt},gy=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 vt(r,e){if(GA(e))return;let t={};for(let s in e){let i=Number(s),o=py[s];o&&(typeof o=="string"?t[o]=!0:o(r,e[s],i))}let n=r.state&&r.state.cache;if(n)for(let s in t){let i=my[s];i(r,e,n)}}function Uc(r,e=to){if(typeof e=="number"){let s=e,i=td[s];return i?i(r,s):r.getParameter(s)}let t=Array.isArray(e)?e:Object.keys(e),n={};for(let s of t){let i=td[s];n[s]=i?i(r,Number(s)):r.getParameter(Number(s))}return n}function _y(r){vt(r,to)}function GA(r){for(let e in r)return!1;return!0}var ys=O(()=>{rd()});function xy(r,e){if(r===e)return!0;if(yy(r)&&yy(e)&&r.length===e.length){for(let t=0;t<r.length;++t)if(r[t]!==e[t])return!1;return!0}return!1}function yy(r){return Array.isArray(r)||ArrayBuffer.isView(r)}var by=O(()=>{});function Ty(r,e){let t=r[e].bind(r);r[e]=function(s){if(s===void 0||gy.has(s))return t(s);let i=At.get(r);return s in i.cache||(i.cache[s]=t(s)),i.enable?i.cache[s]:t(s)},Object.defineProperty(r[e],"name",{value:`${e}-from-cache`,configurable:!1})}function QA(r,e,t){if(!r[e])return;let n=r[e].bind(r);r[e]=function(...i){let o=At.get(r),{valueChanged:a,oldValue:c}=t(o._updateCache,...i);return a&&n(...i),c},Object.defineProperty(r[e],"name",{value:`${e}-to-cache`,configurable:!1})}function JA(r){let e=r.useProgram.bind(r);r.useProgram=function(n){let s=At.get(r);s.program!==n&&(e(n),s.program=n)}}var At,nd=O(()=>{ys();by();rd();At=class{static get(e){return e.state}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];vt(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?Uc(e):Object.assign({},to),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.state=this,JA(e);for(let n in ed){let s=ed[n];QA(e,n,s)}Ty(e,"getParameter"),Ty(e,"isEnabled")}_updateCache(e){let t=!1,n,s=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let i in e){let o=e[i],a=this.cache[i];xy(o,a)||(t=!0,n=a,s&&!(i in s)&&(s[i]=a),this.cache[i]=o)}return{valueChanged:t,oldValue:n}}}});function wy(r,e,t){let n="",s={preserveDrawingBuffer:!0,...t},i=null;if(i||=r.getContext("webgl2",s),s.failIfMajorPerformanceCaveat&&(n||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow."),!i&&!t.failIfMajorPerformanceCaveat&&(s.failIfMajorPerformanceCaveat=!1,i=r.getContext("webgl2",s),i.luma||={},i.luma.softwareRenderer=!0),i||(i=r.getContext("webgl",{}),i&&(i=null,n||="Your browser only supports WebGL1")),!i)throw n||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${n}`);let{onContextLost:o,onContextRestored:a}=e;return r.addEventListener("webglcontextlost",c=>o(c),!1),r.addEventListener("webglcontextrestored",c=>a(c),!1),i.luma||={},i}var vy=O(()=>{});function Ut(r,e,t){return t[e]===void 0&&(t[e]=r.getExtension(e)||null),t[e]}var ro=O(()=>{});function Ay(r,e){let t=r.getParameter(7936),n=r.getParameter(7937);Ut(r,"WEBGL_debug_renderer_info",e);let s=e.WEBGL_debug_renderer_info,i=r.getParameter(s?s.UNMASKED_VENDOR_WEBGL:7936),o=r.getParameter(s?s.UNMASKED_RENDERER_WEBGL:7937),a=i||t,c=o||n,l=r.getParameter(7938),u=Sy(a,c),f=eS(a,c),h=tS(a,c);return{type:"webgl",gpu:u,gpuType:h,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function Sy(r,e){return/NVIDIA/i.exec(r)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(r)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(r)||/Apple/i.exec(e)?"apple":/AMD/i.exec(r)||/AMD/i.exec(e)||/ATI/i.exec(r)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(r)||/SwiftShader/i.exec(e)?"software":"unknown"}function eS(r,e){return/Metal/i.exec(r)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(r)||/ANGLE/i.exec(e)?"opengl":"unknown"}function tS(r,e){if(/SwiftShader/i.exec(r)||/SwiftShader/i.exec(e))return"cpu";switch(Sy(r,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}var Ey=O(()=>{ro()});function Vc(r){switch(r){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(r))}var sd=O(()=>{});function Py(r){return r in zc}function Cy(r,e,t){return(zc[e]||[]).every(s=>Ut(r,s,t))}function My(r,e,t){let n=e.create,s=id[e.format];return s?.gl===void 0&&(n=!1),s?.x&&(n=n&&Boolean(Ut(r,s.x,t))),{format:e.format,create:n&&e.create,render:n&&e.render,filter:n&&e.filter,blend:n&&e.blend,store:n&&e.store}}function Wc(r){let e=id[r],t=lS(r),n=Yt.getInfo(r);return n.compressed&&(e.dataFormat=t),{internalFormat:t,format:e?.dataFormat||cS(n.channels,n.integer,n.normalized,t),type:n.dataType?Vc(n.dataType):e?.types?.[0]||5121,compressed:n.compressed||!1}}function Oy(r){switch(Yt.getInfo(r).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${r}`)}}function cS(r,e,t,n){if(n===6408||n===6407)return n;switch(r){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function lS(r){let t=id[r]?.gl;if(t===void 0)throw new Error(`Unsupported texture format ${r}`);return t}var no,so,xs,bs,rS,nS,sS,iS,oS,Ry,Iy,aS,zc,id,Ts=O(()=>{H();ro();sd();no="WEBGL_compressed_texture_s3tc",so="WEBGL_compressed_texture_s3tc_srgb",xs="EXT_texture_compression_rgtc",bs="EXT_texture_compression_bptc",rS="WEBGL_compressed_texture_etc",nS="WEBGL_compressed_texture_astc",sS="WEBGL_compressed_texture_etc1",iS="WEBGL_compressed_texture_pvrtc",oS="WEBGL_compressed_texture_atc",Ry="EXT_texture_norm16",Iy="EXT_render_snorm",aS="EXT_color_buffer_float",zc={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat-renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[Iy],"norm16-renderable-webgl":[Ry],"snorm16-renderable-webgl":[Ry,Iy],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[no,so,xs,bs],"texture-compression-bc5-webgl":[xs],"texture-compression-bc7-webgl":[bs],"texture-compression-etc2":[rS],"texture-compression-astc":[nS],"texture-compression-etc1-webgl":[sS],"texture-compression-pvrtc-webgl":[iS],"texture-compression-atc-webgl":[oS]};id={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757},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},r16unorm:{gl:33322,rb:!0},r16snorm:{gl:36760},"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},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0},rg16unorm:{gl:33324},rg16snorm:{gl:36761},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326},rgb9e5ufloat:{gl:35901},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852},"rgb16snorm-webgl":{gl:36762},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842},rgba16unorm:{gl:32859,rb:!0},rgba16snorm:{gl:36763},"rgb32float-webgl":{gl:34837,x:aS,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0},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:no},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:so},"bc1-rgba-unorm":{gl:33777,x:no},"bc1-rgba-unorm-srgb":{gl:35916,x:so},"bc2-rgba-unorm":{gl:33778,x:no},"bc2-rgba-unorm-srgb":{gl:35918,x:so},"bc3-rgba-unorm":{gl:33779,x:no},"bc3-rgba-unorm-srgb":{gl:35919,x:so},"bc4-r-unorm":{gl:36283,x:xs},"bc4-r-snorm":{gl:36284,x:xs},"bc5-rg-unorm":{gl:36285,x:xs},"bc5-rg-snorm":{gl:36286,x:xs},"bc6h-rgb-ufloat":{gl:36495,x:bs},"bc6h-rgb-float":{gl:36494,x:bs},"bc7-rgba-unorm":{gl:36492,x:bs},"bc7-rgba-unorm-srgb":{gl:36493,x:bs},"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:37819},"astc-10x5-unorm-srgb":{gl:37851},"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-rbg2unorm-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}}});var ky,$c,Ny=O(()=>{H();ro();Ts();ky={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},$c=class extends Fs{gl;extensions;testedFeatures=new Set;constructor(e,t,n){super([],n),this.gl=e,this.extensions=t,Ut(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){let e=this.getFeatures();for(let t of e)this.has(t)&&(yield t);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),Py(e)&&Cy(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(t=>t!=="polygon-mode-webgl");for(let t of e)this.has(t)}getFeatures(){return[...Object.keys(ky),...Object.keys(zc)]}getWebGLFeature(e){let t=ky[e];return Boolean(typeof t=="string"?Ut(this.gl,t,this.extensions):t)}}});var jc,Dy=O(()=>{H();jc=class extends Ds{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 this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}});function uS(r){return r<34069?r+34069:r}function fS(r){switch(r){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`${r}`}}var Vt,Hc=O(()=>{H();Ts();Vt=class extends It{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);let n=t.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),n||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.autoCreateAttachmentTextures(),this.updateAttachments())}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let t=0;t<this.colorAttachments.length;++t){let n=this.colorAttachments[t];if(n){let s=36064+t;this._attachTextureView(s,n)}}if(this.depthStencilAttachment){let t=Oy(this.depthStencilAttachment.props.format);this._attachTextureView(t,this.depthStencilAttachment)}if(this.device.props.debug){let t=this.gl.checkFramebufferStatus(36160);if(t!==36053)throw new Error(`Framebuffer ${fS(t)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,t){let{gl:n}=this.device,{texture:s}=t,i=t.props.baseMipLevel,o=t.props.baseArrayLayer;switch(n.bindTexture(s.glTarget,s.handle),s.glTarget){case 35866:case 32879:n.framebufferTextureLayer(36160,e,s.handle,i,o);break;case 34067:let a=uS(o);n.framebufferTexture2D(36160,e,a,s.handle,i);break;case 3553:n.framebufferTexture2D(36160,e,3553,s.handle,i);break;default:throw new Error("Illegal texture type")}n.bindTexture(s.glTarget,null)}}});var Xc,Fy=O(()=>{H();Hc();Xc=class extends Hr{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._updateDevice()}getCurrentFramebuffer(){return this._framebuffer=this._framebuffer||new Vt(this.device,{handle:null}),this._framebuffer}_updateDevice(){}}});function By(r="id"){od[r]=od[r]||1;let e=od[r]++;return`${r}-${e}`}var od,Ly=O(()=>{od={}});function hS(r){return r&W.INDEX?34963:r&W.VERTEX?34962:r&W.UNIFORM?35345:34962}function dS(r){return r&W.INDEX||r&W.VERTEX?35044:r&W.UNIFORM?35048:35044}var St,Yc=O(()=>{H();St=class extends W{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;let n=typeof t=="object"?t.handle:void 0;this.handle=n||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=hS(this.props.usage),this.glUsage=dS(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?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.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,n=e.byteLength+t){let s=this.glTarget;this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,n,this.glUsage),this.gl.bufferSubData(s,t,e),this.gl.bindBuffer(s,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(e,t,n),this.trackAllocatedMemory(n)}_initWithByteLength(e){let t=e;e===0&&(t=new Float32Array(0));let n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,t,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}write(e,t=0){let n=ArrayBuffer.isView(e)?e:new Uint8Array(e),s=0,i=void 0,o=36663;this.gl.bindBuffer(o,this.handle),s!==0||i!==void 0?this.gl.bufferSubData(o,t,n,s,i):this.gl.bufferSubData(o,t,n),this.gl.bindBuffer(o,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,n=this.byteLength-t){let s=new ArrayBuffer(n);await e(s,"copied"),this.write(s,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,n){let s=await this.readAsync(t,n);return await e(s.buffer,"copied")}readSyncWebGL(e=0,t){t=t??this.byteLength-e;let n=new Uint8Array(t),s=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,n,s,t),this.gl.bindBuffer(36662,null),this._setDebugData(n,e,t),n}}});function Vy(r){let e=r.split(/\r?\n/),t=[];for(let n of e){if(n.length<=1)continue;let s=n.split(":");if(s.length===2){let[f,h]=s;t.push({message:h.trim(),type:Uy(f),lineNum:0,linePos:0});continue}let[i,o,a,...c]=s,l=parseInt(a,10);isNaN(l)&&(l=0);let u=parseInt(o,10);isNaN(u)&&(u=0),t.push({message:c.join(":").trim(),type:Uy(i),lineNum:l,linePos:u})}return t}function Uy(r){let e=["warning","error","info"],t=r.toLowerCase();return e.includes(t)?t:"info"}var zy=O(()=>{});var qc,Wy=O(()=>{H();zy();qc=class extends _r{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 new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!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?Vy(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}async _compile(e){e=e.startsWith("#version ")?e:`#version 300 es
18
- ${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(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}I.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),I.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async s=>await new Promise(i=>setTimeout(i,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}});function jy(r,e,t,n){if(_S(e))return n(r);let s=r;s.pushState();try{return pS(r,e),vt(s.gl,t),n(r)}finally{s.popState()}}function pS(r,e){let t=r,{gl:n}=t;if(e.cullMode)switch(e.cullMode){case"none":n.disable(2884);break;case"front":n.enable(2884),n.cullFace(1028);break;case"back":n.enable(2884),n.cullFace(1029);break}if(e.frontFace&&n.frontFace(Tn("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&r.features.has("depth-clip-control")&&n.enable(34383),e.depthBias!==void 0&&(n.enable(32823),n.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&r.features.has("provoking-vertex-webgl")){let i=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=Tn("provokingVertex",e.provokingVertex,{first:36429,last:36430});i?.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&r.features.has("polygon-mode-webgl")){if(e.polygonMode){let i=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=Tn("polygonMode",e.polygonMode,{fill:6914,line:6913});i?.polygonModeWEBGL(1028,o),i?.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&n.enable(10754)}if(r.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&n.enable(12288),e.clipDistance1&&n.enable(12289),e.clipDistance2&&n.enable(12290),e.clipDistance3&&n.enable(12291),e.clipDistance4&&n.enable(12292),e.clipDistance5&&n.enable(12293),e.clipDistance6&&n.enable(12294),e.clipDistance7&&n.enable(12295)),e.depthWriteEnabled!==void 0&&n.depthMask(gS("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?n.enable(2929):n.disable(2929),n.depthFunc(Zc("depthCompare",e.depthCompare))),e.stencilWriteMask){let s=e.stencilWriteMask;n.stencilMaskSeparate(1028,s),n.stencilMaskSeparate(1029,s)}if(e.stencilReadMask&&I.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let s=e.stencilReadMask||4294967295,i=Zc("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?n.enable(2960):n.disable(2960),n.stencilFuncSeparate(1028,i,0,s),n.stencilFuncSeparate(1029,i,0,s)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let s=ad("stencilPassOperation",e.stencilPassOperation),i=ad("stencilFailOperation",e.stencilFailOperation),o=ad("stencilDepthFailOperation",e.stencilDepthFailOperation);n.stencilOpSeparate(1028,i,o,s),n.stencilOpSeparate(1029,i,o,s)}switch(e.blend){case!0:n.enable(3042);break;case!1:n.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let s=$y("blendColorOperation",e.blendColorOperation||"add"),i=$y("blendAlphaOperation",e.blendAlphaOperation||"add");n.blendEquationSeparate(s,i);let o=Kc("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=Kc("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=Kc("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=Kc("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");n.blendFuncSeparate(o,a,c,l)}}function Zc(r,e){return Tn(r,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function ad(r,e){return Tn(r,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function $y(r,e){return Tn(r,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function Kc(r,e,t="color"){return Tn(r,e,{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:t==="color"?32769:32771,"one-minus-constant":t==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function mS(r,e){return`Illegal parameter ${e} for ${r}`}function Tn(r,e,t){if(!(e in t))throw new Error(mS(r,e));return t[e]}function gS(r,e){return e}function _S(r){let e=!0;for(let t in r){e=!1;break}return e}var cd=O(()=>{H();ys()});function Gc(r){let e={};return r.addressModeU&&(e[10242]=ld(r.addressModeU)),r.addressModeV&&(e[10243]=ld(r.addressModeV)),r.addressModeW&&(e[32882]=ld(r.addressModeW)),r.magFilter&&(e[10240]=ud(r.magFilter)),(r.minFilter||r.mipmapFilter)&&(e[10241]=yS(r.minFilter||"linear",r.mipmapFilter)),r.lodMinClamp!==void 0&&(e[33082]=r.lodMinClamp),r.lodMaxClamp!==void 0&&(e[33083]=r.lodMaxClamp),r.type==="comparison-sampler"&&(e[34892]=34894),r.compare&&(e[34893]=Zc("compare",r.compare)),r.maxAnisotropy&&(e[34046]=r.maxAnisotropy),e}function ld(r){switch(r){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function ud(r){switch(r){case"nearest":return 9728;case"linear":return 9729}}function yS(r,e="none"){if(!e)return ud(r);switch(e){case"none":return ud(r);case"nearest":switch(r){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(r){case"nearest":return 9986;case"linear":return 9987}}}var fd=O(()=>{cd()});var Qc,Hy=O(()=>{H();fd();Qc=class extends Ge{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=Gc(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,n]of Object.entries(e)){let s=Number(t);switch(s){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,s,n);break;default:this.device.gl.samplerParameteri(this.handle,s,n);break}}}}});function Lr(r,e,t){if(xS(e))return t(r);let{nocatch:n=!0}=e,s=At.get(r);s.push(),vt(r,e);let i;if(n)i=t(r),s.pop();else try{i=t(r)}finally{s.pop()}return i}function xS(r){for(let e in r)return!1;return!0}var Jc=O(()=>{ys();nd()});var zt,hd=O(()=>{H();zt=class extends gr{device;gl;handle;texture;constructor(e,t){super(e,{...K.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}});function bS(r){switch(r){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(r)}function Xy(r,e,t){return e==="cube"?34069+t:r}var Wt,el=O(()=>{H();Ts();fd();Jc();hd();Wt=class extends K{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;constructor(e,t){super(e,t),this.device=e,this.gl=this.device.gl;let n=Wc(this.props.format);this.glTarget=bS(this.props.dimension),this.glInternalFormat=n.internalFormat,this.glFormat=n.format,this.glType=n.type,this.compressed=n.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);let{dimension:s,width:i,height:o,depth:a,mipLevels:c,glTarget:l,glInternalFormat:u}=this;switch(s){case"2d":case"cube":this.gl.texStorage2D(l,c,u,i,o);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,u,i,o,a);break;default:throw new Error(s)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data),this.setSampler(this.props.sampler),this.view=new zt(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}createView(e){return new zt(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);let t=Gc(this.sampler.props);this._setSamplerParameters(t)}copyImageData(e){let t=this._normalizeCopyImageDataOptions(e),n=t.data,{width:s,height:i,depth:o}=this,{mipLevel:a=0,byteOffset:c=0,x:l=0,y:u=0,z:f=0}=t,{glFormat:h,glType:d,compressed:m}=this,y=Xy(this.glTarget,this.dimension,f),_;if(!this.compressed){let{bytesPerPixel:E}=this.device.getTextureFormatInfo(this.format);if(E){if(t.bytesPerRow%E!==0)throw new Error(`bytesPerRow (${t.bytesPerRow}) must be a multiple of bytesPerPixel (${E}) for ${this.format}`);_=t.bytesPerRow/E}}let x=this.compressed?{}:{..._!==void 0?{[3314]:_}:{},[32878]:t.rowsPerImage};this.gl.bindTexture(y,this.handle),Lr(this.gl,x,()=>{switch(this.dimension){case"2d":case"cube":m?this.gl.compressedTexSubImage2D(y,a,l,u,s,i,h,n,c):this.gl.texSubImage2D(y,a,l,u,s,i,h,d,n,c);break;case"2d-array":case"3d":m?this.gl.compressedTexSubImage3D(y,a,l,u,f,s,i,o,h,n,c):this.gl.texSubImage3D(y,a,l,u,f,s,i,o,h,d,n,c);break;default:}}),this.gl.bindTexture(y,null)}copyExternalImage(e){let t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:n,glType:s}=this,{image:i,depth:o,mipLevel:a,x:c,y:l,z:u,width:f,height:h}=t,d=Xy(this.glTarget,this.dimension,o),m=t.flipY?{[37440]:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),Lr(this.gl,m,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(d,a,c,l,f,h,n,s,i);break;case"2d-array":case"3d":this.gl.texSubImage3D(d,a,c,l,u,f,h,o,n,s,i);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}generateMipmapsWebGL(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(I.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(n){I.warn(`Error generating mipmap for ${this}: ${n.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){I.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[t,n]of Object.entries(e)){let s=Number(t),i=n;switch(s){case 33082:case 33083:this.gl.texParameterf(this.glTarget,s,i);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,s,i);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,s,i);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,s,i);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,s,i);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}}});function Yy(r){return wS[r]}function tl(r){return TS[r]}function qy(r){return Boolean(Zy[r])}function Ky(r){return Zy[r]}var TS,Zy,wS,dd=O(()=>{TS={[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>"},Zy={[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"}},wS={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function Gy(r,e){let t={attributes:[],bindings:[]};t.attributes=vS(r,e);let n=ES(r,e);for(let a of n){let c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));t.bindings.push({type:"uniform",name:a.name,group:0,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:c})}let s=SS(r,e),i=0;for(let a of s)if(qy(a.type)){let{viewDimension:c,sampleType:l}=Ky(a.type);t.bindings.push({type:"texture",name:a.name,group:0,location:i,viewDimension:c,sampleType:l}),a.textureUnit=i,i+=1}s.length&&(t.uniforms=s);let o=AS(r,e);return o?.length&&(t.varyings=o),t}function vS(r,e){let t=[],n=r.getProgramParameter(e,35721);for(let s=0;s<n;s++){let i=r.getActiveAttrib(e,s);if(!i)throw new Error("activeInfo");let{name:o,type:a}=i,c=r.getAttribLocation(e,o);if(c>=0){let l=tl(a),u=/instance/i.test(o)?"instance":"vertex";t.push({name:o,location:c,stepMode:u,type:l})}}return t.sort((s,i)=>s.location-i.location),t}function AS(r,e){let t=[],n=r.getProgramParameter(e,35971);for(let s=0;s<n;s++){let i=r.getTransformFeedbackVarying(e,s);if(!i)throw new Error("activeInfo");let{name:o,type:a,size:c}=i,l=tl(a),{type:u,components:f}=Ls(l);t.push({location:s,name:o,type:u,size:c*f})}return t.sort((s,i)=>s.location-i.location),t}function SS(r,e){let t=[],n=r.getProgramParameter(e,35718);for(let s=0;s<n;s++){let i=r.getActiveUniform(e,s);if(!i)throw new Error("activeInfo");let{name:o,size:a,type:c}=i,{name:l,isArray:u}=RS(o),f=r.getUniformLocation(e,l),h={location:f,name:l,size:a,type:c,isArray:u};if(t.push(h),h.size>1)for(let d=0;d<h.size;d++){let m=`${l}[${d}]`;f=r.getUniformLocation(e,m);let y={...h,name:m,location:f};t.push(y)}}return t}function ES(r,e){let t=(i,o)=>r.getActiveUniformBlockParameter(e,i,o),n=[],s=r.getProgramParameter(e,35382);for(let i=0;i<s;i++){let o={name:r.getActiveUniformBlockName(e,i)||"",location:t(i,35391),byteLength:t(i,35392),vertex:t(i,35396),fragment:t(i,35398),uniformCount:t(i,35394),uniforms:[]},a=t(i,35395)||[],c=r.getActiveUniforms(e,a,35383),l=r.getActiveUniforms(e,a,35384),u=r.getActiveUniforms(e,a,35387),f=r.getActiveUniforms(e,a,35388);for(let h=0;h<o.uniformCount;++h){let d=r.getActiveUniform(e,a[h]);if(!d)throw new Error("activeInfo");let m=tl(c[h]);o.uniforms.push({name:d.name,format:m,type:c[h],arrayLength:l[h],byteOffset:u[h],byteStride:f[h]})}n.push(o)}return n.sort((i,o)=>i.location-o.location),n}function RS(r){if(r[r.length-1]!=="]")return{name:r,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(r);if(!t||t.length<2)throw new Error(`Failed to parse GLSL uniform name ${r}`);return{name:t[1],length:t[2]?1:0,isArray:Boolean(t[2])}}var Qy=O(()=>{H();dd()});function Jy(r,e,t,n){let s=r,i=n;i===!0&&(i=1),i===!1&&(i=0);let o=typeof i=="number"?[i]:i;switch(t){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof n!="number")throw new Error("samplers must be set to integers");return r.uniform1i(e,n);case 5126:return r.uniform1fv(e,o);case 35664:return r.uniform2fv(e,o);case 35665:return r.uniform3fv(e,o);case 35666:return r.uniform4fv(e,o);case 5124:return r.uniform1iv(e,o);case 35667:return r.uniform2iv(e,o);case 35668:return r.uniform3iv(e,o);case 35669:return r.uniform4iv(e,o);case 35670:return r.uniform1iv(e,o);case 35671:return r.uniform2iv(e,o);case 35672:return r.uniform3iv(e,o);case 35673:return r.uniform4iv(e,o);case 5125:return s.uniform1uiv(e,o,1);case 36294:return s.uniform2uiv(e,o,2);case 36295:return s.uniform3uiv(e,o,3);case 36296:return s.uniform4uiv(e,o,4);case 35674:return r.uniformMatrix2fv(e,!1,o);case 35675:return r.uniformMatrix3fv(e,!1,o);case 35676:return r.uniformMatrix4fv(e,!1,o);case 35685:return s.uniformMatrix2x3fv(e,!1,o);case 35686:return s.uniformMatrix2x4fv(e,!1,o);case 35687:return s.uniformMatrix3x2fv(e,!1,o);case 35688:return s.uniformMatrix3x4fv(e,!1,o);case 35689:return s.uniformMatrix4x2fv(e,!1,o);case 35690:return s.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}var ex=O(()=>{});function tx(r){switch(r){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 new Error(r)}}function rx(r){switch(r){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(r)}}var pd=O(()=>{});function IS(r,e){let t={...r,attributes:r.attributes.map(n=>({...n}))};for(let n of e?.attributes||[]){let s=t.attributes.find(i=>i.name===n.name);s?(s.type=n.type||s.type,s.stepMode=n.stepMode||s.stepMode):I.warn(`shader layout attribute ${n.name} not present in shader`)}return t}var nx,rl,sx=O(()=>{H();Qy();cd();ex();Yc();Hc();el();hd();pd();nx=4,rl=class extends Qe{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.vs=t.vs,this.fs=t.fs;let{varyings:n,bufferMode:s=35981}=t;n&&n.length>0&&(this.varyings=n,this.device.gl.transformFeedbackVaryings(this.handle,n,s)),this._linkShaders(),I.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Gy(this.device.gl,this.handle),I.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=t.shaderLayout?IS(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.handle&&(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.destroyed=!0,this.handle.destroyed=!0,this.handle=null)}setBindings(e,t){for(let[n,s]of Object.entries(e)){let i=this.shaderLayout.bindings.find(o=>o.name===n)||this.shaderLayout.bindings.find(o=>o.name===`${n}Uniforms`);if(!i){let o=this.shaderLayout.bindings.map(a=>`"${a.name}"`).join(", ");t?.disableWarnings||I.warn(`No binding "${n}" in render pipeline "${this.id}", expected one of ${o}`,s)();continue}switch(s||I.warn(`Unsetting binding "${n}" in render pipeline "${this.id}"`)(),i.type){case"uniform":if(!(s instanceof St)&&!(s.buffer instanceof St))throw new Error("buffer value");break;case"texture":if(!(s instanceof zt||s instanceof Wt||s instanceof Vt))throw new Error(`${this} Bad texture binding for ${n}`);break;case"sampler":I.warn(`Ignoring sampler ${n}`)();break;default:throw new Error(i.type)}this.bindings[n]=s}}draw(e){let{renderPass:t,parameters:n=this.props.parameters,topology:s=this.props.topology,vertexArray:i,vertexCount:o,instanceCount:a,isInstanced:c=!1,firstVertex:l=0,transformFeedback:u}=e,f=tx(s),h=Boolean(i.indexBuffer),d=i.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return I.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable())return I.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),i.bindBeforeRender(t),u&&u.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let m=t;return jy(this.device,n,m.glParameters,()=>{h&&c?this.device.gl.drawElementsInstanced(f,o||0,d,l,a||0):h?this.device.gl.drawElements(f,o||0,d,l):c?this.device.gl.drawArraysInstanced(f,l,o||0,a||0):this.device.gl.drawArrays(f,l,o||0),u&&u.end()}),i.unbindAfterRender(t),!0}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),I.time(nx,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),I.timeEnd(nx,`linkProgram for ${this.id}`)(),I.level,!this.device.features.has("compilation-status-async-webgl")){let n=this._getLinkStatus();this._reportLinkStatus(n);return}I.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),I.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){switch(e){case"success":return;default:let t=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${t} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${t} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let n=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${t} during ${e}: ${n}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}async _waitForLinkComplete(){let e=async s=>await new Promise(i=>setTimeout(i,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(let t of this.shaderLayout.bindings)!this.bindings[t.name]&&!this.bindings[t.name.replace(/Uniforms$/,"")]&&(I.warn(`Binding ${t.name} not found in ${this.id}`)(),e=!1);return e}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:e}=this.device;e.useProgram(this.handle);let t=0,n=0;for(let s of this.shaderLayout.bindings){let i=this.bindings[s.name]||this.bindings[s.name.replace(/Uniforms$/,"")];if(!i)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":let{name:o}=s,a=e.getUniformBlockIndex(this.handle,o);if(a===4294967295)throw new Error(`Invalid uniform block name ${o}`);e.uniformBlockBinding(this.handle,n,a),i instanceof St?e.bindBufferBase(35345,n,i.handle):e.bindBufferRange(35345,n,i.buffer.handle,i.offset||0,i.size||i.buffer.byteLength-i.offset),n+=1;break;case"texture":if(!(i instanceof zt||i instanceof Wt||i instanceof Vt))throw new Error("texture");let c;if(i instanceof zt)c=i.texture;else if(i instanceof Wt)c=i;else if(i instanceof Vt&&i.colorAttachments[0]instanceof zt)I.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),c=i.colorAttachments[0].texture;else throw new Error("No texture");e.activeTexture(33984+t),e.bindTexture(c.glTarget,c.handle),t+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(){for(let e of this.shaderLayout.uniforms||[]){let{name:t,location:n,type:s,textureUnit:i}=e,o=this.uniforms[t]??i;o!==void 0&&Jy(this.device.gl,n,s,o)}}}});function PS(r,e){let t=e.sourceBuffer,n=e.destinationBuffer;r.gl.bindBuffer(36662,t.handle),r.gl.bindBuffer(36663,n.handle),r.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),r.gl.bindBuffer(36662,null),r.gl.bindBuffer(36663,null)}function CS(r,e){throw new Error("Not implemented")}function MS(r,e){let{sourceTexture:t,mipLevel:n=0,aspect:s="all",width:i=e.sourceTexture.width,height:o=e.sourceTexture.height,depthOrArrayLayers:a=0,origin:c=[0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:f,rowsPerImage:h}=e;if(s!=="all")throw new Error("aspect not supported in WebGL");if(n!==0||a!==0||f||h)throw new Error("not implemented");let{framebuffer:d,destroyFramebuffer:m}=ix(t),y;try{let _=l,x=i||d.width,E=o||d.height,b=Wc(d.colorAttachments[0].texture.props.format),S=b.format,C=b.type;r.gl.bindBuffer(35051,_.handle),y=r.gl.bindFramebuffer(36160,d.handle),r.gl.readPixels(c[0],c[1],x,E,S,C,u)}finally{r.gl.bindBuffer(35051,null),y!==void 0&&r.gl.bindFramebuffer(36160,y),m&&d.destroy()}}function OS(r,e){let{sourceTexture:t,destinationMipLevel:n=0,origin:s=[0,0],destinationOrigin:i=[0,0],destinationTexture:o}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:u}=ix(t),[f,h]=s,[d,m,y]=i,_=r.gl.bindFramebuffer(36160,l.handle),x,E;if(o instanceof Wt)x=o,a=Number.isFinite(a)?a:x.width,c=Number.isFinite(c)?c:x.height,x._bind(0),E=x.glTarget;else throw new Error("invalid destination");switch(E){case 3553:case 34067:r.gl.copyTexSubImage2D(E,n,d,m,f,h,a,c);break;case 35866:case 32879:r.gl.copyTexSubImage3D(E,n,d,m,y,f,h,a,c);break;default:}x&&x._unbind(),r.gl.bindFramebuffer(36160,_),u&&l.destroy()}function ix(r){if(r instanceof K){let{width:e,height:t,id:n}=r;return{framebuffer:r.device.createFramebuffer({id:`framebuffer-for-${n}`,width:e,height:t,colorAttachments:[r]}),destroyFramebuffer:!0}}return{framebuffer:r,destroyFramebuffer:!1}}var nl,ox=O(()=>{H();el();Ts();nl=class extends Dn{device;handle=null;commands=[];constructor(e){super(e,{}),this.device=e}_executeCommands(e=this.commands){for(let t of e)switch(t.name){case"copy-buffer-to-buffer":PS(this.device,t.options);break;case"copy-buffer-to-texture":CS(this.device,t.options);break;case"copy-texture-to-buffer":MS(this.device,t.options);break;case"copy-texture-to-texture":OS(this.device,t.options);break;default:throw new Error(t.name)}}}});var kS,sl,ax=O(()=>{H();Jc();ys();kS=[1,2,4,8],sl=class extends Kt{device;handle=null;glParameters={};constructor(e,t){super(e,t),this.device=e;let n;if(!t?.parameters?.viewport)if(t?.framebuffer){let{width:i,height:o}=t.framebuffer;n=[0,0,i,o]}else{let[i,o]=e.getDefaultCanvasContext().getDrawingBufferSize();n=[0,0,i,o]}this.device.pushState(),this.setParameters({viewport:n,...this.props.parameters});let s=this.props.framebuffer;if(this.props.framebuffer&&s?.handle){let i=this.props.framebuffer.colorAttachments.map((o,a)=>36064+a);this.device.gl.drawBuffers(i)}else this.device.gl.drawBuffers([1029]);this.clear()}end(){this.device.popState()}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?0:1,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),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),t[2967]=e.stencilReference),"colorMask"in e&&(t.colorMask=kS.map(n=>Boolean(n&e.colorMask))),this.glParameters=t,vt(this.device.gl,t)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},t=0;this.props.clearColors&&this.props.clearColors.forEach((n,s)=>{n&&this.clearColorBuffer(s,n)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(t|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=1024,e.clearStencil=this.props.clearStencil),t!==0&&Lr(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){Lr(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 new Error("clearColorBuffer: color must be typed array")}})}}});var io,cx=O(()=>{H();ox();ax();io=class extends Nn{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new nl(e)}destroy(){}finish(){return this.commandBuffer}beginRenderPass(e){return new sl(this.device,e)}beginComputePass(e){throw new 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,n){}}});function lx(r){let{target:e,source:t,start:n=0,count:s=1}=r,i=t.length,o=s*i,a=0;for(let c=n;a<i;a++)e[c++]=t[a];for(;a<o;)a<o-a?(e.copyWithin(n+a,n,n+a),a*=2):(e.copyWithin(n+a,n,n+o-a),a=o);return r.target}var ux=O(()=>{});function NS(r){return Array.isArray(r)?new Float32Array(r):r}function DS(r,e){if(!r||!e||r.length!==e.length||r.constructor!==e.constructor)return!1;for(let t=0;t<r.length;++t)if(r[t]!==e[t])return!1;return!0}var ws,fx=O(()=>{H();dr();sd();ux();ws=class extends Fn{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return Wl()==="Chrome"}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){let t=e;if(t&&t.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){let n=t;if(n.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:s,type:i,stride:o,offset:a,normalized:c,integer:l,divisor:u}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),l?this.device.gl.vertexAttribIPointer(e,s,i,o,a):this.device.gl.vertexAttribPointer(e,s,i,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,u||0),this.attributes[e]=n,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 new Error(`Unknown attribute location ${e}`);let n=Vc(t.bufferDataType);return{size:t.bufferComponents,type:n,stride:t.byteStride,offset:t.byteOffset,normalized:t.normalized,integer:t.integer,divisor:t.stepMode==="instance"?1:0}}_enable(e,t=!0){let s=ws.isConstantAttributeZeroSupported(this.device)||e!==0;(t||s)&&(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){let n=NS(t),s=n.byteLength*e,i=n.length*e;if(this.buffer&&s!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${s} !== ${this.buffer.byteLength}.`);let o=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:s}),o||=!DS(n,this.bufferValue),o){let a=xu(t.constructor,i);lx({target:a,source:n,start:0,count:i}),this.buffer.write(a),this.bufferValue=t}return this.buffer}}});function hx(r){return typeof r=="number"?Number.isInteger(r):/^\d+$/.test(r)}var il,dx=O(()=>{H();ol();pd();il=class extends Bn{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(rx(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 in e)this.setBuffer(t,e[t])})}setBuffer(e,t){let n=this._getVaryingIndex(e),{buffer:s,byteLength:i,byteOffset:o}=this._getBufferRange(t);if(n<0){this.unusedBuffers[e]=s,I.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[n]={buffer:s,byteLength:i,byteOffset:o},this.bindOnUse||this._bindBuffer(n,s,o,i)}getBuffer(e){if(hx(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return t>=0?this.buffers[t]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let t;return 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 St)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:n=0,byteLength:s=e.buffer.byteLength}=e;return{buffer:t,byteOffset:n,byteLength:s}}_getVaryingIndex(e){if(hx(e))return Number(e);for(let t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(let e in this.buffers){let{buffer:t,byteLength:n,byteOffset:s}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),t,s,n)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,n=0,s){let i=t&&t.handle;!i||s===void 0?this.gl.bindBufferBase(35982,e,i):this.gl.bindBufferRange(35982,e,i,n,s)}}});var al,px=O(()=>{H();al=class extends Ln{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,t){if(super(e,t),this.device=e,t.count>1)throw new Error("WebGL QuerySet can only have one value");let n=this.device.gl.createQuery();if(!n)throw new Error("WebGL query not supported");this.handle=n,Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;let e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let t=0;return this._pollingPromise=new Promise((n,s)=>{let i=()=>{this.isResultAvailable()?(n(this.getResult()),this._pollingPromise=null):t++>e?(s("Timed out"),this._pollingPromise=null):requestAnimationFrame(i)};requestAnimationFrame(i)}),this._pollingPromise}}});function md(r){switch(r){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 mx(r){switch(r){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var gx=O(()=>{});function _x(r){return FS[r]}var FS,yx=O(()=>{FS={[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"}});function xx(r,e){let{sourceX:t=0,sourceY:n=0,sourceAttachment:s=0}=e||{},{target:i=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:u}=e||{},{framebuffer:f,deleteFramebuffer:h}=Tx(r),{gl:d,handle:m}=f;o||=f.width,a||=f.height;let y=f.colorAttachments[s]?.texture;if(!y)throw new Error(`Invalid framebuffer attachment ${s}`);c=y?.depth||1,l||=y?.glFormat||6408,u||=y?.glType||5121,i=LS(i,u,l,o,a,c);let _=$r(i);u=u||Yy(_);let x=d.bindFramebuffer(36160,m);return d.readBuffer(36064+s),d.readPixels(t,n,o,a,l,u,i),d.readBuffer(36064),d.bindFramebuffer(36160,x||null),h&&f.destroy(),i}function bx(r,e){let{target:t,sourceX:n=0,sourceY:s=0,sourceFormat:i=6408,targetByteOffset:o=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=Tx(r);a=a||u.width,c=c||u.height;let h=u;l=l||5121;let d=t;if(!d){let y=md(i),_=mx(l),x=o+a*c*y*_;d=h.device.createBuffer({byteLength:x})}let m=r.device.createCommandEncoder();return m.copyTextureToBuffer({sourceTexture:r,width:a,height:c,origin:[n,s],destinationBuffer:d,byteOffset:o}),m.destroy(),f&&u.destroy(),d}function Tx(r){return r instanceof It?{framebuffer:r,deleteFramebuffer:!1}:{framebuffer:BS(r),deleteFramebuffer:!0}}function BS(r,e){let{device:t,width:n,height:s,id:i}=r;return t.createFramebuffer({...e,id:`framebuffer-for-${i}`,width:n,height:s,colorAttachments:[r]})}function LS(r,e,t,n,s,i){if(r)return r;e||=5121;let o=_x(e),a=jr(o),c=md(t);return new a(n*s*c)}var wx=O(()=>{H();dd();gx();yx()});var gd={};Ht(gd,{WebGLDevice:()=>wn});function US(r,e,t){switch(t.length){case 1:r.gl.vertexAttrib1fv(e,t);break;case 2:r.gl.vertexAttrib2fv(e,t);break;case 3:r.gl.vertexAttrib3fv(e,t);break;case 4:r.gl.vertexAttrib4fv(e,t);break;default:}}function VS(r,e,t){r.gl.vertexAttribI4iv(e,t)}function zS(r,e,t){r.gl.vertexAttribI4uiv(e,t)}function WS(r,e){if(!r||!e||r.length!==e.length||r.constructor!==e.constructor)return!1;for(let t=0;t<r.length;++t)if(r[t]!==e[t])return!1;return!0}var wn,cl=O(()=>{H();nd();vy();Ey();Ny();Dy();Fy();Gh();Qh();Ts();Ly();Yc();Wy();Hy();el();Hc();sx();cx();fx();dx();px();wx();ys();Jc();ro();wn=class extends Be{type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;gl;_constants;_extensions={};_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case"unorm8x4-bgra":return!1;default:return!0}}constructor(e){super({...e,id:e.id||By("webgl-device")});let t=Be._getCanvasContextProps(e);if(!t)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let n=t.canvas?.gl?.device;if(n)throw new Error(`WebGL context already attached to device ${n.id}`);this.canvasContext=new Xc(this,t),this.lost=new Promise(u=>{this._resolveContextLost=u});let s={...e.webgl};t.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),e.powerPreference!==void 0&&(s.powerPreference=e.powerPreference);let o=this.props._handle||wy(this.canvasContext.canvas,{onContextLost:u=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:u=>console.log("WebGL context restored")},s);if(!o)throw new Error("WebGL context creation failed");if(n=o.device,n){if(e._reuseDevices)return I.log(1,`Not creating a new Device, instead returning a reference to Device ${n.id} already attached to WebGL context`,n)(),n._reused=!0,n;throw new Error(`WebGL context already attached to device ${n.id}`)}this.handle=o,this.gl=o,this.spectorJS=ay({...this.props,gl:this.handle}),this.gl.device=this,this.gl._version=2,this.info=Ay(this.gl,this._extensions),this.limits=new jc(this.gl),this.features=new $c(this.gl,this._extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new At(this.gl,{log:(...u)=>I.log(1,...u)()}).trackState(this.gl,{copyState:!1});let c=e.debugWebGL||e.debug,l=e.debugWebGL;c&&(this.gl=fy(this.gl,{debugWebGL:c,traceWebGL:l}),I.warn("WebGL debug mode activated. Performance reduced.")(),e.debugWebGL&&(I.level=Math.max(I.level,1))),this.commandEncoder=new io(this,{id:`${this}-command-encoder`})}destroy(){!this.props._reuseDevices&&!this._reused&&delete this.gl.device}get isLost(){return this.gl.isContextLost()}getTextureByteAlignment(){return 4}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){let t=this._normalizeBufferProps(e);return new St(this,t)}createTexture(e){return new Wt(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new Qc(this,e)}createShader(e){return new qc(this,e)}createFramebuffer(e){return new Vt(this,e)}createVertexArray(e){return new ws(this,e)}createTransformFeedback(e){return new il(this,e)}createQuerySet(e){return new al(this,e)}createRenderPipeline(e){return new rl(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(e={}){return new io(this,e)}submit(e){e||(e=this.commandEncoder.finish(),this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:`${this.id}-default-encoder`})),e._executeCommands()}readPixelsToArrayWebGL(e,t){return xx(e,t)}readPixelsToBufferWebGL(e,t){return bx(e,t)}setParametersWebGL(e){vt(this.gl,e)}getParametersWebGL(e){return Uc(this.gl,e)}withParametersWebGL(e,t){return Lr(this.gl,e,t)}resetWebGL(){I.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),_y(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return My(this.gl,e,this._extensions)}loseDevice(){let e=!1,n=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return n&&(e=!0,n.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){At.get(this.gl).push()}popState(){At.get(this.gl).pop()}getGLKey(e,t){let n=Number(e);for(let s in this.gl)if(this.gl[s]===n)return`GL.${s}`;return t?.emptyIfUnknown?"":String(e)}getGLKeys(e){let t={emptyIfUnknown:!0};return Object.entries(e).reduce((n,[s,i])=>(n[`${s}:${this.getGLKey(s,t)}`]=`${i}:${this.getGLKey(i,t)}`,n),{})}setConstantAttributeWebGL(e,t){let n=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(n).fill(null);let s=this._constants[e];switch(s&&WS(s,t)&&I.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:US(this,e,t);break;case Int32Array:VS(this,e,t);break;case Uint32Array:zS(this,e,t);break;default:throw new Error("constant")}}getExtension(e){return Ut(this.gl,e,this._extensions),this._extensions}_setWebGLDebugMetadata(e,t,n){e.luma=t;let s={props:n.spector,id:n.spector.id};e.__SPECTOR_Metadata=s}}});function $S(r){return typeof WebGL2RenderingContext<"u"&&r instanceof WebGL2RenderingContext?!0:Boolean(r&&Number.isFinite(r._version))}var ll,_d,oo,vx=O(()=>{H();sy();Gh();Qh();ll=1,_d=class extends Bs{type="webgl";constructor(){super(),Be.defaultProps={...Be.defaultProps,...Lc}}enforceWebGL2(e){ny(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&I.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){let{WebGLDevice:n}=await Promise.resolve().then(()=>(cl(),gd));if(e instanceof n)return e;if(e?.device instanceof n)return e.device;if(!$S(e))throw new Error("Invalid WebGL2RenderingContext");let s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){let{WebGLDevice:t}=await Promise.resolve().then(()=>(cl(),gd));I.groupCollapsed(ll,"WebGLDevice created")();try{let n=[];(e.debugWebGL||e.debug)&&n.push(uy()),e.debugSpectorJS&&n.push(oy(e));let s=await Promise.allSettled(n);for(let a of s)a.status==="rejected"&&I.error(`Failed to initialize debug libraries ${a.reason}`)();let i=new t(e),o=`${i._reused?"Reusing":"Created"} device with WebGL2 ${i.props.debug?"debug ":""}context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return I.probe(ll,o)(),I.table(ll,i.info)(),i}finally{I.groupEnd(ll)()}}};oo=new _d});var ol=O(()=>{vx();cl();Yc()});var YE={};Ht(YE,{AmbientLight:()=>ls,Attribute:()=>hr,AttributeManager:()=>vn,COORDINATE_SYSTEM:()=>Y,CompositeLayer:()=>Zx,Controller:()=>De,Deck:()=>ul,DeckGL:()=>Io,DeckRenderer:()=>bn,DirectionalLight:()=>sr,FirstPersonController:()=>En,FirstPersonView:()=>Qx,FirstPersonViewport:()=>Pl,FlyToInterpolator:()=>Eo,Layer:()=>wl,LayerExtension:()=>rb,LayerManager:()=>gn,LightingEffect:()=>Or,LinearInterpolator:()=>Ae,MapController:()=>xn,MapView:()=>Oc,OPERATION:()=>b_,OrbitController:()=>Rn,OrbitView:()=>Jx,OrbitViewport:()=>Sl,OrthographicController:()=>In,OrthographicView:()=>eb,OrthographicViewport:()=>Rl,PointLight:()=>ds,PostProcessEffect:()=>Wi,TRANSITION_EVENTS:()=>Xi,Tesselator:()=>Ro,TransitionInterpolator:()=>lr,UNIT:()=>Pr,VERSION:()=>tc,View:()=>Ne,Viewport:()=>je,WebMercatorViewport:()=>kr,Widget:()=>Fr,_CameraLight:()=>Ui,_Component:()=>Ss,_ComponentState:()=>An,_GlobeController:()=>Pn,_GlobeView:()=>tb,_GlobeViewport:()=>gs,_LayersPass:()=>xt,_PickLayersPass:()=>ir,_SunLight:()=>Vi,_applyStyles:()=>Qi,_compareProps:()=>xl,_count:()=>bl,_deepEqual:()=>le,_fillArray:()=>Ec,_flatten:()=>Dr,_memoize:()=>ot,_mergeShaders:()=>yo,_registerLoggers:()=>ec,_removeStyles:()=>Fc,assert:()=>ie,color:()=>bh,createIterable:()=>vs,fp64LowPart:()=>zh,getShaderAssembler:()=>bc,gouraudMaterial:()=>si,log:()=>$,phongMaterial:()=>ii,picking:()=>Uh,project:()=>Cr,project32:()=>Mh,shadow:()=>cs});var Uf={};Ht(Uf,{Buffer:()=>W,BufferTransform:()=>pt,CubeGeometry:()=>fi,Device:()=>Be,Framebuffer:()=>It,Geometry:()=>mt,GroupNode:()=>nn,Model:()=>Ye,ModelNode:()=>ui,ScenegraphNode:()=>Ot,SphereGeometry:()=>hi,Texture:()=>K,TextureTransform:()=>ci,attachDevice:()=>Z3,createDevice:()=>G3,enforceWebGL2:()=>Q3,getSupportedAdapters:()=>q3,setDefaultDeviceProps:()=>K3,stats:()=>Y3});H();H();var t0=1,r0=1,qr=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:t=0,duration:n=Number.POSITIVE_INFINITY,rate:s=1,repeat:i=1}=e,o=t0++,a={time:0,delay:t,duration:n,rate:s,repeat:i};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(e){this.channels.delete(e);for(let[t,n]of this.animations)n.channel===e&&this.detachAnimation(t)}isFinished(e){let t=this.channels.get(e);return t===void 0?!1:this.time>=t.delay+t.duration*t.repeat}getTime(e){if(e===void 0)return this.time;let t=this.channels.get(e);return t===void 0?-1:t.time}setTime(e){this.time=Math.max(0,e);let t=this.channels.values();for(let s of t)this._setChannelTime(s,this.time);let n=this.animations.values();for(let s of n){let{animation:i,channel:o}=s;i.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){let n=r0++;return this.animations.set(n,{animation:e,channel:t}),e.setTime(this.getTime(t)),n}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){let n=t-e.delay,s=e.duration*e.repeat;n>=s?e.time=e.duration*e.rate:(e.time=Math.max(0,n)%e.duration,e.time*=e.rate)}};H();function Np(r){return typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame(r):setTimeout(r,1e3/60)}function Dp(r){return typeof window<"u"&&window.cancelAnimationFrame?window.cancelAnimationFrame(r):clearTimeout(r)}Rs();var n0=0,wu=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;constructor(e){if(this.props={...wu.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Ze({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}reportError(e){this.props.onError(e),this._error=e}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost||this._error?this:(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=Np(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(Dp(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device?.submit()}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");let t=e?.canvas,n=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:t,useDevicePixels:n,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:t,aspect:n}=this._getSizeAndAspect();(e!==this.animationProps.width||t!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),n!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=n,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);let n=this.props.onAddHTML(t);n&&(t.innerHTML=n)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,t]=this.device?.getDefaultCanvasContext().getDevicePixelSize()||[1,1],n=1,s=this.device?.getDefaultCanvasContext().canvas;return s&&s.clientHeight?n=s.clientWidth/s.clientHeight:e>0&&t>0&&(n=e/t),{width:e,height:t,aspect:n}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}},Vn=wu;L(Vn,"defaultAnimationLoopProps",{device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:mr.stats.get(`animation-loop-${n0++}`),autoResizeViewport:!1});H();function Go(r,e){if(!r)throw new Error(e||"shadertools: assertion failed.")}var vu={number:{type:"number",validate(r,e){return Number.isFinite(r)&&typeof e=="object"&&(e.max===void 0||r<=e.max)&&(e.min===void 0||r>=e.min)}},array:{type:"array",validate(r,e){return Array.isArray(r)||ArrayBuffer.isView(r)}}};function Bp(r){let e={};for(let[t,n]of Object.entries(r))e[t]=s0(n);return e}function s0(r){let e=Fp(r);if(e!=="object")return{value:r,...vu[e],type:e};if(typeof r=="object")return r?r.type!==void 0?{...r,...vu[r.type],type:r.type}:r.value===void 0?{type:"object",value:r}:(e=Fp(r.value),{...r,...vu[e],type:e}):{type:"object",value:null};throw new Error("props")}function Fp(r){return Array.isArray(r)||ArrayBuffer.isView(r)?"array":typeof r}var Lp=`#ifdef MODULE_LOGDEPTH
17
+ </pre></code>`,a.style.top="10px",a.style.left="10px",a.style.position="absolute",a.style.zIndex="9999",a.style.width="100%",a.style.textAlign="left",document.body.appendChild(a),document.getElementsByClassName("luma-compiler-log-error")[0]?.scrollIntoView(),a.onclick=()=>{let l=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(l)}}},gr=mu;L(gr,"defaultProps",{...j.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0})});var gu,Et,Pp=O(()=>{Pe();hu();jt();gu=class extends j{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,t={}){super(e,t,gu.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let t=this.colorAttachments.map(s=>s.texture.clone(e)),n=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,colorAttachments:t,depthStencilAttachment:n})}resize(e){let t=!e;if(e){let[n,s]=Array.isArray(e)?e:[e.width,e.height];t=t||s!==this.height||n!==this.width,this.width=n,this.height=s}t&&(I.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(this.props.colorAttachments.length===0&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map((t,n)=>{if(typeof t=="string"){let s=this.createColorTexture(t,n);return this.attachResource(s),s.view}return t instanceof K?t.view:t});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else e instanceof K?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,t){return this.device.createTexture({id:`${this.id}-color-attachment-${t}`,usage:K.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:K.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let n=0;n<this.colorAttachments.length;++n)if(this.colorAttachments[n]){let s=this.colorAttachments[n].texture.clone({width:e,height:t});this.destroyAttachedResource(this.colorAttachments[n]),this.colorAttachments[n]=s.view,this.attachResource(s.view)}if(this.depthStencilAttachment){let n=this.depthStencilAttachment.texture.clone({width:e,height:t});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=n.view,this.attachResource(n)}this.updateAttachments()}},Et=gu;L(Et,"defaultProps",{...j.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null})});var _u,Ze,Cp=O(()=>{Pe();_u=class extends j{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";constructor(e,t){super(e,t,_u.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[]}},Ze=_u;L(Ze,"defaultProps",{...j.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},bindings:{},uniforms:{}})});var Yr,qt,Mp=O(()=>{Pe();Yr=class extends j{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,t){t=Yr.normalizeProps(e,t),super(e,t,Yr.defaultProps)}static normalizeProps(e,t){return t}},qt=Yr;L(qt,"defaultClearColor",[0,0,0,1]),L(qt,"defaultClearDepth",1),L(qt,"defaultClearStencil",0),L(qt,"defaultProps",{...j.defaultProps,framebuffer:null,parameters:void 0,clearColor:Yr.defaultClearColor,clearColors:void 0,clearDepth:Yr.defaultClearDepth,clearStencil:Yr.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0})});var yu,qr,Op=O(()=>{Pe();yu=class extends j{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,t){super(e,t,yu.defaultProps),this.shaderLayout=t.shaderLayout}},qr=yu;L(qr,"defaultProps",{...j.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0})});var xu,Bn,kp=O(()=>{Pe();xu=class extends j{get[Symbol.toStringTag](){return"CommandEncoder"}constructor(e,t){super(e,t,xu.defaultProps)}},Bn=xu;L(Bn,"defaultProps",{...j.defaultProps,measureExecutionTime:void 0})});var bu,Ln,Np=O(()=>{Pe();bu=class extends j{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,t){super(e,t,bu.defaultProps)}},Ln=bu;L(Ln,"defaultProps",{...j.defaultProps})});function Vs(r){return t0[r]}function Tu(r){let[e,t]=e0[r],n=e==="i32"||e==="u32",s=e!=="u32",i=Jb[e]*t;return{primitiveType:e,components:t,byteLength:i,integer:n,signed:s}}var Jb,e0,t0,r0,kP,Go=O(()=>{Jb={f32:4,f16:2,i32:4,u32:4},e0={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]},t0={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>":{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}},r0={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>"},kP={...r0,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>"}});function Qo(r,e){let t={};for(let n of r.attributes){let s=n0(r,e,n.name);s&&(t[n.name]=s)}return t}function Dp(r,e,t=16){let n=Qo(r,e),s=new Array(t).fill(null);for(let i of Object.values(n))s[i.location]=i;return s}function n0(r,e,t){let n=s0(r,t),s=i0(e,t);if(!n)return null;let i=Tu(n.type),o=op(i),a=s?.vertexFormat||o,c=Dn(a);return{attributeName:s?.attributeName||n.name,bufferName:s?.bufferName||n.name,location:n.location,shaderType:n.type,primitiveType:i.primitiveType,shaderComponents:i.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:i.integer,stepMode:s?.stepMode||n.stepMode||"vertex",byteOffset:s?.byteOffset||0,byteStride:s?.byteStride||0}}function s0(r,e){let t=r.attributes.find(n=>n.name===e);return t||I.warn(`shader layout attribute "${e}" not present in shader`),t||null}function i0(r,e){o0(r);let t=a0(r,e);return t||(t=c0(r,e),t)?t:(I.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function o0(r){for(let e of r)(e.attributes&&e.format||!e.attributes&&!e.format)&&I.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function a0(r,e){for(let t of r)if(t.format&&t.name===e)return{attributeName:t.name,bufferName:e,stepMode:t.stepMode,vertexFormat:t.format,byteOffset:0,byteStride:t.byteStride||0};return null}function c0(r,e){for(let t of r){let n=t.byteStride;if(typeof t.byteStride!="number")for(let i of t.attributes||[]){let o=Dn(i.format);n+=o.byteLength}let s=t.attributes?.find(i=>i.attribute===e);if(s)return{attributeName:s.attribute,bufferName:t.name,stepMode:t.stepMode,vertexFormat:s.format,byteOffset:s.byteOffset,byteStride:n}}return null}var wu=O(()=>{jt();Go();zo()});var vu,Un,Fp=O(()=>{wu();Pe();vu=class extends j{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,vu.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=Dp(t.shaderLayout,t.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){this.device.reportError(new Error("constant attributes not supported"),this)()}},Un=vu;L(Un,"defaultProps",{...j.defaultProps,shaderLayout:void 0,bufferLayout:[]})});var Au,Vn,Bp=O(()=>{Pe();Au=class extends j{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,Au.defaultProps)}},Vn=Au;L(Vn,"defaultProps",{...j.defaultProps,layout:void 0,buffers:{}})});var Su,zn,Lp=O(()=>{Pe();Su=class extends j{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,Su.defaultProps)}},zn=Su;L(zn,"defaultProps",{...j.defaultProps,type:void 0,count:void 0})});function Eu(r){return(!Jo||Jo.byteLength<r)&&(Jo=new ArrayBuffer(r)),Jo}function Ru(r,e){let t=Eu(r.BYTES_PER_ELEMENT*e);return new r(t,0,e)}var Jo,Iu=O(()=>{});function l0(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Wn(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number":l0(r)}var Pu=O(()=>{});var u0,ea,Up=O(()=>{Ns();Go();Iu();Pu();jt();u0=1024,ea=class{layout={};byteLength;constructor(e,t={}){let n=0;for(let[i,o]of Object.entries(e)){let a=Vs(o),{type:c,components:l}=a,u=l*(t?.[i]??1);n=sp(n,u);let f=n;n+=u,this.layout[i]={type:c,size:u,offset:f}}n+=(4-n%4)%4;let s=n*4;this.byteLength=Math.max(s,u0)}getData(e){let t=Eu(this.byteLength),n={i32:new Int32Array(t),u32:new Uint32Array(t),f32:new Float32Array(t),f16:new Uint16Array(t)};for(let[s,i]of Object.entries(e)){let o=this.layout[s];if(!o){I.warn(`Supplied uniform value ${s} not present in uniform block layout`)();continue}let{type:a,size:c,offset:l}=o,u=n[a];if(c===1){if(typeof i!="number"&&typeof i!="boolean"){I.warn(`Supplied value for single component uniform ${s} is not a number: ${i}`)();continue}u[l]=Number(i)}else{if(!Wn(i)){I.warn(`Supplied value for multi component / array uniform ${s} is not a numeric array: ${i}`)();continue}u.set(i,l)}}return new Uint8Array(t,0,this.byteLength)}has(e){return Boolean(this.layout[e])}get(e){return this.layout[e]}}});function Vp(r,e,t=16){if(r!==e)return!1;let n=r,s=e;if(!Wn(n))return!1;if(Wn(s)&&n.length===s.length){for(let i=0;i<n.length;++i)if(s[i]!==n[i])return!1}return!0}function zp(r){return Wn(r)?r.slice():r}var Wp=O(()=>{Pu()});var ta,$p=O(()=>{Wp();ta=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let t=e?.shaderLayout.bindings?.find(s=>s.type==="uniform"&&s.name===e?.name);if(!t)throw new Error(e?.name);let n=t;for(let s of n.uniforms||[])this.bindingLayout[s.name]=s}}setUniforms(e){for(let[t,n]of Object.entries(e))this._setUniform(t,n),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${n}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){Vp(this.uniforms[e],t)||(this.uniforms[e]=zp(t),this.modifiedUniforms[e]=!0,this.modified=!0)}}});var zs,jp=O(()=>{Vo();jt();$p();Up();zs=class{uniformBlocks=new Map;uniformBufferLayouts=new Map;uniformBuffers=new Map;constructor(e){for(let[t,n]of Object.entries(e)){let s=t,i=new ea(n.uniformTypes??{},n.uniformSizes??{});this.uniformBufferLayouts.set(s,i);let o=new ta({name:t});o.setUniforms(n.defaultUniforms||{}),this.uniformBlocks.set(s,o)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[t,n]of Object.entries(e))this.uniformBlocks.get(t)?.setUniforms(n);this.updateUniformBuffers()}getUniformBufferByteLength(e){return this.uniformBufferLayouts.get(e)?.byteLength||0}getUniformBufferData(e){let t=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.uniformBufferLayouts.get(e)?.getData(t)}createUniformBuffer(e,t,n){n&&this.setUniforms(n);let s=this.getUniformBufferByteLength(t),i=e.createBuffer({usage:W.UNIFORM|W.COPY_DST,byteLength:s}),o=this.getUniformBufferData(t);return i.write(o),i}getManagedUniformBuffer(e,t){if(!this.uniformBuffers.get(t)){let n=this.getUniformBufferByteLength(t),s=e.createBuffer({usage:W.UNIFORM|W.COPY_DST,byteLength:n});this.uniformBuffers.set(t,s)}return this.uniformBuffers.get(t)}updateUniformBuffers(){let e=!1;for(let t of this.uniformBlocks.keys()){let n=this.updateUniformBuffer(t);e||=n}return e&&I.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let t=this.uniformBlocks.get(e),n=this.uniformBuffers.get(e),s=!1;if(n&&t?.needsRedraw){s||=t.needsRedraw;let i=this.getUniformBufferData(e);n=this.uniformBuffers.get(e),n?.write(i);let o=this.uniformBlocks.get(e)?.getAllUniforms();I.log(4,`Writing to uniform buffer ${String(e)}`,i,o)()}return s}}});var H=O(()=>{pp();yp();au();vp();Vo();hu();Ap();Ip();fu();Pp();Cp();Mp();Op();kp();Np();Fp();Bp();Lp();jp();Ns();Go();zo();iu();jt();Iu();wu()});var Br,hy=O(()=>{(function(r){r[r.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",r[r.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",r[r.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",r[r.POINTS=0]="POINTS",r[r.LINES=1]="LINES",r[r.LINE_LOOP=2]="LINE_LOOP",r[r.LINE_STRIP=3]="LINE_STRIP",r[r.TRIANGLES=4]="TRIANGLES",r[r.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",r[r.TRIANGLE_FAN=6]="TRIANGLE_FAN",r[r.ZERO=0]="ZERO",r[r.ONE=1]="ONE",r[r.SRC_COLOR=768]="SRC_COLOR",r[r.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",r[r.SRC_ALPHA=770]="SRC_ALPHA",r[r.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",r[r.DST_ALPHA=772]="DST_ALPHA",r[r.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",r[r.DST_COLOR=774]="DST_COLOR",r[r.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",r[r.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",r[r.CONSTANT_COLOR=32769]="CONSTANT_COLOR",r[r.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",r[r.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",r[r.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",r[r.FUNC_ADD=32774]="FUNC_ADD",r[r.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",r[r.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",r[r.BLEND_EQUATION=32777]="BLEND_EQUATION",r[r.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",r[r.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",r[r.BLEND_DST_RGB=32968]="BLEND_DST_RGB",r[r.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",r[r.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",r[r.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",r[r.BLEND_COLOR=32773]="BLEND_COLOR",r[r.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",r[r.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",r[r.LINE_WIDTH=2849]="LINE_WIDTH",r[r.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",r[r.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",r[r.CULL_FACE_MODE=2885]="CULL_FACE_MODE",r[r.FRONT_FACE=2886]="FRONT_FACE",r[r.DEPTH_RANGE=2928]="DEPTH_RANGE",r[r.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",r[r.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",r[r.DEPTH_FUNC=2932]="DEPTH_FUNC",r[r.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",r[r.STENCIL_FUNC=2962]="STENCIL_FUNC",r[r.STENCIL_FAIL=2964]="STENCIL_FAIL",r[r.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",r[r.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",r[r.STENCIL_REF=2967]="STENCIL_REF",r[r.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",r[r.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",r[r.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",r[r.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",r[r.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",r[r.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",r[r.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",r[r.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",r[r.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",r[r.VIEWPORT=2978]="VIEWPORT",r[r.SCISSOR_BOX=3088]="SCISSOR_BOX",r[r.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",r[r.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",r[r.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",r[r.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",r[r.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",r[r.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",r[r.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",r[r.RED_BITS=3410]="RED_BITS",r[r.GREEN_BITS=3411]="GREEN_BITS",r[r.BLUE_BITS=3412]="BLUE_BITS",r[r.ALPHA_BITS=3413]="ALPHA_BITS",r[r.DEPTH_BITS=3414]="DEPTH_BITS",r[r.STENCIL_BITS=3415]="STENCIL_BITS",r[r.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",r[r.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",r[r.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",r[r.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",r[r.SAMPLES=32937]="SAMPLES",r[r.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",r[r.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",r[r.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",r[r.VENDOR=7936]="VENDOR",r[r.RENDERER=7937]="RENDERER",r[r.VERSION=7938]="VERSION",r[r.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",r[r.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",r[r.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",r[r.STATIC_DRAW=35044]="STATIC_DRAW",r[r.STREAM_DRAW=35040]="STREAM_DRAW",r[r.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.BUFFER_SIZE=34660]="BUFFER_SIZE",r[r.BUFFER_USAGE=34661]="BUFFER_USAGE",r[r.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",r[r.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",r[r.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",r[r.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",r[r.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",r[r.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",r[r.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",r[r.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",r[r.CULL_FACE=2884]="CULL_FACE",r[r.FRONT=1028]="FRONT",r[r.BACK=1029]="BACK",r[r.FRONT_AND_BACK=1032]="FRONT_AND_BACK",r[r.BLEND=3042]="BLEND",r[r.DEPTH_TEST=2929]="DEPTH_TEST",r[r.DITHER=3024]="DITHER",r[r.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",r[r.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",r[r.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",r[r.SCISSOR_TEST=3089]="SCISSOR_TEST",r[r.STENCIL_TEST=2960]="STENCIL_TEST",r[r.NO_ERROR=0]="NO_ERROR",r[r.INVALID_ENUM=1280]="INVALID_ENUM",r[r.INVALID_VALUE=1281]="INVALID_VALUE",r[r.INVALID_OPERATION=1282]="INVALID_OPERATION",r[r.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",r[r.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",r[r.CW=2304]="CW",r[r.CCW=2305]="CCW",r[r.DONT_CARE=4352]="DONT_CARE",r[r.FASTEST=4353]="FASTEST",r[r.NICEST=4354]="NICEST",r[r.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",r[r.BYTE=5120]="BYTE",r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.SHORT=5122]="SHORT",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.INT=5124]="INT",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.FLOAT=5126]="FLOAT",r[r.DOUBLE=5130]="DOUBLE",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.ALPHA=6406]="ALPHA",r[r.RGB=6407]="RGB",r[r.RGBA=6408]="RGBA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",r[r.VERTEX_SHADER=35633]="VERTEX_SHADER",r[r.COMPILE_STATUS=35713]="COMPILE_STATUS",r[r.DELETE_STATUS=35712]="DELETE_STATUS",r[r.LINK_STATUS=35714]="LINK_STATUS",r[r.VALIDATE_STATUS=35715]="VALIDATE_STATUS",r[r.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",r[r.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",r[r.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",r[r.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",r[r.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",r[r.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",r[r.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",r[r.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",r[r.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",r[r.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",r[r.SHADER_TYPE=35663]="SHADER_TYPE",r[r.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",r[r.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",r[r.NEVER=512]="NEVER",r[r.LESS=513]="LESS",r[r.EQUAL=514]="EQUAL",r[r.LEQUAL=515]="LEQUAL",r[r.GREATER=516]="GREATER",r[r.NOTEQUAL=517]="NOTEQUAL",r[r.GEQUAL=518]="GEQUAL",r[r.ALWAYS=519]="ALWAYS",r[r.KEEP=7680]="KEEP",r[r.REPLACE=7681]="REPLACE",r[r.INCR=7682]="INCR",r[r.DECR=7683]="DECR",r[r.INVERT=5386]="INVERT",r[r.INCR_WRAP=34055]="INCR_WRAP",r[r.DECR_WRAP=34056]="DECR_WRAP",r[r.NEAREST=9728]="NEAREST",r[r.LINEAR=9729]="LINEAR",r[r.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",r[r.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",r[r.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",r[r.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",r[r.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",r[r.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",r[r.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",r[r.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE=5890]="TEXTURE",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r[r.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",r[r.TEXTURE0=33984]="TEXTURE0",r[r.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",r[r.REPEAT=10497]="REPEAT",r[r.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",r[r.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",r[r.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",r[r.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",r[r.FLOAT_VEC2=35664]="FLOAT_VEC2",r[r.FLOAT_VEC3=35665]="FLOAT_VEC3",r[r.FLOAT_VEC4=35666]="FLOAT_VEC4",r[r.INT_VEC2=35667]="INT_VEC2",r[r.INT_VEC3=35668]="INT_VEC3",r[r.INT_VEC4=35669]="INT_VEC4",r[r.BOOL=35670]="BOOL",r[r.BOOL_VEC2=35671]="BOOL_VEC2",r[r.BOOL_VEC3=35672]="BOOL_VEC3",r[r.BOOL_VEC4=35673]="BOOL_VEC4",r[r.FLOAT_MAT2=35674]="FLOAT_MAT2",r[r.FLOAT_MAT3=35675]="FLOAT_MAT3",r[r.FLOAT_MAT4=35676]="FLOAT_MAT4",r[r.SAMPLER_2D=35678]="SAMPLER_2D",r[r.SAMPLER_CUBE=35680]="SAMPLER_CUBE",r[r.LOW_FLOAT=36336]="LOW_FLOAT",r[r.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",r[r.HIGH_FLOAT=36338]="HIGH_FLOAT",r[r.LOW_INT=36339]="LOW_INT",r[r.MEDIUM_INT=36340]="MEDIUM_INT",r[r.HIGH_INT=36341]="HIGH_INT",r[r.FRAMEBUFFER=36160]="FRAMEBUFFER",r[r.RENDERBUFFER=36161]="RENDERBUFFER",r[r.RGBA4=32854]="RGBA4",r[r.RGB5_A1=32855]="RGB5_A1",r[r.RGB565=36194]="RGB565",r[r.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",r[r.STENCIL_INDEX=6401]="STENCIL_INDEX",r[r.STENCIL_INDEX8=36168]="STENCIL_INDEX8",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r[r.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",r[r.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",r[r.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",r[r.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",r[r.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",r[r.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",r[r.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",r[r.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",r[r.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",r[r.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",r[r.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",r[r.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",r[r.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",r[r.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",r[r.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",r[r.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",r[r.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",r[r.NONE=0]="NONE",r[r.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",r[r.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",r[r.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",r[r.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",r[r.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",r[r.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",r[r.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",r[r.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",r[r.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",r[r.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",r[r.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",r[r.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",r[r.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",r[r.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",r[r.READ_BUFFER=3074]="READ_BUFFER",r[r.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",r[r.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",r[r.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",r[r.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",r[r.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",r[r.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",r[r.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",r[r.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",r[r.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",r[r.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",r[r.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",r[r.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",r[r.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",r[r.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",r[r.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",r[r.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",r[r.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",r[r.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",r[r.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",r[r.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",r[r.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",r[r.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",r[r.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",r[r.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",r[r.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",r[r.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",r[r.RED=6403]="RED",r[r.RGB8=32849]="RGB8",r[r.RGBA8=32856]="RGBA8",r[r.RGB10_A2=32857]="RGB10_A2",r[r.TEXTURE_3D=32879]="TEXTURE_3D",r[r.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",r[r.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",r[r.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",r[r.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",r[r.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",r[r.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",r[r.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",r[r.SRGB=35904]="SRGB",r[r.SRGB8=35905]="SRGB8",r[r.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",r[r.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",r[r.RGBA32F=34836]="RGBA32F",r[r.RGB32F=34837]="RGB32F",r[r.RGBA16F=34842]="RGBA16F",r[r.RGB16F=34843]="RGB16F",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",r[r.R11F_G11F_B10F=35898]="R11F_G11F_B10F",r[r.RGB9_E5=35901]="RGB9_E5",r[r.RGBA32UI=36208]="RGBA32UI",r[r.RGB32UI=36209]="RGB32UI",r[r.RGBA16UI=36214]="RGBA16UI",r[r.RGB16UI=36215]="RGB16UI",r[r.RGBA8UI=36220]="RGBA8UI",r[r.RGB8UI=36221]="RGB8UI",r[r.RGBA32I=36226]="RGBA32I",r[r.RGB32I=36227]="RGB32I",r[r.RGBA16I=36232]="RGBA16I",r[r.RGB16I=36233]="RGB16I",r[r.RGBA8I=36238]="RGBA8I",r[r.RGB8I=36239]="RGB8I",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.R8=33321]="R8",r[r.RG8=33323]="RG8",r[r.R16F=33325]="R16F",r[r.R32F=33326]="R32F",r[r.RG16F=33327]="RG16F",r[r.RG32F=33328]="RG32F",r[r.R8I=33329]="R8I",r[r.R8UI=33330]="R8UI",r[r.R16I=33331]="R16I",r[r.R16UI=33332]="R16UI",r[r.R32I=33333]="R32I",r[r.R32UI=33334]="R32UI",r[r.RG8I=33335]="RG8I",r[r.RG8UI=33336]="RG8UI",r[r.RG16I=33337]="RG16I",r[r.RG16UI=33338]="RG16UI",r[r.RG32I=33339]="RG32I",r[r.RG32UI=33340]="RG32UI",r[r.R8_SNORM=36756]="R8_SNORM",r[r.RG8_SNORM=36757]="RG8_SNORM",r[r.RGB8_SNORM=36758]="RGB8_SNORM",r[r.RGBA8_SNORM=36759]="RGBA8_SNORM",r[r.RGB10_A2UI=36975]="RGB10_A2UI",r[r.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",r[r.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.HALF_FLOAT=5131]="HALF_FLOAT",r[r.RG=33319]="RG",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",r[r.CURRENT_QUERY=34917]="CURRENT_QUERY",r[r.QUERY_RESULT=34918]="QUERY_RESULT",r[r.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",r[r.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",r[r.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",r[r.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",r[r.DRAW_BUFFER0=34853]="DRAW_BUFFER0",r[r.DRAW_BUFFER1=34854]="DRAW_BUFFER1",r[r.DRAW_BUFFER2=34855]="DRAW_BUFFER2",r[r.DRAW_BUFFER3=34856]="DRAW_BUFFER3",r[r.DRAW_BUFFER4=34857]="DRAW_BUFFER4",r[r.DRAW_BUFFER5=34858]="DRAW_BUFFER5",r[r.DRAW_BUFFER6=34859]="DRAW_BUFFER6",r[r.DRAW_BUFFER7=34860]="DRAW_BUFFER7",r[r.DRAW_BUFFER8=34861]="DRAW_BUFFER8",r[r.DRAW_BUFFER9=34862]="DRAW_BUFFER9",r[r.DRAW_BUFFER10=34863]="DRAW_BUFFER10",r[r.DRAW_BUFFER11=34864]="DRAW_BUFFER11",r[r.DRAW_BUFFER12=34865]="DRAW_BUFFER12",r[r.DRAW_BUFFER13=34866]="DRAW_BUFFER13",r[r.DRAW_BUFFER14=34867]="DRAW_BUFFER14",r[r.DRAW_BUFFER15=34868]="DRAW_BUFFER15",r[r.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",r[r.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",r[r.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",r[r.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",r[r.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",r[r.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",r[r.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",r[r.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",r[r.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",r[r.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",r[r.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",r[r.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",r[r.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",r[r.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",r[r.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",r[r.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",r[r.SAMPLER_3D=35679]="SAMPLER_3D",r[r.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",r[r.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",r[r.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",r[r.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",r[r.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",r[r.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",r[r.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",r[r.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",r[r.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",r[r.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",r[r.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",r[r.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",r[r.MAX_SAMPLES=36183]="MAX_SAMPLES",r[r.SAMPLER_BINDING=35097]="SAMPLER_BINDING",r[r.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",r[r.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",r[r.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",r[r.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",r[r.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",r[r.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",r[r.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",r[r.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",r[r.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",r[r.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",r[r.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",r[r.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",r[r.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",r[r.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",r[r.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",r[r.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",r[r.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",r[r.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",r[r.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",r[r.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",r[r.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",r[r.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",r[r.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",r[r.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",r[r.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",r[r.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",r[r.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",r[r.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",r[r.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",r[r.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",r[r.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",r[r.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",r[r.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",r[r.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",r[r.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",r[r.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",r[r.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",r[r.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",r[r.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",r[r.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",r[r.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",r[r.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",r[r.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",r[r.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",r[r.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",r[r.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",r[r.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",r[r.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",r[r.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",r[r.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",r[r.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",r[r.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r[r.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",r[r.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",r[r.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",r[r.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",r[r.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",r[r.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",r[r.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",r[r.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",r[r.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",r[r.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",r[r.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",r[r.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",r[r.UNIFORM_TYPE=35383]="UNIFORM_TYPE",r[r.UNIFORM_SIZE=35384]="UNIFORM_SIZE",r[r.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",r[r.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",r[r.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",r[r.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",r[r.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",r[r.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",r[r.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",r[r.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",r[r.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",r[r.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",r[r.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",r[r.OBJECT_TYPE=37138]="OBJECT_TYPE",r[r.SYNC_CONDITION=37139]="SYNC_CONDITION",r[r.SYNC_STATUS=37140]="SYNC_STATUS",r[r.SYNC_FLAGS=37141]="SYNC_FLAGS",r[r.SYNC_FENCE=37142]="SYNC_FENCE",r[r.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",r[r.UNSIGNALED=37144]="UNSIGNALED",r[r.SIGNALED=37145]="SIGNALED",r[r.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",r[r.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",r[r.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",r[r.WAIT_FAILED=37149]="WAIT_FAILED",r[r.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",r[r.COLOR=6144]="COLOR",r[r.DEPTH=6145]="DEPTH",r[r.STENCIL=6146]="STENCIL",r[r.MIN=32775]="MIN",r[r.MAX=32776]="MAX",r[r.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",r[r.STREAM_READ=35041]="STREAM_READ",r[r.STREAM_COPY=35042]="STREAM_COPY",r[r.STATIC_READ=35045]="STATIC_READ",r[r.STATIC_COPY=35046]="STATIC_COPY",r[r.DYNAMIC_READ=35049]="DYNAMIC_READ",r[r.DYNAMIC_COPY=35050]="DYNAMIC_COPY",r[r.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",r[r.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",r[r.INVALID_INDEX=4294967295]="INVALID_INDEX",r[r.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",r[r.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",r[r.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",r[r.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",r[r.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",r[r.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",r[r.R16_EXT=33322]="R16_EXT",r[r.RG16_EXT=33324]="RG16_EXT",r[r.RGB16_EXT=32852]="RGB16_EXT",r[r.RGBA16_EXT=32859]="RGBA16_EXT",r[r.R16_SNORM_EXT=36760]="R16_SNORM_EXT",r[r.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",r[r.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",r[r.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",r[r.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",r[r.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",r[r.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",r[r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",r[r.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",r[r.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",r[r.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",r[r.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",r[r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",r[r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",r[r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",r[r.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",r[r.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",r[r.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",r[r.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",r[r.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",r[r.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",r[r.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",r[r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",r[r.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",r[r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",r[r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",r[r.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",r[r.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",r[r.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",r[r.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",r[r.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",r[r.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",r[r.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",r[r.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",r[r.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",r[r.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",r[r.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",r[r.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",r[r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",r[r.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",r[r.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",r[r.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",r[r.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",r[r.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",r[r.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",r[r.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",r[r.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",r[r.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",r[r.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",r[r.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",r[r.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",r[r.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",r[r.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",r[r.LINE_WEBGL=6913]="LINE_WEBGL",r[r.FILL_WEBGL=6914]="FILL_WEBGL",r[r.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",r[r.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",r[r.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",r[r.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",r[r.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",r[r.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",r[r.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",r[r.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",r[r.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",r[r.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",r[r.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",r[r.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",r[r.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",r[r.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",r[r.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",r[r.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",r[r.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",r[r.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",r[r.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",r[r.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",r[r.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",r[r.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",r[r.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",r[r.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Br||(Br={}))});var dy=O(()=>{hy()});function py(r=!0){let e=HTMLCanvasElement.prototype;if(!r&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(t,n){if(t==="webgl"||t==="experimental-webgl"){let s=this.originalGetContext("webgl2",n);return s instanceof HTMLElement&&eS(s),s}return this.originalGetContext(t,n)}}function eS(r){r.getExtension("EXT_color_buffer_float");let e={...ZA,WEBGL_disjoint_timer_query:r.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:GA(r),OES_vertex_array_object:QA(r),ANGLE_instanced_arrays:JA(r)},t=r.getExtension;r.getExtension=function(s){let i=t.call(r,s);return i||(s in e?e[s]:null)};let n=r.getSupportedExtensions;r.getSupportedExtensions=function(){return(n.apply(r)||[])?.concat(Object.keys(e))}}var ZA,GA,QA,JA,my=O(()=>{ZA={WEBGL_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},OES_element_index_uint:{},OES_texture_float:{},OES_texture_half_float:{HALF_FLOAT_OES:5131},EXT_color_buffer_float:{},OES_standard_derivatives:{FRAGMENT_SHADER_DERIVATIVE_HINT_OES:35723},EXT_frag_depth:{},EXT_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},EXT_shader_texture_lod:{}},GA=r=>({drawBuffersWEBGL(e){return r.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),QA=r=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return r.createVertexArray()},deleteVertexArrayOES(e){return r.deleteVertexArray(e)},isVertexArrayOES(e){return r.isVertexArray(e)},bindVertexArrayOES(e){return r.bindVertexArray(e)}}),JA=r=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return r.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return r.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return r.vertexAttribDivisor(...e)}})});async function Wc(r,e){let t=document.getElementsByTagName("head")[0];if(!t)throw new Error("loadScript");let n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",r),e&&(n.id=e),new Promise((s,i)=>{n.onload=s,n.onerror=o=>i(new Error(`Unable to load script '${r}': ${o}`)),t.appendChild(n)})}var sd=O(()=>{});async function _y(r){if(!globalThis.SPECTOR)try{await Wc(r.debugSpectorJSUrl||$c.debugSpectorJSUrl)}catch(e){I.warn(String(e))}}function yy(r){if(r={...$c,...r},!r.debugSpectorJS)return null;if(!Ye&&globalThis.SPECTOR&&!globalThis.luma?.spector){I.probe(tS,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();let{Spector:e}=globalThis.SPECTOR;Ye=new e,globalThis.luma&&(globalThis.luma.spector=Ye)}if(!Ye)return null;if(gy||(gy=!0,Ye.spyCanvases(),Ye?.onCaptureStarted.add(e=>I.info("Spector capture started:",e)()),Ye?.onCapture.add(e=>{I.info("Spector capture complete:",e)(),Ye?.getResultUI(),Ye?.resultView.display(),Ye?.resultView.addCapture(e)})),r.gl){let e=r.gl,t=e.device;Ye?.startCapture(r.gl,500),e.device=t,new Promise(n=>setTimeout(n,2e3)).then(n=>{I.info("Spector capture stopped after 2 seconds")(),Ye?.stopCapture()})}return Ye}var tS,Ye,gy,$c,id=O(()=>{H();sd();tS=1,Ye=null,gy=!1,$c={debugSpectorJS:I.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0}});function by(r){return r.luma=r.luma||{},r.luma}async function Ty(){Xt()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await Wc(rS))}function wy(r,e={}){return e.debugWebGL||e.traceWebGL?sS(r,e):nS(r)}function nS(r){let e=by(r);return e.realContext?e.realContext:r}function sS(r,e){if(!globalThis.WebGLDebugUtils)return I.warn("webgl-debug not loaded")(),r;let t=by(r);if(t.debugContext)return t.debugContext;globalThis.WebGLDebugUtils.init({...Br,...r});let n=globalThis.WebGLDebugUtils.makeDebugContext(r,iS.bind(null,e),oS.bind(null,e));for(let o in Br)!(o in n)&&typeof Br[o]=="number"&&(n[o]=Br[o]);class s{}Object.setPrototypeOf(n,Object.getPrototypeOf(r)),Object.setPrototypeOf(s,n);let i=Object.create(s);return t.realContext=r,t.debugContext=i,i.debug=!0,i}function xy(r,e){e=Array.from(e).map(n=>n===void 0?"undefined":n);let t=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,e);return t=`${t.slice(0,100)}${t.length>100?"...":""}`,`gl.${r}(${t})`}function iS(r,e,t,n){n=Array.from(n).map(a=>a===void 0?"undefined":a);let s=globalThis.WebGLDebugUtils.glEnumToString(e),i=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,n),o=`${s} in gl.${t}(${i})`;I.error(o)();debugger}function oS(r,e,t){let n="";I.level>=1&&(n=xy(e,t),r.traceWebGL&&I.log(1,n)());for(let s of t)if(s===void 0){n=n||xy(e,t);debugger}}var rS,od=O(()=>{H();dy();Ls();sd();rS="https://unpkg.com/webgl-debug@2.0.1/index.js"});function ad(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}function de(r,e,t){return e[r]!==void 0?e[r]:t[r]}var so,be,vy,qe,Ay,no,Sy,Ey,cd,Ft,ld,Ry,ud=O(()=>{so={[3042]:!1,[32773]:new Float32Array([0,0,0,0]),[32777]:32774,[34877]:32774,[32969]:1,[32968]:0,[32971]:1,[32970]:0,[3106]:new Float32Array([0,0,0,0]),[3107]:[!0,!0,!0,!0],[2884]:!1,[2885]:1029,[2929]:!1,[2931]:1,[2932]:513,[2928]:new Float32Array([0,1]),[2930]:!0,[3024]:!0,[35725]:null,[36006]:null,[36007]:null,[34229]:null,[34964]:null,[2886]:2305,[33170]:4352,[2849]:1,[32823]:!1,[32824]:0,[10752]:0,[32926]:!1,[32928]:!1,[32938]:1,[32939]:!1,[3089]:!1,[3088]:new Int32Array([0,0,1024,1024]),[2960]:!1,[2961]:0,[2968]:4294967295,[36005]:4294967295,[2962]:519,[2967]:0,[2963]:4294967295,[34816]:519,[36003]:0,[36004]:4294967295,[2964]:7680,[2965]:7680,[2966]:7680,[34817]:7680,[34818]:7680,[34819]:7680,[2978]:[0,0,1024,1024],[36389]:null,[36662]:null,[36663]:null,[35053]:null,[35055]:null,[35723]:4352,[36010]:null,[35977]:!1,[3333]:4,[3317]:4,[37440]:!1,[37441]:!1,[37443]:37444,[3330]:0,[3332]:0,[3331]:0,[3314]:0,[32878]:0,[3316]:0,[3315]:0,[32877]:0},be=(r,e,t)=>e?r.enable(t):r.disable(t),vy=(r,e,t)=>r.hint(t,e),qe=(r,e,t)=>r.pixelStorei(t,e),Ay=(r,e,t)=>{let n=t===36006?36009:36008;return r.bindFramebuffer(n,e)},no=(r,e,t)=>{let s={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[t];r.bindBuffer(s,e)};Sy={[3042]:be,[32773]:(r,e)=>r.blendColor(...e),[32777]:"blendEquation",[34877]:"blendEquation",[32969]:"blendFunc",[32968]:"blendFunc",[32971]:"blendFunc",[32970]:"blendFunc",[3106]:(r,e)=>r.clearColor(...e),[3107]:(r,e)=>r.colorMask(...e),[2884]:be,[2885]:(r,e)=>r.cullFace(e),[2929]:be,[2931]:(r,e)=>r.clearDepth(e),[2932]:(r,e)=>r.depthFunc(e),[2928]:(r,e)=>r.depthRange(...e),[2930]:(r,e)=>r.depthMask(e),[3024]:be,[35723]:vy,[35725]:(r,e)=>r.useProgram(e),[36007]:(r,e)=>r.bindRenderbuffer(36161,e),[36389]:(r,e)=>r.bindTransformFeedback?.(36386,e),[34229]:(r,e)=>r.bindVertexArray(e),[36006]:Ay,[36010]:Ay,[34964]:no,[36662]:no,[36663]:no,[35053]:no,[35055]:no,[2886]:(r,e)=>r.frontFace(e),[33170]:vy,[2849]:(r,e)=>r.lineWidth(e),[32823]:be,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:be,[32926]:be,[32928]:be,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:be,[3088]:(r,e)=>r.scissor(...e),[2960]:be,[2961]:(r,e)=>r.clearStencil(e),[2968]:(r,e)=>r.stencilMaskSeparate(1028,e),[36005]:(r,e)=>r.stencilMaskSeparate(1029,e),[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]:(r,e)=>r.viewport(...e),[34383]:be,[10754]:be,[12288]:be,[12289]:be,[12290]:be,[12291]:be,[12292]:be,[12293]:be,[12294]:be,[12295]:be,[3333]:qe,[3317]:qe,[37440]:qe,[37441]:qe,[37443]:qe,[3330]:qe,[3332]:qe,[3331]:qe,[3314]:qe,[32878]:qe,[3316]:qe,[3315]:qe,[32877]:qe,framebuffer:(r,e)=>{let t=e&&"handle"in e?e.handle:e;return r.bindFramebuffer(36160,t)},blend:(r,e)=>e?r.enable(3042):r.disable(3042),blendColor:(r,e)=>r.blendColor(...e),blendEquation:(r,e)=>{let t=typeof e=="number"?[e,e]:e;r.blendEquationSeparate(...t)},blendFunc:(r,e)=>{let t=e?.length===2?[...e,...e]:e;r.blendFuncSeparate(...t)},clearColor:(r,e)=>r.clearColor(...e),clearDepth:(r,e)=>r.clearDepth(e),clearStencil:(r,e)=>r.clearStencil(e),colorMask:(r,e)=>r.colorMask(...e),cull:(r,e)=>e?r.enable(2884):r.disable(2884),cullFace:(r,e)=>r.cullFace(e),depthTest:(r,e)=>e?r.enable(2929):r.disable(2929),depthFunc:(r,e)=>r.depthFunc(e),depthMask:(r,e)=>r.depthMask(e),depthRange:(r,e)=>r.depthRange(...e),dither:(r,e)=>e?r.enable(3024):r.disable(3024),derivativeHint:(r,e)=>{r.hint(35723,e)},frontFace:(r,e)=>r.frontFace(e),mipmapHint:(r,e)=>r.hint(33170,e),lineWidth:(r,e)=>r.lineWidth(e),polygonOffsetFill:(r,e)=>e?r.enable(32823):r.disable(32823),polygonOffset:(r,e)=>r.polygonOffset(...e),sampleCoverage:(r,e)=>r.sampleCoverage(e[0],e[1]||!1),scissorTest:(r,e)=>e?r.enable(3089):r.disable(3089),scissor:(r,e)=>r.scissor(...e),stencilTest:(r,e)=>e?r.enable(2960):r.disable(2960),stencilMask:(r,e)=>{e=ad(e)?e:[e,e];let[t,n]=e;r.stencilMaskSeparate(1028,t),r.stencilMaskSeparate(1029,n)},stencilFunc:(r,e)=>{e=ad(e)&&e.length===3?[...e,...e]:e;let[t,n,s,i,o,a]=e;r.stencilFuncSeparate(1028,t,n,s),r.stencilFuncSeparate(1029,i,o,a)},stencilOp:(r,e)=>{e=ad(e)&&e.length===3?[...e,...e]:e;let[t,n,s,i,o,a]=e;r.stencilOpSeparate(1028,t,n,s),r.stencilOpSeparate(1029,i,o,a)},viewport:(r,e)=>r.viewport(...e)};Ey={blendEquation:(r,e,t)=>r.blendEquationSeparate(de(32777,e,t),de(34877,e,t)),blendFunc:(r,e,t)=>r.blendFuncSeparate(de(32969,e,t),de(32968,e,t),de(32971,e,t),de(32970,e,t)),polygonOffset:(r,e,t)=>r.polygonOffset(de(32824,e,t),de(10752,e,t)),sampleCoverage:(r,e,t)=>r.sampleCoverage(de(32938,e,t),de(32939,e,t)),stencilFuncFront:(r,e,t)=>r.stencilFuncSeparate(1028,de(2962,e,t),de(2967,e,t),de(2963,e,t)),stencilFuncBack:(r,e,t)=>r.stencilFuncSeparate(1029,de(34816,e,t),de(36003,e,t),de(36004,e,t)),stencilOpFront:(r,e,t)=>r.stencilOpSeparate(1028,de(2964,e,t),de(2965,e,t),de(2966,e,t)),stencilOpBack:(r,e,t)=>r.stencilOpSeparate(1029,de(34817,e,t),de(34818,e,t),de(34819,e,t))},cd={enable:(r,e)=>r({[e]:!0}),disable:(r,e)=>r({[e]:!1}),pixelStorei:(r,e,t)=>r({[e]:t}),hint:(r,e,t)=>r({[e]:t}),useProgram:(r,e)=>r({[35725]:e}),bindRenderbuffer:(r,e,t)=>r({[36007]:t}),bindTransformFeedback:(r,e,t)=>r({[36389]:t}),bindVertexArray:(r,e)=>r({[34229]:e}),bindFramebuffer:(r,e,t)=>{switch(e){case 36160:return r({[36006]:t,[36010]:t});case 36009:return r({[36006]:t});case 36008:return r({[36010]:t});default:return null}},bindBuffer:(r,e,t)=>{let n={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[e];return n?r({[n]:t}):{valueChanged:!0}},blendColor:(r,e,t,n,s)=>r({[32773]:new Float32Array([e,t,n,s])}),blendEquation:(r,e)=>r({[32777]:e,[34877]:e}),blendEquationSeparate:(r,e,t)=>r({[32777]:e,[34877]:t}),blendFunc:(r,e,t)=>r({[32969]:e,[32968]:t,[32971]:e,[32970]:t}),blendFuncSeparate:(r,e,t,n,s)=>r({[32969]:e,[32968]:t,[32971]:n,[32970]:s}),clearColor:(r,e,t,n,s)=>r({[3106]:new Float32Array([e,t,n,s])}),clearDepth:(r,e)=>r({[2931]:e}),clearStencil:(r,e)=>r({[2961]:e}),colorMask:(r,e,t,n,s)=>r({[3107]:[e,t,n,s]}),cullFace:(r,e)=>r({[2885]:e}),depthFunc:(r,e)=>r({[2932]:e}),depthRange:(r,e,t)=>r({[2928]:new Float32Array([e,t])}),depthMask:(r,e)=>r({[2930]:e}),frontFace:(r,e)=>r({[2886]:e}),lineWidth:(r,e)=>r({[2849]:e}),polygonOffset:(r,e,t)=>r({[32824]:e,[10752]:t}),sampleCoverage:(r,e,t)=>r({[32938]:e,[32939]:t}),scissor:(r,e,t,n,s)=>r({[3088]:new Int32Array([e,t,n,s])}),stencilMask:(r,e)=>r({[2968]:e,[36005]:e}),stencilMaskSeparate:(r,e,t)=>r({[e===1028?2968:36005]:t}),stencilFunc:(r,e,t,n)=>r({[2962]:e,[2967]:t,[2963]:n,[34816]:e,[36003]:t,[36004]:n}),stencilFuncSeparate:(r,e,t,n,s)=>r({[e===1028?2962:34816]:t,[e===1028?2967:36003]:n,[e===1028?2963:36004]:s}),stencilOp:(r,e,t,n)=>r({[2964]:e,[2965]:t,[2966]:n,[34817]:e,[34818]:t,[34819]:n}),stencilOpSeparate:(r,e,t,n,s)=>r({[e===1028?2964:34817]:t,[e===1028?2965:34818]:n,[e===1028?2966:34819]:s}),viewport:(r,e,t,n,s)=>r({[2978]:[e,t,n,s]})},Ft=(r,e)=>r.isEnabled(e),ld={[3042]:Ft,[2884]:Ft,[2929]:Ft,[3024]:Ft,[32823]:Ft,[32926]:Ft,[32928]:Ft,[3089]:Ft,[2960]:Ft,[35977]:Ft},Ry=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 Tt(r,e){if(aS(e))return;let t={};for(let s in e){let i=Number(s),o=Sy[s];o&&(typeof o=="string"?t[o]=!0:o(r,e[s],i))}let n=r.state&&r.state.cache;if(n)for(let s in t){let i=Ey[s];i(r,e,n)}}function jc(r,e=so){if(typeof e=="number"){let s=e,i=ld[s];return i?i(r,s):r.getParameter(s)}let t=Array.isArray(e)?e:Object.keys(e),n={};for(let s of t){let i=ld[s];n[s]=i?i(r,Number(s)):r.getParameter(Number(s))}return n}function Iy(r){Tt(r,so)}function aS(r){for(let e in r)return!1;return!0}var Ts=O(()=>{ud()});function Cy(r,e){if(r===e)return!0;if(Py(r)&&Py(e)&&r.length===e.length){for(let t=0;t<r.length;++t)if(r[t]!==e[t])return!1;return!0}return!1}function Py(r){return Array.isArray(r)||ArrayBuffer.isView(r)}var My=O(()=>{});function Oy(r,e){let t=r[e].bind(r);r[e]=function(s){if(s===void 0||Ry.has(s))return t(s);let i=wt.get(r);return s in i.cache||(i.cache[s]=t(s)),i.enable?i.cache[s]:t(s)},Object.defineProperty(r[e],"name",{value:`${e}-from-cache`,configurable:!1})}function cS(r,e,t){if(!r[e])return;let n=r[e].bind(r);r[e]=function(...i){let o=wt.get(r),{valueChanged:a,oldValue:c}=t(o._updateCache,...i);return a&&n(...i),c},Object.defineProperty(r[e],"name",{value:`${e}-to-cache`,configurable:!1})}function lS(r){let e=r.useProgram.bind(r);r.useProgram=function(n){let s=wt.get(r);s.program!==n&&(e(n),s.program=n)}}var wt,fd=O(()=>{Ts();My();ud();wt=class{static get(e){return e.state}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];Tt(this.gl,e),this.stateStack.pop()}trackState(e,t){if(this.cache=t?.copyState?jc(e):Object.assign({},so),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.state=this,lS(e);for(let n in cd){let s=cd[n];cS(e,n,s)}Oy(e,"getParameter"),Oy(e,"isEnabled")}_updateCache(e){let t=!1,n,s=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let i in e){let o=e[i],a=this.cache[i];Cy(o,a)||(t=!0,n=a,s&&!(i in s)&&(s[i]=a),this.cache[i]=o)}return{valueChanged:t,oldValue:n}}}});function ky(r,e,t){let n="",s={preserveDrawingBuffer:!0,...t},i=null;if(i||=r.getContext("webgl2",s),s.failIfMajorPerformanceCaveat&&(n||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow."),!i&&!t.failIfMajorPerformanceCaveat&&(s.failIfMajorPerformanceCaveat=!1,i=r.getContext("webgl2",s),i.luma||={},i.luma.softwareRenderer=!0),i||(i=r.getContext("webgl",{}),i&&(i=null,n||="Your browser only supports WebGL1")),!i)throw n||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${n}`);let{onContextLost:o,onContextRestored:a}=e;return r.addEventListener("webglcontextlost",c=>o(c),!1),r.addEventListener("webglcontextrestored",c=>a(c),!1),i.luma||={},i}var Ny=O(()=>{});function Bt(r,e,t){return t[e]===void 0&&(t[e]=r.getExtension(e)||null),t[e]}var io=O(()=>{});function Dy(r,e){let t=r.getParameter(7936),n=r.getParameter(7937);Bt(r,"WEBGL_debug_renderer_info",e);let s=e.WEBGL_debug_renderer_info,i=r.getParameter(s?s.UNMASKED_VENDOR_WEBGL:7936),o=r.getParameter(s?s.UNMASKED_RENDERER_WEBGL:7937),a=i||t,c=o||n,l=r.getParameter(7938),u=Fy(a,c),f=uS(a,c),h=fS(a,c);return{type:"webgl",gpu:u,gpuType:h,gpuBackend:f,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function Fy(r,e){return/NVIDIA/i.exec(r)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(r)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(r)||/Apple/i.exec(e)?"apple":/AMD/i.exec(r)||/AMD/i.exec(e)||/ATI/i.exec(r)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(r)||/SwiftShader/i.exec(e)?"software":"unknown"}function uS(r,e){return/Metal/i.exec(r)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(r)||/ANGLE/i.exec(e)?"opengl":"unknown"}function fS(r,e){if(/SwiftShader/i.exec(r)||/SwiftShader/i.exec(e))return"cpu";switch(Fy(r,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}var By=O(()=>{io()});function Hc(r){switch(r){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(r))}var hd=O(()=>{});function Vy(r){return r in Xc}function zy(r,e,t){return(Xc[e]||[]).every(s=>Bt(r,s,t))}function Wy(r,e,t){let n=e.create,s=dd[e.format];return s?.gl===void 0&&(n=!1),s?.x&&(n=n&&Boolean(Bt(r,s.x,t))),{format:e.format,create:n&&e.create,render:n&&e.render,filter:n&&e.filter,blend:n&&e.blend,store:n&&e.store}}function Yc(r){let e=dd[r],t=xS(r),n=Ht.getInfo(r);return n.compressed&&(e.dataFormat=t),{internalFormat:t,format:e?.dataFormat||yS(n.channels,n.integer,n.normalized,t),type:n.dataType?Hc(n.dataType):e?.types?.[0]||5121,compressed:n.compressed||!1}}function $y(r){switch(Ht.getInfo(r).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${r}`)}}function yS(r,e,t,n){if(n===6408||n===6407)return n;switch(r){case"r":return e&&!t?36244:6403;case"rg":return e&&!t?33320:33319;case"rgb":return e&&!t?36248:6407;case"rgba":return e&&!t?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function xS(r){let t=dd[r]?.gl;if(t===void 0)throw new Error(`Unsupported texture format ${r}`);return t}var oo,ao,ws,vs,hS,dS,pS,mS,gS,Ly,Uy,_S,Xc,dd,As=O(()=>{H();io();hd();oo="WEBGL_compressed_texture_s3tc",ao="WEBGL_compressed_texture_s3tc_srgb",ws="EXT_texture_compression_rgtc",vs="EXT_texture_compression_bptc",hS="WEBGL_compressed_texture_etc",dS="WEBGL_compressed_texture_astc",pS="WEBGL_compressed_texture_etc1",mS="WEBGL_compressed_texture_pvrtc",gS="WEBGL_compressed_texture_atc",Ly="EXT_texture_norm16",Uy="EXT_render_snorm",_S="EXT_color_buffer_float",Xc={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat-renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[Uy],"norm16-renderable-webgl":[Ly],"snorm16-renderable-webgl":[Ly,Uy],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[oo,ao,ws,vs],"texture-compression-bc5-webgl":[ws],"texture-compression-bc7-webgl":[vs],"texture-compression-etc2":[hS],"texture-compression-astc":[dS],"texture-compression-etc1-webgl":[pS],"texture-compression-pvrtc-webgl":[mS],"texture-compression-atc-webgl":[gS]};dd={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757},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},r16unorm:{gl:33322,rb:!0},r16snorm:{gl:36760},"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},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0},rg16unorm:{gl:33324},rg16snorm:{gl:36761},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326},rgb9e5ufloat:{gl:35901},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852},"rgb16snorm-webgl":{gl:36762},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842},rgba16unorm:{gl:32859,rb:!0},rgba16snorm:{gl:36763},"rgb32float-webgl":{gl:34837,x:_S,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0},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:oo},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:ao},"bc1-rgba-unorm":{gl:33777,x:oo},"bc1-rgba-unorm-srgb":{gl:35916,x:ao},"bc2-rgba-unorm":{gl:33778,x:oo},"bc2-rgba-unorm-srgb":{gl:35918,x:ao},"bc3-rgba-unorm":{gl:33779,x:oo},"bc3-rgba-unorm-srgb":{gl:35919,x:ao},"bc4-r-unorm":{gl:36283,x:ws},"bc4-r-snorm":{gl:36284,x:ws},"bc5-rg-unorm":{gl:36285,x:ws},"bc5-rg-snorm":{gl:36286,x:ws},"bc6h-rgb-ufloat":{gl:36495,x:vs},"bc6h-rgb-float":{gl:36494,x:vs},"bc7-rgba-unorm":{gl:36492,x:vs},"bc7-rgba-unorm-srgb":{gl:36493,x:vs},"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:37819},"astc-10x5-unorm-srgb":{gl:37851},"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-rbg2unorm-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}}});var jy,qc,Hy=O(()=>{H();io();As();jy={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},qc=class extends Bs{gl;extensions;testedFeatures=new Set;constructor(e,t,n){super([],n),this.gl=e,this.extensions=t,Bt(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){let e=this.getFeatures();for(let t of e)this.has(t)&&(yield t);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),Vy(e)&&zy(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){let e=this.getFeatures().filter(t=>t!=="polygon-mode-webgl");for(let t of e)this.has(t)}getFeatures(){return[...Object.keys(jy),...Object.keys(Xc)]}getWebGLFeature(e){let t=jy[e];return Boolean(typeof t=="string"?Bt(this.gl,t,this.extensions):t)}}});var Kc,Xy=O(()=>{H();Kc=class extends Fs{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 this.limits[e]===void 0&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]||0}}});function bS(r){return r<34069?r+34069:r}function TS(r){switch(r){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`${r}`}}var Lt,Zc=O(()=>{H();As();Lt=class extends Et{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,t){super(e,t);let n=t.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||n?this.props.handle:this.gl.createFramebuffer(),n||(e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this.autoCreateAttachmentTextures(),this.updateAttachments())}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let e=this.gl.bindFramebuffer(36160,this.handle);for(let t=0;t<this.colorAttachments.length;++t){let n=this.colorAttachments[t];if(n){let s=36064+t;this._attachTextureView(s,n)}}if(this.depthStencilAttachment){let t=$y(this.depthStencilAttachment.props.format);this._attachTextureView(t,this.depthStencilAttachment)}if(this.device.props.debug){let t=this.gl.checkFramebufferStatus(36160);if(t!==36053)throw new Error(`Framebuffer ${TS(t)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,t){let{gl:n}=this.device,{texture:s}=t,i=t.props.baseMipLevel,o=t.props.baseArrayLayer;switch(n.bindTexture(s.glTarget,s.handle),s.glTarget){case 35866:case 32879:n.framebufferTextureLayer(36160,e,s.handle,i,o);break;case 34067:let a=bS(o);n.framebufferTexture2D(36160,e,a,s.handle,i);break;case 3553:n.framebufferTexture2D(36160,e,3553,s.handle,i);break;default:throw new Error("Illegal texture type")}n.bindTexture(s.glTarget,null)}}});var Gc,Yy=O(()=>{H();Zc();Gc=class extends Xr{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._updateDevice()}getCurrentFramebuffer(){return this._framebuffer=this._framebuffer||new Lt(this.device,{handle:null}),this._framebuffer}_updateDevice(){}}});function qy(r="id"){pd[r]=pd[r]||1;let e=pd[r]++;return`${r}-${e}`}var pd,Ky=O(()=>{pd={}});function wS(r){return r&W.INDEX?34963:r&W.VERTEX?34962:r&W.UNIFORM?35345:34962}function vS(r){return r&W.INDEX||r&W.VERTEX?35044:r&W.UNIFORM?35048:35044}var vt,Qc=O(()=>{H();vt=class extends W{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;let n=typeof t=="object"?t.handle:void 0;this.handle=n||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=wS(this.props.usage),this.glUsage=vS(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?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.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}_initWithData(e,t=0,n=e.byteLength+t){let s=this.glTarget;this.gl.bindBuffer(s,this.handle),this.gl.bufferData(s,n,this.glUsage),this.gl.bufferSubData(s,t,e),this.gl.bindBuffer(s,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(e,t,n),this.trackAllocatedMemory(n)}_initWithByteLength(e){let t=e;e===0&&(t=new Float32Array(0));let n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,t,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}write(e,t=0){let n=ArrayBuffer.isView(e)?e:new Uint8Array(e),s=0,i=void 0,o=36663;this.gl.bindBuffer(o,this.handle),s!==0||i!==void 0?this.gl.bufferSubData(o,t,n,s,i):this.gl.bufferSubData(o,t,n),this.gl.bindBuffer(o,null),this._setDebugData(e,t,e.byteLength)}async mapAndWriteAsync(e,t=0,n=this.byteLength-t){let s=new ArrayBuffer(n);await e(s,"copied"),this.write(s,t)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}async mapAndReadAsync(e,t=0,n){let s=await this.readAsync(t,n);return await e(s.buffer,"copied")}readSyncWebGL(e=0,t){t=t??this.byteLength-e;let n=new Uint8Array(t),s=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,n,s,t),this.gl.bindBuffer(36662,null),this._setDebugData(n,e,t),n}}});function Gy(r){let e=r.split(/\r?\n/),t=[];for(let n of e){if(n.length<=1)continue;let s=n.split(":");if(s.length===2){let[f,h]=s;t.push({message:h.trim(),type:Zy(f),lineNum:0,linePos:0});continue}let[i,o,a,...c]=s,l=parseInt(a,10);isNaN(l)&&(l=0);let u=parseInt(o,10);isNaN(u)&&(u=0),t.push({message:c.join(":").trim(),type:Zy(i),lineNum:l,linePos:u})}return t}function Zy(r){let e=["warning","error","info"],t=r.toLowerCase();return e.includes(t)?t:"info"}var Qy=O(()=>{});var Jc,Jy=O(()=>{H();Qy();Jc=class extends gr{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 new Error(this.props.stage)}e._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0,this.handle.destroyed=!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?Gy(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}async _compile(e){e=e.startsWith("#version ")?e:`#version 300 es
18
+ ${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(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}I.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),I.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){let e=async s=>await new Promise(i=>setTimeout(i,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}});function tx(r,e,t,n){if(RS(e))return n(r);let s=r;s.pushState();try{return AS(r,e),Tt(s.gl,t),n(r)}finally{s.popState()}}function AS(r,e){let t=r,{gl:n}=t;if(e.cullMode)switch(e.cullMode){case"none":n.disable(2884);break;case"front":n.enable(2884),n.cullFace(1028);break;case"back":n.enable(2884),n.cullFace(1029);break}if(e.frontFace&&n.frontFace(vn("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&r.features.has("depth-clip-control")&&n.enable(34383),e.depthBias!==void 0&&(n.enable(32823),n.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&r.features.has("provoking-vertex-webgl")){let i=t.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=vn("provokingVertex",e.provokingVertex,{first:36429,last:36430});i?.provokingVertexWEBGL(o)}if((e.polygonMode||e.polygonOffsetLine)&&r.features.has("polygon-mode-webgl")){if(e.polygonMode){let i=t.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=vn("polygonMode",e.polygonMode,{fill:6914,line:6913});i?.polygonModeWEBGL(1028,o),i?.polygonModeWEBGL(1029,o)}e.polygonOffsetLine&&n.enable(10754)}if(r.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&n.enable(12288),e.clipDistance1&&n.enable(12289),e.clipDistance2&&n.enable(12290),e.clipDistance3&&n.enable(12291),e.clipDistance4&&n.enable(12292),e.clipDistance5&&n.enable(12293),e.clipDistance6&&n.enable(12294),e.clipDistance7&&n.enable(12295)),e.depthWriteEnabled!==void 0&&n.depthMask(ES("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?n.enable(2929):n.disable(2929),n.depthFunc(tl("depthCompare",e.depthCompare))),e.stencilWriteMask){let s=e.stencilWriteMask;n.stencilMaskSeparate(1028,s),n.stencilMaskSeparate(1029,s)}if(e.stencilReadMask&&I.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let s=e.stencilReadMask||4294967295,i=tl("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?n.enable(2960):n.disable(2960),n.stencilFuncSeparate(1028,i,0,s),n.stencilFuncSeparate(1029,i,0,s)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let s=md("stencilPassOperation",e.stencilPassOperation),i=md("stencilFailOperation",e.stencilFailOperation),o=md("stencilDepthFailOperation",e.stencilDepthFailOperation);n.stencilOpSeparate(1028,i,o,s),n.stencilOpSeparate(1029,i,o,s)}switch(e.blend){case!0:n.enable(3042);break;case!1:n.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let s=ex("blendColorOperation",e.blendColorOperation||"add"),i=ex("blendAlphaOperation",e.blendAlphaOperation||"add");n.blendEquationSeparate(s,i);let o=el("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=el("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=el("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=el("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");n.blendFuncSeparate(o,a,c,l)}}function tl(r,e){return vn(r,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function md(r,e){return vn(r,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function ex(r,e){return vn(r,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function el(r,e,t="color"){return vn(r,e,{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:t==="color"?32769:32771,"one-minus-constant":t==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function SS(r,e){return`Illegal parameter ${e} for ${r}`}function vn(r,e,t){if(!(e in t))throw new Error(SS(r,e));return t[e]}function ES(r,e){return e}function RS(r){let e=!0;for(let t in r){e=!1;break}return e}var gd=O(()=>{H();Ts()});function rl(r){let e={};return r.addressModeU&&(e[10242]=_d(r.addressModeU)),r.addressModeV&&(e[10243]=_d(r.addressModeV)),r.addressModeW&&(e[32882]=_d(r.addressModeW)),r.magFilter&&(e[10240]=yd(r.magFilter)),(r.minFilter||r.mipmapFilter)&&(e[10241]=IS(r.minFilter||"linear",r.mipmapFilter)),r.lodMinClamp!==void 0&&(e[33082]=r.lodMinClamp),r.lodMaxClamp!==void 0&&(e[33083]=r.lodMaxClamp),r.type==="comparison-sampler"&&(e[34892]=34894),r.compare&&(e[34893]=tl("compare",r.compare)),r.maxAnisotropy&&(e[34046]=r.maxAnisotropy),e}function _d(r){switch(r){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function yd(r){switch(r){case"nearest":return 9728;case"linear":return 9729}}function IS(r,e="none"){if(!e)return yd(r);switch(e){case"none":return yd(r);case"nearest":switch(r){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(r){case"nearest":return 9986;case"linear":return 9987}}}var xd=O(()=>{gd()});var nl,rx=O(()=>{H();xd();nl=class extends Ke{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=rl(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,n]of Object.entries(e)){let s=Number(t);switch(s){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,s,n);break;default:this.device.gl.samplerParameteri(this.handle,s,n);break}}}}});function Lr(r,e,t){if(PS(e))return t(r);let{nocatch:n=!0}=e,s=wt.get(r);s.push(),Tt(r,e);let i;if(n)i=t(r),s.pop();else try{i=t(r)}finally{s.pop()}return i}function PS(r){for(let e in r)return!1;return!0}var sl=O(()=>{Ts();fd()});var Ut,bd=O(()=>{H();Ut=class extends mr{device;gl;handle;texture;constructor(e,t){super(e,{...K.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}});function CS(r){switch(r){case"1d":break;case"2d":return 3553;case"3d":return 32879;case"cube":return 34067;case"2d-array":return 35866;case"cube-array":break}throw new Error(r)}function nx(r,e,t){return e==="cube"?34069+t:r}var Vt,il=O(()=>{H();As();xd();sl();bd();Vt=class extends K{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;constructor(e,t){super(e,t),this.device=e,this.gl=this.device.gl;let n=Yc(this.props.format);this.glTarget=CS(this.props.dimension),this.glInternalFormat=n.internalFormat,this.glFormat=n.format,this.glType=n.type,this.compressed=n.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);let{dimension:s,width:i,height:o,depth:a,mipLevels:c,glTarget:l,glInternalFormat:u}=this;switch(s){case"2d":case"cube":this.gl.texStorage2D(l,c,u,i,o);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,u,i,o,a);break;default:throw new Error(s)}this.gl.bindTexture(this.glTarget,null),this._initializeData(t.data),this.setSampler(this.props.sampler),this.view=new Ut(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}createView(e){return new Ut(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);let t=rl(this.sampler.props);this._setSamplerParameters(t)}copyImageData(e){let t=this._normalizeCopyImageDataOptions(e),n=t.data,{width:s,height:i,depth:o}=this,{mipLevel:a=0,byteOffset:c=0,x:l=0,y:u=0,z:f=0}=t,{glFormat:h,glType:d,compressed:m}=this,y=nx(this.glTarget,this.dimension,f),_;if(!this.compressed){let{bytesPerPixel:E}=this.device.getTextureFormatInfo(this.format);if(E){if(t.bytesPerRow%E!==0)throw new Error(`bytesPerRow (${t.bytesPerRow}) must be a multiple of bytesPerPixel (${E}) for ${this.format}`);_=t.bytesPerRow/E}}let x=this.compressed?{}:{..._!==void 0?{[3314]:_}:{},[32878]:t.rowsPerImage};this.gl.bindTexture(y,this.handle),Lr(this.gl,x,()=>{switch(this.dimension){case"2d":case"cube":m?this.gl.compressedTexSubImage2D(y,a,l,u,s,i,h,n,c):this.gl.texSubImage2D(y,a,l,u,s,i,h,d,n,c);break;case"2d-array":case"3d":m?this.gl.compressedTexSubImage3D(y,a,l,u,f,s,i,o,h,n,c):this.gl.texSubImage3D(y,a,l,u,f,s,i,o,h,d,n,c);break;default:}}),this.gl.bindTexture(y,null)}copyExternalImage(e){let t=this._normalizeCopyExternalImageOptions(e);if(t.sourceX||t.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:n,glType:s}=this,{image:i,depth:o,mipLevel:a,x:c,y:l,z:u,width:f,height:h}=t,d=nx(this.glTarget,this.dimension,o),m=t.flipY?{[37440]:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),Lr(this.gl,m,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(d,a,c,l,f,h,n,s,i);break;case"2d-array":case"3d":this.gl.texSubImage3D(d,a,c,l,u,f,h,o,n,s,i);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:t.width,height:t.height}}generateMipmapsWebGL(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(I.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(n){I.warn(`Error generating mipmap for ${this}: ${n.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){I.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[t,n]of Object.entries(e)){let s=Number(t),i=n;switch(s){case 33082:case 33083:this.gl.texParameterf(this.glTarget,s,i);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,s,i);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,s,i);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,s,i);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,s,i);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:t}=this;return e!==void 0&&(this._textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.glTarget,null),e}}});function sx(r){return OS[r]}function ol(r){return MS[r]}function ix(r){return Boolean(ax[r])}function ox(r){return ax[r]}var MS,ax,OS,Td=O(()=>{MS={[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>"},ax={[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"}},OS={uint8:5121,sint8:5120,unorm8:5121,snorm8:5120,uint16:5123,sint16:5122,unorm16:5123,snorm16:5122,uint32:5125,sint32:5124,float16:5131,float32:5126}});function cx(r,e){let t={attributes:[],bindings:[]};t.attributes=kS(r,e);let n=FS(r,e);for(let a of n){let c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));t.bindings.push({type:"uniform",name:a.name,group:0,location:a.location,visibility:(a.vertex?1:0)&(a.fragment?2:0),minBindingSize:a.byteLength,uniforms:c})}let s=DS(r,e),i=0;for(let a of s)if(ix(a.type)){let{viewDimension:c,sampleType:l}=ox(a.type);t.bindings.push({type:"texture",name:a.name,group:0,location:i,viewDimension:c,sampleType:l}),a.textureUnit=i,i+=1}s.length&&(t.uniforms=s);let o=NS(r,e);return o?.length&&(t.varyings=o),t}function kS(r,e){let t=[],n=r.getProgramParameter(e,35721);for(let s=0;s<n;s++){let i=r.getActiveAttrib(e,s);if(!i)throw new Error("activeInfo");let{name:o,type:a}=i,c=r.getAttribLocation(e,o);if(c>=0){let l=ol(a),u=/instance/i.test(o)?"instance":"vertex";t.push({name:o,location:c,stepMode:u,type:l})}}return t.sort((s,i)=>s.location-i.location),t}function NS(r,e){let t=[],n=r.getProgramParameter(e,35971);for(let s=0;s<n;s++){let i=r.getTransformFeedbackVarying(e,s);if(!i)throw new Error("activeInfo");let{name:o,type:a,size:c}=i,l=ol(a),{type:u,components:f}=Vs(l);t.push({location:s,name:o,type:u,size:c*f})}return t.sort((s,i)=>s.location-i.location),t}function DS(r,e){let t=[],n=r.getProgramParameter(e,35718);for(let s=0;s<n;s++){let i=r.getActiveUniform(e,s);if(!i)throw new Error("activeInfo");let{name:o,size:a,type:c}=i,{name:l,isArray:u}=BS(o),f=r.getUniformLocation(e,l),h={location:f,name:l,size:a,type:c,isArray:u};if(t.push(h),h.size>1)for(let d=0;d<h.size;d++){let m=`${l}[${d}]`;f=r.getUniformLocation(e,m);let y={...h,name:m,location:f};t.push(y)}}return t}function FS(r,e){let t=(i,o)=>r.getActiveUniformBlockParameter(e,i,o),n=[],s=r.getProgramParameter(e,35382);for(let i=0;i<s;i++){let o={name:r.getActiveUniformBlockName(e,i)||"",location:t(i,35391),byteLength:t(i,35392),vertex:t(i,35396),fragment:t(i,35398),uniformCount:t(i,35394),uniforms:[]},a=t(i,35395)||[],c=r.getActiveUniforms(e,a,35383),l=r.getActiveUniforms(e,a,35384),u=r.getActiveUniforms(e,a,35387),f=r.getActiveUniforms(e,a,35388);for(let h=0;h<o.uniformCount;++h){let d=r.getActiveUniform(e,a[h]);if(!d)throw new Error("activeInfo");let m=ol(c[h]);o.uniforms.push({name:d.name,format:m,type:c[h],arrayLength:l[h],byteOffset:u[h],byteStride:f[h]})}n.push(o)}return n.sort((i,o)=>i.location-o.location),n}function BS(r){if(r[r.length-1]!=="]")return{name:r,length:1,isArray:!1};let t=/([^[]*)(\[[0-9]+\])?/.exec(r);if(!t||t.length<2)throw new Error(`Failed to parse GLSL uniform name ${r}`);return{name:t[1],length:t[2]?1:0,isArray:Boolean(t[2])}}var lx=O(()=>{H();Td()});function ux(r,e,t,n){let s=r,i=n;i===!0&&(i=1),i===!1&&(i=0);let o=typeof i=="number"?[i]:i;switch(t){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof n!="number")throw new Error("samplers must be set to integers");return r.uniform1i(e,n);case 5126:return r.uniform1fv(e,o);case 35664:return r.uniform2fv(e,o);case 35665:return r.uniform3fv(e,o);case 35666:return r.uniform4fv(e,o);case 5124:return r.uniform1iv(e,o);case 35667:return r.uniform2iv(e,o);case 35668:return r.uniform3iv(e,o);case 35669:return r.uniform4iv(e,o);case 35670:return r.uniform1iv(e,o);case 35671:return r.uniform2iv(e,o);case 35672:return r.uniform3iv(e,o);case 35673:return r.uniform4iv(e,o);case 5125:return s.uniform1uiv(e,o,1);case 36294:return s.uniform2uiv(e,o,2);case 36295:return s.uniform3uiv(e,o,3);case 36296:return s.uniform4uiv(e,o,4);case 35674:return r.uniformMatrix2fv(e,!1,o);case 35675:return r.uniformMatrix3fv(e,!1,o);case 35676:return r.uniformMatrix4fv(e,!1,o);case 35685:return s.uniformMatrix2x3fv(e,!1,o);case 35686:return s.uniformMatrix2x4fv(e,!1,o);case 35687:return s.uniformMatrix3x2fv(e,!1,o);case 35688:return s.uniformMatrix3x4fv(e,!1,o);case 35689:return s.uniformMatrix4x2fv(e,!1,o);case 35690:return s.uniformMatrix4x3fv(e,!1,o)}throw new Error("Illegal uniform")}var fx=O(()=>{});function hx(r){switch(r){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 new Error(r)}}function dx(r){switch(r){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;default:throw new Error(r)}}var wd=O(()=>{});function LS(r,e){let t={...r,attributes:r.attributes.map(n=>({...n}))};for(let n of e?.attributes||[]){let s=t.attributes.find(i=>i.name===n.name);s?(s.type=n.type||s.type,s.stepMode=n.stepMode||s.stepMode):I.warn(`shader layout attribute ${n.name} not present in shader`)}return t}var px,al,mx=O(()=>{H();lx();gd();fx();Qc();Zc();il();bd();wd();px=4,al=class extends Ze{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.vs=t.vs,this.fs=t.fs;let{varyings:n,bufferMode:s=35981}=t;n&&n.length>0&&(this.varyings=n,this.device.gl.transformFeedbackVaryings(this.handle,n,s)),this._linkShaders(),I.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=cx(this.device.gl,this.handle),I.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=t.shaderLayout?LS(this.introspectedLayout,t.shaderLayout):this.introspectedLayout}destroy(){this.handle&&(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.destroyed=!0,this.handle.destroyed=!0,this.handle=null)}setBindings(e,t){for(let[n,s]of Object.entries(e)){let i=this.shaderLayout.bindings.find(o=>o.name===n)||this.shaderLayout.bindings.find(o=>o.name===`${n}Uniforms`);if(!i){let o=this.shaderLayout.bindings.map(a=>`"${a.name}"`).join(", ");t?.disableWarnings||I.warn(`No binding "${n}" in render pipeline "${this.id}", expected one of ${o}`,s)();continue}switch(s||I.warn(`Unsetting binding "${n}" in render pipeline "${this.id}"`)(),i.type){case"uniform":if(!(s instanceof vt)&&!(s.buffer instanceof vt))throw new Error("buffer value");break;case"texture":if(!(s instanceof Ut||s instanceof Vt||s instanceof Lt))throw new Error(`${this} Bad texture binding for ${n}`);break;case"sampler":I.warn(`Ignoring sampler ${n}`)();break;default:throw new Error(i.type)}this.bindings[n]=s}}draw(e){let{renderPass:t,parameters:n=this.props.parameters,topology:s=this.props.topology,vertexArray:i,vertexCount:o,instanceCount:a,isInstanced:c=!1,firstVertex:l=0,transformFeedback:u}=e,f=hx(s),h=Boolean(i.indexBuffer),d=i.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return I.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable())return I.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),i.bindBeforeRender(t),u&&u.begin(this.props.topology),this._applyBindings(),this._applyUniforms();let m=t;return tx(this.device,n,m.glParameters,()=>{h&&c?this.device.gl.drawElementsInstanced(f,o||0,d,l,a||0):h?this.device.gl.drawElements(f,o||0,d,l):c?this.device.gl.drawArraysInstanced(f,l,o||0,a||0):this.device.gl.drawArrays(f,l,o||0),u&&u.end()}),i.unbindAfterRender(t),!0}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),I.time(px,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),I.timeEnd(px,`linkProgram for ${this.id}`)(),I.level,!this.device.features.has("compilation-status-async-webgl")){let n=this._getLinkStatus();this._reportLinkStatus(n);return}I.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),I.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let t=this._getLinkStatus();this._reportLinkStatus(t)}async _reportLinkStatus(e){switch(e){case"success":return;default:let t=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${t} during compilation of ${this.vs}`);case"pending":await this.vs.asyncCompilationStatus,this.vs.debugShader();break;case"success":break}switch(this.fs?.compilationStatus){case"error":throw this.fs.debugShader(),new Error(`${this} ${t} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let n=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${t} during ${e}: ${n}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}async _waitForLinkComplete(){let e=async s=>await new Promise(i=>setTimeout(i,s));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:n}=this.device;for(;;){if(n.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(let t of this.shaderLayout.bindings)!this.bindings[t.name]&&!this.bindings[t.name.replace(/Uniforms$/,"")]&&(I.warn(`Binding ${t.name} not found in ${this.id}`)(),e=!1);return e}_applyBindings(){if(this.linkStatus!=="success")return;let{gl:e}=this.device;e.useProgram(this.handle);let t=0,n=0;for(let s of this.shaderLayout.bindings){let i=this.bindings[s.name]||this.bindings[s.name.replace(/Uniforms$/,"")];if(!i)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":let{name:o}=s,a=e.getUniformBlockIndex(this.handle,o);if(a===4294967295)throw new Error(`Invalid uniform block name ${o}`);e.uniformBlockBinding(this.handle,n,a),i instanceof vt?e.bindBufferBase(35345,n,i.handle):e.bindBufferRange(35345,n,i.buffer.handle,i.offset||0,i.size||i.buffer.byteLength-i.offset),n+=1;break;case"texture":if(!(i instanceof Ut||i instanceof Vt||i instanceof Lt))throw new Error("texture");let c;if(i instanceof Ut)c=i.texture;else if(i instanceof Vt)c=i;else if(i instanceof Lt&&i.colorAttachments[0]instanceof Ut)I.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),c=i.colorAttachments[0].texture;else throw new Error("No texture");e.activeTexture(33984+t),e.bindTexture(c.glTarget,c.handle),t+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(){for(let e of this.shaderLayout.uniforms||[]){let{name:t,location:n,type:s,textureUnit:i}=e,o=this.uniforms[t]??i;o!==void 0&&ux(this.device.gl,n,s,o)}}}});function US(r,e){let t=e.sourceBuffer,n=e.destinationBuffer;r.gl.bindBuffer(36662,t.handle),r.gl.bindBuffer(36663,n.handle),r.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),r.gl.bindBuffer(36662,null),r.gl.bindBuffer(36663,null)}function VS(r,e){throw new Error("Not implemented")}function zS(r,e){let{sourceTexture:t,mipLevel:n=0,aspect:s="all",width:i=e.sourceTexture.width,height:o=e.sourceTexture.height,depthOrArrayLayers:a=0,origin:c=[0,0],destinationBuffer:l,byteOffset:u=0,bytesPerRow:f,rowsPerImage:h}=e;if(s!=="all")throw new Error("aspect not supported in WebGL");if(n!==0||a!==0||f||h)throw new Error("not implemented");let{framebuffer:d,destroyFramebuffer:m}=gx(t),y;try{let _=l,x=i||d.width,E=o||d.height,b=Yc(d.colorAttachments[0].texture.props.format),S=b.format,C=b.type;r.gl.bindBuffer(35051,_.handle),y=r.gl.bindFramebuffer(36160,d.handle),r.gl.readPixels(c[0],c[1],x,E,S,C,u)}finally{r.gl.bindBuffer(35051,null),y!==void 0&&r.gl.bindFramebuffer(36160,y),m&&d.destroy()}}function WS(r,e){let{sourceTexture:t,destinationMipLevel:n=0,origin:s=[0,0],destinationOrigin:i=[0,0],destinationTexture:o}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:u}=gx(t),[f,h]=s,[d,m,y]=i,_=r.gl.bindFramebuffer(36160,l.handle),x,E;if(o instanceof Vt)x=o,a=Number.isFinite(a)?a:x.width,c=Number.isFinite(c)?c:x.height,x._bind(0),E=x.glTarget;else throw new Error("invalid destination");switch(E){case 3553:case 34067:r.gl.copyTexSubImage2D(E,n,d,m,f,h,a,c);break;case 35866:case 32879:r.gl.copyTexSubImage3D(E,n,d,m,y,f,h,a,c);break;default:}x&&x._unbind(),r.gl.bindFramebuffer(36160,_),u&&l.destroy()}function gx(r){if(r instanceof K){let{width:e,height:t,id:n}=r;return{framebuffer:r.device.createFramebuffer({id:`framebuffer-for-${n}`,width:e,height:t,colorAttachments:[r]}),destroyFramebuffer:!0}}return{framebuffer:r,destroyFramebuffer:!1}}var cl,_x=O(()=>{H();il();As();cl=class extends Ln{device;handle=null;commands=[];constructor(e){super(e,{}),this.device=e}_executeCommands(e=this.commands){for(let t of e)switch(t.name){case"copy-buffer-to-buffer":US(this.device,t.options);break;case"copy-buffer-to-texture":VS(this.device,t.options);break;case"copy-texture-to-buffer":zS(this.device,t.options);break;case"copy-texture-to-texture":WS(this.device,t.options);break;default:throw new Error(t.name)}}}});var $S,ll,yx=O(()=>{H();sl();Ts();$S=[1,2,4,8],ll=class extends qt{device;handle=null;glParameters={};constructor(e,t){super(e,t),this.device=e;let n;if(!t?.parameters?.viewport)if(t?.framebuffer){let{width:i,height:o}=t.framebuffer;n=[0,0,i,o]}else{let[i,o]=e.getDefaultCanvasContext().getDrawingBufferSize();n=[0,0,i,o]}this.device.pushState(),this.setParameters({viewport:n,...this.props.parameters});let s=this.props.framebuffer;if(this.props.framebuffer&&s?.handle){let i=this.props.framebuffer.colorAttachments.map((o,a)=>36064+a);this.device.gl.drawBuffers(i)}else this.device.gl.drawBuffers([1029]);this.clear()}end(){this.device.popState()}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?0:1,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),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),t[2967]=e.stencilReference),"colorMask"in e&&(t.colorMask=$S.map(n=>Boolean(n&e.colorMask))),this.glParameters=t,Tt(this.device.gl,t)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},t=0;this.props.clearColors&&this.props.clearColors.forEach((n,s)=>{n&&this.clearColorBuffer(s,n)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(t|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(t|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(t|=1024,e.clearStencil=this.props.clearStencil),t!==0&&Lr(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){Lr(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 new Error("clearColorBuffer: color must be typed array")}})}}});var co,xx=O(()=>{H();_x();yx();co=class extends Bn{device;handle=null;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new cl(e)}destroy(){}finish(){return this.commandBuffer}beginRenderPass(e){return new ll(this.device,e)}beginComputePass(e){throw new 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,n){}}});function bx(r){let{target:e,source:t,start:n=0,count:s=1}=r,i=t.length,o=s*i,a=0;for(let c=n;a<i;a++)e[c++]=t[a];for(;a<o;)a<o-a?(e.copyWithin(n+a,n,n+a),a*=2):(e.copyWithin(n+a,n,n+o-a),a=o);return r.target}var Tx=O(()=>{});function jS(r){return Array.isArray(r)?new Float32Array(r):r}function HS(r,e){if(!r||!e||r.length!==e.length||r.constructor!==e.constructor)return!1;for(let t=0;t<r.length;++t)if(r[t]!==e[t])return!1;return!0}var Ss,wx=O(()=>{H();Ls();hd();Tx();Ss=class extends Un{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return uu()==="Chrome"}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){let t=e;if(t&&t.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){let n=t;if(n.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:s,type:i,stride:o,offset:a,normalized:c,integer:l,divisor:u}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),l?this.device.gl.vertexAttribIPointer(e,s,i,o,a):this.device.gl.vertexAttribPointer(e,s,i,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,u||0),this.attributes[e]=n,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 new Error(`Unknown attribute location ${e}`);let n=Hc(t.bufferDataType);return{size:t.bufferComponents,type:n,stride:t.byteStride,offset:t.byteOffset,normalized:t.normalized,integer:t.integer,divisor:t.stepMode==="instance"?1:0}}_enable(e,t=!0){let s=Ss.isConstantAttributeZeroSupported(this.device)||e!==0;(t||s)&&(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){let n=jS(t),s=n.byteLength*e,i=n.length*e;if(this.buffer&&s!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${s} !== ${this.buffer.byteLength}.`);let o=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:s}),o||=!HS(n,this.bufferValue),o){let a=Ru(t.constructor,i);bx({target:a,source:n,start:0,count:i}),this.buffer.write(a),this.bufferValue=t}return this.buffer}}});function vx(r){return typeof r=="number"?Number.isInteger(r):/^\d+$/.test(r)}var ul,Ax=O(()=>{H();fl();wd();ul=class extends Vn{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(dx(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 in e)this.setBuffer(t,e[t])})}setBuffer(e,t){let n=this._getVaryingIndex(e),{buffer:s,byteLength:i,byteOffset:o}=this._getBufferRange(t);if(n<0){this.unusedBuffers[e]=s,I.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[n]={buffer:s,byteLength:i,byteOffset:o},this.bindOnUse||this._bindBuffer(n,s,o,i)}getBuffer(e){if(vx(e))return this.buffers[e]||null;let t=this._getVaryingIndex(e);return t>=0?this.buffers[t]:null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let t;return 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 vt)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:t,byteOffset:n=0,byteLength:s=e.buffer.byteLength}=e;return{buffer:t,byteOffset:n,byteLength:s}}_getVaryingIndex(e){if(vx(e))return Number(e);for(let t of this.layout.varyings||[])if(e===t.name)return t.location;return-1}_bindBuffers(){for(let e in this.buffers){let{buffer:t,byteLength:n,byteOffset:s}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),t,s,n)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,n=0,s){let i=t&&t.handle;!i||s===void 0?this.gl.bindBufferBase(35982,e,i):this.gl.bindBufferRange(35982,e,i,n,s)}}});var hl,Sx=O(()=>{H();hl=class extends zn{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,t){if(super(e,t),this.device=e,t.count>1)throw new Error("WebGL QuerySet can only have one value");let n=this.device.gl.createQuery();if(!n)throw new Error("WebGL query not supported");this.handle=n,Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;let e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let t=0;return this._pollingPromise=new Promise((n,s)=>{let i=()=>{this.isResultAvailable()?(n(this.getResult()),this._pollingPromise=null):t++>e?(s("Timed out"),this._pollingPromise=null):requestAnimationFrame(i)};requestAnimationFrame(i)}),this._pollingPromise}}});function vd(r){switch(r){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 Ex(r){switch(r){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var Rx=O(()=>{});function Ix(r){return XS[r]}var XS,Px=O(()=>{XS={[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"}});function Cx(r,e){let{sourceX:t=0,sourceY:n=0,sourceAttachment:s=0}=e||{},{target:i=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:u}=e||{},{framebuffer:f,deleteFramebuffer:h}=Ox(r),{gl:d,handle:m}=f;o||=f.width,a||=f.height;let y=f.colorAttachments[s]?.texture;if(!y)throw new Error(`Invalid framebuffer attachment ${s}`);c=y?.depth||1,l||=y?.glFormat||6408,u||=y?.glType||5121,i=qS(i,u,l,o,a,c);let _=jr(i);u=u||sx(_);let x=d.bindFramebuffer(36160,m);return d.readBuffer(36064+s),d.readPixels(t,n,o,a,l,u,i),d.readBuffer(36064),d.bindFramebuffer(36160,x||null),h&&f.destroy(),i}function Mx(r,e){let{target:t,sourceX:n=0,sourceY:s=0,sourceFormat:i=6408,targetByteOffset:o=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:u,deleteFramebuffer:f}=Ox(r);a=a||u.width,c=c||u.height;let h=u;l=l||5121;let d=t;if(!d){let y=vd(i),_=Ex(l),x=o+a*c*y*_;d=h.device.createBuffer({byteLength:x})}let m=r.device.createCommandEncoder();return m.copyTextureToBuffer({sourceTexture:r,width:a,height:c,origin:[n,s],destinationBuffer:d,byteOffset:o}),m.destroy(),f&&u.destroy(),d}function Ox(r){return r instanceof Et?{framebuffer:r,deleteFramebuffer:!1}:{framebuffer:YS(r),deleteFramebuffer:!0}}function YS(r,e){let{device:t,width:n,height:s,id:i}=r;return t.createFramebuffer({...e,id:`framebuffer-for-${i}`,width:n,height:s,colorAttachments:[r]})}function qS(r,e,t,n,s,i){if(r)return r;e||=5121;let o=Ix(e),a=Hr(o),c=vd(t);return new a(n*s*c)}var kx=O(()=>{H();Td();Rx();Px()});var Ad={};$t(Ad,{WebGLDevice:()=>An});function KS(r,e,t){switch(t.length){case 1:r.gl.vertexAttrib1fv(e,t);break;case 2:r.gl.vertexAttrib2fv(e,t);break;case 3:r.gl.vertexAttrib3fv(e,t);break;case 4:r.gl.vertexAttrib4fv(e,t);break;default:}}function ZS(r,e,t){r.gl.vertexAttribI4iv(e,t)}function GS(r,e,t){r.gl.vertexAttribI4uiv(e,t)}function QS(r,e){if(!r||!e||r.length!==e.length||r.constructor!==e.constructor)return!1;for(let t=0;t<r.length;++t)if(r[t]!==e[t])return!1;return!0}var An,dl=O(()=>{H();fd();Ny();By();Hy();Xy();Yy();id();od();As();Ky();Qc();Jy();rx();il();Zc();mx();xx();wx();Ax();Sx();kx();Ts();sl();io();An=class extends Fe{type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;gl;_constants;_extensions={};_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(e){switch(e){case"unorm8x4-bgra":return!1;default:return!0}}constructor(e){super({...e,id:e.id||qy("webgl-device")});let t=Fe._getCanvasContextProps(e);if(!t)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let n=t.canvas?.gl?.device;if(n)throw new Error(`WebGL context already attached to device ${n.id}`);this.canvasContext=new Gc(this,t),this.lost=new Promise(u=>{this._resolveContextLost=u});let s={...e.webgl};t.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),e.powerPreference!==void 0&&(s.powerPreference=e.powerPreference);let o=this.props._handle||ky(this.canvasContext.canvas,{onContextLost:u=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:u=>console.log("WebGL context restored")},s);if(!o)throw new Error("WebGL context creation failed");if(n=o.device,n){if(e._reuseDevices)return I.log(1,`Not creating a new Device, instead returning a reference to Device ${n.id} already attached to WebGL context`,n)(),n._reused=!0,n;throw new Error(`WebGL context already attached to device ${n.id}`)}this.handle=o,this.gl=o,this.spectorJS=yy({...this.props,gl:this.handle}),this.gl.device=this,this.gl._version=2,this.info=Dy(this.gl,this._extensions),this.limits=new Kc(this.gl),this.features=new qc(this.gl,this._extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new wt(this.gl,{log:(...u)=>I.log(1,...u)()}).trackState(this.gl,{copyState:!1});let c=e.debugWebGL||e.debug,l=e.debugWebGL;c&&(this.gl=wy(this.gl,{debugWebGL:c,traceWebGL:l}),I.warn("WebGL debug mode activated. Performance reduced.")(),e.debugWebGL&&(I.level=Math.max(I.level,1))),this.commandEncoder=new co(this,{id:`${this}-command-encoder`})}destroy(){!this.props._reuseDevices&&!this._reused&&delete this.gl.device}get isLost(){return this.gl.isContextLost()}getTextureByteAlignment(){return 4}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){let t=this._normalizeBufferProps(e);return new vt(this,t)}createTexture(e){return new Vt(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new nl(this,e)}createShader(e){return new Jc(this,e)}createFramebuffer(e){return new Lt(this,e)}createVertexArray(e){return new Ss(this,e)}createTransformFeedback(e){return new ul(this,e)}createQuerySet(e){return new hl(this,e)}createRenderPipeline(e){return new al(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(e={}){return new co(this,e)}submit(e){e||(e=this.commandEncoder.finish(),this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:`${this.id}-default-encoder`})),e._executeCommands()}readPixelsToArrayWebGL(e,t){return Cx(e,t)}readPixelsToBufferWebGL(e,t){return Mx(e,t)}setParametersWebGL(e){Tt(this.gl,e)}getParametersWebGL(e){return jc(this.gl,e)}withParametersWebGL(e,t){return Lr(this.gl,e,t)}resetWebGL(){I.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),Iy(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return Wy(this.gl,e,this._extensions)}loseDevice(){let e=!1,n=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return n&&(e=!0,n.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){wt.get(this.gl).push()}popState(){wt.get(this.gl).pop()}getGLKey(e,t){let n=Number(e);for(let s in this.gl)if(this.gl[s]===n)return`GL.${s}`;return t?.emptyIfUnknown?"":String(e)}getGLKeys(e){let t={emptyIfUnknown:!0};return Object.entries(e).reduce((n,[s,i])=>(n[`${s}:${this.getGLKey(s,t)}`]=`${i}:${this.getGLKey(i,t)}`,n),{})}setConstantAttributeWebGL(e,t){let n=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(n).fill(null);let s=this._constants[e];switch(s&&QS(s,t)&&I.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=t,t.constructor){case Float32Array:KS(this,e,t);break;case Int32Array:ZS(this,e,t);break;case Uint32Array:GS(this,e,t);break;default:throw new Error("constant")}}getExtension(e){return Bt(this.gl,e,this._extensions),this._extensions}_setWebGLDebugMetadata(e,t,n){e.luma=t;let s={props:n.spector,id:n.spector.id};e.__SPECTOR_Metadata=s}}});function JS(r){return typeof WebGL2RenderingContext<"u"&&r instanceof WebGL2RenderingContext?!0:Boolean(r&&Number.isFinite(r._version))}var pl,Sd,lo,Nx=O(()=>{H();my();id();od();pl=1,Sd=class extends Us{type="webgl";constructor(){super(),Fe.defaultProps={...Fe.defaultProps,...$c}}enforceWebGL2(e){py(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&I.warn("WebGL1 is not supported",e)(),!1)}async attach(e,t={}){let{WebGLDevice:n}=await Promise.resolve().then(()=>(dl(),Ad));if(e instanceof n)return e;if(e?.device instanceof n)return e.device;if(!JS(e))throw new Error("Invalid WebGL2RenderingContext");let s=t.createCanvasContext===!0?{}:t.createCanvasContext;return new n({...t,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...s}})}async create(e={}){let{WebGLDevice:t}=await Promise.resolve().then(()=>(dl(),Ad));I.groupCollapsed(pl,"WebGLDevice created")();try{let n=[];(e.debugWebGL||e.debug)&&n.push(Ty()),e.debugSpectorJS&&n.push(_y(e));let s=await Promise.allSettled(n);for(let a of s)a.status==="rejected"&&I.error(`Failed to initialize debug libraries ${a.reason}`)();let i=new t(e),o=`${i._reused?"Reusing":"Created"} device with WebGL2 ${i.props.debug?"debug ":""}context: ${i.info.vendor}, ${i.info.renderer} for canvas: ${i.canvasContext.id}`;return I.probe(pl,o)(),I.table(pl,i.info)(),i}finally{I.groupEnd(pl)()}}};lo=new Sd});var fl=O(()=>{Nx();dl();Qc()});var nR={};$t(nR,{AmbientLight:()=>hs,Attribute:()=>fr,AttributeManager:()=>Sn,COORDINATE_SYSTEM:()=>Y,CompositeLayer:()=>ab,Controller:()=>De,Deck:()=>ml,DeckGL:()=>Mo,DeckRenderer:()=>wn,DirectionalLight:()=>nr,FirstPersonController:()=>In,FirstPersonView:()=>lb,FirstPersonViewport:()=>Nl,FlyToInterpolator:()=>Po,Layer:()=>Rl,LayerExtension:()=>db,LayerManager:()=>yn,LightingEffect:()=>Mr,LinearInterpolator:()=>Ae,MapController:()=>Tn,MapView:()=>Bc,OPERATION:()=>M_,OrbitController:()=>Pn,OrbitView:()=>ub,OrbitViewport:()=>Cl,OrthographicController:()=>Cn,OrthographicView:()=>fb,OrthographicViewport:()=>Ol,PointLight:()=>gs,PostProcessEffect:()=>ji,TRANSITION_EVENTS:()=>Ki,Tesselator:()=>Co,TransitionInterpolator:()=>cr,UNIT:()=>Ir,VERSION:()=>oc,View:()=>Ne,Viewport:()=>$e,WebMercatorViewport:()=>Or,Widget:()=>Fr,_CameraLight:()=>zi,_Component:()=>Is,_ComponentState:()=>En,_GlobeController:()=>Mn,_GlobeView:()=>hb,_GlobeViewport:()=>xs,_LayersPass:()=>_t,_PickLayersPass:()=>sr,_SunLight:()=>Wi,_applyStyles:()=>to,_compareProps:()=>Al,_count:()=>Sl,_deepEqual:()=>le,_fillArray:()=>Mc,_flatten:()=>Nr,_memoize:()=>st,_mergeShaders:()=>To,_registerLoggers:()=>ic,_removeStyles:()=>zc,assert:()=>ie,color:()=>Ih,createIterable:()=>Es,fp64LowPart:()=>Kh,getShaderAssembler:()=>Sc,gouraudMaterial:()=>oi,log:()=>$,phongMaterial:()=>ai,picking:()=>Yh,project:()=>Pr,project32:()=>Uh,shadow:()=>fs});var Yf={};$t(Yf,{Buffer:()=>W,BufferTransform:()=>ht,CubeGeometry:()=>di,Device:()=>Fe,Framebuffer:()=>Et,Geometry:()=>dt,GroupNode:()=>sn,Model:()=>Xe,ModelNode:()=>hi,ScenegraphNode:()=>Ct,SphereGeometry:()=>pi,Texture:()=>K,TextureTransform:()=>ui,attachDevice:()=>ow,createDevice:()=>aw,enforceWebGL2:()=>cw,getSupportedAdapters:()=>sw,setDefaultDeviceProps:()=>iw,stats:()=>nw});H();H();var f0=1,h0=1,Kr=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:t=0,duration:n=Number.POSITIVE_INFINITY,rate:s=1,repeat:i=1}=e,o=f0++,a={time:0,delay:t,duration:n,rate:s,repeat:i};return this._setChannelTime(a,this.time),this.channels.set(o,a),o}removeChannel(e){this.channels.delete(e);for(let[t,n]of this.animations)n.channel===e&&this.detachAnimation(t)}isFinished(e){let t=this.channels.get(e);return t===void 0?!1:this.time>=t.delay+t.duration*t.repeat}getTime(e){if(e===void 0)return this.time;let t=this.channels.get(e);return t===void 0?-1:t.time}setTime(e){this.time=Math.max(0,e);let t=this.channels.values();for(let s of t)this._setChannelTime(s,this.time);let n=this.animations.values();for(let s of n){let{animation:i,channel:o}=s;i.setTime(this.getTime(o))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){let n=h0++;return this.animations.set(n,{animation:e,channel:t}),e.setTime(this.getTime(t)),n}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){let n=t-e.delay,s=e.duration*e.repeat;n>=s?e.time=e.duration*e.rate:(e.time=Math.max(0,n)%e.duration,e.time*=e.rate)}};H();function Hp(r){return typeof window<"u"&&window.requestAnimationFrame?window.requestAnimationFrame(r):setTimeout(r,1e3/60)}function Xp(r){return typeof window<"u"&&window.cancelAnimationFrame?window.cancelAnimationFrame(r):clearTimeout(r)}Wl();var d0=0,Cu=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;constructor(e){if(this.props={...Cu.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new hr({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}reportError(e){this.props.onError(e),this._error=e}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){return this._running&&(this.animationProps&&!this._error&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost||this._error?this:(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=Hp(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(Xp(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device?.submit()}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeViewport()}_initializeAnimationProps(){let e=this.device?.getDefaultCanvasContext();if(!this.device||!e)throw new Error("loop");let t=e?.canvas,n=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:t,useDevicePixels:n,timeline:this.timeline,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;let{width:e,height:t,aspect:n}=this._getSizeAndAspect();(e!==this.animationProps.width||t!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),n!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=n,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.getDefaultCanvasContext().canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){let e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";let t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);let n=this.props.onAddHTML(t);n&&(t.innerHTML=n)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,t]=this.device?.getDefaultCanvasContext().getDevicePixelSize()||[1,1],n=1,s=this.device?.getDefaultCanvasContext().canvas;return s&&s.clientHeight?n=s.clientWidth/s.clientHeight:e>0&&t>0&&(n=e/t),{width:e,height:t,aspect:n}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}},$n=Cu;L($n,"defaultAnimationLoopProps",{device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:pr.stats.get(`animation-loop-${d0++}`),autoResizeViewport:!1});H();function ra(r,e){if(!r)throw new Error(e||"shadertools: assertion failed.")}var Mu={number:{type:"number",validate(r,e){return Number.isFinite(r)&&typeof e=="object"&&(e.max===void 0||r<=e.max)&&(e.min===void 0||r>=e.min)}},array:{type:"array",validate(r,e){return Array.isArray(r)||ArrayBuffer.isView(r)}}};function qp(r){let e={};for(let[t,n]of Object.entries(r))e[t]=p0(n);return e}function p0(r){let e=Yp(r);if(e!=="object")return{value:r,...Mu[e],type:e};if(typeof r=="object")return r?r.type!==void 0?{...r,...Mu[r.type],type:r.type}:r.value===void 0?{type:"object",value:r}:(e=Yp(r.value),{...r,...Mu[e],type:e}):{type:"object",value:null};throw new Error("props")}function Yp(r){return Array.isArray(r)||ArrayBuffer.isView(r)?"array":typeof r}var Kp=`#ifdef MODULE_LOGDEPTH
19
19
  logdepth_adjustPosition(gl_Position);
20
20
  #endif
21
- `,Up=`#ifdef MODULE_MATERIAL
21
+ `,Zp=`#ifdef MODULE_MATERIAL
22
22
  fragColor = material_filterColor(fragColor);
23
23
  #endif
24
24
 
@@ -38,9 +38,9 @@ ${e}`;let{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(thi
38
38
  #ifdef MODULE_LOGDEPTH
39
39
  logdepth_setFragDepth();
40
40
  #endif
41
- `;var i0={vertex:Lp,fragment:Up},Vp=/void\s+main\s*\([^)]*\)\s*\{\n?/,zp=/}\n?[^{}]*$/,Au=[],Vs="__LUMA_INJECT_DECLARATIONS__";function Wp(r){let e={vertex:{},fragment:{}};for(let t in r){let n=r[t],s=o0(t);typeof n=="string"&&(n={order:0,injection:n}),e[s][t]=n}return e}function o0(r){let e=r.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function zs(r,e,t,n=!1){let s=e==="vertex";for(let i in t){let o=t[i];o.sort((c,l)=>c.order-l.order),Au.length=o.length;for(let c=0,l=o.length;c<l;++c)Au[c]=o[c].injection;let a=`${Au.join(`
41
+ `;var m0={vertex:Kp,fragment:Zp},Gp=/void\s+main\s*\([^)]*\)\s*\{\n?/,Qp=/}\n?[^{}]*$/,Ou=[],Ws="__LUMA_INJECT_DECLARATIONS__";function Jp(r){let e={vertex:{},fragment:{}};for(let t in r){let n=r[t],s=g0(t);typeof n=="string"&&(n={order:0,injection:n}),e[s][t]=n}return e}function g0(r){let e=r.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function $s(r,e,t,n=!1){let s=e==="vertex";for(let i in t){let o=t[i];o.sort((c,l)=>c.order-l.order),Ou.length=o.length;for(let c=0,l=o.length;c<l;++c)Ou[c]=o[c].injection;let a=`${Ou.join(`
42
42
  `)}
43
- `;switch(i){case"vs:#decl":s&&(r=r.replace(Vs,a));break;case"vs:#main-start":s&&(r=r.replace(Vp,c=>c+a));break;case"vs:#main-end":s&&(r=r.replace(zp,c=>a+c));break;case"fs:#decl":s||(r=r.replace(Vs,a));break;case"fs:#main-start":s||(r=r.replace(Vp,c=>c+a));break;case"fs:#main-end":s||(r=r.replace(zp,c=>a+c));break;default:r=r.replace(i,c=>c+a)}}return r=r.replace(Vs,""),n&&(r=r.replace(/\}\s*$/,i=>i+i0[e])),r}function Kr(r){r.map(e=>Qo(e))}function Qo(r){if(r.instance)return;Kr(r.dependencies||[]);let{propTypes:e={},deprecations:t=[],inject:n={}}=r,s={normalizedInjections:Wp(n),parsedDeprecations:a0(t)};e&&(s.propValidators=Bp(e)),r.instance=s;let i={};e&&(i=Object.entries(e).reduce((o,[a,c])=>{let l=c?.value;return l&&(o[a]=l),o},{})),r.defaultUniforms={...r.defaultUniforms,...i}}function Su(r,e,t){r.deprecations?.forEach(n=>{n.regex?.test(e)&&(n.deprecated?t.deprecated(n.old,n.new)():t.removed(n.old,n.new)())})}function a0(r){return r.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),r}function zn(r){Kr(r);let e={},t={};$p({modules:r,level:0,moduleMap:e,moduleDepth:t});let n=Object.keys(t).sort((s,i)=>t[i]-t[s]).map(s=>e[s]);return Kr(n),n}function $p(r){let{modules:e,level:t,moduleMap:n,moduleDepth:s}=r;if(t>=5)throw new Error("Possible loop in shader dependency graph");for(let i of e)n[i.name]=i,(s[i.name]===void 0||s[i.name]<t)&&(s[i.name]=t);for(let i of e)i.dependencies&&$p({modules:i.dependencies,level:t+1,moduleMap:n,moduleDepth:s})}function jp(r){switch(r?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
43
+ `;switch(i){case"vs:#decl":s&&(r=r.replace(Ws,a));break;case"vs:#main-start":s&&(r=r.replace(Gp,c=>c+a));break;case"vs:#main-end":s&&(r=r.replace(Qp,c=>a+c));break;case"fs:#decl":s||(r=r.replace(Ws,a));break;case"fs:#main-start":s||(r=r.replace(Gp,c=>c+a));break;case"fs:#main-end":s||(r=r.replace(Qp,c=>a+c));break;default:r=r.replace(i,c=>c+a)}}return r=r.replace(Ws,""),n&&(r=r.replace(/\}\s*$/,i=>i+m0[e])),r}function Zr(r){r.map(e=>na(e))}function na(r){if(r.instance)return;Zr(r.dependencies||[]);let{propTypes:e={},deprecations:t=[],inject:n={}}=r,s={normalizedInjections:Jp(n),parsedDeprecations:_0(t)};e&&(s.propValidators=qp(e)),r.instance=s;let i={};e&&(i=Object.entries(e).reduce((o,[a,c])=>{let l=c?.value;return l&&(o[a]=l),o},{})),r.defaultUniforms={...r.defaultUniforms,...i}}function ku(r,e,t){r.deprecations?.forEach(n=>{n.regex?.test(e)&&(n.deprecated?t.deprecated(n.old,n.new)():t.removed(n.old,n.new)())})}function _0(r){return r.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),r}function jn(r){Zr(r);let e={},t={};em({modules:r,level:0,moduleMap:e,moduleDepth:t});let n=Object.keys(t).sort((s,i)=>t[i]-t[s]).map(s=>e[s]);return Zr(n),n}function em(r){let{modules:e,level:t,moduleMap:n,moduleDepth:s}=r;if(t>=5)throw new Error("Possible loop in shader dependency graph");for(let i of e)n[i.name]=i,(s[i.name]===void 0||s[i.name]<t)&&(s[i.name]=t);for(let i of e)i.dependencies&&em({modules:i.dependencies,level:t+1,moduleMap:n,moduleDepth:s})}function tm(r){switch(r?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
44
44
  // Apple optimizes away the calculation necessary for emulated fp64
45
45
  #define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
46
46
  #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
@@ -64,50 +64,50 @@ ${e}`;let{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(thi
64
64
  #define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
65
65
  // If the GPU doesn't have full 32 bits precision, will causes overflow
66
66
  #define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
67
- `}}function Xp(r,e){if(Number(r.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return r=Hp(r,c0),r;case"fragment":return r=Hp(r,l0),r;default:throw new Error(e)}}var Yp=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
68
- `],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],c0=[...Yp,[Eu("attribute"),"in $1"],[Eu("varying"),"out $1"]],l0=[...Yp,[Eu("varying"),"in $1"]];function Hp(r,e){for(let[t,n]of e)r=r.replace(t,n);return r}function Eu(r){return new RegExp(`\\b${r}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function Ru(r,e){let t="";for(let n in r){let s=r[n];if(t+=`void ${s.signature} {
67
+ `}}function nm(r,e){if(Number(r.match(/^#version[ \t]+(\d+)/m)?.[1]||100)!==300)throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(e){case"vertex":return r=rm(r,y0),r;case"fragment":return r=rm(r,x0),r;default:throw new Error(e)}}var sm=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
68
+ `],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],y0=[...sm,[Nu("attribute"),"in $1"],[Nu("varying"),"out $1"]],x0=[...sm,[Nu("varying"),"in $1"]];function rm(r,e){for(let[t,n]of e)r=r.replace(t,n);return r}function Nu(r){return new RegExp(`\\b${r}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function Du(r,e){let t="";for(let n in r){let s=r[n];if(t+=`void ${s.signature} {
69
69
  `,s.header&&(t+=` ${s.header}`),e[n]){let i=e[n];i.sort((o,a)=>o.order-a.order);for(let o of i)t+=` ${o.injection}
70
70
  `}s.footer&&(t+=` ${s.footer}`),t+=`}
71
- `}return t}function Iu(r){let e={vertex:{},fragment:{}};for(let t of r){let n,s;typeof t!="string"?(n=t,s=n.hook):(n={},s=t),s=s.trim();let[i,o]=s.split(":"),a=s.replace(/\(.+/,""),c=Object.assign(n,{signature:o});switch(i){case"vs":e.vertex[a]=c;break;case"fs":e.fragment[a]=c;break;default:throw new Error(i)}}return e}function qp(r,e){return{name:u0(r,e),language:"glsl",version:f0(r)}}function u0(r,e="unnamed"){let n=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(r);return n?n[1]:e}function f0(r){let e=100,t=r.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){let n=parseInt(t[1],10);Number.isFinite(n)&&(e=n)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var Zp=`
71
+ `}return t}function Fu(r){let e={vertex:{},fragment:{}};for(let t of r){let n,s;typeof t!="string"?(n=t,s=n.hook):(n={},s=t),s=s.trim();let[i,o]=s.split(":"),a=s.replace(/\(.+/,""),c=Object.assign(n,{signature:o});switch(i){case"vs":e.vertex[a]=c;break;case"fs":e.fragment[a]=c;break;default:throw new Error(i)}}return e}function im(r,e){return{name:b0(r,e),language:"glsl",version:T0(r)}}function b0(r,e="unnamed"){let n=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(r);return n?n[1]:e}function T0(r){let e=100,t=r.match(/[^\s]+/g);if(t&&t.length>=2&&t[0]==="#version"){let n=parseInt(t[1],10);Number.isFinite(n)&&(e=n)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var am=`
72
72
 
73
- ${Vs}
74
- `,h0=`precision highp float;
75
- `;function Gp(r){let e=zn(r.modules||[]);return{source:d0(r.platformInfo,{...r,source:r.source,stage:"vertex",modules:e}),getUniforms:Jp(e)}}function Qp(r){let{vs:e,fs:t}=r,n=zn(r.modules||[]);return{vs:Kp(r.platformInfo,{...r,source:e,stage:"vertex",modules:n}),fs:Kp(r.platformInfo,{...r,source:t,stage:"fragment",modules:n}),getUniforms:Jp(n)}}function d0(r,e){let{source:t,stage:n,modules:s,hookFunctions:i=[],inject:o={},log:a}=e;Go(typeof t=="string","shader source must be a string");let c=t,l="",u=Iu(i),f={},h={},d={};for(let y in o){let _=typeof o[y]=="string"?{injection:o[y],order:0}:o[y],x=/^(v|f)s:(#)?([\w-]+)$/.exec(y);if(x){let E=x[2],b=x[3];E?b==="decl"?h[y]=[_]:d[y]=[_]:f[y]=[_]}else d[y]=[_]}let m=s;for(let y of m){a&&Su(y,c,a);let _=em(y,"wgsl");l+=_;let x=y.injections?.[n]||{};for(let E in x){let b=/^(v|f)s:#([\w-]+)$/.exec(E);if(b){let C=b[2]==="decl"?h:d;C[E]=C[E]||[],C[E].push(x[E])}else f[E]=f[E]||[],f[E].push(x[E])}}return l+=Zp,l=zs(l,n,h),l+=Ru(u[n],f),l+=c,l=zs(l,n,d),l}function Kp(r,e){let{source:t,stage:n,language:s="glsl",modules:i,defines:o={},hookFunctions:a=[],inject:c={},prologue:l=!0,log:u}=e;Go(typeof t=="string","shader source must be a string");let f=s==="glsl"?qp(t).version:-1,h=r.shaderLanguageVersion,d=f===100?"#version 100":"#version 300 es",y=t.split(`
73
+ ${Ws}
74
+ `,w0=`precision highp float;
75
+ `;function cm(r){let e=jn(r.modules||[]);return{source:v0(r.platformInfo,{...r,source:r.source,stage:"vertex",modules:e}),getUniforms:um(e)}}function lm(r){let{vs:e,fs:t}=r,n=jn(r.modules||[]);return{vs:om(r.platformInfo,{...r,source:e,stage:"vertex",modules:n}),fs:om(r.platformInfo,{...r,source:t,stage:"fragment",modules:n}),getUniforms:um(n)}}function v0(r,e){let{source:t,stage:n,modules:s,hookFunctions:i=[],inject:o={},log:a}=e;ra(typeof t=="string","shader source must be a string");let c=t,l="",u=Fu(i),f={},h={},d={};for(let y in o){let _=typeof o[y]=="string"?{injection:o[y],order:0}:o[y],x=/^(v|f)s:(#)?([\w-]+)$/.exec(y);if(x){let E=x[2],b=x[3];E?b==="decl"?h[y]=[_]:d[y]=[_]:f[y]=[_]}else d[y]=[_]}let m=s;for(let y of m){a&&ku(y,c,a);let _=fm(y,"wgsl");l+=_;let x=y.injections?.[n]||{};for(let E in x){let b=/^(v|f)s:#([\w-]+)$/.exec(E);if(b){let C=b[2]==="decl"?h:d;C[E]=C[E]||[],C[E].push(x[E])}else f[E]=f[E]||[],f[E].push(x[E])}}return l+=am,l=$s(l,n,h),l+=Du(u[n],f),l+=c,l=$s(l,n,d),l}function om(r,e){let{source:t,stage:n,language:s="glsl",modules:i,defines:o={},hookFunctions:a=[],inject:c={},prologue:l=!0,log:u}=e;ra(typeof t=="string","shader source must be a string");let f=s==="glsl"?im(t).version:-1,h=r.shaderLanguageVersion,d=f===100?"#version 100":"#version 300 es",y=t.split(`
76
76
  `).slice(1).join(`
77
77
  `),_={};i.forEach(P=>{Object.assign(_,P.defines)}),Object.assign(_,o);let x="";switch(s){case"wgsl":break;case"glsl":x=l?`${d}
78
78
 
79
79
  // ----- PROLOGUE -------------------------
80
80
  ${`#define SHADER_TYPE_${n.toUpperCase()}`}
81
81
 
82
- ${jp(r)}
83
- ${n==="fragment"?h0:""}
82
+ ${tm(r)}
83
+ ${n==="fragment"?w0:""}
84
84
 
85
85
  // ----- APPLICATION DEFINES -------------------------
86
86
 
87
- ${p0(_)}
87
+ ${A0(_)}
88
88
 
89
89
  `:`${d}
90
- `;break}let E=Iu(a),b={},S={},C={};for(let P in c){let B=typeof c[P]=="string"?{injection:c[P],order:0}:c[P],N=/^(v|f)s:(#)?([\w-]+)$/.exec(P);if(N){let k=N[2],F=N[3];k?F==="decl"?S[P]=[B]:C[P]=[B]:b[P]=[B]}else C[P]=[B]}for(let P of i){u&&Su(P,y,u);let B=em(P,n);x+=B;let N=P.instance?.normalizedInjections[n]||{};for(let k in N){let F=/^(v|f)s:#([\w-]+)$/.exec(k);if(F){let X=F[2]==="decl"?S:C;X[k]=X[k]||[],X[k].push(N[k])}else b[k]=b[k]||[],b[k].push(N[k])}}return x+="// ----- MAIN SHADER SOURCE -------------------------",x+=Zp,x=zs(x,n,S),x+=Ru(E[n],b),x+=y,x=zs(x,n,C),s==="glsl"&&f!==h&&(x=Xp(x,n)),x.trim()}function Jp(r){return function(t){let n={};for(let s of r){let i=s.getUniforms?.(t,n);Object.assign(n,i)}return n}}function p0(r={}){let e="";for(let t in r){let n=r[t];(n||Number.isFinite(n))&&(e+=`#define ${t.toUpperCase()} ${r[t]}
91
- `)}return e}function em(r,e){let t;switch(e){case"vertex":t=r.vs||"";break;case"fragment":t=r.fs||"";break;case"wgsl":t=r.source||"";break;default:Go(!1)}if(!r.name)throw new Error("Shader module must have a name");let n=r.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),s=`// ----- MODULE ${r.name} ---------------
90
+ `;break}let E=Fu(a),b={},S={},C={};for(let P in c){let B=typeof c[P]=="string"?{injection:c[P],order:0}:c[P],N=/^(v|f)s:(#)?([\w-]+)$/.exec(P);if(N){let k=N[2],F=N[3];k?F==="decl"?S[P]=[B]:C[P]=[B]:b[P]=[B]}else C[P]=[B]}for(let P of i){u&&ku(P,y,u);let B=fm(P,n);x+=B;let N=P.instance?.normalizedInjections[n]||{};for(let k in N){let F=/^(v|f)s:#([\w-]+)$/.exec(k);if(F){let X=F[2]==="decl"?S:C;X[k]=X[k]||[],X[k].push(N[k])}else b[k]=b[k]||[],b[k].push(N[k])}}return x+="// ----- MAIN SHADER SOURCE -------------------------",x+=am,x=$s(x,n,S),x+=Du(E[n],b),x+=y,x=$s(x,n,C),s==="glsl"&&f!==h&&(x=nm(x,n)),x.trim()}function um(r){return function(t){let n={};for(let s of r){let i=s.getUniforms?.(t,n);Object.assign(n,i)}return n}}function A0(r={}){let e="";for(let t in r){let n=r[t];(n||Number.isFinite(n))&&(e+=`#define ${t.toUpperCase()} ${r[t]}
91
+ `)}return e}function fm(r,e){let t;switch(e){case"vertex":t=r.vs||"";break;case"fragment":t=r.fs||"";break;case"wgsl":t=r.source||"";break;default:ra(!1)}if(!r.name)throw new Error("Shader module must have a name");let n=r.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),s=`// ----- MODULE ${r.name} ---------------
92
92
 
93
93
  `;return e!=="wgsl"&&(s+=`#define MODULE_${n}
94
94
  `),s+=`${t}
95
- `,s}var m0=/^\s*\#\s*ifdef\s*([a-zA-Z_]+)\s*$/,g0=/^\s*\#\s*endif\s*$/;function tm(r,e){let t=r.split(`
96
- `),n=[],s=!0,i=null;for(let o of t){let a=o.match(m0),c=o.match(g0);a?(i=a[1],s=Boolean(e?.defines?.[i])):c?s=!0:s&&n.push(o)}return n.join(`
97
- `)}var Wn=class{_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return Wn.defaultShaderAssembler=Wn.defaultShaderAssembler||new Wn,Wn.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(n=>n.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){let t=this._getModuleList(e.modules),n=this._hookFunctions,{source:s,getUniforms:i}=Gp({...e,source:e.source,modules:t,hookFunctions:n});return{source:e.platformInfo.shaderLanguage==="wgsl"?tm(s):s,getUniforms:i,modules:t}}assembleGLSLShaderPair(e){let t=this._getModuleList(e.modules),n=this._hookFunctions;return{...Qp({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:n}),modules:t}}_getModuleList(e=[]){let t=new Array(this._defaultModules.length+e.length),n={},s=0;for(let i=0,o=this._defaultModules.length;i<o;++i){let a=this._defaultModules[i],c=a.name;t[s++]=a,n[c]=!0}for(let i=0,o=e.length;i<o;++i){let a=e[i],c=a.name;n[c]||(t[s++]=a,n[c]=!0)}return t.length=s,Kr(t),t}},yr=Wn;L(yr,"defaultShaderAssembler");var _0=`out vec4 transform_output;
95
+ `,s}var S0=/^\s*\#\s*ifdef\s*([a-zA-Z_]+)\s*$/,E0=/^\s*\#\s*endif\s*$/;function hm(r,e){let t=r.split(`
96
+ `),n=[],s=!0,i=null;for(let o of t){let a=o.match(S0),c=o.match(E0);a?(i=a[1],s=Boolean(e?.defines?.[i])):c?s=!0:s&&n.push(o)}return n.join(`
97
+ `)}var Hn=class{_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return Hn.defaultShaderAssembler=Hn.defaultShaderAssembler||new Hn,Hn.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let t=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(n=>n.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){let t=this._getModuleList(e.modules),n=this._hookFunctions,{source:s,getUniforms:i}=cm({...e,source:e.source,modules:t,hookFunctions:n});return{source:e.platformInfo.shaderLanguage==="wgsl"?hm(s):s,getUniforms:i,modules:t}}assembleGLSLShaderPair(e){let t=this._getModuleList(e.modules),n=this._hookFunctions;return{...lm({...e,vs:e.vs,fs:e.fs,modules:t,hookFunctions:n}),modules:t}}_getModuleList(e=[]){let t=new Array(this._defaultModules.length+e.length),n={},s=0;for(let i=0,o=this._defaultModules.length;i<o;++i){let a=this._defaultModules[i],c=a.name;t[s++]=a,n[c]=!0}for(let i=0,o=e.length;i<o;++i){let a=e[i],c=a.name;n[c]||(t[s++]=a,n[c]=!0)}return t.length=s,Zr(t),t}},_r=Hn;L(_r,"defaultShaderAssembler");var R0=`out vec4 transform_output;
98
98
  void main() {
99
99
  transform_output = vec4(0);
100
- }`,y0=`#version 300 es
101
- ${_0}`;function Ws(r){let{input:e,inputChannels:t,output:n}=r||{};if(!e)return y0;if(!t)throw new Error("inputChannels");let s=x0(t),i=rm(e,t);return`#version 300 es
100
+ }`,I0=`#version 300 es
101
+ ${R0}`;function js(r){let{input:e,inputChannels:t,output:n}=r||{};if(!e)return I0;if(!t)throw new Error("inputChannels");let s=P0(t),i=dm(e,t);return`#version 300 es
102
102
  in ${s} ${e};
103
103
  out vec4 ${n};
104
104
  void main() {
105
105
  ${n} = ${i};
106
- }`}function x0(r){switch(r){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${r}`)}}function rm(r,e){switch(e){case 1:return`vec4(${r}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${r}, 0.0, 1.0)`;case 3:return`vec4(${r}, 1.0)`;case 4:return r;default:throw new Error(`invalid channels: ${e}`)}}H();var Le=class{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}getTypeName(){return this.name}},Jo=class{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},Pt=class extends Le{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}},Ct=class extends Le{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}},Zt=class extends Le{constructor(e,t,n,s){super(e,n),this.format=t,this.access=s}get isTemplate(){return!0}getTypeName(){let e=this.name;if(this.format!==null){if(e==="vec2"||e==="vec3"||e==="vec4"||e==="mat2x2"||e==="mat2x3"||e==="mat2x4"||e==="mat3x2"||e==="mat3x3"||e==="mat3x4"||e==="mat4x2"||e==="mat4x3"||e==="mat4x4"){if(this.format.name==="f32")return e+="f",e;if(this.format.name==="i32")return e+="i",e;if(this.format.name==="u32")return e+="u",e;if(this.format.name==="bool")return e+="b",e;if(this.format.name==="f16")return e+="h",e}e+=`<${this.format.name}>`}else if(e==="vec2"||e==="vec3"||e==="vec4")return e;return e}},xr;(r=>{r[r.Uniform=0]="Uniform",r[r.Storage=1]="Storage",r[r.Texture=2]="Texture",r[r.Sampler=3]="Sampler",r[r.StorageTexture=4]="StorageTexture"})(xr||(xr={}));var $n=class{constructor(e,t,n,s,i,o,a){this.name=e,this.type=t,this.group=n,this.binding=s,this.attributes=i,this.resourceType=o,this.access=a}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},Mu=class{constructor(e,t){this.name=e,this.type=t}},Ou=class{constructor(e,t,n,s){this.name=e,this.type=t,this.locationType=n,this.location=s,this.interpolation=null}},ea=class{constructor(e,t,n,s){this.name=e,this.type=t,this.locationType=n,this.location=s}},ku=class{constructor(e,t,n,s){this.name=e,this.type=t,this.attributes=n,this.id=s}},Nu=class{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n}},Du=class{constructor(e,t=null,n){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=n}},Fu=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},im=new Float32Array(1),b0=new Int32Array(im.buffer),Ee=new Uint16Array(1);function T0(r){im[0]=r;let e=b0[0],t=e>>31&1,n=e>>23&255,s=8388607&e;if(n===255)return Ee[0]=t<<15|31744|(s!==0?512:0),Ee[0];if(n===0){if(s===0)return Ee[0]=t<<15,Ee[0];s|=8388608;let i=113;for(;!(8388608&s);)s<<=1,i--;return n=127-i,s&=8388607,n>0?(s=(s>>126-n)+(s>>127-n&1),Ee[0]=t<<15|n<<10|s>>13,Ee[0]):(Ee[0]=t<<15,Ee[0])}return n=n-127+15,n>=31?(Ee[0]=t<<15|31744,Ee[0]):n<=0?n<-10?(Ee[0]=t<<15,Ee[0]):(s=(8388608|s)>>1-n,Ee[0]=t<<15|s>>13,Ee[0]):(s>>=13,Ee[0]=t<<15|n<<10|s,Ee[0])}var qu=new Uint32Array(1),om=new Float32Array(qu.buffer,0,1);function nm(r){let e=112+(r>>6&31)<<23|(63&r)<<17;return qu[0]=e,om[0]}function w0(r,e,t,n,s,i,o,a,c){let l=n*(o>>=s)*(i>>=s)+t*o+e*a;switch(c){case"r8unorm":return[te(r,l,"8unorm",1)[0]];case"r8snorm":return[te(r,l,"8snorm",1)[0]];case"r8uint":return[te(r,l,"8uint",1)[0]];case"r8sint":return[te(r,l,"8sint",1)[0]];case"rg8unorm":{let u=te(r,l,"8unorm",2);return[u[0],u[1]]}case"rg8snorm":{let u=te(r,l,"8snorm",2);return[u[0],u[1]]}case"rg8uint":{let u=te(r,l,"8uint",2);return[u[0],u[1]]}case"rg8sint":{let u=te(r,l,"8sint",2);return[u[0],u[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{let u=te(r,l,"8unorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8snorm":{let u=te(r,l,"8snorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8uint":{let u=te(r,l,"8uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba8sint":{let u=te(r,l,"8sint",4);return[u[0],u[1],u[2],u[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{let u=te(r,l,"8unorm",4);return[u[2],u[1],u[0],u[3]]}case"r16uint":return[te(r,l,"16uint",1)[0]];case"r16sint":return[te(r,l,"16sint",1)[0]];case"r16float":return[te(r,l,"16float",1)[0]];case"rg16uint":{let u=te(r,l,"16uint",2);return[u[0],u[1]]}case"rg16sint":{let u=te(r,l,"16sint",2);return[u[0],u[1]]}case"rg16float":{let u=te(r,l,"16float",2);return[u[0],u[1]]}case"rgba16uint":{let u=te(r,l,"16uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16sint":{let u=te(r,l,"16sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16float":{let u=te(r,l,"16float",4);return[u[0],u[1],u[2],u[3]]}case"r32uint":return[te(r,l,"32uint",1)[0]];case"r32sint":return[te(r,l,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[te(r,l,"32float",1)[0]];case"rg32uint":{let u=te(r,l,"32uint",2);return[u[0],u[1]]}case"rg32sint":{let u=te(r,l,"32sint",2);return[u[0],u[1]]}case"rg32float":{let u=te(r,l,"32float",2);return[u[0],u[1]]}case"rgba32uint":{let u=te(r,l,"32uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32sint":{let u=te(r,l,"32sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32float":{let u=te(r,l,"32float",4);return[u[0],u[1],u[2],u[3]]}case"rg11b10ufloat":{let u=new Uint32Array(r.buffer,l,1)[0],f=(4192256&u)>>11,h=(4290772992&u)>>22;return[nm(2047&u),nm(f),function(d){let m=112+(d>>5&31)<<23|(31&d)<<18;return qu[0]=m,om[0]}(h),1]}}return null}function te(r,e,t,n){let s=[0,0,0,0];for(let l=0;l<n;++l)switch(t){case"8unorm":s[l]=r[e]/255,e++;break;case"8snorm":s[l]=r[e]/255*2-1,e++;break;case"8uint":s[l]=r[e],e++;break;case"8sint":s[l]=r[e]-127,e++;break;case"16uint":s[l]=r[e]|r[e+1]<<8,e+=2;break;case"16sint":s[l]=(r[e]|r[e+1]<<8)-32768,e+=2;break;case"16float":s[l]=(i=r[e]|r[e+1]<<8,o=void 0,a=void 0,c=void 0,o=(32768&i)>>15,c=1023&i,(a=(31744&i)>>10)==0?(o?-1:1)*Math.pow(2,-14)*(c/Math.pow(2,10)):a==31?c?NaN:1/0*(o?-1:1):(o?-1:1)*Math.pow(2,a-15)*(1+c/Math.pow(2,10))),e+=2;break;case"32uint":case"32sint":s[l]=r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24,e+=4;break;case"32float":s[l]=new Float32Array(r.buffer,e,1)[0],e+=4}var i,o,a,c;return s}function re(r,e,t,n,s){for(let i=0;i<n;++i)switch(t){case"8unorm":r[e]=255*s[i],e++;break;case"8snorm":r[e]=.5*(s[i]+1)*255,e++;break;case"8uint":r[e]=s[i],e++;break;case"8sint":r[e]=s[i]+127,e++;break;case"16uint":new Uint16Array(r.buffer,e,1)[0]=s[i],e+=2;break;case"16sint":new Int16Array(r.buffer,e,1)[0]=s[i],e+=2;break;case"16float":{let o=T0(s[i]);new Uint16Array(r.buffer,e,1)[0]=o,e+=2;break}case"32uint":new Uint32Array(r.buffer,e,1)[0]=s[i],e+=4;break;case"32sint":new Int32Array(r.buffer,e,1)[0]=s[i],e+=4;break;case"32float":new Float32Array(r.buffer,e,1)[0]=s[i],e+=4}return s}var Pu={r8unorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8snorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8uint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8sint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg8unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8snorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"rgba8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8snorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},bgra8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bgra8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r16uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16float:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg16uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba16uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r32uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg32uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba32uint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32sint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32float:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rg11b10ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},stencil8:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!1,hasStencil:!0,channels:1},depth16unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},depth24plus:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,depthOnlyFormat:"depth32float",channels:1},"depth24plus-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,depthOnlyFormat:"depth32float",channels:1},depth32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},"depth32float-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,stencilOnlyFormat:"depth32float",channels:1},rgb9e5ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bc1-rgba-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc1-rgba-unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc4-r-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc4-r-snorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc5-rg-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc5-rg-snorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc6h-rgb-ufloat":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc6h-rgb-float":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"eac-r11unorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-r11snorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-rg11unorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"eac-rg11snorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"astc-4x4-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-4x4-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x5-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-5x5-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x6-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-6x6-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-8x5-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x5-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x6-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x6-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x8-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-8x8-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-10x5-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x5-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x6-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x6-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x8-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x8-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x10-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-10x10-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x12-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4},"astc-12x12-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4}},Ue=class{constructor(){this.id=Ue._id++,this.line=0}get isAstNode(){return!0}get astNodeType(){return""}search(e){e(this)}searchBlock(e,t){if(e){t(qn.instance);for(let n of e)n instanceof Array?this.searchBlock(n,t):n.search(t);t(Kn.instance)}}constEvaluate(e,t){throw new Error("Cannot evaluate node")}constEvaluateString(e){return this.constEvaluate(e).toString()}};Ue._id=0;var qn=class extends Ue{};qn.instance=new qn;var Kn=class extends Ue{};Kn.instance=new Kn;var am=new Set(["all","all","any","select","arrayLength","abs","acos","acosh","asin","asinh","atan","atanh","atan2","ceil","clamp","cos","cosh","countLeadingZeros","countOneBits","countTrailingZeros","cross","degrees","determinant","distance","dot","dot4U8Packed","dot4I8Packed","exp","exp2","extractBits","faceForward","firstLeadingBit","firstTrailingBit","floor","fma","fract","frexp","insertBits","inverseSqrt","ldexp","length","log","log2","max","min","mix","modf","normalize","pow","quantizeToF16","radians","reflect","refract","reverseBits","round","saturate","sign","sin","sinh","smoothStep","sqrt","step","tan","tanh","transpose","trunc","dpdx","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","textureDimensions","textureGather","textureGatherCompare","textureLoad","textureNumLayers","textureNumLevels","textureNumSamples","textureSample","textureSampleBias","textureSampleCompare","textureSampleCompareLevel","textureSampleGrad","textureSampleLevel","textureSampleBaseClampToEdge","textureStore","atomicLoad","atomicStore","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","atomicExchange","atomicCompareExchangeWeak","pack4x8snorm","pack4x8unorm","pack4xI8","pack4xU8","pack4x8Clamp","pack4xU8Clamp","pack2x16snorm","pack2x16unorm","pack2x16float","unpack4x8snorm","unpack4x8unorm","unpack4xI8","unpack4xU8","unpack2x16snorm","unpack2x16unorm","unpack2x16float","storageBarrier","textureBarrier","workgroupBarrier","workgroupUniformLoad","subgroupAdd","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","subgroupAnd","subgroupAny","subgroupBallot","subgroupBroadcast","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","subgroupShuffleUp","subgroupShuffleXor","subgroupXor","quadBroadcast","quadSwapDiagonal","quadSwapX","quadSwapY"]),oe=class extends Ue{constructor(){super()}},Jr=class extends oe{constructor(e,t,n,s,i,o){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=n,this.body=s,this.startLine=i,this.endLine=o}get astNodeType(){return"function"}search(e){if(this.attributes)for(let t of this.attributes)e(t);e(this);for(let t of this.args)e(t);this.searchBlock(this.body,e)}},Bu=class extends oe{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}},ta=class extends oe{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},Hs=class extends oe{constructor(e,t){super(),this.body=e,this.loopId=t}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}},ra=class extends oe{constructor(e,t,n,s){super(),this.init=e,this.condition=t,this.increment=n,this.body=s}get astNodeType(){return"for"}search(e){var t,n,s;(t=this.init)===null||t===void 0||t.search(e),(n=this.condition)===null||n===void 0||n.search(e),(s=this.increment)===null||s===void 0||s.search(e),this.searchBlock(this.body,e)}},ht=class extends oe{constructor(e,t,n,s,i){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=i}get astNodeType(){return"var"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},Xs=class extends oe{constructor(e,t,n){super(),this.attributes=null,this.name=e,this.type=t,this.value=n}get astNodeType(){return"override"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}},Gr=class extends oe{constructor(e,t,n,s,i){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=i}get astNodeType(){return"let"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},Xn=class extends oe{constructor(e,t,n,s,i){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=i}get astNodeType(){return"const"}constEvaluate(e,t){return this.value.constEvaluate(e,t)}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},jn,$s,R,v;(r=>{r.increment="++",r.decrement="--"})(jn||(jn={})),(r=>{r.parse=function(e){let t=e;if(t=="parse")throw new Error("Invalid value for IncrementOperator");return r[t]}})(jn||(jn={}));var na=class extends oe{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}};(r=>{r.assign="=",r.addAssign="+=",r.subtractAssin="-=",r.multiplyAssign="*=",r.divideAssign="/=",r.moduloAssign="%=",r.andAssign="&=",r.orAssign="|=",r.xorAssign="^=",r.shiftLeftAssign="<<=",r.shiftRightAssign=">>="})($s||($s={})),(r=>{r.parse=function(e){let t=e;if(t=="parse")throw new Error("Invalid value for AssignOperator");return t}})($s||($s={}));var sa=class extends oe{constructor(e,t,n){super(),this.operator=e,this.variable=t,this.value=n}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}},Ys=class extends oe{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return am.has(this.name)}search(e){for(let t of this.args)t.search(e);e(this)}},ia=class extends oe{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}},oa=class extends oe{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return"switch"}},aa=class extends oe{constructor(e,t,n,s){super(),this.condition=e,this.body=t,this.elseif=n,this.else=s}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}},ca=class extends oe{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}},Lu=class extends oe{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}},Uu=class extends oe{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}},la=class extends oe{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}},qs=class extends oe{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}},Vu=class extends oe{constructor(){super()}get astNodeType(){return"discard"}},ua=class extends oe{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}},fa=class extends oe{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}},M=class extends oe{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if(t.name==="f32")return t;for(let n=1;n<e.length;++n){let s=M._priority.get(t.name);M._priority.get(e[n].name)<s&&(t=e[n])}return t.name==="x32"?M.i32:t}getTypeName(){return this.name}};M.x32=new M("x32"),M.f32=new M("f32"),M.i32=new M("i32"),M.u32=new M("u32"),M.f16=new M("f16"),M.bool=new M("bool"),M.void=new M("void"),M._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);var ha=class extends M{constructor(e){super(e)}},ut=class extends M{constructor(e,t,n,s){super(e),this.members=t,this.startLine=n,this.endLine=s}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name==e)return t;return-1}search(e){for(let t of this.members)e(t)}},A=class extends M{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return"template"}getTypeName(){let e=this.name;if(this.format!==null){if(e==="vec2"||e==="vec3"||e==="vec4"||e==="mat2x2"||e==="mat2x3"||e==="mat2x4"||e==="mat3x2"||e==="mat3x3"||e==="mat3x4"||e==="mat4x2"||e==="mat4x3"||e==="mat4x4"){if(this.format.name==="f32")return e+="f",e;if(this.format.name==="i32")return e+="i",e;if(this.format.name==="u32")return e+="u",e;if(this.format.name==="bool")return e+="b",e;if(this.format.name==="f16")return e+="h",e}e+=`<${this.format.name}>`}else if(e==="vec2"||e==="vec3"||e==="vec4")return e;return e}};A.vec2f=new A("vec2",M.f32,null),A.vec3f=new A("vec3",M.f32,null),A.vec4f=new A("vec4",M.f32,null),A.vec2i=new A("vec2",M.i32,null),A.vec3i=new A("vec3",M.i32,null),A.vec4i=new A("vec4",M.i32,null),A.vec2u=new A("vec2",M.u32,null),A.vec3u=new A("vec3",M.u32,null),A.vec4u=new A("vec4",M.u32,null),A.vec2h=new A("vec2",M.f16,null),A.vec3h=new A("vec3",M.f16,null),A.vec4h=new A("vec4",M.f16,null),A.vec2b=new A("vec2",M.bool,null),A.vec3b=new A("vec3",M.bool,null),A.vec4b=new A("vec4",M.bool,null),A.mat2x2f=new A("mat2x2",M.f32,null),A.mat2x3f=new A("mat2x3",M.f32,null),A.mat2x4f=new A("mat2x4",M.f32,null),A.mat3x2f=new A("mat3x2",M.f32,null),A.mat3x3f=new A("mat3x3",M.f32,null),A.mat3x4f=new A("mat3x4",M.f32,null),A.mat4x2f=new A("mat4x2",M.f32,null),A.mat4x3f=new A("mat4x3",M.f32,null),A.mat4x4f=new A("mat4x4",M.f32,null),A.mat2x2h=new A("mat2x2",M.f16,null),A.mat2x3h=new A("mat2x3",M.f16,null),A.mat2x4h=new A("mat2x4",M.f16,null),A.mat3x2h=new A("mat3x2",M.f16,null),A.mat3x3h=new A("mat3x3",M.f16,null),A.mat3x4h=new A("mat3x4",M.f16,null),A.mat4x2h=new A("mat4x2",M.f16,null),A.mat4x3h=new A("mat4x3",M.f16,null),A.mat4x4h=new A("mat4x4",M.f16,null),A.mat2x2i=new A("mat2x2",M.i32,null),A.mat2x3i=new A("mat2x3",M.i32,null),A.mat2x4i=new A("mat2x4",M.i32,null),A.mat3x2i=new A("mat3x2",M.i32,null),A.mat3x3i=new A("mat3x3",M.i32,null),A.mat3x4i=new A("mat3x4",M.i32,null),A.mat4x2i=new A("mat4x2",M.i32,null),A.mat4x3i=new A("mat4x3",M.i32,null),A.mat4x4i=new A("mat4x4",M.i32,null),A.mat2x2u=new A("mat2x2",M.u32,null),A.mat2x3u=new A("mat2x3",M.u32,null),A.mat2x4u=new A("mat2x4",M.u32,null),A.mat3x2u=new A("mat3x2",M.u32,null),A.mat3x3u=new A("mat3x3",M.u32,null),A.mat3x4u=new A("mat3x4",M.u32,null),A.mat4x2u=new A("mat4x2",M.u32,null),A.mat4x3u=new A("mat4x3",M.u32,null),A.mat4x4u=new A("mat4x4",M.u32,null);var js=class extends M{constructor(e,t,n,s){super(e),this.storage=t,this.type=n,this.access=s}get astNodeType(){return"pointer"}},Qr=class extends M{constructor(e,t,n,s){super(e),this.attributes=t,this.format=n,this.count=s}get astNodeType(){return"array"}get isArray(){return!0}},Zr=class extends M{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return"sampler"}},tt=class extends Ue{constructor(){super(),this.postfix=null}},Gt=class extends tt{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}},Je=class extends tt{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(let t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}},Ks=class extends tt{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return am.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(let t of this.args)t.search(e);e(this)}},Me=class extends tt{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}},da=class extends tt{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}constEvaluate(e,t){if(this.initializer){let n=e.evalExpression(this.initializer,e.context);return n!==null&&this.postfix?n.getSubData(e,this.postfix,e.context):n}return null}search(e){this.initializer.search(e)}},me=class extends tt{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return"literalExpr"}constEvaluate(e,t){return t!==void 0&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof T}get isVector(){return this.value instanceof g||this.value instanceof z}get scalarValue(){return this.value instanceof T?this.value.value:(console.error("Value is not scalar."),0)}get vectorValue(){return this.value instanceof g||this.value instanceof z?this.value.data:(console.error("Value is not a vector or matrix."),new Float32Array(0))}},pa=class extends tt{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}};var Tr=class extends tt{constructor(e){super(),this.index=e}search(e){this.index.search(e)}},ma=class extends tt{constructor(){super()}},ue=class extends ma{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}},He=class extends ma{constructor(e,t,n){super(),this.operator=e,this.left=t,this.right=n}get astNodeType(){return"binaryOp"}_getPromotedType(e,t){return e.name===t.name?e:e.name==="f32"||t.name==="f32"?M.f32:e.name==="u32"||t.name==="u32"?M.u32:M.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}},ga=class extends Ue{constructor(e){super(),this.body=e}},Yn=class extends tt{constructor(){super()}get astNodeType(){return"default"}},_a=class extends ga{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}},ya=class extends ga{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}},xa=class extends Ue{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"argument"}},zu=class extends Ue{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},ba=class extends Ue{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"member"}},Ta=class extends Ue{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}},Ve=class{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=Ve._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,n,s){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,n){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.name}>`}};Ve._id=0;var Zs=class extends Ve{constructor(){super(new Le("void",null),null)}toString(){return"void"}};Zs.void=new Zs;var br=class extends Ve{constructor(e){super(new Le("pointer",null),null),this.reference=e}clone(){return this}setDataValue(e,t,n,s){this.reference.setDataValue(e,t,n,s)}getSubData(e,t,n){return t?this.reference.getSubData(e,t,n):this}},T=class extends Ve{constructor(e,t,n=null){super(t,n),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:this.typeInfo.name==="x32"?e-Math.floor(e)!=0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):this.typeInfo.name==="i32"||this.typeInfo.name==="bool"?this.data=new Int32Array([e]):this.typeInfo.name==="u32"?this.data=new Uint32Array([e]):this.typeInfo.name==="f32"||this.typeInfo.name==="f16"?this.data=new Float32Array([e]):console.error("ScalarData2: Invalid type",t)}clone(){if(this.data instanceof Float32Array)return new T(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new T(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new T(new Uint32Array(this.data),this.typeInfo,null);throw"ScalarData: Invalid data type"}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,n,s){if(n)return void console.error("SetDataValue: Scalar data does not support postfix",n);if(!(t instanceof T))return void console.error("SetDataValue: Invalid value",t);let i=t.data[0];this.typeInfo.name==="i32"||this.typeInfo.name==="u32"?i=Math.floor(i):this.typeInfo.name==="bool"&&(i=i?1:0),this.data[0]=i}getSubData(e,t,n){return t?(console.error("getSubData: Scalar data does not support postfix",t),null):this}toString(){return`${this.value}`}};function v0(r,e,t){let n=e.length;return n===2?t==="f32"?new g(new Float32Array(e),r.getTypeInfo("vec2f")):t==="i32"||t==="bool"?new g(new Int32Array(e),r.getTypeInfo("vec2i")):t==="u32"?new g(new Uint32Array(e),r.getTypeInfo("vec2u")):t==="f16"?new g(new Float32Array(e),r.getTypeInfo("vec2h")):(console.error(`getSubData: Unknown format ${t}`),null):n===3?t==="f32"?new g(new Float32Array(e),r.getTypeInfo("vec3f")):t==="i32"||t==="bool"?new g(new Int32Array(e),r.getTypeInfo("vec3i")):t==="u32"?new g(new Uint32Array(e),r.getTypeInfo("vec3u")):t==="f16"?new g(new Float32Array(e),r.getTypeInfo("vec3h")):(console.error(`getSubData: Unknown format ${t}`),null):n===4?t==="f32"?new g(new Float32Array(e),r.getTypeInfo("vec4f")):t==="i32"||t==="bool"?new g(new Int32Array(e),r.getTypeInfo("vec4i")):t==="u32"?new g(new Uint32Array(e),r.getTypeInfo("vec4u")):t==="f16"?new g(new Float32Array(e),r.getTypeInfo("vec4h")):(console.error(`getSubData: Unknown format ${t}`),null):(console.error(`getSubData: Invalid vector size ${e.length}`),null)}var g=class extends Ve{constructor(e,t,n=null){if(super(t,n),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{let s=this.typeInfo.name;s==="vec2f"||s==="vec3f"||s==="vec4f"?this.data=new Float32Array(e):s==="vec2i"||s==="vec3i"||s==="vec4i"?this.data=new Int32Array(e):s==="vec2u"||s==="vec3u"||s==="vec4u"?this.data=new Uint32Array(e):s==="vec2h"||s==="vec3h"||s==="vec4h"?this.data=new Float32Array(e):s==="vec2b"||s==="vec3b"||s==="vec4b"?this.data=new Int32Array(e):s==="vec2"||s==="vec3"||s==="vec4"?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${s}`)}}clone(){if(this.data instanceof Float32Array)return new g(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new g(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new g(new Uint32Array(this.data),this.typeInfo,null);throw"VectorData: Invalid data type"}setDataValue(e,t,n,s){n instanceof Gt?console.error("TODO: Set vector postfix"):t instanceof g?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,n){if(t===null)return this;let s=e.getTypeInfo("f32");if(this.typeInfo instanceof Zt)s=this.typeInfo.format||s;else{let o=this.typeInfo.name;o==="vec2f"||o==="vec3f"||o==="vec4f"?s=e.getTypeInfo("f32"):o==="vec2i"||o==="vec3i"||o==="vec4i"?s=e.getTypeInfo("i32"):o==="vec2b"||o==="vec3b"||o==="vec4b"?s=e.getTypeInfo("bool"):o==="vec2u"||o==="vec3u"||o==="vec4u"?s=e.getTypeInfo("u32"):o==="vec2h"||o==="vec3h"||o==="vec4h"?s=e.getTypeInfo("f16"):console.error(`GetSubData: Unknown type ${o}`)}let i=this;for(;t!==null&&i!==null;){if(t instanceof Tr){let o=t.index,a=-1;if(o instanceof me){if(!(o.value instanceof T))return console.error(`GetSubData: Invalid array index ${o.value}`),null;a=o.value.value}else{let c=e.evalExpression(o,n);if(!(c instanceof T))return console.error("GetSubData: Unknown index type",o),null;a=c.value}if(a<0||a>=i.data.length)return console.error("GetSubData: Index out of range",a),null;if(i.data instanceof Float32Array){let c=new Float32Array(i.data.buffer,i.data.byteOffset+4*a,1);return new T(c,s)}if(i.data instanceof Int32Array){let c=new Int32Array(i.data.buffer,i.data.byteOffset+4*a,1);return new T(c,s)}if(i.data instanceof Uint32Array){let c=new Uint32Array(i.data.buffer,i.data.byteOffset+4*a,1);return new T(c,s)}throw"GetSubData: Invalid data type"}if(!(t instanceof Gt))return console.error("GetSubData: Unknown postfix",t),null;{let o=t.value.toLowerCase();if(o.length===1){let c=0;if(o==="x"||o==="r")c=0;else if(o==="y"||o==="g")c=1;else if(o==="z"||o==="b")c=2;else{if(o!=="w"&&o!=="a")return console.error(`GetSubData: Unknown member ${o}`),null;c=3}if(this.data instanceof Float32Array){let l=new Float32Array(this.data.buffer,this.data.byteOffset+4*c,1);return new T(l,s,this)}if(this.data instanceof Int32Array){let l=new Int32Array(this.data.buffer,this.data.byteOffset+4*c,1);return new T(l,s,this)}if(this.data instanceof Uint32Array){let l=new Uint32Array(this.data.buffer,this.data.byteOffset+4*c,1);return new T(l,s,this)}}let a=[];for(let c of o)c==="x"||c==="r"?a.push(this.data[0]):c==="y"||c==="g"?a.push(this.data[1]):c==="z"||c==="b"?a.push(this.data[2]):c==="w"||c==="a"?a.push(this.data[3]):console.error(`GetDataValue: Unknown member ${c}`);i=v0(e,a,s.name)}t=t.postfix}return i}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}},z=class extends Ve{constructor(e,t,n=null){super(t,n),e instanceof Float32Array?this.data=e:this.data=new Float32Array(e)}clone(){return new z(new Float32Array(this.data),this.typeInfo,null)}setDataValue(e,t,n,s){n instanceof Gt?console.error("TODO: Set matrix postfix"):t instanceof z?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,n){if(t===null)return this;let s=this.typeInfo.name;if(e.getTypeInfo("f32"),this.typeInfo instanceof Zt)this.typeInfo.format;else if(s.endsWith("f"))e.getTypeInfo("f32");else if(s.endsWith("i"))e.getTypeInfo("i32");else if(s.endsWith("u"))e.getTypeInfo("u32");else{if(!s.endsWith("h"))return console.error(`GetDataValue: Unknown type ${s}`),null;e.getTypeInfo("f16")}if(t instanceof Tr){let i=t.index,o=-1;if(i instanceof me){if(!(i.value instanceof T))return console.error(`GetDataValue: Invalid array index ${i.value}`),null;o=i.value.value}else{let l=e.evalExpression(i,n);if(!(l instanceof T))return console.error("GetDataValue: Unknown index type",i),null;o=l.value}if(o<0||o>=this.data.length)return console.error("GetDataValue: Index out of range",o),null;let a=s.endsWith("h")?"h":"f",c;if(s==="mat2x2"||s==="mat2x2f"||s==="mat2x2h"||s==="mat3x2"||s==="mat3x2f"||s==="mat3x2h"||s==="mat4x2"||s==="mat4x2f"||s==="mat4x2h")c=new g(new Float32Array(this.data.buffer,this.data.byteOffset+2*o*4,2),e.getTypeInfo(`vec2${a}`));else if(s==="mat2x3"||s==="mat2x3f"||s==="mat2x3h"||s==="mat3x3"||s==="mat3x3f"||s==="mat3x3h"||s==="mat4x3"||s==="mat4x3f"||s==="mat4x3h")c=new g(new Float32Array(this.data.buffer,this.data.byteOffset+3*o*4,3),e.getTypeInfo(`vec3${a}`));else{if(s!=="mat2x4"&&s!=="mat2x4f"&&s!=="mat2x4h"&&s!=="mat3x4"&&s!=="mat3x4f"&&s!=="mat3x4h"&&s!=="mat4x4"&&s!=="mat4x4f"&&s!=="mat4x4h")return console.error(`GetDataValue: Unknown type ${s}`),null;c=new g(new Float32Array(this.data.buffer,this.data.byteOffset+4*o*4,4),e.getTypeInfo(`vec4${a}`))}return t.postfix?c.getSubData(e,t.postfix,n):c}return console.error("GetDataValue: Invalid postfix",t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}},ce=class extends Ve{constructor(e,t,n=0,s=null){super(t,s),this.buffer=e instanceof ArrayBuffer?e:e.buffer,this.offset=n}clone(){let e=new Uint8Array(new Uint8Array(this.buffer,this.offset,this.typeInfo.size));return new ce(e.buffer,this.typeInfo,0,null)}setDataValue(e,t,n,s){if(t===null)return void console.log("setDataValue: NULL data.");let i=this.offset,o=this.typeInfo;for(;n;){if(n instanceof Tr)if(o instanceof Ct){let a=n.index;if(a instanceof me){if(!(a.value instanceof T))return void console.error(`SetDataValue: Invalid index type ${a.value}`);i+=a.value.value*o.stride}else{let c=e.evalExpression(a,s);if(!(c instanceof T))return void console.error("SetDataValue: Unknown index type",a);i+=c.value*o.stride}o=o.format}else console.error(`SetDataValue: Type ${o.getTypeName()} is not an array`);else{if(!(n instanceof Gt))return void console.error("SetDataValue: Unknown postfix type",n);{let a=n.value;if(o instanceof Pt){let c=!1;for(let l of o.members)if(l.name===a){i+=l.offset,o=l.type,c=!0;break}if(!c)return void console.error(`SetDataValue: Member ${a} not found`)}else if(o instanceof Le){let c=o.getTypeName(),l=0;if(a==="x"||a==="r")l=0;else if(a==="y"||a==="g")l=1;else if(a==="z"||a==="b")l=2;else{if(a!=="w"&&a!=="a")return void console.error(`SetDataValue: Unknown member ${a}`);l=3}if(!(t instanceof T))return void console.error("SetDataValue: Invalid value",t);let u=t.value;return c==="vec2f"?void(new Float32Array(this.buffer,i,2)[l]=u):c==="vec3f"?void(new Float32Array(this.buffer,i,3)[l]=u):c==="vec4f"?void(new Float32Array(this.buffer,i,4)[l]=u):c==="vec2i"?void(new Int32Array(this.buffer,i,2)[l]=u):c==="vec3i"?void(new Int32Array(this.buffer,i,3)[l]=u):c==="vec4i"?void(new Int32Array(this.buffer,i,4)[l]=u):c==="vec2u"?void(new Uint32Array(this.buffer,i,2)[l]=u):c==="vec3u"?void(new Uint32Array(this.buffer,i,3)[l]=u):c==="vec4u"?void(new Uint32Array(this.buffer,i,4)[l]=u):void console.error(`SetDataValue: Type ${c} is not a struct`)}}}n=n.postfix}this.setData(e,t,o,i,s)}setData(e,t,n,s,i){let o=n.getTypeName();if(o!=="f32"&&o!=="f16")if(o!=="i32"&&o!=="atomic<i32>"&&o!=="x32")if(o!=="u32"&&o!=="atomic<u32>")if(o!=="bool")if(o!=="vec2f"&&o!=="vec2h")if(o!=="vec3f"&&o!=="vec3h")if(o!=="vec4f"&&o!=="vec4h")if(o!=="vec2i")if(o!=="vec3i")if(o!=="vec4i")if(o!=="vec2u")if(o!=="vec3u")if(o!=="vec4u")if(o!=="vec2b")if(o!=="vec3b")if(o!=="vec4b")if(o!=="mat2x2f"&&o!=="mat2x2h")if(o!=="mat2x3f"&&o!=="mat2x3h")if(o!=="mat2x4f"&&o!=="mat2x4h")if(o!=="mat3x2f"&&o!=="mat3x2h")if(o!=="mat3x3f"&&o!=="mat3x3h")if(o!=="mat3x4f"&&o!=="mat3x4h")if(o!=="mat4x2f"&&o!=="mat4x2h")if(o!=="mat4x3f"&&o!=="mat4x3h")if(o!=="mat4x4f"&&o!=="mat4x4h")if(t instanceof ce){if(n===t.typeInfo)return void new Uint8Array(this.buffer,s,t.buffer.byteLength).set(new Uint8Array(t.buffer));console.error("SetDataValue: Type mismatch",o,t.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${o}`);else{let a=new Float32Array(this.buffer,s,16);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11],a[12]=t.data[12],a[13]=t.data[13],a[14]=t.data[14],a[15]=t.data[15]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11],a[12]=t[12],a[13]=t[13],a[14]=t[14],a[15]=t[15])}else{let a=new Float32Array(this.buffer,s,12);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11])}else{let a=new Float32Array(this.buffer,s,8);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7])}else{let a=new Float32Array(this.buffer,s,12);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11])}else{let a=new Float32Array(this.buffer,s,9);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8])}else{let a=new Float32Array(this.buffer,s,6);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5])}else{let a=new Float32Array(this.buffer,s,8);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7])}else{let a=new Float32Array(this.buffer,s,6);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5])}else{let a=new Float32Array(this.buffer,s,4);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3])}else{let a=new Uint32Array(this.buffer,s,4);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3])}else{let a=new Uint32Array(this.buffer,s,3);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2])}else{let a=new Uint32Array(this.buffer,s,2);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1])}else{let a=new Uint32Array(this.buffer,s,4);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3])}else{let a=new Uint32Array(this.buffer,s,3);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2])}else{let a=new Uint32Array(this.buffer,s,2);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1])}else{let a=new Int32Array(this.buffer,s,4);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3])}else{let a=new Int32Array(this.buffer,s,3);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2])}else{let a=new Int32Array(this.buffer,s,2);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1])}else{let a=new Float32Array(this.buffer,s,4);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3])}else{let a=new Float32Array(this.buffer,s,3);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2])}else{let a=new Float32Array(this.buffer,s,2);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1])}else t instanceof T&&(new Int32Array(this.buffer,s,1)[0]=t.value);else t instanceof T&&(new Uint32Array(this.buffer,s,1)[0]=t.value);else t instanceof T&&(new Int32Array(this.buffer,s,1)[0]=t.value);else t instanceof T&&(new Float32Array(this.buffer,s,1)[0]=t.value)}getSubData(e,t,n){var s,i,o;if(t===null)return this;let a=this.offset,c=this.typeInfo;for(;t;){if(t instanceof Tr){let u=t.index,f=e.evalExpression(u,n),h=0;if(f instanceof T?h=f.value:console.error("GetDataValue: Invalid index type",u),c instanceof Ct)a+=h*c.stride,c=c.format;else{let d=c.getTypeName();d==="mat4x4"||d==="mat4x4f"||d==="mat4x4h"?(a+=16*h,c=e.getTypeInfo("vec4f")):console.error(`getDataValue: Type ${c.getTypeName()} is not an array`)}}else{if(!(t instanceof Gt))return console.error("GetDataValue: Unknown postfix type",t),null;{let u=t.value;if(c instanceof Pt){let f=!1;for(let h of c.members)if(h.name===u){a+=h.offset,c=h.type,f=!0;break}if(!f)return console.error(`GetDataValue: Member ${u} not found`),null}else if(c instanceof Le){let f=c.getTypeName();if(f==="vec2f"||f==="vec3f"||f==="vec4f"||f==="vec2i"||f==="vec3i"||f==="vec4i"||f==="vec2u"||f==="vec3u"||f==="vec4u"||f==="vec2b"||f==="vec3b"||f==="vec4b"||f==="vec2h"||f==="vec3h"||f==="vec4h"||f==="vec2"||f==="vec3"||f==="vec4"){if(u.length>0&&u.length<5){let h="f",d=[];for(let m=0;m<u.length;++m){let y=u[m].toLowerCase(),_=0;if(y==="x"||y==="r")_=0;else if(y==="y"||y==="g")_=1;else if(y==="z"||y==="b")_=2;else{if(y!=="w"&&y!=="a")return console.error(`Unknown member ${u}`),null;_=3}if(u.length===1){if(f.endsWith("f"))return this.buffer.byteLength<a+4*_+4?(console.log("Insufficient buffer data"),null):new T(new Float32Array(this.buffer,a+4*_,1),e.getTypeInfo("f32"),this);if(f.endsWith("h"))return new T(new Float32Array(this.buffer,a+4*_,1),e.getTypeInfo("f16"),this);if(f.endsWith("i"))return new T(new Int32Array(this.buffer,a+4*_,1),e.getTypeInfo("i32"),this);if(f.endsWith("b"))return new T(new Int32Array(this.buffer,a+4*_,1),e.getTypeInfo("bool"),this);if(f.endsWith("u"))return new T(new Uint32Array(this.buffer,a+4*_,1),e.getTypeInfo("i32"),this)}if(f==="vec2f")d.push(new Float32Array(this.buffer,a,2)[_]);else if(f==="vec3f"){if(a+12>=this.buffer.byteLength)return console.log("Insufficient buffer data"),null;let x=new Float32Array(this.buffer,a,3);d.push(x[_])}else if(f==="vec4f")d.push(new Float32Array(this.buffer,a,4)[_]);else if(f==="vec2i")h="i",d.push(new Int32Array(this.buffer,a,2)[_]);else if(f==="vec3i")h="i",d.push(new Int32Array(this.buffer,a,3)[_]);else if(f==="vec4i")h="i",d.push(new Int32Array(this.buffer,a,4)[_]);else if(f==="vec2u"){h="u";let x=new Uint32Array(this.buffer,a,2);d.push(x[_])}else f==="vec3u"?(h="u",d.push(new Uint32Array(this.buffer,a,3)[_])):f==="vec4u"&&(h="u",d.push(new Uint32Array(this.buffer,a,4)[_]))}return d.length===2?c=e.getTypeInfo(`vec2${h}`):d.length===3?c=e.getTypeInfo(`vec3${h}`):d.length===4?c=e.getTypeInfo(`vec4${h}`):console.error(`GetDataValue: Invalid vector length ${d.length}`),new g(d,c,null)}return console.error(`GetDataValue: Unknown member ${u}`),null}return console.error(`GetDataValue: Type ${f} is not a struct`),null}}}t=t.postfix}let l=c.getTypeName();return l==="f32"?new T(new Float32Array(this.buffer,a,1),c,this):l==="i32"?new T(new Int32Array(this.buffer,a,1),c,this):l==="u32"?new T(new Uint32Array(this.buffer,a,1),c,this):l==="vec2f"?new g(new Float32Array(this.buffer,a,2),c,this):l==="vec3f"?new g(new Float32Array(this.buffer,a,3),c,this):l==="vec4f"?new g(new Float32Array(this.buffer,a,4),c,this):l==="vec2i"?new g(new Int32Array(this.buffer,a,2),c,this):l==="vec3i"?new g(new Int32Array(this.buffer,a,3),c,this):l==="vec4i"?new g(new Int32Array(this.buffer,a,4),c,this):l==="vec2u"?new g(new Uint32Array(this.buffer,a,2),c,this):l==="vec3u"?new g(new Uint32Array(this.buffer,a,3),c,this):l==="vec4u"?new g(new Uint32Array(this.buffer,a,4),c,this):c instanceof Zt&&c.name==="atomic"?((s=c.format)===null||s===void 0?void 0:s.name)==="u32"?new T(new Uint32Array(this.buffer,a,1)[0],c.format,this):((i=c.format)===null||i===void 0?void 0:i.name)==="i32"?new T(new Int32Array(this.buffer,a,1)[0],c.format,this):(console.error(`GetDataValue: Invalid atomic format ${(o=c.format)===null||o===void 0?void 0:o.name}`),null):new ce(this.buffer,c,a,this)}toString(){let e="";if(this.typeInfo instanceof Ct)if(this.typeInfo.format.name==="f32"){let t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if(this.typeInfo.format.name==="i32"){let t=new Int32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if(this.typeInfo.format.name==="u32"){let t=new Uint32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if(this.typeInfo.format.name==="vec2f"){let t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}]`;for(let n=1;n<t.length/2;++n)e+=`, [${t[2*n]}, ${t[2*n+1]}]`}else if(this.typeInfo.format.name==="vec3f"){let t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}]`;for(let n=4;n<t.length;n+=4)e+=`, [${t[n]}, ${t[n+1]}, ${t[n+2]}]`}else if(this.typeInfo.format.name==="vec4f"){let t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}]`;for(let n=4;n<t.length;n+=4)e+=`, [${t[n]}, ${t[n+1]}, ${t[n+2]}, ${t[n+3]}]`}else e="[...]";else this.typeInfo instanceof Pt?e+="{...}":e="[...]";return e}},ft=class extends Ve{constructor(e,t,n,s){super(t,null),this.data=e,this.descriptor=n,this.view=s}clone(){return new ft(this.data,this.typeInfo,this.descriptor,this.view)}get width(){var e,t;let n=this.descriptor.size;return n instanceof Array&&n.length>0?(e=n[0])!==null&&e!==void 0?e:0:n instanceof Object&&(t=n.width)!==null&&t!==void 0?t:0}get height(){var e,t;let n=this.descriptor.size;return n instanceof Array&&n.length>1?(e=n[1])!==null&&e!==void 0?e:0:n instanceof Object&&(t=n.height)!==null&&t!==void 0?t:0}get depthOrArrayLayers(){var e,t;let n=this.descriptor.size;return n instanceof Array&&n.length>2?(e=n[2])!==null&&e!==void 0?e:0:n instanceof Object&&(t=n.depthOrArrayLayers)!==null&&t!==void 0?t:0}get format(){var e;return this.descriptor&&(e=this.descriptor.format)!==null&&e!==void 0?e:"rgba8unorm"}get sampleCount(){var e;return this.descriptor&&(e=this.descriptor.sampleCount)!==null&&e!==void 0?e:1}get mipLevelCount(){var e;return this.descriptor&&(e=this.descriptor.mipLevelCount)!==null&&e!==void 0?e:1}get dimension(){var e;return this.descriptor&&(e=this.descriptor.dimension)!==null&&e!==void 0?e:"2d"}getMipLevelSize(e){if(e>=this.mipLevelCount)return[0,0,0];let t=[this.width,this.height,this.depthOrArrayLayers];for(let n=0;n<t.length;++n)t[n]=Math.max(1,t[n]>>e);return t}get texelByteSize(){let e=this.format,t=Pu[e];return t?t.isDepthStencil?4:t.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){let e=this.format,t=Pu[e];return!!t&&t.isDepthStencil}getGpuSize(){let e=this.format,t=Pu[e],n=this.width;if(!e||n<=0||!t)return-1;let s=this.height,i=this.depthOrArrayLayers,o=this.dimension;return n/t.blockWidth*(o==="1d"?1:s/t.blockHeight)*t.bytesPerBlock*i}getPixel(e,t,n=0,s=0){let i=this.texelByteSize,o=this.bytesPerRow,a=this.height,c=this.data[s];return w0(new Uint8Array(c),e,t,n,s,a,o,i,this.format)}setPixel(e,t,n,s,i){let o=this.texelByteSize,a=this.bytesPerRow,c=this.height,l=this.data[s];(function(u,f,h,d,m,y,_,x,E,b){let S=d*(_>>=m)*(y>>=m)+h*_+f*x;switch(E){case"r8unorm":return void re(u,S,"8unorm",1,b);case"r8snorm":return void re(u,S,"8snorm",1,b);case"r8uint":return void re(u,S,"8uint",1,b);case"r8sint":return void re(u,S,"8sint",1,b);case"rg8unorm":return void re(u,S,"8unorm",2,b);case"rg8snorm":return void re(u,S,"8snorm",2,b);case"rg8uint":return void re(u,S,"8uint",2,b);case"rg8sint":return void re(u,S,"8sint",2,b);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void re(u,S,"8unorm",4,b);case"rgba8snorm":return void re(u,S,"8snorm",4,b);case"rgba8uint":return void re(u,S,"8uint",4,b);case"rgba8sint":return void re(u,S,"8sint",4,b);case"r16uint":return void re(u,S,"16uint",1,b);case"r16sint":return void re(u,S,"16sint",1,b);case"r16float":return void re(u,S,"16float",1,b);case"rg16uint":return void re(u,S,"16uint",2,b);case"rg16sint":return void re(u,S,"16sint",2,b);case"rg16float":return void re(u,S,"16float",2,b);case"rgba16uint":return void re(u,S,"16uint",4,b);case"rgba16sint":return void re(u,S,"16sint",4,b);case"rgba16float":return void re(u,S,"16float",4,b);case"r32uint":return void re(u,S,"32uint",1,b);case"r32sint":return void re(u,S,"32sint",1,b);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void re(u,S,"32float",1,b);case"rg32uint":return void re(u,S,"32uint",2,b);case"rg32sint":return void re(u,S,"32sint",2,b);case"rg32float":return void re(u,S,"32float",2,b);case"rgba32uint":return void re(u,S,"32uint",4,b);case"rgba32sint":return void re(u,S,"32sint",4,b);case"rgba32float":return void re(u,S,"32float",4,b);case"rg11b10ufloat":console.error("TODO: rg11b10ufloat not supported for writing")}})(new Uint8Array(l),e,t,n,s,c,a,o,this.format,i)}};(r=>{r[r.token=0]="token",r[r.keyword=1]="keyword",r[r.reserved=2]="reserved"})(v||(v={}));var w=class{constructor(e,t,n){this.name=e,this.type=t,this.rule=n}toString(){return this.name}},p=class{};R=p,p.none=new w("",v.reserved,""),p.eof=new w("EOF",v.token,""),p.reserved={asm:new w("asm",v.reserved,"asm"),bf16:new w("bf16",v.reserved,"bf16"),do:new w("do",v.reserved,"do"),enum:new w("enum",v.reserved,"enum"),f16:new w("f16",v.reserved,"f16"),f64:new w("f64",v.reserved,"f64"),handle:new w("handle",v.reserved,"handle"),i8:new w("i8",v.reserved,"i8"),i16:new w("i16",v.reserved,"i16"),i64:new w("i64",v.reserved,"i64"),mat:new w("mat",v.reserved,"mat"),premerge:new w("premerge",v.reserved,"premerge"),regardless:new w("regardless",v.reserved,"regardless"),typedef:new w("typedef",v.reserved,"typedef"),u8:new w("u8",v.reserved,"u8"),u16:new w("u16",v.reserved,"u16"),u64:new w("u64",v.reserved,"u64"),unless:new w("unless",v.reserved,"unless"),using:new w("using",v.reserved,"using"),vec:new w("vec",v.reserved,"vec"),void:new w("void",v.reserved,"void")},p.keywords={array:new w("array",v.keyword,"array"),atomic:new w("atomic",v.keyword,"atomic"),bool:new w("bool",v.keyword,"bool"),f32:new w("f32",v.keyword,"f32"),i32:new w("i32",v.keyword,"i32"),mat2x2:new w("mat2x2",v.keyword,"mat2x2"),mat2x3:new w("mat2x3",v.keyword,"mat2x3"),mat2x4:new w("mat2x4",v.keyword,"mat2x4"),mat3x2:new w("mat3x2",v.keyword,"mat3x2"),mat3x3:new w("mat3x3",v.keyword,"mat3x3"),mat3x4:new w("mat3x4",v.keyword,"mat3x4"),mat4x2:new w("mat4x2",v.keyword,"mat4x2"),mat4x3:new w("mat4x3",v.keyword,"mat4x3"),mat4x4:new w("mat4x4",v.keyword,"mat4x4"),ptr:new w("ptr",v.keyword,"ptr"),sampler:new w("sampler",v.keyword,"sampler"),sampler_comparison:new w("sampler_comparison",v.keyword,"sampler_comparison"),struct:new w("struct",v.keyword,"struct"),texture_1d:new w("texture_1d",v.keyword,"texture_1d"),texture_2d:new w("texture_2d",v.keyword,"texture_2d"),texture_2d_array:new w("texture_2d_array",v.keyword,"texture_2d_array"),texture_3d:new w("texture_3d",v.keyword,"texture_3d"),texture_cube:new w("texture_cube",v.keyword,"texture_cube"),texture_cube_array:new w("texture_cube_array",v.keyword,"texture_cube_array"),texture_multisampled_2d:new w("texture_multisampled_2d",v.keyword,"texture_multisampled_2d"),texture_storage_1d:new w("texture_storage_1d",v.keyword,"texture_storage_1d"),texture_storage_2d:new w("texture_storage_2d",v.keyword,"texture_storage_2d"),texture_storage_2d_array:new w("texture_storage_2d_array",v.keyword,"texture_storage_2d_array"),texture_storage_3d:new w("texture_storage_3d",v.keyword,"texture_storage_3d"),texture_depth_2d:new w("texture_depth_2d",v.keyword,"texture_depth_2d"),texture_depth_2d_array:new w("texture_depth_2d_array",v.keyword,"texture_depth_2d_array"),texture_depth_cube:new w("texture_depth_cube",v.keyword,"texture_depth_cube"),texture_depth_cube_array:new w("texture_depth_cube_array",v.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new w("texture_depth_multisampled_2d",v.keyword,"texture_depth_multisampled_2d"),texture_external:new w("texture_external",v.keyword,"texture_external"),u32:new w("u32",v.keyword,"u32"),vec2:new w("vec2",v.keyword,"vec2"),vec3:new w("vec3",v.keyword,"vec3"),vec4:new w("vec4",v.keyword,"vec4"),bitcast:new w("bitcast",v.keyword,"bitcast"),block:new w("block",v.keyword,"block"),break:new w("break",v.keyword,"break"),case:new w("case",v.keyword,"case"),continue:new w("continue",v.keyword,"continue"),continuing:new w("continuing",v.keyword,"continuing"),default:new w("default",v.keyword,"default"),diagnostic:new w("diagnostic",v.keyword,"diagnostic"),discard:new w("discard",v.keyword,"discard"),else:new w("else",v.keyword,"else"),enable:new w("enable",v.keyword,"enable"),fallthrough:new w("fallthrough",v.keyword,"fallthrough"),false:new w("false",v.keyword,"false"),fn:new w("fn",v.keyword,"fn"),for:new w("for",v.keyword,"for"),function:new w("function",v.keyword,"function"),if:new w("if",v.keyword,"if"),let:new w("let",v.keyword,"let"),const:new w("const",v.keyword,"const"),loop:new w("loop",v.keyword,"loop"),while:new w("while",v.keyword,"while"),private:new w("private",v.keyword,"private"),read:new w("read",v.keyword,"read"),read_write:new w("read_write",v.keyword,"read_write"),return:new w("return",v.keyword,"return"),requires:new w("requires",v.keyword,"requires"),storage:new w("storage",v.keyword,"storage"),switch:new w("switch",v.keyword,"switch"),true:new w("true",v.keyword,"true"),alias:new w("alias",v.keyword,"alias"),type:new w("type",v.keyword,"type"),uniform:new w("uniform",v.keyword,"uniform"),var:new w("var",v.keyword,"var"),override:new w("override",v.keyword,"override"),workgroup:new w("workgroup",v.keyword,"workgroup"),write:new w("write",v.keyword,"write"),r8unorm:new w("r8unorm",v.keyword,"r8unorm"),r8snorm:new w("r8snorm",v.keyword,"r8snorm"),r8uint:new w("r8uint",v.keyword,"r8uint"),r8sint:new w("r8sint",v.keyword,"r8sint"),r16uint:new w("r16uint",v.keyword,"r16uint"),r16sint:new w("r16sint",v.keyword,"r16sint"),r16float:new w("r16float",v.keyword,"r16float"),rg8unorm:new w("rg8unorm",v.keyword,"rg8unorm"),rg8snorm:new w("rg8snorm",v.keyword,"rg8snorm"),rg8uint:new w("rg8uint",v.keyword,"rg8uint"),rg8sint:new w("rg8sint",v.keyword,"rg8sint"),r32uint:new w("r32uint",v.keyword,"r32uint"),r32sint:new w("r32sint",v.keyword,"r32sint"),r32float:new w("r32float",v.keyword,"r32float"),rg16uint:new w("rg16uint",v.keyword,"rg16uint"),rg16sint:new w("rg16sint",v.keyword,"rg16sint"),rg16float:new w("rg16float",v.keyword,"rg16float"),rgba8unorm:new w("rgba8unorm",v.keyword,"rgba8unorm"),rgba8unorm_srgb:new w("rgba8unorm_srgb",v.keyword,"rgba8unorm_srgb"),rgba8snorm:new w("rgba8snorm",v.keyword,"rgba8snorm"),rgba8uint:new w("rgba8uint",v.keyword,"rgba8uint"),rgba8sint:new w("rgba8sint",v.keyword,"rgba8sint"),bgra8unorm:new w("bgra8unorm",v.keyword,"bgra8unorm"),bgra8unorm_srgb:new w("bgra8unorm_srgb",v.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new w("rgb10a2unorm",v.keyword,"rgb10a2unorm"),rg11b10float:new w("rg11b10float",v.keyword,"rg11b10float"),rg32uint:new w("rg32uint",v.keyword,"rg32uint"),rg32sint:new w("rg32sint",v.keyword,"rg32sint"),rg32float:new w("rg32float",v.keyword,"rg32float"),rgba16uint:new w("rgba16uint",v.keyword,"rgba16uint"),rgba16sint:new w("rgba16sint",v.keyword,"rgba16sint"),rgba16float:new w("rgba16float",v.keyword,"rgba16float"),rgba32uint:new w("rgba32uint",v.keyword,"rgba32uint"),rgba32sint:new w("rgba32sint",v.keyword,"rgba32sint"),rgba32float:new w("rgba32float",v.keyword,"rgba32float"),static_assert:new w("static_assert",v.keyword,"static_assert")},p.tokens={decimal_float_literal:new w("decimal_float_literal",v.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?[fh]?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+[fh]?)|(-?[0-9]+[fh])/),hex_float_literal:new w("hex_float_literal",v.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+[fh]?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+[fh]?))/),int_literal:new w("int_literal",v.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new w("uint_literal",v.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new w("name",v.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new w("ident",v.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new w("and",v.token,"&"),and_and:new w("and_and",v.token,"&&"),arrow:new w("arrow ",v.token,"->"),attr:new w("attr",v.token,"@"),forward_slash:new w("forward_slash",v.token,"/"),bang:new w("bang",v.token,"!"),bracket_left:new w("bracket_left",v.token,"["),bracket_right:new w("bracket_right",v.token,"]"),brace_left:new w("brace_left",v.token,"{"),brace_right:new w("brace_right",v.token,"}"),colon:new w("colon",v.token,":"),comma:new w("comma",v.token,","),equal:new w("equal",v.token,"="),equal_equal:new w("equal_equal",v.token,"=="),not_equal:new w("not_equal",v.token,"!="),greater_than:new w("greater_than",v.token,">"),greater_than_equal:new w("greater_than_equal",v.token,">="),shift_right:new w("shift_right",v.token,">>"),less_than:new w("less_than",v.token,"<"),less_than_equal:new w("less_than_equal",v.token,"<="),shift_left:new w("shift_left",v.token,"<<"),modulo:new w("modulo",v.token,"%"),minus:new w("minus",v.token,"-"),minus_minus:new w("minus_minus",v.token,"--"),period:new w("period",v.token,"."),plus:new w("plus",v.token,"+"),plus_plus:new w("plus_plus",v.token,"++"),or:new w("or",v.token,"|"),or_or:new w("or_or",v.token,"||"),paren_left:new w("paren_left",v.token,"("),paren_right:new w("paren_right",v.token,")"),semicolon:new w("semicolon",v.token,";"),star:new w("star",v.token,"*"),tilde:new w("tilde",v.token,"~"),underscore:new w("underscore",v.token,"_"),xor:new w("xor",v.token,"^"),plus_equal:new w("plus_equal",v.token,"+="),minus_equal:new w("minus_equal",v.token,"-="),times_equal:new w("times_equal",v.token,"*="),division_equal:new w("division_equal",v.token,"/="),modulo_equal:new w("modulo_equal",v.token,"%="),and_equal:new w("and_equal",v.token,"&="),or_equal:new w("or_equal",v.token,"|="),xor_equal:new w("xor_equal",v.token,"^="),shift_right_equal:new w("shift_right_equal",v.token,">>="),shift_left_equal:new w("shift_left_equal",v.token,"<<=")},p.simpleTokens={"@":R.tokens.attr,"{":R.tokens.brace_left,"}":R.tokens.brace_right,":":R.tokens.colon,",":R.tokens.comma,"(":R.tokens.paren_left,")":R.tokens.paren_right,";":R.tokens.semicolon},p.literalTokens={"&":R.tokens.and,"&&":R.tokens.and_and,"->":R.tokens.arrow,"/":R.tokens.forward_slash,"!":R.tokens.bang,"[":R.tokens.bracket_left,"]":R.tokens.bracket_right,"=":R.tokens.equal,"==":R.tokens.equal_equal,"!=":R.tokens.not_equal,">":R.tokens.greater_than,">=":R.tokens.greater_than_equal,">>":R.tokens.shift_right,"<":R.tokens.less_than,"<=":R.tokens.less_than_equal,"<<":R.tokens.shift_left,"%":R.tokens.modulo,"-":R.tokens.minus,"--":R.tokens.minus_minus,".":R.tokens.period,"+":R.tokens.plus,"++":R.tokens.plus_plus,"|":R.tokens.or,"||":R.tokens.or_or,"*":R.tokens.star,"~":R.tokens.tilde,_:R.tokens.underscore,"^":R.tokens.xor,"+=":R.tokens.plus_equal,"-=":R.tokens.minus_equal,"*=":R.tokens.times_equal,"/=":R.tokens.division_equal,"%=":R.tokens.modulo_equal,"&=":R.tokens.and_equal,"|=":R.tokens.or_equal,"^=":R.tokens.xor_equal,">>=":R.tokens.shift_right_equal,"<<=":R.tokens.shift_left_equal},p.regexTokens={decimal_float_literal:R.tokens.decimal_float_literal,hex_float_literal:R.tokens.hex_float_literal,int_literal:R.tokens.int_literal,uint_literal:R.tokens.uint_literal,ident:R.tokens.ident},p.storage_class=[R.keywords.function,R.keywords.private,R.keywords.workgroup,R.keywords.uniform,R.keywords.storage],p.access_mode=[R.keywords.read,R.keywords.write,R.keywords.read_write],p.sampler_type=[R.keywords.sampler,R.keywords.sampler_comparison],p.sampled_texture_type=[R.keywords.texture_1d,R.keywords.texture_2d,R.keywords.texture_2d_array,R.keywords.texture_3d,R.keywords.texture_cube,R.keywords.texture_cube_array],p.multisampled_texture_type=[R.keywords.texture_multisampled_2d],p.storage_texture_type=[R.keywords.texture_storage_1d,R.keywords.texture_storage_2d,R.keywords.texture_storage_2d_array,R.keywords.texture_storage_3d],p.depth_texture_type=[R.keywords.texture_depth_2d,R.keywords.texture_depth_2d_array,R.keywords.texture_depth_cube,R.keywords.texture_depth_cube_array,R.keywords.texture_depth_multisampled_2d],p.texture_external_type=[R.keywords.texture_external],p.any_texture_type=[...R.sampled_texture_type,...R.multisampled_texture_type,...R.storage_texture_type,...R.depth_texture_type,...R.texture_external_type],p.texel_format=[R.keywords.r8unorm,R.keywords.r8snorm,R.keywords.r8uint,R.keywords.r8sint,R.keywords.r16uint,R.keywords.r16sint,R.keywords.r16float,R.keywords.rg8unorm,R.keywords.rg8snorm,R.keywords.rg8uint,R.keywords.rg8sint,R.keywords.r32uint,R.keywords.r32sint,R.keywords.r32float,R.keywords.rg16uint,R.keywords.rg16sint,R.keywords.rg16float,R.keywords.rgba8unorm,R.keywords.rgba8unorm_srgb,R.keywords.rgba8snorm,R.keywords.rgba8uint,R.keywords.rgba8sint,R.keywords.bgra8unorm,R.keywords.bgra8unorm_srgb,R.keywords.rgb10a2unorm,R.keywords.rg11b10float,R.keywords.rg32uint,R.keywords.rg32sint,R.keywords.rg32float,R.keywords.rgba16uint,R.keywords.rgba16sint,R.keywords.rgba16float,R.keywords.rgba32uint,R.keywords.rgba32sint,R.keywords.rgba32float],p.const_literal=[R.tokens.int_literal,R.tokens.uint_literal,R.tokens.decimal_float_literal,R.tokens.hex_float_literal,R.keywords.true,R.keywords.false],p.literal_or_ident=[R.tokens.ident,R.tokens.int_literal,R.tokens.uint_literal,R.tokens.decimal_float_literal,R.tokens.hex_float_literal,R.tokens.name],p.element_count_expression=[R.tokens.int_literal,R.tokens.uint_literal,R.tokens.ident],p.template_types=[R.keywords.vec2,R.keywords.vec3,R.keywords.vec4,R.keywords.mat2x2,R.keywords.mat2x3,R.keywords.mat2x4,R.keywords.mat3x2,R.keywords.mat3x3,R.keywords.mat3x4,R.keywords.mat4x2,R.keywords.mat4x3,R.keywords.mat4x4,R.keywords.atomic,R.keywords.bitcast,...R.any_texture_type],p.attribute_name=[R.tokens.ident,R.keywords.block,R.keywords.diagnostic],p.assignment_operators=[R.tokens.equal,R.tokens.plus_equal,R.tokens.minus_equal,R.tokens.times_equal,R.tokens.division_equal,R.tokens.modulo_equal,R.tokens.and_equal,R.tokens.or_equal,R.tokens.xor_equal,R.tokens.shift_right_equal,R.tokens.shift_left_equal],p.increment_operators=[R.tokens.plus_plus,R.tokens.minus_minus];var wa=class{constructor(e,t,n,s,i){this.type=e,this.lexeme=t,this.line=n,this.start=s,this.end=i}toString(){return this.lexeme}isTemplateType(){return p.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==p.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}},Wu=class{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=e??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new wa(p.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if(e==`
106
+ }`}function P0(r){switch(r){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${r}`)}}function dm(r,e){switch(e){case 1:return`vec4(${r}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${r}, 0.0, 1.0)`;case 3:return`vec4(${r}, 1.0)`;case 4:return r;default:throw new Error(`invalid channels: ${e}`)}}H();var Be=class{constructor(e,t){this.name=e,this.attributes=t,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}getTypeName(){return this.name}},sa=class{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},Rt=class extends Be{constructor(e,t){super(e,t),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}},It=class extends Be{constructor(e,t){super(e,t),this.count=0,this.stride=0}get isArray(){return!0}},Kt=class extends Be{constructor(e,t,n,s){super(e,n),this.format=t,this.access=s}get isTemplate(){return!0}getTypeName(){let e=this.name;if(this.format!==null){if(e==="vec2"||e==="vec3"||e==="vec4"||e==="mat2x2"||e==="mat2x3"||e==="mat2x4"||e==="mat3x2"||e==="mat3x3"||e==="mat3x4"||e==="mat4x2"||e==="mat4x3"||e==="mat4x4"){if(this.format.name==="f32")return e+="f",e;if(this.format.name==="i32")return e+="i",e;if(this.format.name==="u32")return e+="u",e;if(this.format.name==="bool")return e+="b",e;if(this.format.name==="f16")return e+="h",e}e+=`<${this.format.name}>`}else if(e==="vec2"||e==="vec3"||e==="vec4")return e;return e}},yr;(r=>{r[r.Uniform=0]="Uniform",r[r.Storage=1]="Storage",r[r.Texture=2]="Texture",r[r.Sampler=3]="Sampler",r[r.StorageTexture=4]="StorageTexture"})(yr||(yr={}));var Xn=class{constructor(e,t,n,s,i,o,a){this.name=e,this.type=t,this.group=n,this.binding=s,this.attributes=i,this.resourceType=o,this.access=a}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}},Uu=class{constructor(e,t){this.name=e,this.type=t}},Vu=class{constructor(e,t,n,s){this.name=e,this.type=t,this.locationType=n,this.location=s,this.interpolation=null}},ia=class{constructor(e,t,n,s){this.name=e,this.type=t,this.locationType=n,this.location=s}},zu=class{constructor(e,t,n,s){this.name=e,this.type=t,this.attributes=n,this.id=s}},Wu=class{constructor(e,t,n){this.name=e,this.type=t,this.attributes=n}},$u=class{constructor(e,t=null,n){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=n}},ju=class{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}},gm=new Float32Array(1),C0=new Int32Array(gm.buffer),Ee=new Uint16Array(1);function M0(r){gm[0]=r;let e=C0[0],t=e>>31&1,n=e>>23&255,s=8388607&e;if(n===255)return Ee[0]=t<<15|31744|(s!==0?512:0),Ee[0];if(n===0){if(s===0)return Ee[0]=t<<15,Ee[0];s|=8388608;let i=113;for(;!(8388608&s);)s<<=1,i--;return n=127-i,s&=8388607,n>0?(s=(s>>126-n)+(s>>127-n&1),Ee[0]=t<<15|n<<10|s>>13,Ee[0]):(Ee[0]=t<<15,Ee[0])}return n=n-127+15,n>=31?(Ee[0]=t<<15|31744,Ee[0]):n<=0?n<-10?(Ee[0]=t<<15,Ee[0]):(s=(8388608|s)>>1-n,Ee[0]=t<<15|s>>13,Ee[0]):(s>>=13,Ee[0]=t<<15|n<<10|s,Ee[0])}var rf=new Uint32Array(1),_m=new Float32Array(rf.buffer,0,1);function pm(r){let e=112+(r>>6&31)<<23|(63&r)<<17;return rf[0]=e,_m[0]}function O0(r,e,t,n,s,i,o,a,c){let l=n*(o>>=s)*(i>>=s)+t*o+e*a;switch(c){case"r8unorm":return[te(r,l,"8unorm",1)[0]];case"r8snorm":return[te(r,l,"8snorm",1)[0]];case"r8uint":return[te(r,l,"8uint",1)[0]];case"r8sint":return[te(r,l,"8sint",1)[0]];case"rg8unorm":{let u=te(r,l,"8unorm",2);return[u[0],u[1]]}case"rg8snorm":{let u=te(r,l,"8snorm",2);return[u[0],u[1]]}case"rg8uint":{let u=te(r,l,"8uint",2);return[u[0],u[1]]}case"rg8sint":{let u=te(r,l,"8sint",2);return[u[0],u[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{let u=te(r,l,"8unorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8snorm":{let u=te(r,l,"8snorm",4);return[u[0],u[1],u[2],u[3]]}case"rgba8uint":{let u=te(r,l,"8uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba8sint":{let u=te(r,l,"8sint",4);return[u[0],u[1],u[2],u[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{let u=te(r,l,"8unorm",4);return[u[2],u[1],u[0],u[3]]}case"r16uint":return[te(r,l,"16uint",1)[0]];case"r16sint":return[te(r,l,"16sint",1)[0]];case"r16float":return[te(r,l,"16float",1)[0]];case"rg16uint":{let u=te(r,l,"16uint",2);return[u[0],u[1]]}case"rg16sint":{let u=te(r,l,"16sint",2);return[u[0],u[1]]}case"rg16float":{let u=te(r,l,"16float",2);return[u[0],u[1]]}case"rgba16uint":{let u=te(r,l,"16uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16sint":{let u=te(r,l,"16sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba16float":{let u=te(r,l,"16float",4);return[u[0],u[1],u[2],u[3]]}case"r32uint":return[te(r,l,"32uint",1)[0]];case"r32sint":return[te(r,l,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[te(r,l,"32float",1)[0]];case"rg32uint":{let u=te(r,l,"32uint",2);return[u[0],u[1]]}case"rg32sint":{let u=te(r,l,"32sint",2);return[u[0],u[1]]}case"rg32float":{let u=te(r,l,"32float",2);return[u[0],u[1]]}case"rgba32uint":{let u=te(r,l,"32uint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32sint":{let u=te(r,l,"32sint",4);return[u[0],u[1],u[2],u[3]]}case"rgba32float":{let u=te(r,l,"32float",4);return[u[0],u[1],u[2],u[3]]}case"rg11b10ufloat":{let u=new Uint32Array(r.buffer,l,1)[0],f=(4192256&u)>>11,h=(4290772992&u)>>22;return[pm(2047&u),pm(f),function(d){let m=112+(d>>5&31)<<23|(31&d)<<18;return rf[0]=m,_m[0]}(h),1]}}return null}function te(r,e,t,n){let s=[0,0,0,0];for(let l=0;l<n;++l)switch(t){case"8unorm":s[l]=r[e]/255,e++;break;case"8snorm":s[l]=r[e]/255*2-1,e++;break;case"8uint":s[l]=r[e],e++;break;case"8sint":s[l]=r[e]-127,e++;break;case"16uint":s[l]=r[e]|r[e+1]<<8,e+=2;break;case"16sint":s[l]=(r[e]|r[e+1]<<8)-32768,e+=2;break;case"16float":s[l]=(i=r[e]|r[e+1]<<8,o=void 0,a=void 0,c=void 0,o=(32768&i)>>15,c=1023&i,(a=(31744&i)>>10)==0?(o?-1:1)*Math.pow(2,-14)*(c/Math.pow(2,10)):a==31?c?NaN:1/0*(o?-1:1):(o?-1:1)*Math.pow(2,a-15)*(1+c/Math.pow(2,10))),e+=2;break;case"32uint":case"32sint":s[l]=r[e]|r[e+1]<<8|r[e+2]<<16|r[e+3]<<24,e+=4;break;case"32float":s[l]=new Float32Array(r.buffer,e,1)[0],e+=4}var i,o,a,c;return s}function re(r,e,t,n,s){for(let i=0;i<n;++i)switch(t){case"8unorm":r[e]=255*s[i],e++;break;case"8snorm":r[e]=.5*(s[i]+1)*255,e++;break;case"8uint":r[e]=s[i],e++;break;case"8sint":r[e]=s[i]+127,e++;break;case"16uint":new Uint16Array(r.buffer,e,1)[0]=s[i],e+=2;break;case"16sint":new Int16Array(r.buffer,e,1)[0]=s[i],e+=2;break;case"16float":{let o=M0(s[i]);new Uint16Array(r.buffer,e,1)[0]=o,e+=2;break}case"32uint":new Uint32Array(r.buffer,e,1)[0]=s[i],e+=4;break;case"32sint":new Int32Array(r.buffer,e,1)[0]=s[i],e+=4;break;case"32float":new Float32Array(r.buffer,e,1)[0]=s[i],e+=4}return s}var Bu={r8unorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8snorm:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8uint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r8sint:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg8unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8snorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg8sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"rgba8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8snorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba8sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},bgra8unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bgra8unorm-srgb":{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r16uint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16sint:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r16float:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg16uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg16float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba16uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba16float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},r32uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32sint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},r32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:1},rg32uint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32sint:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rg32float:{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,channels:2},rgba32uint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32sint:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgba32float:{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2uint:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rgb10a2unorm:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},rg11b10ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},stencil8:{bytesPerBlock:1,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!1,hasStencil:!0,channels:1},depth16unorm:{bytesPerBlock:2,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},depth24plus:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,depthOnlyFormat:"depth32float",channels:1},"depth24plus-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,depthOnlyFormat:"depth32float",channels:1},depth32float:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!1,channels:1},"depth32float-stencil8":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!1,isDepthStencil:!0,hasDepth:!0,hasStencil:!0,stencilOnlyFormat:"depth32float",channels:1},rgb9e5ufloat:{bytesPerBlock:4,blockWidth:1,blockHeight:1,isCompressed:!1,channels:4},"bc1-rgba-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc1-rgba-unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc2-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc3-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc4-r-unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc4-r-snorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:1},"bc5-rg-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc5-rg-snorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:2},"bc6h-rgb-ufloat":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc6h-rgb-float":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"bc7-rgba-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgb8a1unorm-srgb":{bytesPerBlock:8,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"etc2-rgba8unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"eac-r11unorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-r11snorm":{bytesPerBlock:8,blockWidth:1,blockHeight:1,isCompressed:!0,channels:1},"eac-rg11unorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"eac-rg11snorm":{bytesPerBlock:16,blockWidth:1,blockHeight:1,isCompressed:!0,channels:2},"astc-4x4-unorm":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-4x4-unorm-srgb":{bytesPerBlock:16,blockWidth:4,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x4-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:4,isCompressed:!0,channels:4},"astc-5x5-unorm":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-5x5-unorm-srgb":{bytesPerBlock:16,blockWidth:5,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x5-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:5,isCompressed:!0,channels:4},"astc-6x6-unorm":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-6x6-unorm-srgb":{bytesPerBlock:16,blockWidth:6,blockHeight:6,isCompressed:!0,channels:4},"astc-8x5-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x5-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:5,isCompressed:!0,channels:4},"astc-8x6-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x6-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:6,isCompressed:!0,channels:4},"astc-8x8-unorm":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-8x8-unorm-srgb":{bytesPerBlock:16,blockWidth:8,blockHeight:8,isCompressed:!0,channels:4},"astc-10x5-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x5-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:5,isCompressed:!0,channels:4},"astc-10x6-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x6-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:6,isCompressed:!0,channels:4},"astc-10x8-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x8-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:8,isCompressed:!0,channels:4},"astc-10x10-unorm":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-10x10-unorm-srgb":{bytesPerBlock:16,blockWidth:10,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x10-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:10,isCompressed:!0,channels:4},"astc-12x12-unorm":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4},"astc-12x12-unorm-srgb":{bytesPerBlock:16,blockWidth:12,blockHeight:12,isCompressed:!0,channels:4}},Le=class{constructor(){this.id=Le._id++,this.line=0}get isAstNode(){return!0}get astNodeType(){return""}search(e){e(this)}searchBlock(e,t){if(e){t(Gn.instance);for(let n of e)n instanceof Array?this.searchBlock(n,t):n.search(t);t(Qn.instance)}}constEvaluate(e,t){throw new Error("Cannot evaluate node")}constEvaluateString(e){return this.constEvaluate(e).toString()}};Le._id=0;var Gn=class extends Le{};Gn.instance=new Gn;var Qn=class extends Le{};Qn.instance=new Qn;var ym=new Set(["all","all","any","select","arrayLength","abs","acos","acosh","asin","asinh","atan","atanh","atan2","ceil","clamp","cos","cosh","countLeadingZeros","countOneBits","countTrailingZeros","cross","degrees","determinant","distance","dot","dot4U8Packed","dot4I8Packed","exp","exp2","extractBits","faceForward","firstLeadingBit","firstTrailingBit","floor","fma","fract","frexp","insertBits","inverseSqrt","ldexp","length","log","log2","max","min","mix","modf","normalize","pow","quantizeToF16","radians","reflect","refract","reverseBits","round","saturate","sign","sin","sinh","smoothStep","sqrt","step","tan","tanh","transpose","trunc","dpdx","dpdxCoarse","dpdxFine","dpdy","dpdyCoarse","dpdyFine","fwidth","fwidthCoarse","fwidthFine","textureDimensions","textureGather","textureGatherCompare","textureLoad","textureNumLayers","textureNumLevels","textureNumSamples","textureSample","textureSampleBias","textureSampleCompare","textureSampleCompareLevel","textureSampleGrad","textureSampleLevel","textureSampleBaseClampToEdge","textureStore","atomicLoad","atomicStore","atomicAdd","atomicSub","atomicMax","atomicMin","atomicAnd","atomicOr","atomicXor","atomicExchange","atomicCompareExchangeWeak","pack4x8snorm","pack4x8unorm","pack4xI8","pack4xU8","pack4x8Clamp","pack4xU8Clamp","pack2x16snorm","pack2x16unorm","pack2x16float","unpack4x8snorm","unpack4x8unorm","unpack4xI8","unpack4xU8","unpack2x16snorm","unpack2x16unorm","unpack2x16float","storageBarrier","textureBarrier","workgroupBarrier","workgroupUniformLoad","subgroupAdd","subgroupExclusiveAdd","subgroupInclusiveAdd","subgroupAll","subgroupAnd","subgroupAny","subgroupBallot","subgroupBroadcast","subgroupBroadcastFirst","subgroupElect","subgroupMax","subgroupMin","subgroupMul","subgroupExclusiveMul","subgroupInclusiveMul","subgroupOr","subgroupShuffle","subgroupShuffleDown","subgroupShuffleUp","subgroupShuffleXor","subgroupXor","quadBroadcast","quadSwapDiagonal","quadSwapX","quadSwapY"]),oe=class extends Le{constructor(){super()}},en=class extends oe{constructor(e,t,n,s,i,o){super(),this.calls=new Set,this.name=e,this.args=t,this.returnType=n,this.body=s,this.startLine=i,this.endLine=o}get astNodeType(){return"function"}search(e){if(this.attributes)for(let t of this.attributes)e(t);e(this);for(let t of this.args)e(t);this.searchBlock(this.body,e)}},Hu=class extends oe{constructor(e){super(),this.expression=e}get astNodeType(){return"staticAssert"}search(e){this.expression.search(e)}},oa=class extends oe{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"while"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},Ys=class extends oe{constructor(e,t){super(),this.body=e,this.loopId=t}get astNodeType(){return"continuing"}search(e){this.searchBlock(this.body,e)}},aa=class extends oe{constructor(e,t,n,s){super(),this.init=e,this.condition=t,this.increment=n,this.body=s}get astNodeType(){return"for"}search(e){var t,n,s;(t=this.init)===null||t===void 0||t.search(e),(n=this.condition)===null||n===void 0||n.search(e),(s=this.increment)===null||s===void 0||s.search(e),this.searchBlock(this.body,e)}},ut=class extends oe{constructor(e,t,n,s,i){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=i}get astNodeType(){return"var"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},qs=class extends oe{constructor(e,t,n){super(),this.attributes=null,this.name=e,this.type=t,this.value=n}get astNodeType(){return"override"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}},Qr=class extends oe{constructor(e,t,n,s,i){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=i}get astNodeType(){return"let"}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},Kn=class extends oe{constructor(e,t,n,s,i){super(),this.attributes=null,this.name=e,this.type=t,this.storage=n,this.access=s,this.value=i}get astNodeType(){return"const"}constEvaluate(e,t){return this.value.constEvaluate(e,t)}search(e){var t;e(this),(t=this.value)===null||t===void 0||t.search(e)}},Yn,Hs,R,v;(r=>{r.increment="++",r.decrement="--"})(Yn||(Yn={})),(r=>{r.parse=function(e){let t=e;if(t=="parse")throw new Error("Invalid value for IncrementOperator");return r[t]}})(Yn||(Yn={}));var ca=class extends oe{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}};(r=>{r.assign="=",r.addAssign="+=",r.subtractAssin="-=",r.multiplyAssign="*=",r.divideAssign="/=",r.moduloAssign="%=",r.andAssign="&=",r.orAssign="|=",r.xorAssign="^=",r.shiftLeftAssign="<<=",r.shiftRightAssign=">>="})(Hs||(Hs={})),(r=>{r.parse=function(e){let t=e;if(t=="parse")throw new Error("Invalid value for AssignOperator");return t}})(Hs||(Hs={}));var la=class extends oe{constructor(e,t,n){super(),this.operator=e,this.variable=t,this.value=n}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}},Ks=class extends oe{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return ym.has(this.name)}search(e){for(let t of this.args)t.search(e);e(this)}},ua=class extends oe{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}},fa=class extends oe{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return"switch"}},ha=class extends oe{constructor(e,t,n,s){super(),this.condition=e,this.body=t,this.elseif=n,this.else=s}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}},da=class extends oe{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;(t=this.value)===null||t===void 0||t.search(e)}},Xu=class extends oe{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}},Yu=class extends oe{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}},pa=class extends oe{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}},Zs=class extends oe{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}},qu=class extends oe{constructor(){super()}get astNodeType(){return"discard"}},ma=class extends oe{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}},ga=class extends oe{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}},M=class extends oe{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if(t.name==="f32")return t;for(let n=1;n<e.length;++n){let s=M._priority.get(t.name);M._priority.get(e[n].name)<s&&(t=e[n])}return t.name==="x32"?M.i32:t}getTypeName(){return this.name}};M.x32=new M("x32"),M.f32=new M("f32"),M.i32=new M("i32"),M.u32=new M("u32"),M.f16=new M("f16"),M.bool=new M("bool"),M.void=new M("void"),M._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);var _a=class extends M{constructor(e){super(e)}},ct=class extends M{constructor(e,t,n,s){super(e),this.members=t,this.startLine=n,this.endLine=s}get astNodeType(){return"struct"}get isStruct(){return!0}getMemberIndex(e){for(let t=0;t<this.members.length;t++)if(this.members[t].name==e)return t;return-1}search(e){for(let t of this.members)e(t)}},A=class extends M{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return"template"}getTypeName(){let e=this.name;if(this.format!==null){if(e==="vec2"||e==="vec3"||e==="vec4"||e==="mat2x2"||e==="mat2x3"||e==="mat2x4"||e==="mat3x2"||e==="mat3x3"||e==="mat3x4"||e==="mat4x2"||e==="mat4x3"||e==="mat4x4"){if(this.format.name==="f32")return e+="f",e;if(this.format.name==="i32")return e+="i",e;if(this.format.name==="u32")return e+="u",e;if(this.format.name==="bool")return e+="b",e;if(this.format.name==="f16")return e+="h",e}e+=`<${this.format.name}>`}else if(e==="vec2"||e==="vec3"||e==="vec4")return e;return e}};A.vec2f=new A("vec2",M.f32,null),A.vec3f=new A("vec3",M.f32,null),A.vec4f=new A("vec4",M.f32,null),A.vec2i=new A("vec2",M.i32,null),A.vec3i=new A("vec3",M.i32,null),A.vec4i=new A("vec4",M.i32,null),A.vec2u=new A("vec2",M.u32,null),A.vec3u=new A("vec3",M.u32,null),A.vec4u=new A("vec4",M.u32,null),A.vec2h=new A("vec2",M.f16,null),A.vec3h=new A("vec3",M.f16,null),A.vec4h=new A("vec4",M.f16,null),A.vec2b=new A("vec2",M.bool,null),A.vec3b=new A("vec3",M.bool,null),A.vec4b=new A("vec4",M.bool,null),A.mat2x2f=new A("mat2x2",M.f32,null),A.mat2x3f=new A("mat2x3",M.f32,null),A.mat2x4f=new A("mat2x4",M.f32,null),A.mat3x2f=new A("mat3x2",M.f32,null),A.mat3x3f=new A("mat3x3",M.f32,null),A.mat3x4f=new A("mat3x4",M.f32,null),A.mat4x2f=new A("mat4x2",M.f32,null),A.mat4x3f=new A("mat4x3",M.f32,null),A.mat4x4f=new A("mat4x4",M.f32,null),A.mat2x2h=new A("mat2x2",M.f16,null),A.mat2x3h=new A("mat2x3",M.f16,null),A.mat2x4h=new A("mat2x4",M.f16,null),A.mat3x2h=new A("mat3x2",M.f16,null),A.mat3x3h=new A("mat3x3",M.f16,null),A.mat3x4h=new A("mat3x4",M.f16,null),A.mat4x2h=new A("mat4x2",M.f16,null),A.mat4x3h=new A("mat4x3",M.f16,null),A.mat4x4h=new A("mat4x4",M.f16,null),A.mat2x2i=new A("mat2x2",M.i32,null),A.mat2x3i=new A("mat2x3",M.i32,null),A.mat2x4i=new A("mat2x4",M.i32,null),A.mat3x2i=new A("mat3x2",M.i32,null),A.mat3x3i=new A("mat3x3",M.i32,null),A.mat3x4i=new A("mat3x4",M.i32,null),A.mat4x2i=new A("mat4x2",M.i32,null),A.mat4x3i=new A("mat4x3",M.i32,null),A.mat4x4i=new A("mat4x4",M.i32,null),A.mat2x2u=new A("mat2x2",M.u32,null),A.mat2x3u=new A("mat2x3",M.u32,null),A.mat2x4u=new A("mat2x4",M.u32,null),A.mat3x2u=new A("mat3x2",M.u32,null),A.mat3x3u=new A("mat3x3",M.u32,null),A.mat3x4u=new A("mat3x4",M.u32,null),A.mat4x2u=new A("mat4x2",M.u32,null),A.mat4x3u=new A("mat4x3",M.u32,null),A.mat4x4u=new A("mat4x4",M.u32,null);var Xs=class extends M{constructor(e,t,n,s){super(e),this.storage=t,this.type=n,this.access=s}get astNodeType(){return"pointer"}},Jr=class extends M{constructor(e,t,n,s){super(e),this.attributes=t,this.format=n,this.count=s}get astNodeType(){return"array"}get isArray(){return!0}},Gr=class extends M{constructor(e,t,n){super(e),this.format=t,this.access=n}get astNodeType(){return"sampler"}},Je=class extends Le{constructor(){super(),this.postfix=null}},Zt=class extends Je{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}},Ge=class extends Je{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(let t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}},Gs=class extends Je{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return ym.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(let t of this.args)t.search(e);e(this)}},Me=class extends Je{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}},ya=class extends Je{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}constEvaluate(e,t){if(this.initializer){let n=e.evalExpression(this.initializer,e.context);return n!==null&&this.postfix?n.getSubData(e,this.postfix,e.context):n}return null}search(e){this.initializer.search(e)}},me=class extends Je{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return"literalExpr"}constEvaluate(e,t){return t!==void 0&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof T}get isVector(){return this.value instanceof g||this.value instanceof z}get scalarValue(){return this.value instanceof T?this.value.value:(console.error("Value is not scalar."),0)}get vectorValue(){return this.value instanceof g||this.value instanceof z?this.value.data:(console.error("Value is not a vector or matrix."),new Float32Array(0))}},xa=class extends Je{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}};var br=class extends Je{constructor(e){super(),this.index=e}search(e){this.index.search(e)}},ba=class extends Je{constructor(){super()}},ue=class extends ba{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}},je=class extends ba{constructor(e,t,n){super(),this.operator=e,this.left=t,this.right=n}get astNodeType(){return"binaryOp"}_getPromotedType(e,t){return e.name===t.name?e:e.name==="f32"||t.name==="f32"?M.f32:e.name==="u32"||t.name==="u32"?M.u32:M.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}},Ta=class extends Le{constructor(e){super(),this.body=e}},Zn=class extends Je{constructor(){super()}get astNodeType(){return"default"}},wa=class extends Ta{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}},va=class extends Ta{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}},Aa=class extends Le{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"argument"}},Ku=class extends Le{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}},Sa=class extends Le{constructor(e,t,n){super(),this.name=e,this.type=t,this.attributes=n}get astNodeType(){return"member"}},Ea=class extends Le{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}},Ue=class{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=Ue._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,n,s){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,n){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.name}>`}};Ue._id=0;var Qs=class extends Ue{constructor(){super(new Be("void",null),null)}toString(){return"void"}};Qs.void=new Qs;var xr=class extends Ue{constructor(e){super(new Be("pointer",null),null),this.reference=e}clone(){return this}setDataValue(e,t,n,s){this.reference.setDataValue(e,t,n,s)}getSubData(e,t,n){return t?this.reference.getSubData(e,t,n):this}},T=class extends Ue{constructor(e,t,n=null){super(t,n),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:this.typeInfo.name==="x32"?e-Math.floor(e)!=0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):this.typeInfo.name==="i32"||this.typeInfo.name==="bool"?this.data=new Int32Array([e]):this.typeInfo.name==="u32"?this.data=new Uint32Array([e]):this.typeInfo.name==="f32"||this.typeInfo.name==="f16"?this.data=new Float32Array([e]):console.error("ScalarData2: Invalid type",t)}clone(){if(this.data instanceof Float32Array)return new T(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new T(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new T(new Uint32Array(this.data),this.typeInfo,null);throw"ScalarData: Invalid data type"}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,n,s){if(n)return void console.error("SetDataValue: Scalar data does not support postfix",n);if(!(t instanceof T))return void console.error("SetDataValue: Invalid value",t);let i=t.data[0];this.typeInfo.name==="i32"||this.typeInfo.name==="u32"?i=Math.floor(i):this.typeInfo.name==="bool"&&(i=i?1:0),this.data[0]=i}getSubData(e,t,n){return t?(console.error("getSubData: Scalar data does not support postfix",t),null):this}toString(){return`${this.value}`}};function k0(r,e,t){let n=e.length;return n===2?t==="f32"?new g(new Float32Array(e),r.getTypeInfo("vec2f")):t==="i32"||t==="bool"?new g(new Int32Array(e),r.getTypeInfo("vec2i")):t==="u32"?new g(new Uint32Array(e),r.getTypeInfo("vec2u")):t==="f16"?new g(new Float32Array(e),r.getTypeInfo("vec2h")):(console.error(`getSubData: Unknown format ${t}`),null):n===3?t==="f32"?new g(new Float32Array(e),r.getTypeInfo("vec3f")):t==="i32"||t==="bool"?new g(new Int32Array(e),r.getTypeInfo("vec3i")):t==="u32"?new g(new Uint32Array(e),r.getTypeInfo("vec3u")):t==="f16"?new g(new Float32Array(e),r.getTypeInfo("vec3h")):(console.error(`getSubData: Unknown format ${t}`),null):n===4?t==="f32"?new g(new Float32Array(e),r.getTypeInfo("vec4f")):t==="i32"||t==="bool"?new g(new Int32Array(e),r.getTypeInfo("vec4i")):t==="u32"?new g(new Uint32Array(e),r.getTypeInfo("vec4u")):t==="f16"?new g(new Float32Array(e),r.getTypeInfo("vec4h")):(console.error(`getSubData: Unknown format ${t}`),null):(console.error(`getSubData: Invalid vector size ${e.length}`),null)}var g=class extends Ue{constructor(e,t,n=null){if(super(t,n),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{let s=this.typeInfo.name;s==="vec2f"||s==="vec3f"||s==="vec4f"?this.data=new Float32Array(e):s==="vec2i"||s==="vec3i"||s==="vec4i"?this.data=new Int32Array(e):s==="vec2u"||s==="vec3u"||s==="vec4u"?this.data=new Uint32Array(e):s==="vec2h"||s==="vec3h"||s==="vec4h"?this.data=new Float32Array(e):s==="vec2b"||s==="vec3b"||s==="vec4b"?this.data=new Int32Array(e):s==="vec2"||s==="vec3"||s==="vec4"?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${s}`)}}clone(){if(this.data instanceof Float32Array)return new g(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new g(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new g(new Uint32Array(this.data),this.typeInfo,null);throw"VectorData: Invalid data type"}setDataValue(e,t,n,s){n instanceof Zt?console.error("TODO: Set vector postfix"):t instanceof g?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,n){if(t===null)return this;let s=e.getTypeInfo("f32");if(this.typeInfo instanceof Kt)s=this.typeInfo.format||s;else{let o=this.typeInfo.name;o==="vec2f"||o==="vec3f"||o==="vec4f"?s=e.getTypeInfo("f32"):o==="vec2i"||o==="vec3i"||o==="vec4i"?s=e.getTypeInfo("i32"):o==="vec2b"||o==="vec3b"||o==="vec4b"?s=e.getTypeInfo("bool"):o==="vec2u"||o==="vec3u"||o==="vec4u"?s=e.getTypeInfo("u32"):o==="vec2h"||o==="vec3h"||o==="vec4h"?s=e.getTypeInfo("f16"):console.error(`GetSubData: Unknown type ${o}`)}let i=this;for(;t!==null&&i!==null;){if(t instanceof br){let o=t.index,a=-1;if(o instanceof me){if(!(o.value instanceof T))return console.error(`GetSubData: Invalid array index ${o.value}`),null;a=o.value.value}else{let c=e.evalExpression(o,n);if(!(c instanceof T))return console.error("GetSubData: Unknown index type",o),null;a=c.value}if(a<0||a>=i.data.length)return console.error("GetSubData: Index out of range",a),null;if(i.data instanceof Float32Array){let c=new Float32Array(i.data.buffer,i.data.byteOffset+4*a,1);return new T(c,s)}if(i.data instanceof Int32Array){let c=new Int32Array(i.data.buffer,i.data.byteOffset+4*a,1);return new T(c,s)}if(i.data instanceof Uint32Array){let c=new Uint32Array(i.data.buffer,i.data.byteOffset+4*a,1);return new T(c,s)}throw"GetSubData: Invalid data type"}if(!(t instanceof Zt))return console.error("GetSubData: Unknown postfix",t),null;{let o=t.value.toLowerCase();if(o.length===1){let c=0;if(o==="x"||o==="r")c=0;else if(o==="y"||o==="g")c=1;else if(o==="z"||o==="b")c=2;else{if(o!=="w"&&o!=="a")return console.error(`GetSubData: Unknown member ${o}`),null;c=3}if(this.data instanceof Float32Array){let l=new Float32Array(this.data.buffer,this.data.byteOffset+4*c,1);return new T(l,s,this)}if(this.data instanceof Int32Array){let l=new Int32Array(this.data.buffer,this.data.byteOffset+4*c,1);return new T(l,s,this)}if(this.data instanceof Uint32Array){let l=new Uint32Array(this.data.buffer,this.data.byteOffset+4*c,1);return new T(l,s,this)}}let a=[];for(let c of o)c==="x"||c==="r"?a.push(this.data[0]):c==="y"||c==="g"?a.push(this.data[1]):c==="z"||c==="b"?a.push(this.data[2]):c==="w"||c==="a"?a.push(this.data[3]):console.error(`GetDataValue: Unknown member ${c}`);i=k0(e,a,s.name)}t=t.postfix}return i}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}},z=class extends Ue{constructor(e,t,n=null){super(t,n),e instanceof Float32Array?this.data=e:this.data=new Float32Array(e)}clone(){return new z(new Float32Array(this.data),this.typeInfo,null)}setDataValue(e,t,n,s){n instanceof Zt?console.error("TODO: Set matrix postfix"):t instanceof z?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,n){if(t===null)return this;let s=this.typeInfo.name;if(e.getTypeInfo("f32"),this.typeInfo instanceof Kt)this.typeInfo.format;else if(s.endsWith("f"))e.getTypeInfo("f32");else if(s.endsWith("i"))e.getTypeInfo("i32");else if(s.endsWith("u"))e.getTypeInfo("u32");else{if(!s.endsWith("h"))return console.error(`GetDataValue: Unknown type ${s}`),null;e.getTypeInfo("f16")}if(t instanceof br){let i=t.index,o=-1;if(i instanceof me){if(!(i.value instanceof T))return console.error(`GetDataValue: Invalid array index ${i.value}`),null;o=i.value.value}else{let l=e.evalExpression(i,n);if(!(l instanceof T))return console.error("GetDataValue: Unknown index type",i),null;o=l.value}if(o<0||o>=this.data.length)return console.error("GetDataValue: Index out of range",o),null;let a=s.endsWith("h")?"h":"f",c;if(s==="mat2x2"||s==="mat2x2f"||s==="mat2x2h"||s==="mat3x2"||s==="mat3x2f"||s==="mat3x2h"||s==="mat4x2"||s==="mat4x2f"||s==="mat4x2h")c=new g(new Float32Array(this.data.buffer,this.data.byteOffset+2*o*4,2),e.getTypeInfo(`vec2${a}`));else if(s==="mat2x3"||s==="mat2x3f"||s==="mat2x3h"||s==="mat3x3"||s==="mat3x3f"||s==="mat3x3h"||s==="mat4x3"||s==="mat4x3f"||s==="mat4x3h")c=new g(new Float32Array(this.data.buffer,this.data.byteOffset+3*o*4,3),e.getTypeInfo(`vec3${a}`));else{if(s!=="mat2x4"&&s!=="mat2x4f"&&s!=="mat2x4h"&&s!=="mat3x4"&&s!=="mat3x4f"&&s!=="mat3x4h"&&s!=="mat4x4"&&s!=="mat4x4f"&&s!=="mat4x4h")return console.error(`GetDataValue: Unknown type ${s}`),null;c=new g(new Float32Array(this.data.buffer,this.data.byteOffset+4*o*4,4),e.getTypeInfo(`vec4${a}`))}return t.postfix?c.getSubData(e,t.postfix,n):c}return console.error("GetDataValue: Invalid postfix",t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t<this.data.length;++t)e+=`, ${this.data[t]}`;return e}},ce=class extends Ue{constructor(e,t,n=0,s=null){super(t,s),this.buffer=e instanceof ArrayBuffer?e:e.buffer,this.offset=n}clone(){let e=new Uint8Array(new Uint8Array(this.buffer,this.offset,this.typeInfo.size));return new ce(e.buffer,this.typeInfo,0,null)}setDataValue(e,t,n,s){if(t===null)return void console.log("setDataValue: NULL data.");let i=this.offset,o=this.typeInfo;for(;n;){if(n instanceof br)if(o instanceof It){let a=n.index;if(a instanceof me){if(!(a.value instanceof T))return void console.error(`SetDataValue: Invalid index type ${a.value}`);i+=a.value.value*o.stride}else{let c=e.evalExpression(a,s);if(!(c instanceof T))return void console.error("SetDataValue: Unknown index type",a);i+=c.value*o.stride}o=o.format}else console.error(`SetDataValue: Type ${o.getTypeName()} is not an array`);else{if(!(n instanceof Zt))return void console.error("SetDataValue: Unknown postfix type",n);{let a=n.value;if(o instanceof Rt){let c=!1;for(let l of o.members)if(l.name===a){i+=l.offset,o=l.type,c=!0;break}if(!c)return void console.error(`SetDataValue: Member ${a} not found`)}else if(o instanceof Be){let c=o.getTypeName(),l=0;if(a==="x"||a==="r")l=0;else if(a==="y"||a==="g")l=1;else if(a==="z"||a==="b")l=2;else{if(a!=="w"&&a!=="a")return void console.error(`SetDataValue: Unknown member ${a}`);l=3}if(!(t instanceof T))return void console.error("SetDataValue: Invalid value",t);let u=t.value;return c==="vec2f"?void(new Float32Array(this.buffer,i,2)[l]=u):c==="vec3f"?void(new Float32Array(this.buffer,i,3)[l]=u):c==="vec4f"?void(new Float32Array(this.buffer,i,4)[l]=u):c==="vec2i"?void(new Int32Array(this.buffer,i,2)[l]=u):c==="vec3i"?void(new Int32Array(this.buffer,i,3)[l]=u):c==="vec4i"?void(new Int32Array(this.buffer,i,4)[l]=u):c==="vec2u"?void(new Uint32Array(this.buffer,i,2)[l]=u):c==="vec3u"?void(new Uint32Array(this.buffer,i,3)[l]=u):c==="vec4u"?void(new Uint32Array(this.buffer,i,4)[l]=u):void console.error(`SetDataValue: Type ${c} is not a struct`)}}}n=n.postfix}this.setData(e,t,o,i,s)}setData(e,t,n,s,i){let o=n.getTypeName();if(o!=="f32"&&o!=="f16")if(o!=="i32"&&o!=="atomic<i32>"&&o!=="x32")if(o!=="u32"&&o!=="atomic<u32>")if(o!=="bool")if(o!=="vec2f"&&o!=="vec2h")if(o!=="vec3f"&&o!=="vec3h")if(o!=="vec4f"&&o!=="vec4h")if(o!=="vec2i")if(o!=="vec3i")if(o!=="vec4i")if(o!=="vec2u")if(o!=="vec3u")if(o!=="vec4u")if(o!=="vec2b")if(o!=="vec3b")if(o!=="vec4b")if(o!=="mat2x2f"&&o!=="mat2x2h")if(o!=="mat2x3f"&&o!=="mat2x3h")if(o!=="mat2x4f"&&o!=="mat2x4h")if(o!=="mat3x2f"&&o!=="mat3x2h")if(o!=="mat3x3f"&&o!=="mat3x3h")if(o!=="mat3x4f"&&o!=="mat3x4h")if(o!=="mat4x2f"&&o!=="mat4x2h")if(o!=="mat4x3f"&&o!=="mat4x3h")if(o!=="mat4x4f"&&o!=="mat4x4h")if(t instanceof ce){if(n===t.typeInfo)return void new Uint8Array(this.buffer,s,t.buffer.byteLength).set(new Uint8Array(t.buffer));console.error("SetDataValue: Type mismatch",o,t.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${o}`);else{let a=new Float32Array(this.buffer,s,16);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11],a[12]=t.data[12],a[13]=t.data[13],a[14]=t.data[14],a[15]=t.data[15]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11],a[12]=t[12],a[13]=t[13],a[14]=t[14],a[15]=t[15])}else{let a=new Float32Array(this.buffer,s,12);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11])}else{let a=new Float32Array(this.buffer,s,8);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7])}else{let a=new Float32Array(this.buffer,s,12);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8],a[9]=t.data[9],a[10]=t.data[10],a[11]=t.data[11]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8],a[9]=t[9],a[10]=t[10],a[11]=t[11])}else{let a=new Float32Array(this.buffer,s,9);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7],a[8]=t.data[8]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7],a[8]=t[8])}else{let a=new Float32Array(this.buffer,s,6);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5])}else{let a=new Float32Array(this.buffer,s,8);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5],a[6]=t.data[6],a[7]=t.data[7]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5],a[6]=t[6],a[7]=t[7])}else{let a=new Float32Array(this.buffer,s,6);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3],a[4]=t.data[4],a[5]=t.data[5]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3],a[4]=t[4],a[5]=t[5])}else{let a=new Float32Array(this.buffer,s,4);t instanceof z?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3])}else{let a=new Uint32Array(this.buffer,s,4);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3])}else{let a=new Uint32Array(this.buffer,s,3);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2])}else{let a=new Uint32Array(this.buffer,s,2);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1])}else{let a=new Uint32Array(this.buffer,s,4);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3])}else{let a=new Uint32Array(this.buffer,s,3);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2])}else{let a=new Uint32Array(this.buffer,s,2);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1])}else{let a=new Int32Array(this.buffer,s,4);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3])}else{let a=new Int32Array(this.buffer,s,3);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2])}else{let a=new Int32Array(this.buffer,s,2);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1])}else{let a=new Float32Array(this.buffer,s,4);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2],a[3]=t.data[3]):(a[0]=t[0],a[1]=t[1],a[2]=t[2],a[3]=t[3])}else{let a=new Float32Array(this.buffer,s,3);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1],a[2]=t.data[2]):(a[0]=t[0],a[1]=t[1],a[2]=t[2])}else{let a=new Float32Array(this.buffer,s,2);t instanceof g?(a[0]=t.data[0],a[1]=t.data[1]):(a[0]=t[0],a[1]=t[1])}else t instanceof T&&(new Int32Array(this.buffer,s,1)[0]=t.value);else t instanceof T&&(new Uint32Array(this.buffer,s,1)[0]=t.value);else t instanceof T&&(new Int32Array(this.buffer,s,1)[0]=t.value);else t instanceof T&&(new Float32Array(this.buffer,s,1)[0]=t.value)}getSubData(e,t,n){var s,i,o;if(t===null)return this;let a=this.offset,c=this.typeInfo;for(;t;){if(t instanceof br){let u=t.index,f=e.evalExpression(u,n),h=0;if(f instanceof T?h=f.value:console.error("GetDataValue: Invalid index type",u),c instanceof It)a+=h*c.stride,c=c.format;else{let d=c.getTypeName();d==="mat4x4"||d==="mat4x4f"||d==="mat4x4h"?(a+=16*h,c=e.getTypeInfo("vec4f")):console.error(`getDataValue: Type ${c.getTypeName()} is not an array`)}}else{if(!(t instanceof Zt))return console.error("GetDataValue: Unknown postfix type",t),null;{let u=t.value;if(c instanceof Rt){let f=!1;for(let h of c.members)if(h.name===u){a+=h.offset,c=h.type,f=!0;break}if(!f)return console.error(`GetDataValue: Member ${u} not found`),null}else if(c instanceof Be){let f=c.getTypeName();if(f==="vec2f"||f==="vec3f"||f==="vec4f"||f==="vec2i"||f==="vec3i"||f==="vec4i"||f==="vec2u"||f==="vec3u"||f==="vec4u"||f==="vec2b"||f==="vec3b"||f==="vec4b"||f==="vec2h"||f==="vec3h"||f==="vec4h"||f==="vec2"||f==="vec3"||f==="vec4"){if(u.length>0&&u.length<5){let h="f",d=[];for(let m=0;m<u.length;++m){let y=u[m].toLowerCase(),_=0;if(y==="x"||y==="r")_=0;else if(y==="y"||y==="g")_=1;else if(y==="z"||y==="b")_=2;else{if(y!=="w"&&y!=="a")return console.error(`Unknown member ${u}`),null;_=3}if(u.length===1){if(f.endsWith("f"))return this.buffer.byteLength<a+4*_+4?(console.log("Insufficient buffer data"),null):new T(new Float32Array(this.buffer,a+4*_,1),e.getTypeInfo("f32"),this);if(f.endsWith("h"))return new T(new Float32Array(this.buffer,a+4*_,1),e.getTypeInfo("f16"),this);if(f.endsWith("i"))return new T(new Int32Array(this.buffer,a+4*_,1),e.getTypeInfo("i32"),this);if(f.endsWith("b"))return new T(new Int32Array(this.buffer,a+4*_,1),e.getTypeInfo("bool"),this);if(f.endsWith("u"))return new T(new Uint32Array(this.buffer,a+4*_,1),e.getTypeInfo("i32"),this)}if(f==="vec2f")d.push(new Float32Array(this.buffer,a,2)[_]);else if(f==="vec3f"){if(a+12>=this.buffer.byteLength)return console.log("Insufficient buffer data"),null;let x=new Float32Array(this.buffer,a,3);d.push(x[_])}else if(f==="vec4f")d.push(new Float32Array(this.buffer,a,4)[_]);else if(f==="vec2i")h="i",d.push(new Int32Array(this.buffer,a,2)[_]);else if(f==="vec3i")h="i",d.push(new Int32Array(this.buffer,a,3)[_]);else if(f==="vec4i")h="i",d.push(new Int32Array(this.buffer,a,4)[_]);else if(f==="vec2u"){h="u";let x=new Uint32Array(this.buffer,a,2);d.push(x[_])}else f==="vec3u"?(h="u",d.push(new Uint32Array(this.buffer,a,3)[_])):f==="vec4u"&&(h="u",d.push(new Uint32Array(this.buffer,a,4)[_]))}return d.length===2?c=e.getTypeInfo(`vec2${h}`):d.length===3?c=e.getTypeInfo(`vec3${h}`):d.length===4?c=e.getTypeInfo(`vec4${h}`):console.error(`GetDataValue: Invalid vector length ${d.length}`),new g(d,c,null)}return console.error(`GetDataValue: Unknown member ${u}`),null}return console.error(`GetDataValue: Type ${f} is not a struct`),null}}}t=t.postfix}let l=c.getTypeName();return l==="f32"?new T(new Float32Array(this.buffer,a,1),c,this):l==="i32"?new T(new Int32Array(this.buffer,a,1),c,this):l==="u32"?new T(new Uint32Array(this.buffer,a,1),c,this):l==="vec2f"?new g(new Float32Array(this.buffer,a,2),c,this):l==="vec3f"?new g(new Float32Array(this.buffer,a,3),c,this):l==="vec4f"?new g(new Float32Array(this.buffer,a,4),c,this):l==="vec2i"?new g(new Int32Array(this.buffer,a,2),c,this):l==="vec3i"?new g(new Int32Array(this.buffer,a,3),c,this):l==="vec4i"?new g(new Int32Array(this.buffer,a,4),c,this):l==="vec2u"?new g(new Uint32Array(this.buffer,a,2),c,this):l==="vec3u"?new g(new Uint32Array(this.buffer,a,3),c,this):l==="vec4u"?new g(new Uint32Array(this.buffer,a,4),c,this):c instanceof Kt&&c.name==="atomic"?((s=c.format)===null||s===void 0?void 0:s.name)==="u32"?new T(new Uint32Array(this.buffer,a,1)[0],c.format,this):((i=c.format)===null||i===void 0?void 0:i.name)==="i32"?new T(new Int32Array(this.buffer,a,1)[0],c.format,this):(console.error(`GetDataValue: Invalid atomic format ${(o=c.format)===null||o===void 0?void 0:o.name}`),null):new ce(this.buffer,c,a,this)}toString(){let e="";if(this.typeInfo instanceof It)if(this.typeInfo.format.name==="f32"){let t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if(this.typeInfo.format.name==="i32"){let t=new Int32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if(this.typeInfo.format.name==="u32"){let t=new Uint32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let n=1;n<t.length;++n)e+=`, ${t[n]}`}else if(this.typeInfo.format.name==="vec2f"){let t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}]`;for(let n=1;n<t.length/2;++n)e+=`, [${t[2*n]}, ${t[2*n+1]}]`}else if(this.typeInfo.format.name==="vec3f"){let t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}]`;for(let n=4;n<t.length;n+=4)e+=`, [${t[n]}, ${t[n+1]}, ${t[n+2]}]`}else if(this.typeInfo.format.name==="vec4f"){let t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}]`;for(let n=4;n<t.length;n+=4)e+=`, [${t[n]}, ${t[n+1]}, ${t[n+2]}, ${t[n+3]}]`}else e="[...]";else this.typeInfo instanceof Rt?e+="{...}":e="[...]";return e}},lt=class extends Ue{constructor(e,t,n,s){super(t,null),this.data=e,this.descriptor=n,this.view=s}clone(){return new lt(this.data,this.typeInfo,this.descriptor,this.view)}get width(){var e,t;let n=this.descriptor.size;return n instanceof Array&&n.length>0?(e=n[0])!==null&&e!==void 0?e:0:n instanceof Object&&(t=n.width)!==null&&t!==void 0?t:0}get height(){var e,t;let n=this.descriptor.size;return n instanceof Array&&n.length>1?(e=n[1])!==null&&e!==void 0?e:0:n instanceof Object&&(t=n.height)!==null&&t!==void 0?t:0}get depthOrArrayLayers(){var e,t;let n=this.descriptor.size;return n instanceof Array&&n.length>2?(e=n[2])!==null&&e!==void 0?e:0:n instanceof Object&&(t=n.depthOrArrayLayers)!==null&&t!==void 0?t:0}get format(){var e;return this.descriptor&&(e=this.descriptor.format)!==null&&e!==void 0?e:"rgba8unorm"}get sampleCount(){var e;return this.descriptor&&(e=this.descriptor.sampleCount)!==null&&e!==void 0?e:1}get mipLevelCount(){var e;return this.descriptor&&(e=this.descriptor.mipLevelCount)!==null&&e!==void 0?e:1}get dimension(){var e;return this.descriptor&&(e=this.descriptor.dimension)!==null&&e!==void 0?e:"2d"}getMipLevelSize(e){if(e>=this.mipLevelCount)return[0,0,0];let t=[this.width,this.height,this.depthOrArrayLayers];for(let n=0;n<t.length;++n)t[n]=Math.max(1,t[n]>>e);return t}get texelByteSize(){let e=this.format,t=Bu[e];return t?t.isDepthStencil?4:t.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){let e=this.format,t=Bu[e];return!!t&&t.isDepthStencil}getGpuSize(){let e=this.format,t=Bu[e],n=this.width;if(!e||n<=0||!t)return-1;let s=this.height,i=this.depthOrArrayLayers,o=this.dimension;return n/t.blockWidth*(o==="1d"?1:s/t.blockHeight)*t.bytesPerBlock*i}getPixel(e,t,n=0,s=0){let i=this.texelByteSize,o=this.bytesPerRow,a=this.height,c=this.data[s];return O0(new Uint8Array(c),e,t,n,s,a,o,i,this.format)}setPixel(e,t,n,s,i){let o=this.texelByteSize,a=this.bytesPerRow,c=this.height,l=this.data[s];(function(u,f,h,d,m,y,_,x,E,b){let S=d*(_>>=m)*(y>>=m)+h*_+f*x;switch(E){case"r8unorm":return void re(u,S,"8unorm",1,b);case"r8snorm":return void re(u,S,"8snorm",1,b);case"r8uint":return void re(u,S,"8uint",1,b);case"r8sint":return void re(u,S,"8sint",1,b);case"rg8unorm":return void re(u,S,"8unorm",2,b);case"rg8snorm":return void re(u,S,"8snorm",2,b);case"rg8uint":return void re(u,S,"8uint",2,b);case"rg8sint":return void re(u,S,"8sint",2,b);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void re(u,S,"8unorm",4,b);case"rgba8snorm":return void re(u,S,"8snorm",4,b);case"rgba8uint":return void re(u,S,"8uint",4,b);case"rgba8sint":return void re(u,S,"8sint",4,b);case"r16uint":return void re(u,S,"16uint",1,b);case"r16sint":return void re(u,S,"16sint",1,b);case"r16float":return void re(u,S,"16float",1,b);case"rg16uint":return void re(u,S,"16uint",2,b);case"rg16sint":return void re(u,S,"16sint",2,b);case"rg16float":return void re(u,S,"16float",2,b);case"rgba16uint":return void re(u,S,"16uint",4,b);case"rgba16sint":return void re(u,S,"16sint",4,b);case"rgba16float":return void re(u,S,"16float",4,b);case"r32uint":return void re(u,S,"32uint",1,b);case"r32sint":return void re(u,S,"32sint",1,b);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void re(u,S,"32float",1,b);case"rg32uint":return void re(u,S,"32uint",2,b);case"rg32sint":return void re(u,S,"32sint",2,b);case"rg32float":return void re(u,S,"32float",2,b);case"rgba32uint":return void re(u,S,"32uint",4,b);case"rgba32sint":return void re(u,S,"32sint",4,b);case"rgba32float":return void re(u,S,"32float",4,b);case"rg11b10ufloat":console.error("TODO: rg11b10ufloat not supported for writing")}})(new Uint8Array(l),e,t,n,s,c,a,o,this.format,i)}};(r=>{r[r.token=0]="token",r[r.keyword=1]="keyword",r[r.reserved=2]="reserved"})(v||(v={}));var w=class{constructor(e,t,n){this.name=e,this.type=t,this.rule=n}toString(){return this.name}},p=class{};R=p,p.none=new w("",v.reserved,""),p.eof=new w("EOF",v.token,""),p.reserved={asm:new w("asm",v.reserved,"asm"),bf16:new w("bf16",v.reserved,"bf16"),do:new w("do",v.reserved,"do"),enum:new w("enum",v.reserved,"enum"),f16:new w("f16",v.reserved,"f16"),f64:new w("f64",v.reserved,"f64"),handle:new w("handle",v.reserved,"handle"),i8:new w("i8",v.reserved,"i8"),i16:new w("i16",v.reserved,"i16"),i64:new w("i64",v.reserved,"i64"),mat:new w("mat",v.reserved,"mat"),premerge:new w("premerge",v.reserved,"premerge"),regardless:new w("regardless",v.reserved,"regardless"),typedef:new w("typedef",v.reserved,"typedef"),u8:new w("u8",v.reserved,"u8"),u16:new w("u16",v.reserved,"u16"),u64:new w("u64",v.reserved,"u64"),unless:new w("unless",v.reserved,"unless"),using:new w("using",v.reserved,"using"),vec:new w("vec",v.reserved,"vec"),void:new w("void",v.reserved,"void")},p.keywords={array:new w("array",v.keyword,"array"),atomic:new w("atomic",v.keyword,"atomic"),bool:new w("bool",v.keyword,"bool"),f32:new w("f32",v.keyword,"f32"),i32:new w("i32",v.keyword,"i32"),mat2x2:new w("mat2x2",v.keyword,"mat2x2"),mat2x3:new w("mat2x3",v.keyword,"mat2x3"),mat2x4:new w("mat2x4",v.keyword,"mat2x4"),mat3x2:new w("mat3x2",v.keyword,"mat3x2"),mat3x3:new w("mat3x3",v.keyword,"mat3x3"),mat3x4:new w("mat3x4",v.keyword,"mat3x4"),mat4x2:new w("mat4x2",v.keyword,"mat4x2"),mat4x3:new w("mat4x3",v.keyword,"mat4x3"),mat4x4:new w("mat4x4",v.keyword,"mat4x4"),ptr:new w("ptr",v.keyword,"ptr"),sampler:new w("sampler",v.keyword,"sampler"),sampler_comparison:new w("sampler_comparison",v.keyword,"sampler_comparison"),struct:new w("struct",v.keyword,"struct"),texture_1d:new w("texture_1d",v.keyword,"texture_1d"),texture_2d:new w("texture_2d",v.keyword,"texture_2d"),texture_2d_array:new w("texture_2d_array",v.keyword,"texture_2d_array"),texture_3d:new w("texture_3d",v.keyword,"texture_3d"),texture_cube:new w("texture_cube",v.keyword,"texture_cube"),texture_cube_array:new w("texture_cube_array",v.keyword,"texture_cube_array"),texture_multisampled_2d:new w("texture_multisampled_2d",v.keyword,"texture_multisampled_2d"),texture_storage_1d:new w("texture_storage_1d",v.keyword,"texture_storage_1d"),texture_storage_2d:new w("texture_storage_2d",v.keyword,"texture_storage_2d"),texture_storage_2d_array:new w("texture_storage_2d_array",v.keyword,"texture_storage_2d_array"),texture_storage_3d:new w("texture_storage_3d",v.keyword,"texture_storage_3d"),texture_depth_2d:new w("texture_depth_2d",v.keyword,"texture_depth_2d"),texture_depth_2d_array:new w("texture_depth_2d_array",v.keyword,"texture_depth_2d_array"),texture_depth_cube:new w("texture_depth_cube",v.keyword,"texture_depth_cube"),texture_depth_cube_array:new w("texture_depth_cube_array",v.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new w("texture_depth_multisampled_2d",v.keyword,"texture_depth_multisampled_2d"),texture_external:new w("texture_external",v.keyword,"texture_external"),u32:new w("u32",v.keyword,"u32"),vec2:new w("vec2",v.keyword,"vec2"),vec3:new w("vec3",v.keyword,"vec3"),vec4:new w("vec4",v.keyword,"vec4"),bitcast:new w("bitcast",v.keyword,"bitcast"),block:new w("block",v.keyword,"block"),break:new w("break",v.keyword,"break"),case:new w("case",v.keyword,"case"),continue:new w("continue",v.keyword,"continue"),continuing:new w("continuing",v.keyword,"continuing"),default:new w("default",v.keyword,"default"),diagnostic:new w("diagnostic",v.keyword,"diagnostic"),discard:new w("discard",v.keyword,"discard"),else:new w("else",v.keyword,"else"),enable:new w("enable",v.keyword,"enable"),fallthrough:new w("fallthrough",v.keyword,"fallthrough"),false:new w("false",v.keyword,"false"),fn:new w("fn",v.keyword,"fn"),for:new w("for",v.keyword,"for"),function:new w("function",v.keyword,"function"),if:new w("if",v.keyword,"if"),let:new w("let",v.keyword,"let"),const:new w("const",v.keyword,"const"),loop:new w("loop",v.keyword,"loop"),while:new w("while",v.keyword,"while"),private:new w("private",v.keyword,"private"),read:new w("read",v.keyword,"read"),read_write:new w("read_write",v.keyword,"read_write"),return:new w("return",v.keyword,"return"),requires:new w("requires",v.keyword,"requires"),storage:new w("storage",v.keyword,"storage"),switch:new w("switch",v.keyword,"switch"),true:new w("true",v.keyword,"true"),alias:new w("alias",v.keyword,"alias"),type:new w("type",v.keyword,"type"),uniform:new w("uniform",v.keyword,"uniform"),var:new w("var",v.keyword,"var"),override:new w("override",v.keyword,"override"),workgroup:new w("workgroup",v.keyword,"workgroup"),write:new w("write",v.keyword,"write"),r8unorm:new w("r8unorm",v.keyword,"r8unorm"),r8snorm:new w("r8snorm",v.keyword,"r8snorm"),r8uint:new w("r8uint",v.keyword,"r8uint"),r8sint:new w("r8sint",v.keyword,"r8sint"),r16uint:new w("r16uint",v.keyword,"r16uint"),r16sint:new w("r16sint",v.keyword,"r16sint"),r16float:new w("r16float",v.keyword,"r16float"),rg8unorm:new w("rg8unorm",v.keyword,"rg8unorm"),rg8snorm:new w("rg8snorm",v.keyword,"rg8snorm"),rg8uint:new w("rg8uint",v.keyword,"rg8uint"),rg8sint:new w("rg8sint",v.keyword,"rg8sint"),r32uint:new w("r32uint",v.keyword,"r32uint"),r32sint:new w("r32sint",v.keyword,"r32sint"),r32float:new w("r32float",v.keyword,"r32float"),rg16uint:new w("rg16uint",v.keyword,"rg16uint"),rg16sint:new w("rg16sint",v.keyword,"rg16sint"),rg16float:new w("rg16float",v.keyword,"rg16float"),rgba8unorm:new w("rgba8unorm",v.keyword,"rgba8unorm"),rgba8unorm_srgb:new w("rgba8unorm_srgb",v.keyword,"rgba8unorm_srgb"),rgba8snorm:new w("rgba8snorm",v.keyword,"rgba8snorm"),rgba8uint:new w("rgba8uint",v.keyword,"rgba8uint"),rgba8sint:new w("rgba8sint",v.keyword,"rgba8sint"),bgra8unorm:new w("bgra8unorm",v.keyword,"bgra8unorm"),bgra8unorm_srgb:new w("bgra8unorm_srgb",v.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new w("rgb10a2unorm",v.keyword,"rgb10a2unorm"),rg11b10float:new w("rg11b10float",v.keyword,"rg11b10float"),rg32uint:new w("rg32uint",v.keyword,"rg32uint"),rg32sint:new w("rg32sint",v.keyword,"rg32sint"),rg32float:new w("rg32float",v.keyword,"rg32float"),rgba16uint:new w("rgba16uint",v.keyword,"rgba16uint"),rgba16sint:new w("rgba16sint",v.keyword,"rgba16sint"),rgba16float:new w("rgba16float",v.keyword,"rgba16float"),rgba32uint:new w("rgba32uint",v.keyword,"rgba32uint"),rgba32sint:new w("rgba32sint",v.keyword,"rgba32sint"),rgba32float:new w("rgba32float",v.keyword,"rgba32float"),static_assert:new w("static_assert",v.keyword,"static_assert")},p.tokens={decimal_float_literal:new w("decimal_float_literal",v.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?[fh]?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+[fh]?)|(-?[0-9]+[fh])/),hex_float_literal:new w("hex_float_literal",v.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+[fh]?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+[fh]?))/),int_literal:new w("int_literal",v.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new w("uint_literal",v.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new w("name",v.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new w("ident",v.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new w("and",v.token,"&"),and_and:new w("and_and",v.token,"&&"),arrow:new w("arrow ",v.token,"->"),attr:new w("attr",v.token,"@"),forward_slash:new w("forward_slash",v.token,"/"),bang:new w("bang",v.token,"!"),bracket_left:new w("bracket_left",v.token,"["),bracket_right:new w("bracket_right",v.token,"]"),brace_left:new w("brace_left",v.token,"{"),brace_right:new w("brace_right",v.token,"}"),colon:new w("colon",v.token,":"),comma:new w("comma",v.token,","),equal:new w("equal",v.token,"="),equal_equal:new w("equal_equal",v.token,"=="),not_equal:new w("not_equal",v.token,"!="),greater_than:new w("greater_than",v.token,">"),greater_than_equal:new w("greater_than_equal",v.token,">="),shift_right:new w("shift_right",v.token,">>"),less_than:new w("less_than",v.token,"<"),less_than_equal:new w("less_than_equal",v.token,"<="),shift_left:new w("shift_left",v.token,"<<"),modulo:new w("modulo",v.token,"%"),minus:new w("minus",v.token,"-"),minus_minus:new w("minus_minus",v.token,"--"),period:new w("period",v.token,"."),plus:new w("plus",v.token,"+"),plus_plus:new w("plus_plus",v.token,"++"),or:new w("or",v.token,"|"),or_or:new w("or_or",v.token,"||"),paren_left:new w("paren_left",v.token,"("),paren_right:new w("paren_right",v.token,")"),semicolon:new w("semicolon",v.token,";"),star:new w("star",v.token,"*"),tilde:new w("tilde",v.token,"~"),underscore:new w("underscore",v.token,"_"),xor:new w("xor",v.token,"^"),plus_equal:new w("plus_equal",v.token,"+="),minus_equal:new w("minus_equal",v.token,"-="),times_equal:new w("times_equal",v.token,"*="),division_equal:new w("division_equal",v.token,"/="),modulo_equal:new w("modulo_equal",v.token,"%="),and_equal:new w("and_equal",v.token,"&="),or_equal:new w("or_equal",v.token,"|="),xor_equal:new w("xor_equal",v.token,"^="),shift_right_equal:new w("shift_right_equal",v.token,">>="),shift_left_equal:new w("shift_left_equal",v.token,"<<=")},p.simpleTokens={"@":R.tokens.attr,"{":R.tokens.brace_left,"}":R.tokens.brace_right,":":R.tokens.colon,",":R.tokens.comma,"(":R.tokens.paren_left,")":R.tokens.paren_right,";":R.tokens.semicolon},p.literalTokens={"&":R.tokens.and,"&&":R.tokens.and_and,"->":R.tokens.arrow,"/":R.tokens.forward_slash,"!":R.tokens.bang,"[":R.tokens.bracket_left,"]":R.tokens.bracket_right,"=":R.tokens.equal,"==":R.tokens.equal_equal,"!=":R.tokens.not_equal,">":R.tokens.greater_than,">=":R.tokens.greater_than_equal,">>":R.tokens.shift_right,"<":R.tokens.less_than,"<=":R.tokens.less_than_equal,"<<":R.tokens.shift_left,"%":R.tokens.modulo,"-":R.tokens.minus,"--":R.tokens.minus_minus,".":R.tokens.period,"+":R.tokens.plus,"++":R.tokens.plus_plus,"|":R.tokens.or,"||":R.tokens.or_or,"*":R.tokens.star,"~":R.tokens.tilde,_:R.tokens.underscore,"^":R.tokens.xor,"+=":R.tokens.plus_equal,"-=":R.tokens.minus_equal,"*=":R.tokens.times_equal,"/=":R.tokens.division_equal,"%=":R.tokens.modulo_equal,"&=":R.tokens.and_equal,"|=":R.tokens.or_equal,"^=":R.tokens.xor_equal,">>=":R.tokens.shift_right_equal,"<<=":R.tokens.shift_left_equal},p.regexTokens={decimal_float_literal:R.tokens.decimal_float_literal,hex_float_literal:R.tokens.hex_float_literal,int_literal:R.tokens.int_literal,uint_literal:R.tokens.uint_literal,ident:R.tokens.ident},p.storage_class=[R.keywords.function,R.keywords.private,R.keywords.workgroup,R.keywords.uniform,R.keywords.storage],p.access_mode=[R.keywords.read,R.keywords.write,R.keywords.read_write],p.sampler_type=[R.keywords.sampler,R.keywords.sampler_comparison],p.sampled_texture_type=[R.keywords.texture_1d,R.keywords.texture_2d,R.keywords.texture_2d_array,R.keywords.texture_3d,R.keywords.texture_cube,R.keywords.texture_cube_array],p.multisampled_texture_type=[R.keywords.texture_multisampled_2d],p.storage_texture_type=[R.keywords.texture_storage_1d,R.keywords.texture_storage_2d,R.keywords.texture_storage_2d_array,R.keywords.texture_storage_3d],p.depth_texture_type=[R.keywords.texture_depth_2d,R.keywords.texture_depth_2d_array,R.keywords.texture_depth_cube,R.keywords.texture_depth_cube_array,R.keywords.texture_depth_multisampled_2d],p.texture_external_type=[R.keywords.texture_external],p.any_texture_type=[...R.sampled_texture_type,...R.multisampled_texture_type,...R.storage_texture_type,...R.depth_texture_type,...R.texture_external_type],p.texel_format=[R.keywords.r8unorm,R.keywords.r8snorm,R.keywords.r8uint,R.keywords.r8sint,R.keywords.r16uint,R.keywords.r16sint,R.keywords.r16float,R.keywords.rg8unorm,R.keywords.rg8snorm,R.keywords.rg8uint,R.keywords.rg8sint,R.keywords.r32uint,R.keywords.r32sint,R.keywords.r32float,R.keywords.rg16uint,R.keywords.rg16sint,R.keywords.rg16float,R.keywords.rgba8unorm,R.keywords.rgba8unorm_srgb,R.keywords.rgba8snorm,R.keywords.rgba8uint,R.keywords.rgba8sint,R.keywords.bgra8unorm,R.keywords.bgra8unorm_srgb,R.keywords.rgb10a2unorm,R.keywords.rg11b10float,R.keywords.rg32uint,R.keywords.rg32sint,R.keywords.rg32float,R.keywords.rgba16uint,R.keywords.rgba16sint,R.keywords.rgba16float,R.keywords.rgba32uint,R.keywords.rgba32sint,R.keywords.rgba32float],p.const_literal=[R.tokens.int_literal,R.tokens.uint_literal,R.tokens.decimal_float_literal,R.tokens.hex_float_literal,R.keywords.true,R.keywords.false],p.literal_or_ident=[R.tokens.ident,R.tokens.int_literal,R.tokens.uint_literal,R.tokens.decimal_float_literal,R.tokens.hex_float_literal,R.tokens.name],p.element_count_expression=[R.tokens.int_literal,R.tokens.uint_literal,R.tokens.ident],p.template_types=[R.keywords.vec2,R.keywords.vec3,R.keywords.vec4,R.keywords.mat2x2,R.keywords.mat2x3,R.keywords.mat2x4,R.keywords.mat3x2,R.keywords.mat3x3,R.keywords.mat3x4,R.keywords.mat4x2,R.keywords.mat4x3,R.keywords.mat4x4,R.keywords.atomic,R.keywords.bitcast,...R.any_texture_type],p.attribute_name=[R.tokens.ident,R.keywords.block,R.keywords.diagnostic],p.assignment_operators=[R.tokens.equal,R.tokens.plus_equal,R.tokens.minus_equal,R.tokens.times_equal,R.tokens.division_equal,R.tokens.modulo_equal,R.tokens.and_equal,R.tokens.or_equal,R.tokens.xor_equal,R.tokens.shift_right_equal,R.tokens.shift_left_equal],p.increment_operators=[R.tokens.plus_plus,R.tokens.minus_minus];var Ra=class{constructor(e,t,n,s,i){this.type=e,this.lexeme=t,this.line=n,this.start=s,this.end=i}toString(){return this.lexeme}isTemplateType(){return p.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==p.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}},Zu=class{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=e??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new Ra(p.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if(e==`
107
107
  `)return this._line++,!0;if(this._isWhitespace(e))return!0;if(e=="/"){if(this._peekAhead()=="/"){for(;e!=`
108
108
  `;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}if(this._peekAhead()=="*"){this._advance();let o=1;for(;o>0;){if(this._isAtEnd())return!0;if(e=this._advance(),e==`
109
109
  `)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),o--,o==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),o++)}return!0}}let t=p.simpleTokens[e];if(t)return this._addToken(t),!0;let n=p.none,s=this._isAlpha(e),i=e==="_";if(this._isAlphaNumeric(e)){let o=this._peekAhead();for(;this._isAlphaNumeric(o);)e+=this._advance(),o=this._peekAhead()}if(s){let o=p.keywords[e];if(o)return this._addToken(o),!0}if(s||i)return this._addToken(p.tokens.ident),!0;for(;;){let o=this._findType(e),a=this._peekAhead();if(e=="-"&&this._tokens.length>0){if(a=="=")return this._current++,e+=a,this._addToken(p.tokens.minus_equal),!0;if(a=="-")return this._current++,e+=a,this._addToken(p.tokens.minus_minus),!0;let c=this._tokens.length-1;if((p.literal_or_ident.indexOf(this._tokens[c].type)!=-1||this._tokens[c].type==p.tokens.paren_right)&&a!=">")return this._addToken(o),!0}if(e==">"&&(a==">"||a=="=")){let c=!1,l=this._tokens.length-1;for(let u=0;u<5&&l>=0&&p.assignment_operators.indexOf(this._tokens[l].type)===-1;++u,--l)if(this._tokens[l].type===p.tokens.less_than){l>0&&this._tokens[l-1].isArrayOrTemplateType()&&(c=!0);break}if(c)return this._addToken(o),!0}if(o===p.none){let c=e,l=0,u=2;for(let f=0;f<u;++f)if(c+=this._peekAhead(f),o=this._findType(c),o!==p.none){l=f;break}if(o===p.none)return n!==p.none&&(this._current--,this._addToken(n),!0);e=c,this._current+=l+1}if(n=o,this._isAtEnd())break;e+=this._advance()}return n!==p.none&&(this._addToken(n),!0)}_findType(e){for(let n in p.regexTokens){let s=p.regexTokens[n];if(this._match(e,s.rule))return s}return p.literalTokens[e]||p.none}_match(e,t){let n=t.exec(e);return n&&n.index==0&&n[0]==e}_isAtEnd(){return this._current>=this._source.length}_isAlpha(e){return!this._isNumeric(e)&&!this._isWhitespace(e)&&e!=="_"&&e!=="."&&e!=="("&&e!==")"&&e!=="["&&e!=="]"&&e!=="{"&&e!=="}"&&e!==","&&e!==";"&&e!==":"&&e!=="="&&e!=="!"&&e!=="<"&&e!==">"&&e!=="+"&&e!=="-"&&e!=="*"&&e!=="/"&&e!=="%"&&e!=="&"&&e!=="|"&&e!=="^"&&e!=="~"&&e!=="@"&&e!=="#"&&e!=="?"&&e!=="'"&&e!=="`"&&e!=='"'&&e!=="\\"&&e!==`
110
- `&&e!=="\r"&&e!==" "&&e!=="\0"}_isNumeric(e){return e>="0"&&e<="9"}_isAlphaNumeric(e){return this._isAlpha(e)||this._isNumeric(e)||e==="_"}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){let t=this._source.substring(this._start,this._current);this._tokens.push(new wa(e,t,this._line,this._start,this._current))}};function D(r){return Array.isArray(r)||r?.buffer instanceof ArrayBuffer}var va=new Float32Array(1),A0=new Uint32Array(va.buffer),S0=new Uint32Array(va.buffer),Aa=new Int32Array(1),E0=new Float32Array(Aa.buffer),R0=new Uint32Array(Aa.buffer),Sa=new Uint32Array(1),I0=new Float32Array(Sa.buffer),P0=new Int32Array(Sa.buffer);function sm(r,e,t){if(e===t)return r;if(e==="f32"){if(t==="i32"||t==="x32")return va[0]=r,A0[0];if(t==="u32")return va[0]=r,S0[0]}else if(e==="i32"||e==="x32"){if(t==="f32")return Aa[0]=r,E0[0];if(t==="u32")return Aa[0]=r,R0[0]}else if(e==="u32"){if(t==="f32")return Sa[0]=r,I0[0];if(t==="i32"||t==="x32")return Sa[0]=r,P0[0]}return console.error(`Unsupported cast from ${e} to ${t}`),r}var $u=class{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}},Hn=class{constructor(e,t){this.align=e,this.size=t}},et=class{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Fu,this.functions=[],this._types=new Map,this._functions=new Map}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}updateAST(e){for(let t of e)t instanceof Jr&&this._functions.set(t.name,new $u(t));for(let t of e)if(t instanceof ut){let n=this.getTypeInfo(t,null);n instanceof Pt&&this.structs.push(n)}for(let t of e)if(t instanceof qs)this.aliases.push(this._getAliasInfo(t));else if(t instanceof Xs){let n=t,s=this._getAttributeNum(n.attributes,"id",0),i=n.type!=null?this.getTypeInfo(n.type,n.attributes):null;this.overrides.push(new ku(n.name,i,n.attributes,s))}else if(this._isUniformVar(t)){let n=t,s=this._getAttributeNum(n.attributes,"group",0),i=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=new $n(n.name,o,s,i,n.attributes,xr.Uniform,n.access);a.access||(a.access="read"),this.uniforms.push(a)}else if(this._isStorageVar(t)){let n=t,s=this._getAttributeNum(n.attributes,"group",0),i=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=this._isStorageTexture(o),c=new $n(n.name,o,s,i,n.attributes,a?xr.StorageTexture:xr.Storage,n.access);c.access||(c.access="read"),this.storage.push(c)}else if(this._isTextureVar(t)){let n=t,s=this._getAttributeNum(n.attributes,"group",0),i=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=this._isStorageTexture(o),c=new $n(n.name,o,s,i,n.attributes,a?xr.StorageTexture:xr.Texture,n.access);c.access||(c.access="read"),a?this.storage.push(c):this.textures.push(c)}else if(this._isSamplerVar(t)){let n=t,s=this._getAttributeNum(n.attributes,"group",0),i=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=new $n(n.name,o,s,i,n.attributes,xr.Sampler,n.access);this.samplers.push(a)}else if(t instanceof Jr){let n=this._getAttribute(t,"vertex"),s=this._getAttribute(t,"fragment"),i=this._getAttribute(t,"compute"),o=n||s||i,a=new Du(t.name,o?.name,t.attributes);a.attributes=t.attributes,a.startLine=t.startLine,a.endLine=t.endLine,this.functions.push(a),this._functions.get(t.name).info=a,o&&(this._functions.get(t.name).inUse=!0,a.inUse=!0,a.resources=this._findResources(t,!!o),a.inputs=this._getInputs(t.args),a.outputs=this._getOutputs(t.returnType),this.entry[o.name].push(a)),a.arguments=t.args.map(c=>new Nu(c.name,this.getTypeInfo(c.type,c.attributes),c.attributes)),a.returnType=t.returnType?this.getTypeInfo(t.returnType,t.attributes):null}for(let t of this._functions.values())t.info&&(t.info.inUse=t.inUse,this._addCalls(t.node,t.info.calls));for(let t of this._functions.values())t.node.search(n=>{var s,i,o;if(n instanceof Ta){if(n.value)if(D(n.value))for(let a of n.value)for(let c of this.overrides)a===c.name&&((s=t.info)===null||s===void 0||s.overrides.push(c));else for(let a of this.overrides)n.value===a.name&&((i=t.info)===null||i===void 0||i.overrides.push(a))}else if(n instanceof Me)for(let a of this.overrides)n.name===a.name&&((o=t.info)===null||o===void 0||o.overrides.push(a))});for(let t of this.uniforms)this._markStructsInUse(t.type);for(let t of this.storage)this._markStructsInUse(t.type)}getStructInfo(e){for(let t of this.structs)if(t.name==e)return t;return null}getOverrideInfo(e){for(let t of this.overrides)if(t.name==e)return t;return null}_markStructsInUse(e){if(e)if(e.isStruct){if(e.inUse=!0,e.members)for(let t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{let t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var n;for(let s of e.calls){let i=(n=this._functions.get(s.name))===null||n===void 0?void 0:n.info;i&&t.add(i)}}findResource(e,t,n){if(n){for(let s of this.entry.compute)if(s.name===n){for(let i of s.resources)if(i.group==e&&i.binding==t)return i}for(let s of this.entry.vertex)if(s.name===n){for(let i of s.resources)if(i.group==e&&i.binding==t)return i}for(let s of this.entry.fragment)if(s.name===n){for(let i of s.resources)if(i.group==e&&i.binding==t)return i}}for(let s of this.uniforms)if(s.group==e&&s.binding==t)return s;for(let s of this.storage)if(s.group==e&&s.binding==t)return s;for(let s of this.textures)if(s.group==e&&s.binding==t)return s;for(let s of this.samplers)if(s.group==e&&s.binding==t)return s;return null}_findResource(e){for(let t of this.uniforms)if(t.name==e)return t;for(let t of this.storage)if(t.name==e)return t;for(let t of this.textures)if(t.name==e)return t;for(let t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){let t=this.getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){let n=[],s=this,i=[];return e.search(o=>{if(o instanceof qn)i.push({});else if(o instanceof Kn)i.pop();else if(o instanceof ht){let a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),i.length>0&&(i[i.length-1][a.name]=a)}else if(o instanceof Je){let a=o;t&&a.type!==null&&this._markStructsFromAST(a.type)}else if(o instanceof Gr){let a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),i.length>0&&(i[i.length-1][a.name]=a)}else if(o instanceof Me){let a=o;if(i.length>0&&i[i.length-1][a.name])return;let c=s._findResource(a.name);c&&n.push(c)}else if(o instanceof Ks){let a=o,c=s._functions.get(a.name);c&&(t&&(c.inUse=!0),e.calls.add(c.node),c.resources===null&&(c.resources=s._findResources(c.node,t)),n.push(...c.resources))}else if(o instanceof Ys){let a=o,c=s._functions.get(a.name);c&&(t&&(c.inUse=!0),e.calls.add(c.node),c.resources===null&&(c.resources=s._findResources(c.node,t)),n.push(...c.resources))}}),[...new Map(n.map(o=>[o.name,o])).values()]}getBindGroups(){let e=[];function t(n,s){n>=e.length&&(e.length=n+1),e[n]===void 0&&(e[n]=[]),s>=e[n].length&&(e[n].length=s+1)}for(let n of this.uniforms)t(n.group,n.binding),e[n.group][n.binding]=n;for(let n of this.storage)t(n.group,n.binding),e[n.group][n.binding]=n;for(let n of this.textures)t(n.group,n.binding),e[n.group][n.binding]=n;for(let n of this.samplers)t(n.group,n.binding),e[n.group][n.binding]=n;return e}_getOutputs(e,t=void 0){if(t===void 0&&(t=[]),e instanceof ut)this._getStructOutputs(e,t);else{let n=this._getOutputInfo(e);n!==null&&t.push(n)}return t}_getStructOutputs(e,t){for(let n of e.members)if(n.type instanceof ut)this._getStructOutputs(n.type,t);else{let s=this._getAttribute(n,"location")||this._getAttribute(n,"builtin");if(s!==null){let i=this.getTypeInfo(n.type,n.type.attributes),o=this._parseInt(s.value),a=new ea(n.name,i,s.name,o);t.push(a)}}}_getOutputInfo(e){let t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){let n=this.getTypeInfo(e,e.attributes),s=this._parseInt(t.value);return new ea("",n,t.name,s)}return null}_getInputs(e,t=void 0){t===void 0&&(t=[]);for(let n of e)if(n.type instanceof ut)this._getStructInputs(n.type,t);else{let s=this._getInputInfo(n);s!==null&&t.push(s)}return t}_getStructInputs(e,t){for(let n of e.members)if(n.type instanceof ut)this._getStructInputs(n.type,t);else{let s=this._getInputInfo(n);s!==null&&t.push(s)}}_getInputInfo(e){let t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){let n=this._getAttribute(e,"interpolation"),s=this.getTypeInfo(e.type,e.attributes),i=this._parseInt(t.value),o=new Ou(e.name,s,t.name,i);return n!==null&&(o.interpolation=this._parseString(n.value)),o}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);let t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(let t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new Mu(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(let t of this.structs)if(t.name==e)return t;for(let t of this.aliases)if(t.name==e)return t.type;return null}getTypeInfo(e,t=null){if(this._types.has(e))return this._types.get(e);if(e instanceof Qr){let s=e,i=s.format?this.getTypeInfo(s.format,s.attributes):null,o=new Ct(s.name,t);return o.format=i,o.count=s.count,this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof ut){let s=e,i=new Pt(s.name,t);i.startLine=s.startLine,i.endLine=s.endLine;for(let o of s.members){let a=this.getTypeInfo(o.type,o.attributes);i.members.push(new Jo(o.name,a,o.attributes))}return this._types.set(e,i),this._updateTypeInfo(i),i}if(e instanceof Zr){let s=e,i=s.format instanceof M,o=s.format?i?this.getTypeInfo(s.format,null):new Le(s.format,null):null,a=new Zt(s.name,o,t,s.access);return this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof A){let s=e,i=s.format?this.getTypeInfo(s.format,null):null,o=new Zt(s.name,i,t,s.access);return this._types.set(e,o),this._updateTypeInfo(o),o}let n=new Le(e.name,t);return this._types.set(e,n),this._updateTypeInfo(n),n}_updateTypeInfo(e){var t,n,s;let i=this._getTypeSize(e);if(e.size=(t=i?.size)!==null&&t!==void 0?t:0,e instanceof Ct&&e.format){let o=this._getTypeSize(e.format);e.stride=Math.max((n=o?.size)!==null&&n!==void 0?n:0,(s=o?.align)!==null&&s!==void 0?s:0),this._updateTypeInfo(e.format)}e instanceof Pt&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let n=0,s=0,i=0,o=0;for(let a=0,c=e.members.length;a<c;++a){let l=e.members[a],u=this._getTypeSize(l);if(!u)continue;(t=this._getAlias(l.type.name))!==null&&t!==void 0||l.type;let f=u.align,h=u.size;n=this._roundUp(f,n+s),s=h,i=n,o=Math.max(o,f),l.offset=n,l.size=h,this._updateTypeInfo(l.type)}e.size=this._roundUp(o,i+s),e.align=o}_getTypeSize(e){var t,n;if(e==null)return null;let s=this._getAttributeNum(e.attributes,"size",0),i=this._getAttributeNum(e.attributes,"align",0);if(e instanceof Jo&&(e=e.type),e instanceof Le){let o=this._getAlias(e.name);o!==null&&(e=o)}{let o=et._typeInfo[e.name];if(o!==void 0){let a=((t=e.format)===null||t===void 0?void 0:t.name)==="f16"?2:1;return new Hn(Math.max(i,o.align/a),Math.max(s,o.size/a))}}{let o=et._typeInfo[e.name.substring(0,e.name.length-1)];if(o){let a=e.name[e.name.length-1]==="h"?2:1;return new Hn(Math.max(i,o.align/a),Math.max(s,o.size/a))}}if(e instanceof Ct){let o=e,a=8,c=8,l=this._getTypeSize(o.format);return l!==null&&(c=l.size,a=l.align),c=o.count*this._getAttributeNum((n=e?.attributes)!==null&&n!==void 0?n:null,"stride",this._roundUp(a,c)),s&&(c=s),new Hn(Math.max(i,a),Math.max(s,c))}if(e instanceof Pt){let o=0,a=0,c=0,l=0,u=0;for(let f of e.members){let h=this._getTypeSize(f.type);h!==null&&(o=Math.max(h.align,o),c=this._roundUp(h.align,c+l),l=h.size,u=c)}return a=this._roundUp(o,u+l),new Hn(Math.max(i,o),Math.max(s,a))}return null}_isUniformVar(e){return e instanceof ht&&e.storage=="uniform"}_isStorageVar(e){return e instanceof ht&&e.storage=="storage"}_isTextureVar(e){return e instanceof ht&&e.type!==null&&et._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof ht&&e.type!==null&&et._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,t){let n=e;if(!n||!n.attributes)return null;let s=n.attributes;for(let i of s)if(i.name==t)return i;return null}_getAttributeNum(e,t,n){if(e===null)return n;for(let s of e)if(s.name==t){let i=s!==null&&s.value!==null?s.value:n;return i instanceof Array&&(i=i[0]),typeof i=="number"?i:typeof i=="string"?parseInt(i):n}return n}_roundUp(e,t){return Math.ceil(t/e)*e}};et._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}},et._textureTypes=p.any_texture_type.map(r=>r.name),et._samplerTypes=p.sampler_type.map(r=>r.name);var Gs=class{constructor(e,t,n){this.name=e,this.value=t,this.node=n}clone(){return new Gs(this.name,this.value,this.node)}},Qs=class{constructor(e){this.name=e.name,this.node=e}clone(){return new Qs(this.node)}},Js=class{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var t;return this.variables.has(e)?(t=this.variables.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var t;return this.functions.has(e)?(t=this.functions.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getFunction(e):null}createVariable(e,t,n){this.variables.set(e,new Gs(e,t,n??null))}setVariable(e,t,n){let s=this.getVariable(e);s!==null?s.value=t:this.createVariable(e,t,n)}getVariableValue(e){var t;let n=this.getVariable(e);return(t=n?.value)!==null&&t!==void 0?t:null}clone(){return new Js(this)}},ju=class{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}},Hu=class{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,t){let n=this.exec.evalExpression(e.args[0],t),s=!0;if(n instanceof g)return n.data.forEach(i=>{i||(s=!1)}),new T(s?1:0,this.getTypeInfo("bool"));throw new Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g){let s=n.data.some(i=>i);return new T(s?1:0,this.getTypeInfo("bool"))}throw new Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,t){let n=this.exec.evalExpression(e.args[2],t);if(!(n instanceof T))throw new Error(`Select() expects a bool condition. Line ${e.line}`);return n.value?this.exec.evalExpression(e.args[1],t):this.exec.evalExpression(e.args[0],t)}ArrayLength(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.evalExpression(n,t);if(s instanceof ce&&s.typeInfo.size===0){let i=s.typeInfo,o=s.buffer.byteLength/i.stride;return new T(o,this.getTypeInfo("u32"))}return new T(s.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.abs(i)),n.typeInfo);let s=n;return new T(Math.abs(s.value),s.typeInfo)}Acos(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.acos(i)),n.typeInfo);let s=n;return new T(Math.acos(s.value),n.typeInfo)}Acosh(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.acosh(i)),n.typeInfo);let s=n;return new T(Math.acosh(s.value),n.typeInfo)}Asin(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.asin(i)),n.typeInfo);let s=n;return new T(Math.asin(s.value),n.typeInfo)}Asinh(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.asinh(i)),n.typeInfo);let s=n;return new T(Math.asinh(s.value),n.typeInfo)}Atan(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.atan(i)),n.typeInfo);let s=n;return new T(Math.atan(s.value),n.typeInfo)}Atanh(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.atanh(i)),n.typeInfo);let s=n;return new T(Math.atanh(s.value),n.typeInfo)}Atan2(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g)return new g(n.data.map((a,c)=>Math.atan2(a,s.data[c])),n.typeInfo);let i=n,o=s;return new T(Math.atan2(i.value,o.value),n.typeInfo)}Ceil(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.ceil(i)),n.typeInfo);let s=n;return new T(Math.ceil(s.value),n.typeInfo)}_clamp(e,t,n){return Math.min(Math.max(e,t),n)}Clamp(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof g&&s instanceof g&&i instanceof g)return new g(n.data.map((l,u)=>this._clamp(l,s.data[u],i.data[u])),n.typeInfo);let o=n,a=s,c=i;return new T(this._clamp(o.value,a.value,c.value),n.typeInfo)}Cos(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.cos(i)),n.typeInfo);let s=n;return new T(Math.cos(s.value),n.typeInfo)}Cosh(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.cosh(i)),n.typeInfo);let s=n;return new T(Math.cos(s.value),n.typeInfo)}CountLeadingZeros(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.clz32(i)),n.typeInfo);let s=n;return new T(Math.clz32(s.value),n.typeInfo)}_countOneBits(e){let t=0;for(;e!==0;)1&e&&t++,e>>=1;return t}CountOneBits(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>this._countOneBits(i)),n.typeInfo);let s=n;return new T(this._countOneBits(s.value),n.typeInfo)}_countTrailingZeros(e){if(e===0)return 32;let t=0;for(;!(1&e);)e>>=1,t++;return t}CountTrailingZeros(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>this._countTrailingZeros(i)),n.typeInfo);let s=n;return new T(this._countTrailingZeros(s.value),n.typeInfo)}Cross(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g){if(n.data.length!==3||s.data.length!==3)return console.error(`Cross() expects 3D vectors. Line ${e.line}`),null;let i=n.data,o=s.data;return new g([i[1]*o[2]-o[1]*i[2],i[2]*o[0]-o[2]*i[0],i[0]*o[1]-o[0]*i[1]],n.typeInfo)}return console.error(`Cross() expects vector arguments. Line ${e.line}`),null}Degrees(e,t){let n=this.exec.evalExpression(e.args[0],t),s=180/Math.PI;return n instanceof g?new g(n.data.map(i=>i*s),n.typeInfo):new T(n.value*s,this.getTypeInfo("f32"))}Determinant(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof z){let s=n.data,i=n.typeInfo.getTypeName(),o=i.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if(i==="mat2x2"||i==="mat2x2f"||i==="mat2x2h")return new T(s[0]*s[3]-s[1]*s[2],o);if(i==="mat2x3"||i==="mat2x3f"||i==="mat2x3h")return new T(s[0]*(s[4]*s[8]-s[5]*s[7])-s[1]*(s[3]*s[8]-s[5]*s[6])+s[2]*(s[3]*s[7]-s[4]*s[6]),o);if(i==="mat2x4"||i==="mat2x4f"||i==="mat2x4h")console.error(`TODO: Determinant for ${i}`);else if(i==="mat3x2"||i==="mat3x2f"||i==="mat3x2h")console.error(`TODO: Determinant for ${i}`);else{if(i==="mat3x3"||i==="mat3x3f"||i==="mat3x3h")return new T(s[0]*(s[4]*s[8]-s[5]*s[7])-s[1]*(s[3]*s[8]-s[5]*s[6])+s[2]*(s[3]*s[7]-s[4]*s[6]),o);i==="mat3x4"||i==="mat3x4f"||i==="mat3x4h"||i==="mat4x2"||i==="mat4x2f"||i==="mat4x2h"||i==="mat4x3"||i==="mat4x3f"||i==="mat4x3h"?console.error(`TODO: Determinant for ${i}`):i!=="mat4x4"&&i!=="mat4x4f"&&i!=="mat4x4h"||console.error(`TODO: Determinant for ${i}`)}}return console.error(`Determinant expects a matrix argument. Line ${e.line}`),null}Distance(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g){let a=0;for(let c=0;c<n.data.length;++c)a+=(n.data[c]-s.data[c])*(n.data[c]-s.data[c]);return new T(Math.sqrt(a),this.getTypeInfo("f32"))}let i=n,o=s;return new T(Math.abs(i.value-o.value),n.typeInfo)}_dot(e,t){let n=0;for(let s=0;s<e.length;++s)n+=t[s]*e[s];return n}Dot(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);return n instanceof g&&s instanceof g?new T(this._dot(n.data,s.data),this.getTypeInfo("f32")):(console.error(`Dot() expects vector arguments. Line ${e.line}`),null)}Dot4U8Packed(e,t){return console.error(`TODO: dot4U8Packed. Line ${e.line}`),null}Dot4I8Packed(e,t){return console.error(`TODO: dot4I8Packed. Line ${e.line}`),null}Exp(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.exp(i)),n.typeInfo);let s=n;return new T(Math.exp(s.value),n.typeInfo)}Exp2(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.pow(2,i)),n.typeInfo);let s=n;return new T(Math.pow(2,s.value),n.typeInfo)}ExtractBits(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(s.typeInfo.name!=="u32"&&s.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 offset argument. Line ${e.line}`),null;if(i.typeInfo.name!=="u32"&&i.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 count argument. Line ${e.line}`),null;let o=s.value,a=i.value;if(n instanceof g)return new g(n.data.map(l=>l>>o&(1<<a)-1),n.typeInfo);if(n.typeInfo.name!=="i32"&&n.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 argument. Line ${e.line}`),null;let c=n.value;return new T(c>>o&(1<<a)-1,this.getTypeInfo("i32"))}FaceForward(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof g&&s instanceof g&&i instanceof g){let o=this._dot(s.data,i.data);return new g(o<0?Array.from(n.data):n.data.map(a=>-a),n.typeInfo)}return console.error(`FaceForward() expects vector arguments. Line ${e.line}`),null}_firstLeadingBit(e){return e===0?-1:31-Math.clz32(e)}FirstLeadingBit(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>this._firstLeadingBit(i)),n.typeInfo);let s=n;return new T(this._firstLeadingBit(s.value),n.typeInfo)}_firstTrailingBit(e){return e===0?-1:Math.log2(e&-e)}FirstTrailingBit(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>this._firstTrailingBit(i)),n.typeInfo);let s=n;return new T(this._firstTrailingBit(s.value),n.typeInfo)}Floor(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.floor(i)),n.typeInfo);let s=n;return new T(Math.floor(s.value),n.typeInfo)}Fma(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof g&&s instanceof g&&i instanceof g)return n.data.length!==s.data.length||n.data.length!==i.data.length?(console.error(`Fma() expects vectors of the same length. Line ${e.line}`),null):new g(n.data.map((l,u)=>l*s.data[u]+i.data[u]),n.typeInfo);let o=n,a=s,c=i;return new T(o.value*a.value+c.value,o.typeInfo)}Fract(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>i-Math.floor(i)),n.typeInfo);let s=n;return new T(s.value-Math.floor(s.value),n.typeInfo)}Frexp(e,t){return console.error(`TODO: frexp. Line ${e.line}`),null}InsertBits(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t),o=this.exec.evalExpression(e.args[3],t);if(i.typeInfo.name!=="u32"&&i.typeInfo.name!=="x32")return console.error(`InsertBits() expects an i32 offset argument. Line ${e.line}`),null;let a=i.value,c=(1<<o.value)-1<<a,l=~c;if(n instanceof g&&s instanceof g)return new g(n.data.map((h,d)=>h&l|s.data[d]<<a&c),n.typeInfo);let u=n.value,f=s.value;return new T(u&l|f<<a&c,n.typeInfo)}InverseSqrt(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>1/Math.sqrt(i)),n.typeInfo);let s=n;return new T(1/Math.sqrt(s.value),n.typeInfo)}Ldexp(e,t){return console.error(`TODO: ldexp. Line ${e.line}`),null}Length(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g){let i=0;return n.data.forEach(o=>{i+=o*o}),new T(Math.sqrt(i),this.getTypeInfo("f32"))}let s=n;return new T(Math.abs(s.value),n.typeInfo)}Log(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.log(i)),n.typeInfo);let s=n;return new T(Math.log(s.value),n.typeInfo)}Log2(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.log2(i)),n.typeInfo);let s=n;return new T(Math.log2(s.value),n.typeInfo)}Max(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g)return new g(n.data.map((a,c)=>Math.max(a,s.data[c])),n.typeInfo);let i=n,o=s;return new T(Math.max(i.value,o.value),n.typeInfo)}Min(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g)return new g(n.data.map((a,c)=>Math.min(a,s.data[c])),n.typeInfo);let i=n,o=s;return new T(Math.min(i.value,o.value),n.typeInfo)}Mix(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof g&&s instanceof g&&i instanceof g)return new g(n.data.map((c,l)=>n.data[l]*(1-i.data[l])+s.data[l]*i.data[l]),n.typeInfo);let o=s,a=i;return new T(n.value*(1-a.value)+o.value*a.value,n.typeInfo)}Modf(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g)return new g(n.data.map((o,a)=>o%s.data[a]),n.typeInfo);let i=s;return new T(n.value%i.value,n.typeInfo)}Normalize(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g){let s=this.Length(e,t).value;return new g(n.data.map(i=>i/s),n.typeInfo)}return console.error(`Normalize() expects a vector argument. Line ${e.line}`),null}Pow(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g)return new g(n.data.map((a,c)=>Math.pow(a,s.data[c])),n.typeInfo);let i=n,o=s;return new T(Math.pow(i.value,o.value),n.typeInfo)}QuantizeToF16(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof g?new g(n.data.map(s=>s),n.typeInfo):new T(n.value,n.typeInfo)}Radians(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof g?new g(n.data.map(s=>s*Math.PI/180),n.typeInfo):new T(n.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g){let i=this._dot(n.data,s.data);return new g(n.data.map((o,a)=>o-2*i*s.data[a]),n.typeInfo)}return console.error(`Reflect() expects vector arguments. Line ${e.line}`),null}Refract(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof g&&s instanceof g&&i instanceof T){let o=this._dot(s.data,n.data);return new g(n.data.map((a,c)=>{let l=1-i.value*i.value*(1-o*o);if(l<0)return 0;let u=Math.sqrt(l);return i.value*a-(i.value*o+u)*s.data[c]}),n.typeInfo)}return console.error(`Refract() expects vector arguments and a scalar argument. Line ${e.line}`),null}ReverseBits(e,t){return console.error(`TODO: reverseBits. Line ${e.line}`),null}Round(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.round(i)),n.typeInfo);let s=n;return new T(Math.round(s.value),n.typeInfo)}Saturate(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.min(Math.max(i,0),1)),n.typeInfo);let s=n;return new T(Math.min(Math.max(s.value,0),1),n.typeInfo)}Sign(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.sign(i)),n.typeInfo);let s=n;return new T(Math.sign(s.value),n.typeInfo)}Sin(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.sin(i)),n.typeInfo);let s=n;return new T(Math.sin(s.value),n.typeInfo)}Sinh(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.sinh(i)),n.typeInfo);let s=n;return new T(Math.sinh(s.value),n.typeInfo)}_smoothstep(e,t,n){let s=Math.min(Math.max((n-e)/(t-e),0),1);return s*s*(3-2*s)}SmoothStep(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&n instanceof g&&s instanceof g)return new g(i.data.map((l,u)=>this._smoothstep(n.data[u],s.data[u],l)),i.typeInfo);let o=n,a=s,c=i;return new T(this._smoothstep(o.value,a.value,c.value),i.typeInfo)}Sqrt(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.sqrt(i)),n.typeInfo);let s=n;return new T(Math.sqrt(s.value),n.typeInfo)}Step(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(s instanceof g&&n instanceof g)return new g(s.data.map((o,a)=>o<n.data[a]?0:1),s.typeInfo);let i=n;return new T(s.value<i.value?0:1,i.typeInfo)}Tan(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.tan(i)),n.typeInfo);let s=n;return new T(Math.tan(s.value),n.typeInfo)}Tanh(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.tanh(i)),n.typeInfo);let s=n;return new T(Math.tanh(s.value),n.typeInfo)}_getTransposeType(e){let t=e.getTypeName();return t==="mat2x2f"||t==="mat2x2h"?e:t==="mat2x3f"?this.getTypeInfo("mat3x2f"):t==="mat2x3h"?this.getTypeInfo("mat3x2h"):t==="mat2x4f"?this.getTypeInfo("mat4x2f"):t==="mat2x4h"?this.getTypeInfo("mat4x2h"):t==="mat3x2f"?this.getTypeInfo("mat2x3f"):t==="mat3x2h"?this.getTypeInfo("mat2x3h"):t==="mat3x3f"||t==="mat3x3h"?e:t==="mat3x4f"?this.getTypeInfo("mat4x3f"):t==="mat3x4h"?this.getTypeInfo("mat4x3h"):t==="mat4x2f"?this.getTypeInfo("mat2x4f"):t==="mat4x2h"?this.getTypeInfo("mat2x4h"):t==="mat4x3f"?this.getTypeInfo("mat3x4f"):t==="mat4x3h"?this.getTypeInfo("mat3x4h"):(t==="mat4x4f"||t==="mat4x4h"||console.error(`Invalid matrix type ${t}`),e)}Transpose(e,t){let n=this.exec.evalExpression(e.args[0],t);if(!(n instanceof z))return console.error(`Transpose() expects a matrix argument. Line ${e.line}`),null;let s=this._getTransposeType(n.typeInfo);if(n.typeInfo.name==="mat2x2"||n.typeInfo.name==="mat2x2f"||n.typeInfo.name==="mat2x2h"){let i=n.data;return new z([i[0],i[2],i[1],i[3]],s)}if(n.typeInfo.name==="mat2x3"||n.typeInfo.name==="mat2x3f"||n.typeInfo.name==="mat2x3h"){let i=n.data;return new z([i[0],i[3],i[6],i[1],i[4],i[7]],s)}if(n.typeInfo.name==="mat2x4"||n.typeInfo.name==="mat2x4f"||n.typeInfo.name==="mat2x4h"){let i=n.data;return new z([i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13]],s)}if(n.typeInfo.name==="mat3x2"||n.typeInfo.name==="mat3x2f"||n.typeInfo.name==="mat3x2h"){let i=n.data;return new z([i[0],i[3],i[1],i[4],i[2],i[5]],s)}if(n.typeInfo.name==="mat3x3"||n.typeInfo.name==="mat3x3f"||n.typeInfo.name==="mat3x3h"){let i=n.data;return new z([i[0],i[3],i[6],i[1],i[4],i[7],i[2],i[5],i[8]],s)}if(n.typeInfo.name==="mat3x4"||n.typeInfo.name==="mat3x4f"||n.typeInfo.name==="mat3x4h"){let i=n.data;return new z([i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13],i[2],i[6],i[10],i[14]],s)}if(n.typeInfo.name==="mat4x2"||n.typeInfo.name==="mat4x2f"||n.typeInfo.name==="mat4x2h"){let i=n.data;return new z([i[0],i[4],i[1],i[5],i[2],i[6]],s)}if(n.typeInfo.name==="mat4x3"||n.typeInfo.name==="mat4x3f"||n.typeInfo.name==="mat4x3h"){let i=n.data;return new z([i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]],s)}if(n.typeInfo.name==="mat4x4"||n.typeInfo.name==="mat4x4f"||n.typeInfo.name==="mat4x4h"){let i=n.data;return new z([i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13],i[2],i[6],i[10],i[14],i[3],i[7],i[11],i[15]],s)}return console.error(`Invalid matrix type ${n.typeInfo.name}`),null}Trunc(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.trunc(i)),n.typeInfo);let s=n;return new T(Math.trunc(s.value),n.typeInfo)}Dpdx(e,t){return console.error(`TODO: dpdx. Line ${e.line}`),null}DpdxCoarse(e,t){return console.error(`TODO: dpdxCoarse. Line ${e.line}`),null}DpdxFine(e,t){return console.error("TODO: dpdxFine"),null}Dpdy(e,t){return console.error("TODO: dpdy"),null}DpdyCoarse(e,t){return console.error("TODO: dpdyCoarse"),null}DpdyFine(e,t){return console.error("TODO: dpdyFine"),null}Fwidth(e,t){return console.error("TODO: fwidth"),null}FwidthCoarse(e,t){return console.error("TODO: fwidthCoarse"),null}FwidthFine(e,t){return console.error("TODO: fwidthFine"),null}TextureDimensions(e,t){let n=e.args[0],s=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(n instanceof Me){let i=n.name,o=t.getVariableValue(i);if(o instanceof ft){if(s<0||s>=o.mipLevelCount)return console.error(`Invalid mip level for textureDimensions. Line ${e.line}`),null;let a=o.getMipLevelSize(s),c=o.dimension;return c==="1d"?new T(a[0],this.getTypeInfo("u32")):c==="3d"?new g(a,this.getTypeInfo("vec3u")):c==="2d"?new g(a.slice(0,2),this.getTypeInfo("vec2u")):(console.error(`Invalid texture dimension ${c} not found. Line ${e.line}`),null)}return console.error(`Texture ${i} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureDimensions. Line ${e.line}`),null}TextureGather(e,t){return console.error("TODO: textureGather"),null}TextureGatherCompare(e,t){return console.error("TODO: textureGatherCompare"),null}TextureLoad(e,t){let n=e.args[0],s=this.exec.evalExpression(e.args[1],t),i=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(s instanceof g)||s.data.length!==2)return console.error(`Invalid UV argument for textureLoad. Line ${e.line}`),null;if(n instanceof Me){let o=n.name,a=t.getVariableValue(o);if(a instanceof ft){let c=Math.floor(s.data[0]),l=Math.floor(s.data[1]);if(c<0||c>=a.width||l<0||l>=a.height)return console.error(`Texture ${o} out of bounds. Line ${e.line}`),null;let u=a.getPixel(c,l,0,i);return u===null?(console.error(`Invalid texture format for textureLoad. Line ${e.line}`),null):new g(u,this.getTypeInfo("vec4f"))}return console.error(`Texture ${o} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureLoad. Line ${e.line}`),null}TextureNumLayers(e,t){let n=e.args[0];if(n instanceof Me){let s=n.name,i=t.getVariableValue(s);return i instanceof ft?new T(i.depthOrArrayLayers,this.getTypeInfo("u32")):(console.error(`Texture ${s} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLayers. Line ${e.line}`),null}TextureNumLevels(e,t){let n=e.args[0];if(n instanceof Me){let s=n.name,i=t.getVariableValue(s);return i instanceof ft?new T(i.mipLevelCount,this.getTypeInfo("u32")):(console.error(`Texture ${s} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLevels. Line ${e.line}`),null}TextureNumSamples(e,t){let n=e.args[0];if(n instanceof Me){let s=n.name,i=t.getVariableValue(s);return i instanceof ft?new T(i.sampleCount,this.getTypeInfo("u32")):(console.error(`Texture ${s} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumSamples. Line ${e.line}`),null}TextureSample(e,t){return console.error("TODO: textureSample"),null}TextureSampleBias(e,t){return console.error("TODO: textureSampleBias"),null}TextureSampleCompare(e,t){return console.error("TODO: textureSampleCompare"),null}TextureSampleCompareLevel(e,t){return console.error("TODO: textureSampleCompareLevel"),null}TextureSampleGrad(e,t){return console.error("TODO: textureSampleGrad"),null}TextureSampleLevel(e,t){return console.error("TODO: textureSampleLevel"),null}TextureSampleBaseClampToEdge(e,t){return console.error("TODO: textureSampleBaseClampToEdge"),null}TextureStore(e,t){let n=e.args[0],s=this.exec.evalExpression(e.args[1],t),i=e.args.length===4?this.exec.evalExpression(e.args[2],t).value:0,o=e.args.length===4?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(o.length!==4)return console.error(`Invalid value argument for textureStore. Line ${e.line}`),null;if(!(s instanceof g)||s.data.length!==2)return console.error(`Invalid UV argument for textureStore. Line ${e.line}`),null;if(n instanceof Me){let a=n.name,c=t.getVariableValue(a);if(c instanceof ft){let l=c.getMipLevelSize(0),u=Math.floor(s.data[0]),f=Math.floor(s.data[1]);return u<0||u>=l[0]||f<0||f>=l[1]?(console.error(`Texture ${a} out of bounds. Line ${e.line}`),null):(c.setPixel(u,f,0,i,Array.from(o)),null)}return console.error(`Texture ${a} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureStore. Line ${e.line}`),null}AtomicLoad(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t);return t.getVariable(s).value.getSubData(this.exec,n.postfix,t)}AtomicStore(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t);return c instanceof T&&a instanceof T&&(c.value=a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),null}AtomicAdd(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value+=a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicSub(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value-=a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicMax(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value=Math.max(c.value,a.value)),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicMin(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value=Math.min(c.value,a.value)),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicAnd(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value=c.value&a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicOr(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value=c.value|a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicXor(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value=c.value^a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicExchange(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value=a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicCompareExchangeWeak(e,t){return console.error("TODO: atomicCompareExchangeWeak"),null}Pack4x8snorm(e,t){return console.error("TODO: pack4x8snorm"),null}Pack4x8unorm(e,t){return console.error("TODO: pack4x8unorm"),null}Pack4xI8(e,t){return console.error("TODO: pack4xI8"),null}Pack4xU8(e,t){return console.error("TODO: pack4xU8"),null}Pack4x8Clamp(e,t){return console.error("TODO: pack4x8Clamp"),null}Pack4xU8Clamp(e,t){return console.error("TODO: pack4xU8Clamp"),null}Pack2x16snorm(e,t){return console.error("TODO: pack2x16snorm"),null}Pack2x16unorm(e,t){return console.error("TODO: pack2x16unorm"),null}Pack2x16float(e,t){return console.error("TODO: pack2x16float"),null}Unpack4x8snorm(e,t){return console.error("TODO: unpack4x8snorm"),null}Unpack4x8unorm(e,t){return console.error("TODO: unpack4x8unorm"),null}Unpack4xI8(e,t){return console.error("TODO: unpack4xI8"),null}Unpack4xU8(e,t){return console.error("TODO: unpack4xU8"),null}Unpack2x16snorm(e,t){return console.error("TODO: unpack2x16snorm"),null}Unpack2x16unorm(e,t){return console.error("TODO: unpack2x16unorm"),null}Unpack2x16float(e,t){return console.error("TODO: unpack2x16float"),null}StorageBarrier(e,t){return null}TextureBarrier(e,t){return null}WorkgroupBarrier(e,t){return null}WorkgroupUniformLoad(e,t){return null}SubgroupAdd(e,t){return console.error("TODO: subgroupAdd"),null}SubgroupExclusiveAdd(e,t){return console.error("TODO: subgroupExclusiveAdd"),null}SubgroupInclusiveAdd(e,t){return console.error("TODO: subgroupInclusiveAdd"),null}SubgroupAll(e,t){return console.error("TODO: subgroupAll"),null}SubgroupAnd(e,t){return console.error("TODO: subgroupAnd"),null}SubgroupAny(e,t){return console.error("TODO: subgroupAny"),null}SubgroupBallot(e,t){return console.error("TODO: subgroupBallot"),null}SubgroupBroadcast(e,t){return console.error("TODO: subgroupBroadcast"),null}SubgroupBroadcastFirst(e,t){return console.error("TODO: subgroupBroadcastFirst"),null}SubgroupElect(e,t){return console.error("TODO: subgroupElect"),null}SubgroupMax(e,t){return console.error("TODO: subgroupMax"),null}SubgroupMin(e,t){return console.error("TODO: subgroupMin"),null}SubgroupMul(e,t){return console.error("TODO: subgroupMul"),null}SubgroupExclusiveMul(e,t){return console.error("TODO: subgroupExclusiveMul"),null}SubgroupInclusiveMul(e,t){return console.error("TODO: subgroupInclusiveMul"),null}SubgroupOr(e,t){return console.error("TODO: subgroupOr"),null}SubgroupShuffle(e,t){return console.error("TODO: subgroupShuffle"),null}SubgroupShuffleDown(e,t){return console.error("TODO: subgroupShuffleDown"),null}SubgroupShuffleUp(e,t){return console.error("TODO: subgroupShuffleUp"),null}SubgroupShuffleXor(e,t){return console.error("TODO: subgroupShuffleXor"),null}SubgroupXor(e,t){return console.error("TODO: subgroupXor"),null}QuadBroadcast(e,t){return console.error("TODO: quadBroadcast"),null}QuadSwapDiagonal(e,t){return console.error("TODO: quadSwapDiagonal"),null}QuadSwapX(e,t){return console.error("TODO: quadSwapX"),null}QuadSwapY(e,t){return console.error("TODO: quadSwapY"),null}},Cu={vec2:2,vec2f:2,vec2i:2,vec2u:2,vec2b:2,vec2h:2,vec3:3,vec3f:3,vec3i:3,vec3u:3,vec3b:3,vec3h:3,vec4:4,vec4f:4,vec4i:4,vec4u:4,vec4b:4,vec4h:4},Ce={mat2x2:[2,2,4],mat2x2f:[2,2,4],mat2x2h:[2,2,4],mat2x3:[2,3,6],mat2x3f:[2,3,6],mat2x3h:[2,3,6],mat2x4:[2,4,8],mat2x4f:[2,4,8],mat2x4h:[2,4,8],mat3x2:[3,2,6],mat3x2f:[3,2,6],mat3x2h:[3,2,6],mat3x3:[3,3,9],mat3x3f:[3,3,9],mat3x3h:[3,3,9],mat3x4:[3,4,12],mat3x4f:[3,4,12],mat3x4h:[3,4,12],mat4x2:[4,2,8],mat4x2f:[4,2,8],mat4x2h:[4,2,8],mat4x3:[4,3,12],mat4x3f:[4,3,12],mat4x3h:[4,3,12],mat4x4:[4,4,16],mat4x4f:[4,4,16],mat4x4h:[4,4,16]},we=class extends ju{constructor(e,t){var n;super(),this.ast=e??[],this.reflection=new et,this.reflection.updateAST(this.ast),this.context=(n=t?.clone())!==null&&n!==void 0?n:new Js,this.builtins=new Hu(this),this.typeInfo={bool:this.getTypeInfo(M.bool),i32:this.getTypeInfo(M.i32),u32:this.getTypeInfo(M.u32),f32:this.getTypeInfo(M.f32),f16:this.getTypeInfo(M.f16),vec2f:this.getTypeInfo(A.vec2f),vec2u:this.getTypeInfo(A.vec2u),vec2i:this.getTypeInfo(A.vec2i),vec2h:this.getTypeInfo(A.vec2h),vec3f:this.getTypeInfo(A.vec3f),vec3u:this.getTypeInfo(A.vec3u),vec3i:this.getTypeInfo(A.vec3i),vec3h:this.getTypeInfo(A.vec3h),vec4f:this.getTypeInfo(A.vec4f),vec4u:this.getTypeInfo(A.vec4u),vec4i:this.getTypeInfo(A.vec4i),vec4h:this.getTypeInfo(A.vec4h),mat2x2f:this.getTypeInfo(A.mat2x2f),mat2x3f:this.getTypeInfo(A.mat2x3f),mat2x4f:this.getTypeInfo(A.mat2x4f),mat3x2f:this.getTypeInfo(A.mat3x2f),mat3x3f:this.getTypeInfo(A.mat3x3f),mat3x4f:this.getTypeInfo(A.mat3x4f),mat4x2f:this.getTypeInfo(A.mat4x2f),mat4x3f:this.getTypeInfo(A.mat4x3f),mat4x4f:this.getTypeInfo(A.mat4x4f)}}getVariableValue(e){var t,n;let s=(n=(t=this.context.getVariable(e))===null||t===void 0?void 0:t.value)!==null&&n!==void 0?n:null;if(s===null)return null;if(s instanceof T)return s.value;if(s instanceof g||s instanceof z)return Array.from(s.data);if(s instanceof ce&&s.typeInfo instanceof Ct){if(s.typeInfo.format.name==="u32")return Array.from(new Uint32Array(s.buffer,s.offset,s.typeInfo.count));if(s.typeInfo.format.name==="i32")return Array.from(new Int32Array(s.buffer,s.offset,s.typeInfo.count));if(s.typeInfo.format.name==="f32")return Array.from(new Float32Array(s.buffer,s.offset,s.typeInfo.count))}return console.error(`Unsupported return variable type ${s.typeInfo.name}`),null}execute(e){(e=e??{}).constants&&this._setOverrides(e.constants,this.context),this._execStatements(this.ast,this.context)}dispatchWorkgroups(e,t,n,s){let i=this.context.clone();(s=s??{}).constants&&this._setOverrides(s.constants,i),this._execStatements(this.ast,i);let o=i.getFunction(e);if(!o)return void console.error(`Function ${e} not found`);if(typeof t=="number")t=[t,1,1];else{if(t.length===0)return void console.error("Invalid dispatch count");t.length===1?t=[t[0],1,1]:t.length===2?t=[t[0],t[1],1]:t.length>3&&(t=[t[0],t[1],t[2]])}let a=t[0],c=t[1],l=t[2],u=this.getTypeInfo("vec3u");i.setVariable("@num_workgroups",new g(t,u));for(let f in n)for(let h in n[f]){let d=n[f][h];i.variables.forEach(m=>{var y;let _=m.node;if(_?.attributes){let x=null,E=null;for(let b of _.attributes)b.name==="binding"?x=b.value:b.name==="group"&&(E=b.value);if(h==x&&f==E)if(d.texture!==void 0&&d.descriptor!==void 0){let b=new ft(d.texture,this.getTypeInfo(_.type),d.descriptor,(y=d.texture.view)!==null&&y!==void 0?y:null);m.value=b}else d.uniform!==void 0?m.value=new ce(d.uniform,this.getTypeInfo(_.type)):m.value=new ce(d,this.getTypeInfo(_.type))}})}for(let f=0;f<l;++f)for(let h=0;h<c;++h)for(let d=0;d<a;++d)i.setVariable("@workgroup_id",new g([d,h,f],this.getTypeInfo("vec3u"))),this._dispatchWorkgroup(o,[d,h,f],i)}execStatement(e,t){if(e instanceof ca)return this.evalExpression(e.value,t);if(e instanceof ua){if(e.condition){let n=this.evalExpression(e.condition,t);if(!(n instanceof T))throw new Error("Invalid break-if condition");if(!n.value)return null}return we._breakObj}if(e instanceof fa)return we._continueObj;if(e instanceof Gr)this._let(e,t);else if(e instanceof ht)this._var(e,t);else if(e instanceof Xn)this._const(e,t);else if(e instanceof Jr)this._function(e,t);else{if(e instanceof aa)return this._if(e,t);if(e instanceof oa)return this._switch(e,t);if(e instanceof ra)return this._for(e,t);if(e instanceof ta)return this._while(e,t);if(e instanceof ia)return this._loop(e,t);if(e instanceof Hs){let n=t.clone();return n.currentFunctionName=t.currentFunctionName,this._execStatements(e.body,n)}if(e instanceof sa)this._assign(e,t);else if(e instanceof na)this._increment(e,t);else{if(e instanceof ut)return null;if(e instanceof Xs){let n=e.name;t.getVariable(n)===null&&t.setVariable(n,new T(0,this.getTypeInfo("u32")))}else if(e instanceof Ys)this._call(e,t);else{if(e instanceof la||e instanceof qs)return null;console.error("Invalid statement type.",e,`Line ${e.line}`)}}}return null}evalExpression(e,t){return e instanceof He?this._evalBinaryOp(e,t):e instanceof me?this._evalLiteral(e,t):e instanceof Me?this._evalVariable(e,t):e instanceof Ks?this._evalCall(e,t):e instanceof Je?this._evalCreate(e,t):e instanceof da?this._evalConst(e,t):e instanceof pa?this._evalBitcast(e,t):e instanceof ue?this._evalUnaryOp(e,t):(console.error("Invalid expression type",e,`Line ${e.line}`),null)}getTypeInfo(e){var t;if(e instanceof M){let s=this.reflection.getTypeInfo(e);if(s!==null)return s}let n=(t=this.typeInfo[e])!==null&&t!==void 0?t:null;return n!==null||(n=this.reflection.getTypeInfoByName(e)),n}_setOverrides(e,t){for(let n in e){let s=e[n],i=this.reflection.getOverrideInfo(n);i!==null?(i.type===null&&(i.type=this.getTypeInfo("u32")),i.type.name==="u32"||i.type.name==="i32"||i.type.name==="f32"||i.type.name==="f16"?t.setVariable(n,new T(s,i.type)):i.type.name==="bool"?t.setVariable(n,new T(s?1:0,i.type)):i.type.name==="vec2"||i.type.name==="vec3"||i.type.name==="vec4"||i.type.name==="vec2f"||i.type.name==="vec3f"||i.type.name==="vec4f"||i.type.name==="vec2i"||i.type.name==="vec3i"||i.type.name==="vec4i"||i.type.name==="vec2u"||i.type.name==="vec3u"||i.type.name==="vec4u"||i.type.name==="vec2h"||i.type.name==="vec3h"||i.type.name==="vec4h"?t.setVariable(n,new g(s,i.type)):console.error(`Invalid constant type for ${n}`)):console.error(`Override ${n} does not exist in the shader.`)}}_dispatchWorkgroup(e,t,n){let s=[1,1,1];for(let u of e.node.attributes)if(u.name==="workgroup_size"){if(u.value.length>0){let f=n.getVariableValue(u.value[0]);s[0]=f instanceof T?f.value:parseInt(u.value[0])}if(u.value.length>1){let f=n.getVariableValue(u.value[1]);s[1]=f instanceof T?f.value:parseInt(u.value[1])}if(u.value.length>2){let f=n.getVariableValue(u.value[2]);s[2]=f instanceof T?f.value:parseInt(u.value[2])}}let i=this.getTypeInfo("vec3u"),o=this.getTypeInfo("u32");n.setVariable("@workgroup_size",new g(s,i));let a=s[0],c=s[1],l=s[2];for(let u=0,f=0;u<l;++u)for(let h=0;h<c;++h)for(let d=0;d<a;++d,++f){let m=[d,h,u],y=[d+t[0]*s[0],h+t[1]*s[1],u+t[2]*s[2]];n.setVariable("@local_invocation_id",new g(m,i)),n.setVariable("@global_invocation_id",new g(y,i)),n.setVariable("@local_invocation_index",new T(f,o)),this._dispatchExec(e,n)}}_dispatchExec(e,t){for(let n of e.node.args)for(let s of n.attributes)if(s.name==="builtin"){let i=`@${s.value}`,o=t.getVariable(i);o!==void 0&&t.variables.set(n.name,o)}this._execStatements(e.node.body,t)}getVariableName(e,t){for(;e instanceof ue;)e=e.right;return e instanceof Me?e.name:(console.error("Unknown variable type",e,"Line",e.line),null)}_execStatements(e,t){for(let n of e){if(n instanceof Array){let i=t.clone(),o=this._execStatements(n,i);if(o)return o;continue}let s=this.execStatement(n,t);if(s)return s}return null}_call(e,t){let n=t.clone();n.currentFunctionName=e.name;let s=t.getFunction(e.name);if(s){for(let i=0;i<s.node.args.length;++i){let o=s.node.args[i],a=this.evalExpression(e.args[i],n);n.setVariable(o.name,a,o)}this._execStatements(s.node.body,n)}else e.isBuiltin?this._callBuiltinFunction(e,n):this.getTypeInfo(e.name)&&this._evalCreate(e,t)}_increment(e,t){let n=this.getVariableName(e.variable,t),s=t.getVariable(n);s?e.operator==="++"?s.value instanceof T?s.value.value++:console.error(`Variable ${n} is not a scalar. Line ${e.line}`):e.operator==="--"?s.value instanceof T?s.value.value--:console.error(`Variable ${n} is not a scalar. Line ${e.line}`):console.error(`Unknown increment operator ${e.operator}. Line ${e.line}`):console.error(`Variable ${n} not found. Line ${e.line}`)}_getVariableData(e,t){if(e instanceof Me){let n=this.getVariableName(e,t),s=t.getVariable(n);return s===null?(console.error(`Variable ${n} not found. Line ${e.line}`),null):s.value.getSubData(this,e.postfix,t)}if(e instanceof ue){if(e.operator==="*"){let n=this._getVariableData(e.right,t);return n instanceof br?n.reference.getSubData(this,e.postfix,t):(console.error(`Variable ${e.right} is not a pointer. Line ${e.line}`),null)}if(e.operator==="&"){let n=this._getVariableData(e.right,t);return new br(n)}}return null}_assign(e,t){let n=null,s="<var>",i=null;if(e.variable instanceof ue){let c=this._getVariableData(e.variable,t),l=this.evalExpression(e.value,t),u=e.operator;if(u==="="){if(c instanceof T||c instanceof g||c instanceof z){if(l instanceof T||l instanceof g||l instanceof z&&c.data.length===l.data.length)return void c.data.set(l.data);console.error(`Invalid assignment. Line ${e.line}`)}else if(c instanceof ce&&l instanceof ce&&c.buffer.byteLength-c.offset>=l.buffer.byteLength-l.offset)return void(c.buffer.byteLength%4==0?new Uint32Array(c.buffer,c.offset,c.typeInfo.size/4).set(new Uint32Array(l.buffer,l.offset,l.typeInfo.size/4)):new Uint8Array(c.buffer,c.offset,c.typeInfo.size).set(new Uint8Array(l.buffer,l.offset,l.typeInfo.size)));return console.error(`Invalid assignment. Line ${e.line}`),null}if(u==="+=")return c instanceof T||c instanceof g||c instanceof z?l instanceof T||l instanceof g||l instanceof z?void c.data.set(l.data.map((f,h)=>c.data[h]+f)):void console.error(`Invalid assignment . Line ${e.line}`):void console.error(`Invalid assignment. Line ${e.line}`);if(u==="-=")return(c instanceof T||c instanceof g||c instanceof z)&&(l instanceof T||l instanceof g||l instanceof z)?void c.data.set(l.data.map((f,h)=>c.data[h]-f)):void console.error(`Invalid assignment. Line ${e.line}`)}if(e.variable instanceof ue){if(e.variable.operator==="*"){s=this.getVariableName(e.variable.right,t);let c=t.getVariable(s);if(!(c&&c.value instanceof br))return void console.error(`Variable ${s} is not a pointer. Line ${e.line}`);n=c.value.reference;let l=e.variable.postfix;if(!l){let u=e.variable.right;for(;u instanceof ue;){if(u.postfix){l=u.postfix;break}u=u.right}}l&&(n=n.getSubData(this,l,t))}}else{i=e.variable.postfix,s=this.getVariableName(e.variable,t);let c=t.getVariable(s);if(c===null)return void console.error(`Variable ${s} not found. Line ${e.line}`);n=c.value}if(n instanceof br&&(n=n.reference),n===null)return void console.error(`Variable ${s} not found. Line ${e.line}`);let o=this.evalExpression(e.value,t),a=e.operator;if(a==="=")if(n instanceof ce)n.setDataValue(this,o,i,t);else if(i){if(!(n instanceof g||n instanceof z))return void console.error(`Variable ${s} is not a vector or matrix. Line ${e.line}`);if(i instanceof Tr){let c=this.evalExpression(i.index,t).value;if(n instanceof g){if(!(o instanceof T))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[c]=o.value}else{if(!(n instanceof z))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);{let l=this.evalExpression(i.index,t).value;if(l<0)return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);if(!(o instanceof g))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);{let u=n.typeInfo.getTypeName();if(u==="mat2x2"||u==="mat2x2f"||u==="mat2x2h"){if(!(l<2&&o.data.length===2))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[2*l]=o.data[0],n.data[2*l+1]=o.data[1]}else if(u==="mat2x3"||u==="mat2x3f"||u==="mat2x3h"){if(!(l<2&&o.data.length===3))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[3*l]=o.data[0],n.data[3*l+1]=o.data[1],n.data[3*l+2]=o.data[2]}else if(u==="mat2x4"||u==="mat2x4f"||u==="mat2x4h"){if(!(l<2&&o.data.length===4))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[4*l]=o.data[0],n.data[4*l+1]=o.data[1],n.data[4*l+2]=o.data[2],n.data[4*l+3]=o.data[3]}else if(u==="mat3x2"||u==="mat3x2f"||u==="mat3x2h"){if(!(l<3&&o.data.length===2))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[2*l]=o.data[0],n.data[2*l+1]=o.data[1]}else if(u==="mat3x3"||u==="mat3x3f"||u==="mat3x3h"){if(!(l<3&&o.data.length===3))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[3*l]=o.data[0],n.data[3*l+1]=o.data[1],n.data[3*l+2]=o.data[2]}else if(u==="mat3x4"||u==="mat3x4f"||u==="mat3x4h"){if(!(l<3&&o.data.length===4))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[4*l]=o.data[0],n.data[4*l+1]=o.data[1],n.data[4*l+2]=o.data[2],n.data[4*l+3]=o.data[3]}else if(u==="mat4x2"||u==="mat4x2f"||u==="mat4x2h"){if(!(l<4&&o.data.length===2))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[2*l]=o.data[0],n.data[2*l+1]=o.data[1]}else if(u==="mat4x3"||u==="mat4x3f"||u==="mat4x3h"){if(!(l<4&&o.data.length===3))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[3*l]=o.data[0],n.data[3*l+1]=o.data[1],n.data[3*l+2]=o.data[2]}else{if(u!=="mat4x4"&&u!=="mat4x4f"&&u!=="mat4x4h")return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);if(!(l<4&&o.data.length===4))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[4*l]=o.data[0],n.data[4*l+1]=o.data[1],n.data[4*l+2]=o.data[2],n.data[4*l+3]=o.data[3]}}}}}else if(i instanceof Gt){let c=i.value;if(!(n instanceof g))return void console.error(`Invalid assignment to ${c}. Variable ${s} is not a vector. Line ${e.line}`);if(o instanceof T){if(c.length>1)return void console.error(`Invalid assignment to ${c} for variable ${s}. Line ${e.line}`);if(c==="x")n.data[0]=o.value;else if(c==="y"){if(n.data.length<2)return void console.error(`Invalid assignment to ${c} for variable ${s}. Line ${e.line}`);n.data[1]=o.value}else if(c==="z"){if(n.data.length<3)return void console.error(`Invalid assignment to ${c} for variable ${s}. Line ${e.line}`);n.data[2]=o.value}else if(c==="w"){if(n.data.length<4)return void console.error(`Invalid assignment to ${c} for variable ${s}. Line ${e.line}`);n.data[3]=o.value}}else{if(!(o instanceof g))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);if(c.length!==o.data.length)return void console.error(`Invalid assignment to ${c} for variable ${s}. Line ${e.line}`);for(let l=0;l<c.length;++l){let u=c[l];if(u==="x"||u==="r")n.data[0]=o.data[l];else if(u==="y"||u==="g"){if(o.data.length<2)return void console.error(`Invalid assignment to ${u} for variable ${s}. Line ${e.line}`);n.data[1]=o.data[l]}else if(u==="z"||u==="b"){if(o.data.length<3)return void console.error(`Invalid assignment to ${u} for variable ${s}. Line ${e.line}`);n.data[2]=o.data[l]}else{if(u!=="w"&&u!=="a")return void console.error(`Invalid assignment to ${u} for variable ${s}. Line ${e.line}`);if(o.data.length<4)return void console.error(`Invalid assignment to ${u} for variable ${s}. Line ${e.line}`);n.data[3]=o.data[l]}}}}}else n instanceof T&&o instanceof T?n.value=o.value:n instanceof g&&o instanceof g||n instanceof z&&o instanceof z?n.data.set(o.data):console.error(`Invalid assignment to ${s}. Line ${e.line}`);else{let c=n.getSubData(this,i,t);if(c instanceof g&&o instanceof T){let l=c.data,u=o.value;if(a==="+=")for(let f=0;f<l.length;++f)l[f]+=u;else if(a==="-=")for(let f=0;f<l.length;++f)l[f]-=u;else if(a==="*=")for(let f=0;f<l.length;++f)l[f]*=u;else if(a==="/=")for(let f=0;f<l.length;++f)l[f]/=u;else if(a==="%=")for(let f=0;f<l.length;++f)l[f]%=u;else if(a==="&=")for(let f=0;f<l.length;++f)l[f]&=u;else if(a==="|=")for(let f=0;f<l.length;++f)l[f]|=u;else if(a==="^=")for(let f=0;f<l.length;++f)l[f]^=u;else if(a==="<<=")for(let f=0;f<l.length;++f)l[f]<<=u;else if(a===">>=")for(let f=0;f<l.length;++f)l[f]>>=u;else console.error(`Invalid operator ${a}. Line ${e.line}`)}else if(c instanceof g&&o instanceof g){let l=c.data,u=o.data;if(l.length!==u.length)return void console.error(`Vector length mismatch. Line ${e.line}`);if(a==="+=")for(let f=0;f<l.length;++f)l[f]+=u[f];else if(a==="-=")for(let f=0;f<l.length;++f)l[f]-=u[f];else if(a==="*=")for(let f=0;f<l.length;++f)l[f]*=u[f];else if(a==="/=")for(let f=0;f<l.length;++f)l[f]/=u[f];else if(a==="%=")for(let f=0;f<l.length;++f)l[f]%=u[f];else if(a==="&=")for(let f=0;f<l.length;++f)l[f]&=u[f];else if(a==="|=")for(let f=0;f<l.length;++f)l[f]|=u[f];else if(a==="^=")for(let f=0;f<l.length;++f)l[f]^=u[f];else if(a==="<<=")for(let f=0;f<l.length;++f)l[f]<<=u[f];else if(a===">>=")for(let f=0;f<l.length;++f)l[f]>>=u[f];else console.error(`Invalid operator ${a}. Line ${e.line}`)}else{if(!(c instanceof T&&o instanceof T))return void console.error(`Invalid type for ${e.operator} operator. Line ${e.line}`);a==="+="?c.value+=o.value:a==="-="?c.value-=o.value:a==="*="?c.value*=o.value:a==="/="?c.value/=o.value:a==="%="?c.value%=o.value:a==="&="?c.value&=o.value:a==="|="?c.value|=o.value:a==="^="?c.value^=o.value:a==="<<="?c.value<<=o.value:a===">>="?c.value>>=o.value:console.error(`Invalid operator ${a}. Line ${e.line}`)}n instanceof ce&&n.setDataValue(this,c,i,t)}}_function(e,t){let n=new Qs(e);t.functions.set(e.name,n)}_const(e,t){let n=null;e.value!==null&&(n=this.evalExpression(e.value,t)),t.createVariable(e.name,n,e)}_let(e,t){let n=null;if(e.value!==null){if(n=this.evalExpression(e.value,t),n===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof ue||(n=n.clone())}else{let s=e.type.name;if(s==="f32"||s==="i32"||s==="u32"||s==="bool"||s==="f16"||s==="vec2"||s==="vec3"||s==="vec4"||s==="vec2f"||s==="vec3f"||s==="vec4f"||s==="vec2i"||s==="vec3i"||s==="vec4i"||s==="vec2u"||s==="vec3u"||s==="vec4u"||s==="vec2h"||s==="vec3h"||s==="vec4h"||s==="vec2b"||s==="vec3b"||s==="vec4b"||s==="mat2x2"||s==="mat2x3"||s==="mat2x4"||s==="mat3x2"||s==="mat3x3"||s==="mat3x4"||s==="mat4x2"||s==="mat4x3"||s==="mat4x4"||s==="mat2x2f"||s==="mat2x3f"||s==="mat2x4f"||s==="mat3x2f"||s==="mat3x3f"||s==="mat3x4f"||s==="mat4x2f"||s==="mat4x3f"||s==="mat4x4f"||s==="mat2x2h"||s==="mat2x3h"||s==="mat2x4h"||s==="mat3x2h"||s==="mat3x3h"||s==="mat3x4h"||s==="mat4x2h"||s==="mat4x3h"||s==="mat4x4h"||s==="array"){let i=new Je(e.type,[]);n=this._evalCreate(i,t)}}t.createVariable(e.name,n,e)}_var(e,t){let n=null;if(e.value!==null){if(n=this.evalExpression(e.value,t),n===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof ue||(n=n.clone())}else{if(e.type===null)return void console.error(`Variable ${e.name} has no type. Line ${e.line}`);let s=e.type.name;if(s==="f32"||s==="i32"||s==="u32"||s==="bool"||s==="f16"||s==="vec2"||s==="vec3"||s==="vec4"||s==="vec2f"||s==="vec3f"||s==="vec4f"||s==="vec2i"||s==="vec3i"||s==="vec4i"||s==="vec2u"||s==="vec3u"||s==="vec4u"||s==="vec2h"||s==="vec3h"||s==="vec4h"||s==="vec2b"||s==="vec3b"||s==="vec4b"||s==="mat2x2"||s==="mat2x3"||s==="mat2x4"||s==="mat3x2"||s==="mat3x3"||s==="mat3x4"||s==="mat4x2"||s==="mat4x3"||s==="mat4x4"||s==="mat2x2f"||s==="mat2x3f"||s==="mat2x4f"||s==="mat3x2f"||s==="mat3x3f"||s==="mat3x4f"||s==="mat4x2f"||s==="mat4x3f"||s==="mat4x4f"||s==="mat2x2h"||s==="mat2x3h"||s==="mat2x4h"||s==="mat3x2h"||s==="mat3x3h"||s==="mat3x4h"||s==="mat4x2h"||s==="mat4x3h"||s==="mat4x4h"||e.type instanceof Qr||e.type instanceof ut||e.type instanceof A){let i=new Je(e.type,[]);n=this._evalCreate(i,t)}}t.createVariable(e.name,n,e)}_switch(e,t){t=t.clone();let n=this.evalExpression(e.condition,t);if(!(n instanceof T))return console.error(`Invalid if condition. Line ${e.line}`),null;let s=null;for(let i of e.cases)if(i instanceof _a)for(let o of i.selectors){if(o instanceof Yn){s=i;continue}let a=this.evalExpression(o,t);if(!(a instanceof T))return console.error(`Invalid case selector. Line ${e.line}`),null;if(a.value===n.value)return this._execStatements(i.body,t)}else i instanceof ya&&(s=i);return s?this._execStatements(s.body,t):null}_if(e,t){t=t.clone();let n=this.evalExpression(e.condition,t);if(!(n instanceof T))return console.error(`Invalid if condition. Line ${e.line}`),null;if(n.value)return this._execStatements(e.body,t);for(let s of e.elseif){let i=this.evalExpression(s.condition,t);if(!(i instanceof T))return console.error(`Invalid if condition. Line ${e.line}`),null;if(i.value)return this._execStatements(s.body,t)}return e.else?this._execStatements(e.else,t):null}_getScalarValue(e){return e instanceof T?e.value:(console.error("Expected scalar value.",e),0)}_for(e,t){for(t=t.clone(),this.execStatement(e.init,t);this._getScalarValue(this.evalExpression(e.condition,t));){let n=this._execStatements(e.body,t);if(n===we._breakObj)break;if(n!==null&&n!==we._continueObj)return n;this.execStatement(e.increment,t)}return null}_loop(e,t){for(t=t.clone();;){let n=this._execStatements(e.body,t);if(n===we._breakObj)break;if(n===we._continueObj){if(e.continuing&&this._execStatements(e.continuing.body,t)===we._breakObj)break}else if(n!==null)return n}return null}_while(e,t){for(t=t.clone();this._getScalarValue(this.evalExpression(e.condition,t));){let n=this._execStatements(e.body,t);if(n===we._breakObj)break;if(n!==we._continueObj&&n!==null)return n}return null}_evalBitcast(e,t){let n=this.evalExpression(e.value,t),s=e.type;if(n instanceof T){let i=sm(n.value,n.typeInfo.name,s.name);return new T(i,this.getTypeInfo(s))}if(n instanceof g){let i=n.typeInfo.getTypeName(),o="";if(i.endsWith("f"))o="f32";else if(i.endsWith("i"))o="i32";else if(i.endsWith("u"))o="u32";else if(i.endsWith("b"))o="bool";else{if(!i.endsWith("h"))return console.error(`Unknown vector type ${i}. Line ${e.line}`),null;o="f16"}let a=s.getTypeName(),c="";if(a.endsWith("f"))c="f32";else if(a.endsWith("i"))c="i32";else if(a.endsWith("u"))c="u32";else if(a.endsWith("b"))c="bool";else{if(!a.endsWith("h"))return console.error(`Unknown vector type ${c}. Line ${e.line}`),null;c="f16"}let l=function(u,f,h){if(f===h)return u;let d=new Array(u.length);for(let m=0;m<u.length;m++)d[m]=sm(u[m],f,h);return d}(Array.from(n.data),o,c);return new g(l,this.getTypeInfo(s))}return console.error(`TODO: bitcast for ${n.typeInfo.name}. Line ${e.line}`),null}_evalConst(e,t){return t.getVariableValue(e.name).clone().getSubData(this,e.postfix,t)}_evalCreate(e,t){var n;if(e instanceof Je){if(e.type===null)return Zs.void;switch(e.type.getTypeName()){case"bool":case"i32":case"u32":case"f32":case"f16":return this._callConstructorValue(e,t);case"vec2":case"vec3":case"vec4":case"vec2f":case"vec3f":case"vec4f":case"vec2h":case"vec3h":case"vec4h":case"vec2i":case"vec3i":case"vec4i":case"vec2u":case"vec3u":case"vec4u":case"vec2b":case"vec3b":case"vec4b":return this._callConstructorVec(e,t);case"mat2x2":case"mat2x2f":case"mat2x2h":case"mat2x3":case"mat2x3f":case"mat2x3h":case"mat2x4":case"mat2x4f":case"mat2x4h":case"mat3x2":case"mat3x2f":case"mat3x2h":case"mat3x3":case"mat3x3f":case"mat3x3h":case"mat3x4":case"mat3x4f":case"mat3x4h":case"mat4x2":case"mat4x2f":case"mat4x2h":case"mat4x3":case"mat4x3f":case"mat4x3h":case"mat4x4":case"mat4x4f":case"mat4x4h":return this._callConstructorMatrix(e,t)}}let s=e instanceof Je?e.type.name:e.name,i=e instanceof Je?this.getTypeInfo(e.type):this.getTypeInfo(e.name);if(i===null)return console.error(`Unknown type ${s}. Line ${e.line}`),null;if(i.size===0)return null;let o=new ce(new ArrayBuffer(i.size),i,0);if(i instanceof Pt){if(e.args)for(let a=0;a<e.args.length;++a){let c=i.members[a],l=e.args[a],u=this.evalExpression(l,t);o.setData(this,u,c.type,c.offset,t)}}else if(i instanceof Ct){let a=0;if(e.args)for(let c=0;c<e.args.length;++c){let l=e.args[c],u=this.evalExpression(l,t);i.format===null&&(((n=u.typeInfo)===null||n===void 0?void 0:n.name)==="x32"?i.format=this.getTypeInfo("i32"):i.format=u.typeInfo),o.setData(this,u,i.format,a,t),a+=i.stride}}else console.error(`Unknown type "${s}". Line ${e.line}`);return e instanceof Je?o.getSubData(this,e.postfix,t):o}_evalLiteral(e,t){let n=this.getTypeInfo(e.type),s=n.name;return s==="x32"||s==="u32"||s==="f32"||s==="f16"||s==="i32"||s==="bool"?new T(e.scalarValue,n):s==="vec2"||s==="vec3"||s==="vec4"||s==="vec2f"||s==="vec3f"||s==="vec4f"||s==="vec2h"||s==="vec3h"||s==="vec4h"||s==="vec2i"||s==="vec3i"||s==="vec4i"||s==="vec2u"||s==="vec3u"||s==="vec4u"?this._callConstructorVec(e,t):s==="mat2x2"||s==="mat2x3"||s==="mat2x4"||s==="mat3x2"||s==="mat3x3"||s==="mat3x4"||s==="mat4x2"||s==="mat4x3"||s==="mat4x4"||s==="mat2x2f"||s==="mat2x3f"||s==="mat2x4f"||s==="mat3x2f"||s==="mat3x3f"||s==="mat3x4f"||s==="mat4x2f"||s==="mat4x3f"||s==="mat4x4f"||s==="mat2x2h"||s==="mat2x3h"||s==="mat2x4h"||s==="mat3x2h"||s==="mat3x3h"||s==="mat3x4h"||s==="mat4x2h"||s==="mat4x3h"||s==="mat4x4h"?this._callConstructorMatrix(e,t):e.value}_evalVariable(e,t){let n=t.getVariableValue(e.name);return n===null?n:n.getSubData(this,e.postfix,t)}_maxFormatTypeInfo(e){let t=e[0];if(t.name==="f32")return t;for(let n=1;n<e.length;++n){let s=we._priority.get(t.name);we._priority.get(e[n].name)<s&&(t=e[n])}return t.name==="x32"?this.getTypeInfo("i32"):t}_evalUnaryOp(e,t){let n=this.evalExpression(e.right,t);if(e.operator==="&")return new br(n);if(e.operator==="*")return n instanceof br?n.reference.getSubData(this,e.postfix,t):(console.error(`Invalid dereference. Line ${e.line}`),null);let s=n instanceof T?n.value:n instanceof g?Array.from(n.data):null;switch(e.operator){case"+":{if(D(s)){let a=s.map((c,l)=>+c);return new g(a,n.typeInfo)}let i=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new T(+i,o)}case"-":{if(D(s)){let a=s.map((c,l)=>-c);return new g(a,n.typeInfo)}let i=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new T(-i,o)}case"!":{if(D(s)){let a=s.map((c,l)=>c?0:1);return new g(a,n.typeInfo)}let i=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new T(i?0:1,o)}case"~":{if(D(s)){let a=s.map((c,l)=>~c);return new g(a,n.typeInfo)}let i=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new T(~i,o)}}return console.error(`Invalid unary operator ${e.operator}. Line ${e.line}`),null}_evalBinaryOp(e,t){let n=this.evalExpression(e.left,t),s=this.evalExpression(e.right,t),i=n instanceof T?n.value:n instanceof g||n instanceof z?Array.from(n.data):null,o=s instanceof T?s.value:s instanceof g||s instanceof z?Array.from(s.data):null;switch(e.operator){case"+":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d+f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h+u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u+h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a+c,l)}case"-":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d-f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h-u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u-h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a-c,l)}case"*":{if(D(i)&&D(o)){let u=i,f=o;if(n instanceof z&&s instanceof z){let h=function(_,x,E,b){if(Ce[x.name]===void 0||Ce[b.name]===void 0)return null;let S=Ce[x.name][0],C=Ce[x.name][1],P=Ce[b.name][0];if(S!==Ce[b.name][1])return null;let B=new Array(P*C);for(let N=0;N<C;N++)for(let k=0;k<P;k++){let F=0;for(let U=0;U<S;U++)F+=_[U*C+N]*E[k*S+U];B[N*P+k]=F}return B}(u,n.typeInfo,f,s.typeInfo);if(h===null)return console.error(`Matrix multiplication failed. Line ${e.line}.`),null;let d=Ce[s.typeInfo.name][0],m=Ce[n.typeInfo.name][1],y=this.getTypeInfo(`mat${d}x${m}f`);return new z(h,y)}if(n instanceof z&&s instanceof g){let h=function(d,m,y,_){if(Ce[m.name]===void 0||Cu[_.name]===void 0)return null;let x=Ce[m.name][0],E=Ce[m.name][1];if(x!==y.length)return null;let b=new Array(E);for(let S=0;S<E;S++){let C=0;for(let P=0;P<x;P++)C+=d[P*E+S]*y[P];b[S]=C}return b}(u,n.typeInfo,f,s.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new g(h,s.typeInfo)}if(n instanceof g&&s instanceof z){let h=function(d,m,y,_){if(Cu[m.name]===void 0||Ce[_.name]===void 0)return null;let x=Ce[_.name][0],E=Ce[_.name][1];if(E!==d.length)return null;let b=[];for(let S=0;S<x;S++){let C=0;for(let P=0;P<E;P++)C+=d[P]*y[P*x+S];b[S]=C}return b}(u,n.typeInfo,f,s.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new g(h,n.typeInfo)}{if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d*f[m]);return new g(h,n.typeInfo)}}if(D(i)){let u=o,f=i.map((h,d)=>h*u);return n instanceof z?new z(f,n.typeInfo):new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u*h);return s instanceof z?new z(f,s.typeInfo):new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a*c,l)}case"%":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d%f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h%u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u%h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a%c,l)}case"/":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d/f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h/u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u/h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a/c,l)}case"&":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d&f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h&u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u&h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a&c,l)}case"|":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d|f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h|u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u|h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a|c,l)}case"^":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d^f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h^u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u^h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a^c,l)}case"<<":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d<<f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h<<u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u<<h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a<<c,l)}case">>":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d>>f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h>>u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u>>h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a>>c,l)}case">":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u>c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l>a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a>l?1:0);return new g(c,s.typeInfo)}return new T(i>o?1:0,this.getTypeInfo("bool"));case"<":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u<c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l<a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a<l?1:0);return new g(c,s.typeInfo)}return new T(i<o?1:0,this.getTypeInfo("bool"));case"==":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u===c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l==a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a==l?1:0);return new g(c,s.typeInfo)}return new T(i===o?1:0,this.getTypeInfo("bool"));case"!=":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u!==c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l!==a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a!==l?1:0);return new g(c,s.typeInfo)}return new T(i!==o?1:0,this.getTypeInfo("bool"));case">=":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u>=c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l>=a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a>=l?1:0);return new g(c,s.typeInfo)}return new T(i>=o?1:0,this.getTypeInfo("bool"));case"<=":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u<=c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l<=a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a<=l?1:0);return new g(c,s.typeInfo)}return new T(i<=o?1:0,this.getTypeInfo("bool"));case"&&":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u&&c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l&&a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a&&l?1:0);return new g(c,s.typeInfo)}return new T(i&&o?1:0,this.getTypeInfo("bool"));case"||":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u||c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l||a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a||l?1:0);return new g(c,s.typeInfo)}return new T(i||o?1:0,this.getTypeInfo("bool"))}return console.error(`Unknown operator ${e.operator}. Line ${e.line}`),null}_evalCall(e,t){if(e.cachedReturnValue!==null)return e.cachedReturnValue;let n=t.clone();n.currentFunctionName=e.name;let s=t.getFunction(e.name);if(!s)return e.isBuiltin?this._callBuiltinFunction(e,n):this.getTypeInfo(e.name)?this._evalCreate(e,t):(console.error(`Unknown function "${e.name}". Line ${e.line}`),null);for(let i=0;i<s.node.args.length;++i){let o=s.node.args[i],a=this.evalExpression(e.args[i],n);n.createVariable(o.name,a,o)}return this._execStatements(s.node.body,n)}_callBuiltinFunction(e,t){switch(e.name){case"all":return this.builtins.All(e,t);case"any":return this.builtins.Any(e,t);case"select":return this.builtins.Select(e,t);case"arrayLength":return this.builtins.ArrayLength(e,t);case"abs":return this.builtins.Abs(e,t);case"acos":return this.builtins.Acos(e,t);case"acosh":return this.builtins.Acosh(e,t);case"asin":return this.builtins.Asin(e,t);case"asinh":return this.builtins.Asinh(e,t);case"atan":return this.builtins.Atan(e,t);case"atanh":return this.builtins.Atanh(e,t);case"atan2":return this.builtins.Atan2(e,t);case"ceil":return this.builtins.Ceil(e,t);case"clamp":return this.builtins.Clamp(e,t);case"cos":return this.builtins.Cos(e,t);case"cosh":return this.builtins.Cosh(e,t);case"countLeadingZeros":return this.builtins.CountLeadingZeros(e,t);case"countOneBits":return this.builtins.CountOneBits(e,t);case"countTrailingZeros":return this.builtins.CountTrailingZeros(e,t);case"cross":return this.builtins.Cross(e,t);case"degrees":return this.builtins.Degrees(e,t);case"determinant":return this.builtins.Determinant(e,t);case"distance":return this.builtins.Distance(e,t);case"dot":return this.builtins.Dot(e,t);case"dot4U8Packed":return this.builtins.Dot4U8Packed(e,t);case"dot4I8Packed":return this.builtins.Dot4I8Packed(e,t);case"exp":return this.builtins.Exp(e,t);case"exp2":return this.builtins.Exp2(e,t);case"extractBits":return this.builtins.ExtractBits(e,t);case"faceForward":return this.builtins.FaceForward(e,t);case"firstLeadingBit":return this.builtins.FirstLeadingBit(e,t);case"firstTrailingBit":return this.builtins.FirstTrailingBit(e,t);case"floor":return this.builtins.Floor(e,t);case"fma":return this.builtins.Fma(e,t);case"fract":return this.builtins.Fract(e,t);case"frexp":return this.builtins.Frexp(e,t);case"insertBits":return this.builtins.InsertBits(e,t);case"inverseSqrt":return this.builtins.InverseSqrt(e,t);case"ldexp":return this.builtins.Ldexp(e,t);case"length":return this.builtins.Length(e,t);case"log":return this.builtins.Log(e,t);case"log2":return this.builtins.Log2(e,t);case"max":return this.builtins.Max(e,t);case"min":return this.builtins.Min(e,t);case"mix":return this.builtins.Mix(e,t);case"modf":return this.builtins.Modf(e,t);case"normalize":return this.builtins.Normalize(e,t);case"pow":return this.builtins.Pow(e,t);case"quantizeToF16":return this.builtins.QuantizeToF16(e,t);case"radians":return this.builtins.Radians(e,t);case"reflect":return this.builtins.Reflect(e,t);case"refract":return this.builtins.Refract(e,t);case"reverseBits":return this.builtins.ReverseBits(e,t);case"round":return this.builtins.Round(e,t);case"saturate":return this.builtins.Saturate(e,t);case"sign":return this.builtins.Sign(e,t);case"sin":return this.builtins.Sin(e,t);case"sinh":return this.builtins.Sinh(e,t);case"smoothStep":return this.builtins.SmoothStep(e,t);case"sqrt":return this.builtins.Sqrt(e,t);case"step":return this.builtins.Step(e,t);case"tan":return this.builtins.Tan(e,t);case"tanh":return this.builtins.Tanh(e,t);case"transpose":return this.builtins.Transpose(e,t);case"trunc":return this.builtins.Trunc(e,t);case"dpdx":return this.builtins.Dpdx(e,t);case"dpdxCoarse":return this.builtins.DpdxCoarse(e,t);case"dpdxFine":return this.builtins.DpdxFine(e,t);case"dpdy":return this.builtins.Dpdy(e,t);case"dpdyCoarse":return this.builtins.DpdyCoarse(e,t);case"dpdyFine":return this.builtins.DpdyFine(e,t);case"fwidth":return this.builtins.Fwidth(e,t);case"fwidthCoarse":return this.builtins.FwidthCoarse(e,t);case"fwidthFine":return this.builtins.FwidthFine(e,t);case"textureDimensions":return this.builtins.TextureDimensions(e,t);case"textureGather":return this.builtins.TextureGather(e,t);case"textureGatherCompare":return this.builtins.TextureGatherCompare(e,t);case"textureLoad":return this.builtins.TextureLoad(e,t);case"textureNumLayers":return this.builtins.TextureNumLayers(e,t);case"textureNumLevels":return this.builtins.TextureNumLevels(e,t);case"textureNumSamples":return this.builtins.TextureNumSamples(e,t);case"textureSample":return this.builtins.TextureSample(e,t);case"textureSampleBias":return this.builtins.TextureSampleBias(e,t);case"textureSampleCompare":return this.builtins.TextureSampleCompare(e,t);case"textureSampleCompareLevel":return this.builtins.TextureSampleCompareLevel(e,t);case"textureSampleGrad":return this.builtins.TextureSampleGrad(e,t);case"textureSampleLevel":return this.builtins.TextureSampleLevel(e,t);case"textureSampleBaseClampToEdge":return this.builtins.TextureSampleBaseClampToEdge(e,t);case"textureStore":return this.builtins.TextureStore(e,t);case"atomicLoad":return this.builtins.AtomicLoad(e,t);case"atomicStore":return this.builtins.AtomicStore(e,t);case"atomicAdd":return this.builtins.AtomicAdd(e,t);case"atomicSub":return this.builtins.AtomicSub(e,t);case"atomicMax":return this.builtins.AtomicMax(e,t);case"atomicMin":return this.builtins.AtomicMin(e,t);case"atomicAnd":return this.builtins.AtomicAnd(e,t);case"atomicOr":return this.builtins.AtomicOr(e,t);case"atomicXor":return this.builtins.AtomicXor(e,t);case"atomicExchange":return this.builtins.AtomicExchange(e,t);case"atomicCompareExchangeWeak":return this.builtins.AtomicCompareExchangeWeak(e,t);case"pack4x8snorm":return this.builtins.Pack4x8snorm(e,t);case"pack4x8unorm":return this.builtins.Pack4x8unorm(e,t);case"pack4xI8":return this.builtins.Pack4xI8(e,t);case"pack4xU8":return this.builtins.Pack4xU8(e,t);case"pack4x8Clamp":return this.builtins.Pack4x8Clamp(e,t);case"pack4xU8Clamp":return this.builtins.Pack4xU8Clamp(e,t);case"pack2x16snorm":return this.builtins.Pack2x16snorm(e,t);case"pack2x16unorm":return this.builtins.Pack2x16unorm(e,t);case"pack2x16float":return this.builtins.Pack2x16float(e,t);case"unpack4x8snorm":return this.builtins.Unpack4x8snorm(e,t);case"unpack4x8unorm":return this.builtins.Unpack4x8unorm(e,t);case"unpack4xI8":return this.builtins.Unpack4xI8(e,t);case"unpack4xU8":return this.builtins.Unpack4xU8(e,t);case"unpack2x16snorm":return this.builtins.Unpack2x16snorm(e,t);case"unpack2x16unorm":return this.builtins.Unpack2x16unorm(e,t);case"unpack2x16float":return this.builtins.Unpack2x16float(e,t);case"storageBarrier":return this.builtins.StorageBarrier(e,t);case"textureBarrier":return this.builtins.TextureBarrier(e,t);case"workgroupBarrier":return this.builtins.WorkgroupBarrier(e,t);case"workgroupUniformLoad":return this.builtins.WorkgroupUniformLoad(e,t);case"subgroupAdd":return this.builtins.SubgroupAdd(e,t);case"subgroupExclusiveAdd":return this.builtins.SubgroupExclusiveAdd(e,t);case"subgroupInclusiveAdd":return this.builtins.SubgroupInclusiveAdd(e,t);case"subgroupAll":return this.builtins.SubgroupAll(e,t);case"subgroupAnd":return this.builtins.SubgroupAnd(e,t);case"subgroupAny":return this.builtins.SubgroupAny(e,t);case"subgroupBallot":return this.builtins.SubgroupBallot(e,t);case"subgroupBroadcast":return this.builtins.SubgroupBroadcast(e,t);case"subgroupBroadcastFirst":return this.builtins.SubgroupBroadcastFirst(e,t);case"subgroupElect":return this.builtins.SubgroupElect(e,t);case"subgroupMax":return this.builtins.SubgroupMax(e,t);case"subgroupMin":return this.builtins.SubgroupMin(e,t);case"subgroupMul":return this.builtins.SubgroupMul(e,t);case"subgroupExclusiveMul":return this.builtins.SubgroupExclusiveMul(e,t);case"subgroupInclusiveMul":return this.builtins.SubgroupInclusiveMul(e,t);case"subgroupOr":return this.builtins.SubgroupOr(e,t);case"subgroupShuffle":return this.builtins.SubgroupShuffle(e,t);case"subgroupShuffleDown":return this.builtins.SubgroupShuffleDown(e,t);case"subgroupShuffleUp":return this.builtins.SubgroupShuffleUp(e,t);case"subgroupShuffleXor":return this.builtins.SubgroupShuffleXor(e,t);case"subgroupXor":return this.builtins.SubgroupXor(e,t);case"quadBroadcast":return this.builtins.QuadBroadcast(e,t);case"quadSwapDiagonal":return this.builtins.QuadSwapDiagonal(e,t);case"quadSwapX":return this.builtins.QuadSwapX(e,t);case"quadSwapY":return this.builtins.QuadSwapY(e,t)}let n=t.getFunction(e.name);if(n){let s=t.clone();for(let i=0;i<n.node.args.length;++i){let o=n.node.args[i],a=this.evalExpression(e.args[i],s);s.setVariable(o.name,a,o)}return this._execStatements(n.node.body,s)}return null}_callConstructorValue(e,t){if(!e.args||e.args.length===0)return new T(0,this.getTypeInfo(e.type));let n=this.evalExpression(e.args[0],t);return n.typeInfo=this.getTypeInfo(e.type),n.getSubData(this,e.postfix,t).clone()}_callConstructorVec(e,t){let n=this.getTypeInfo(e.type),s=e.type.getTypeName(),i=Cu[s];if(i===void 0)return console.error(`Invalid vec constructor ${s}. Line ${e.line}`),null;let o=[];if(e instanceof me)if(e.isVector){let a=e.vectorValue;for(let c of a)o.push(c)}else o.push(e.scalarValue);else if(e.args)for(let a of e.args){let c=this.evalExpression(a,t);if(c instanceof g){let l=c.data;for(let u=0;u<l.length;++u){let f=l[u];o.push(f)}}else if(c instanceof T){let l=c.value;o.push(l)}}if(e.type instanceof A&&e.type.format===null&&(e.type.format=A.f32),o.length===0){let a=new Array(i).fill(0);return new g(a,n).getSubData(this,e.postfix,t)}if(o.length===1)for(;o.length<i;)o.push(o[0]);return o.length<i?(console.error(`Invalid vec constructor. Line ${e.line}`),null):new g(o.length>i?o.slice(0,i):o,n).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){let n=this.getTypeInfo(e.type),s=e.type.getTypeName(),i=Ce[s];if(i===void 0)return console.error(`Invalid matrix constructor ${s}. Line ${e.line}`),null;let o=[];if(e instanceof me)if(e.isVector){let a=e.vectorValue;for(let c of a)o.push(c)}else o.push(e.scalarValue);else if(e.args)for(let a of e.args){let c=this.evalExpression(a,t);c instanceof g?o.push(...c.data):c instanceof T?o.push(c.value):c instanceof z&&o.push(...c.data)}if(n instanceof Zt&&n.format===null&&(n.format=this.getTypeInfo("f32")),o.length===0){let a=new Array(i[2]).fill(0);return new z(a,n).getSubData(this,e.postfix,t)}return o.length!==i[2]?(console.error(`Invalid matrix constructor. Line ${e.line}`),null):new z(o,n).getSubData(this,e.postfix,t)}};we._breakObj=new Ve(new Le("BREAK",null),null),we._continueObj=new Ve(new Le("CONTINUE",null),null),we._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);var Xu=class{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}},Yu=class{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new Xu,this._exec=new we,this._forwardTypeCount=0}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;let t=[];for(;!this._isAtEnd();){let n=this._global_decl_or_directive();if(!n)break;t.push(n)}if(this._deferArrayCountEval.length>0){for(let n of this._deferArrayCountEval){let s=n.arrayType,i=n.countNode;if(i instanceof Me){let o=i.name,a=this._context.constants.get(o);if(a)try{let c=a.constEvaluate(this._exec);s.count=c}catch{}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(let n of t)n.search(s=>{s instanceof ba||s instanceof js?s.type=this._forwardType(s.type):s instanceof Qr?s.format=this._forwardType(s.format):s instanceof ht||s instanceof Gr||s instanceof Xn?s.type=this._forwardType(s.type):s instanceof Jr?s.returnType=this._forwardType(s.returnType):s instanceof xa&&(s.type=this._forwardType(s.type))});return t}_forwardType(e){if(e instanceof ha){let t=this._getType(e.name);if(t)return t}else e instanceof js?e.type=this._forwardType(e.type):e instanceof Qr&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if(typeof e=="string"){let t=new Wu(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_updateNode(e,t){return e.line=t??this._currentLine,e}_error(e,t){return{token:e,message:t,toString:()=>`${t}`}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==p.eof}_match(e){if(e instanceof w)return!!this._check(e)&&(this._advance(),!0);for(let t=0,n=e.length;t<n;++t){let s=e[t];if(this._check(s))return this._advance(),!0}return!1}_consume(e,t){if(this._check(e))return this._advance();throw this._error(this._peek(),`${t}. Line:${this._currentLine}`)}_check(e){if(this._isAtEnd())return!1;let t=this._peek();if(e instanceof Array){let n=t.type,s=!1;for(let i of e){if(n===i)return!0;i===p.tokens.name&&(s=!0)}if(s){let i=p.tokens.name.rule.exec(t.lexeme);if(i&&i.index==0&&i[0]==t.lexeme)return!0}return!1}if(t.type===e)return!0;if(e===p.tokens.name){let n=p.tokens.name.rule.exec(t.lexeme);return n&&n.index==0&&n[0]==t.lexeme}return!1}_advance(){var e,t;return this._currentLine=(t=(e=this._peek())===null||e===void 0?void 0:e.line)!==null&&t!==void 0?t:-1,this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(p.tokens.semicolon)&&!this._isAtEnd(););if(this._match(p.keywords.alias)){let t=this._type_alias();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.diagnostic)){let t=this._diagnostic();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.requires)){let t=this._requires_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.enable)){let t=this._enable_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}let e=this._attribute();if(this._check(p.keywords.var)){let t=this._global_variable_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.override)){let t=this._override_variable_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.let)){let t=this._global_let_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.const)){let t=this._global_const_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.struct)){let t=this._struct_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.fn)){let t=this._function_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}return null}_function_decl(){if(!this._match(p.keywords.fn))return null;let e=this._currentLine,t=this._consume(p.tokens.ident,"Expected function name.").toString();this._consume(p.tokens.paren_left,"Expected '(' for function arguments.");let n=[];if(!this._check(p.tokens.paren_right))do{if(this._check(p.tokens.paren_right))break;let a=this._attribute(),c=this._consume(p.tokens.name,"Expected argument name.").toString();this._consume(p.tokens.colon,"Expected ':' for argument type.");let l=this._attribute(),u=this._type_decl();u!=null&&(u.attributes=l,n.push(this._updateNode(new xa(c,u,a))))}while(this._match(p.tokens.comma));this._consume(p.tokens.paren_right,"Expected ')' after function arguments.");let s=null;if(this._match(p.tokens.arrow)){let a=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=a)}let i=this._compound_statement(),o=this._currentLine;return this._updateNode(new Jr(t,n,s,i,e,o),e)}_compound_statement(){let e=[];for(this._consume(p.tokens.brace_left,"Expected '{' for block.");!this._check(p.tokens.brace_right);){let t=this._statement();t!==null&&e.push(t)}return this._consume(p.tokens.brace_right,"Expected '}' for block."),e}_statement(){for(;this._match(p.tokens.semicolon)&&!this._isAtEnd(););if(this._check(p.tokens.attr)&&this._attribute(),this._check(p.keywords.if))return this._if_statement();if(this._check(p.keywords.switch))return this._switch_statement();if(this._check(p.keywords.loop))return this._loop_statement();if(this._check(p.keywords.for))return this._for_statement();if(this._check(p.keywords.while))return this._while_statement();if(this._check(p.keywords.continuing))return this._continuing_statement();if(this._check(p.keywords.static_assert))return this._static_assert_statement();if(this._check(p.tokens.brace_left))return this._compound_statement();let e=null;if(this._check(p.keywords.return))e=this._return_statement();else if(this._check([p.keywords.var,p.keywords.let,p.keywords.const]))e=this._variable_statement();else if(this._match(p.keywords.discard))e=this._updateNode(new Vu);else if(this._match(p.keywords.break)){let t=this._updateNode(new ua);if(this._currentLoop.length>0){let n=this._currentLoop[this._currentLoop.length-1];t.loopId=n.id}e=t,this._check(p.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match(p.keywords.continue)){let t=this._updateNode(new fa);if(!(this._currentLoop.length>0))throw this._error(this._peek(),`Continue statement must be inside a loop. Line: ${t.line}`);{let n=this._currentLoop[this._currentLoop.length-1];t.loopId=n.id}e=t}else e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement();return e!=null&&this._consume(p.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match(p.keywords.static_assert))return null;let e=this._currentLine,t=this._optional_paren_expression();return this._updateNode(new Bu(t),e)}_while_statement(){if(!this._match(p.keywords.while))return null;let e=this._updateNode(new ta(null,null));return this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(p.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_continuing_statement(){let e=this._currentLoop.length>0?this._currentLoop[this._currentLoop.length-1].id:-1;if(!this._match(p.keywords.continuing))return null;let t=this._currentLine,n=this._compound_statement();return this._updateNode(new Hs(n,e),t)}_for_statement(){if(!this._match(p.keywords.for))return null;this._consume(p.tokens.paren_left,"Expected '('.");let e=this._updateNode(new ra(null,null,null,null));return this._currentLoop.push(e),e.init=this._check(p.tokens.semicolon)?null:this._for_init(),this._consume(p.tokens.semicolon,"Expected ';'."),e.condition=this._check(p.tokens.semicolon)?null:this._short_circuit_or_expression(),this._consume(p.tokens.semicolon,"Expected ';'."),e.increment=this._check(p.tokens.paren_right)?null:this._for_increment(),this._consume(p.tokens.paren_right,"Expected ')'."),this._check(p.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(p.keywords.var)){let e=this._variable_decl();if(e===null)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match(p.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new ht(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match(p.keywords.let)){let e=this._currentLine,t=this._consume(p.tokens.name,"Expected name for let.").toString(),n=null;if(this._match(p.tokens.colon)){let i=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=i)}this._consume(p.tokens.equal,"Expected '=' for let.");let s=this._short_circuit_or_expression();return this._updateNode(new Gr(t,n,null,null,s),e)}if(this._match(p.keywords.const)){let e=this._currentLine,t=this._consume(p.tokens.name,"Expected name for const.").toString(),n=null;if(this._match(p.tokens.colon)){let i=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=i)}this._consume(p.tokens.equal,"Expected '=' for const.");let s=this._short_circuit_or_expression();return n===null&&s instanceof me&&(n=s.type),this._updateNode(new Xn(t,n,null,null,s),e)}return null}_increment_decrement_statement(){let e=this._current,t=this._unary_expression();if(t==null)return null;if(!this._check(p.increment_operators))return this._current=e,null;let n=this._consume(p.increment_operators,"Expected increment operator");return this._updateNode(new na(n.type===p.tokens.plus_plus?jn.increment:jn.decrement,t))}_assignment_statement(){let e=null,t=this._currentLine;if(this._check(p.tokens.brace_right))return null;let n=this._match(p.tokens.underscore);if(n||(e=this._unary_expression()),!n&&e==null)return null;let s=this._consume(p.assignment_operators,"Expected assignment operator."),i=this._short_circuit_or_expression();return this._updateNode(new sa($s.parse(s.lexeme),e,i),t)}_func_call_statement(){if(!this._check(p.tokens.ident))return null;let e=this._currentLine,t=this._current,n=this._consume(p.tokens.ident,"Expected function name."),s=this._argument_expression_list();return s===null?(this._current=t,null):this._updateNode(new Ys(n.lexeme,s),e)}_loop_statement(){if(!this._match(p.keywords.loop))return null;this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Expected '{' for loop.");let e=this._updateNode(new ia([],null));this._currentLoop.push(e);let t=this._statement();for(;t!==null;){if(Array.isArray(t))for(let n of t)e.body.push(n);else e.body.push(t);if(t instanceof Hs){e.continuing=t;break}t=this._statement()}return this._currentLoop.pop(),this._consume(p.tokens.brace_right,"Expected '}' for loop."),e}_switch_statement(){if(!this._match(p.keywords.switch))return null;let e=this._updateNode(new oa(null,[]));if(this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Expected '{' for switch."),e.cases=this._switch_body(),e.cases==null||e.cases.length==0)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(p.tokens.brace_right,"Expected '}' for switch."),this._currentLoop.pop(),e}_switch_body(){let e=[],t=!1;for(;this._check([p.keywords.default,p.keywords.case]);){if(this._match(p.keywords.case)){let n=this._case_selectors();for(let i of n)if(i instanceof Yn){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!0;break}this._match(p.tokens.colon),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Exected '{' for switch case.");let s=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new _a(n,s)))}if(this._match(p.keywords.default)){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");this._match(p.tokens.colon),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Exected '{' for switch default.");let n=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new ya(n)))}}return e}_case_selectors(){let e=[];for(this._match(p.keywords.default)?e.push(this._updateNode(new Yn)):e.push(this._shift_expression());this._match(p.tokens.comma);)this._match(p.keywords.default)?e.push(this._updateNode(new Yn)):e.push(this._shift_expression());return e}_case_body(){if(this._match(p.keywords.fallthrough))return this._consume(p.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(e==null)return[];e instanceof Array||(e=[e]);let t=this._case_body();return t.length==0?e:[...e,t[0]]}_if_statement(){if(!this._match(p.keywords.if))return null;let e=this._currentLine,t=this._optional_paren_expression();this._check(p.tokens.attr)&&this._attribute();let n=this._compound_statement(),s=[];this._match_elseif()&&(this._check(p.tokens.attr)&&this._attribute(),s=this._elseif_statement(s));let i=null;return this._match(p.keywords.else)&&(this._check(p.tokens.attr)&&this._attribute(),i=this._compound_statement()),this._updateNode(new aa(t,n,s,i),e)}_match_elseif(){return this._tokens[this._current].type===p.keywords.else&&this._tokens[this._current+1].type===p.keywords.if&&(this._advance(),this._advance(),!0)}_elseif_statement(e=[]){let t=this._optional_paren_expression(),n=this._compound_statement();return e.push(this._updateNode(new zu(t,n))),this._match_elseif()&&(this._check(p.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match(p.keywords.return))return null;let e=this._short_circuit_or_expression();return this._updateNode(new ca(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(p.tokens.or_or);)e=this._updateNode(new He(this._previous().toString(),e,this._short_circuit_and_expr()));return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(p.tokens.and_and);)e=this._updateNode(new He(this._previous().toString(),e,this._inclusive_or_expression()));return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(p.tokens.or);)e=this._updateNode(new He(this._previous().toString(),e,this._exclusive_or_expression()));return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(p.tokens.xor);)e=this._updateNode(new He(this._previous().toString(),e,this._and_expression()));return e}_and_expression(){let e=this._equality_expression();for(;this._match(p.tokens.and);)e=this._updateNode(new He(this._previous().toString(),e,this._equality_expression()));return e}_equality_expression(){let e=this._relational_expression();return this._match([p.tokens.equal_equal,p.tokens.not_equal])?this._updateNode(new He(this._previous().toString(),e,this._relational_expression())):e}_relational_expression(){let e=this._shift_expression();for(;this._match([p.tokens.less_than,p.tokens.greater_than,p.tokens.less_than_equal,p.tokens.greater_than_equal]);)e=this._updateNode(new He(this._previous().toString(),e,this._shift_expression()));return e}_shift_expression(){let e=this._additive_expression();for(;this._match([p.tokens.shift_left,p.tokens.shift_right]);)e=this._updateNode(new He(this._previous().toString(),e,this._additive_expression()));return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([p.tokens.plus,p.tokens.minus]);)e=this._updateNode(new He(this._previous().toString(),e,this._multiplicative_expression()));return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([p.tokens.star,p.tokens.forward_slash,p.tokens.modulo]);)e=this._updateNode(new He(this._previous().toString(),e,this._unary_expression()));return e}_unary_expression(){return this._match([p.tokens.minus,p.tokens.bang,p.tokens.tilde,p.tokens.star,p.tokens.and])?this._updateNode(new ue(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){let e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match(p.tokens.bracket_left)){let e=this._short_circuit_or_expression();this._consume(p.tokens.bracket_right,"Expected ']'.");let t=this._updateNode(new Tr(e)),n=this._postfix_expression();return n&&(t.postfix=n),t}if(this._match(p.tokens.period)){let e=this._consume(p.tokens.name,"Expected member name."),t=this._postfix_expression(),n=this._updateNode(new Gt(e.lexeme));return t&&(n.postfix=t),n}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_getType(e){let t=this._getStruct(e);if(t!==null)return t;switch(e){case"void":return M.void;case"bool":return M.bool;case"i32":return M.i32;case"u32":return M.u32;case"f32":return M.f32;case"f16":return M.f16;case"vec2f":return A.vec2f;case"vec3f":return A.vec3f;case"vec4f":return A.vec4f;case"vec2i":return A.vec2i;case"vec3i":return A.vec3i;case"vec4i":return A.vec4i;case"vec2u":return A.vec2u;case"vec3u":return A.vec3u;case"vec4u":return A.vec4u;case"vec2h":return A.vec2h;case"vec3h":return A.vec3h;case"vec4h":return A.vec4h;case"mat2x2f":return A.mat2x2f;case"mat2x3f":return A.mat2x3f;case"mat2x4f":return A.mat2x4f;case"mat3x2f":return A.mat3x2f;case"mat3x3f":return A.mat3x3f;case"mat3x4f":return A.mat3x4f;case"mat4x2f":return A.mat4x2f;case"mat4x3f":return A.mat4x3f;case"mat4x4f":return A.mat4x4f;case"mat2x2h":return A.mat2x2h;case"mat2x3h":return A.mat2x3h;case"mat2x4h":return A.mat2x4h;case"mat3x2h":return A.mat3x2h;case"mat3x3h":return A.mat3x3h;case"mat3x4h":return A.mat3x4h;case"mat4x2h":return A.mat4x2h;case"mat4x3h":return A.mat4x3h;case"mat4x4h":return A.mat4x4h;case"mat2x2i":return A.mat2x2i;case"mat2x3i":return A.mat2x3i;case"mat2x4i":return A.mat2x4i;case"mat3x2i":return A.mat3x2i;case"mat3x3i":return A.mat3x3i;case"mat3x4i":return A.mat3x4i;case"mat4x2i":return A.mat4x2i;case"mat4x3i":return A.mat4x3i;case"mat4x4i":return A.mat4x4i;case"mat2x2u":return A.mat2x2u;case"mat2x3u":return A.mat2x3u;case"mat2x4u":return A.mat2x4u;case"mat3x2u":return A.mat3x2u;case"mat3x3u":return A.mat3x3u;case"mat3x4u":return A.mat3x4u;case"mat4x2u":return A.mat4x2u;case"mat4x3u":return A.mat4x3u;case"mat4x4u":return A.mat4x4u}return null}_validateTypeRange(e,t){if(t.name==="i32"){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}. Line: ${this._currentLine}.`)}else if(t.name==="u32"&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}. Line: ${this._currentLine}.`)}_primary_expression(){if(this._match(p.tokens.ident)){let n=this._previous().toString();if(this._check(p.tokens.paren_left)){let s=this._argument_expression_list(),i=this._getType(n);return i!==null?this._updateNode(new Je(i,s)):this._updateNode(new Ks(n,s))}if(this._context.constants.has(n)){let s=this._context.constants.get(n);return this._updateNode(new da(n,s.value))}return this._updateNode(new Me(n))}if(this._match(p.tokens.int_literal)){let n=this._previous().toString(),s=n.endsWith("i")||n.endsWith("i")?M.i32:n.endsWith("u")||n.endsWith("U")?M.u32:M.x32,i=parseInt(n);return this._validateTypeRange(i,s),this._updateNode(new me(new T(i,this._exec.getTypeInfo(s)),s))}if(this._match(p.tokens.uint_literal)){let n=parseInt(this._previous().toString());return this._validateTypeRange(n,M.u32),this._updateNode(new me(new T(n,this._exec.getTypeInfo(M.u32)),M.u32))}if(this._match([p.tokens.decimal_float_literal,p.tokens.hex_float_literal])){let n=this._previous().toString(),s=n.endsWith("h");s&&(n=n.substring(0,n.length-1));let i=parseFloat(n);this._validateTypeRange(i,s?M.f16:M.f32);let o=s?M.f16:M.f32;return this._updateNode(new me(new T(i,this._exec.getTypeInfo(o)),o))}if(this._match([p.keywords.true,p.keywords.false])){let n=this._previous().toString()===p.keywords.true.rule;return this._updateNode(new me(new T(n?1:0,this._exec.getTypeInfo(M.bool)),M.bool))}if(this._check(p.tokens.paren_left))return this._paren_expression();if(this._match(p.keywords.bitcast)){this._consume(p.tokens.less_than,"Expected '<'.");let n=this._type_decl();this._consume(p.tokens.greater_than,"Expected '>'.");let s=this._paren_expression();return this._updateNode(new pa(n,s))}let e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new Je(e,t))}_argument_expression_list(){if(!this._match(p.tokens.paren_left))return null;let e=[];do{if(this._check(p.tokens.paren_right))break;let t=this._short_circuit_or_expression();e.push(t)}while(this._match(p.tokens.comma));return this._consume(p.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(p.tokens.paren_left);let e=this._short_circuit_or_expression();return this._match(p.tokens.paren_right),e}_paren_expression(){this._consume(p.tokens.paren_left,"Expected '('.");let e=this._short_circuit_or_expression();return this._consume(p.tokens.paren_right,"Expected ')'."),e}_struct_decl(){if(!this._match(p.keywords.struct))return null;let e=this._currentLine,t=this._consume(p.tokens.ident,"Expected name for struct.").toString();this._consume(p.tokens.brace_left,"Expected '{' for struct body.");let n=[];for(;!this._check(p.tokens.brace_right);){let o=this._attribute(),a=this._consume(p.tokens.name,"Expected variable name.").toString();this._consume(p.tokens.colon,"Expected ':' for struct member type.");let c=this._attribute(),l=this._type_decl();l!=null&&(l.attributes=c),this._check(p.tokens.brace_right)?this._match(p.tokens.comma):this._consume(p.tokens.comma,"Expected ',' for struct member."),n.push(this._updateNode(new ba(a,l,o)))}this._consume(p.tokens.brace_right,"Expected '}' after struct body.");let s=this._currentLine,i=this._updateNode(new ut(t,n,e,s),e);return this._context.structs.set(t,i),i}_global_variable_decl(){let e=this._variable_decl();if(!e)return null;if(this._match(p.tokens.equal)){let t=this._const_expression();e.value=t}if(e.type!==null&&e.value instanceof me){if(e.value.type.name!=="x32"&&e.type.getTypeName()!==e.value.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${e.value.type.name} to ${e.type.name}. Line:${this._currentLine}`);e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else e.type===null&&e.value instanceof me&&(e.type=e.value.type.name==="x32"?M.i32:e.value.type,e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type));return e}_override_variable_decl(){let e=this._override_decl();return e&&this._match(p.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){var e;if(!this._match(p.keywords.const))return null;let t=this._consume(p.tokens.name,"Expected variable name"),n=this._currentLine,s=null;if(this._match(p.tokens.colon)){let c=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=c)}let i=null;this._consume(p.tokens.equal,"const declarations require an assignment");let o=this._short_circuit_or_expression();try{let c=[M.f32],l=o.constEvaluate(this._exec,c);l instanceof T&&this._validateTypeRange(l.value,c[0]),c[0]instanceof A&&c[0].format===null&&l.typeInfo instanceof Zt&&l.typeInfo.format!==null&&(l.typeInfo.format.name==="f16"?c[0].format=M.f16:l.typeInfo.format.name==="f32"?c[0].format=M.f32:l.typeInfo.format.name==="i32"?c[0].format=M.i32:l.typeInfo.format.name==="u32"?c[0].format=M.u32:l.typeInfo.format.name==="bool"?c[0].format=M.bool:console.error(`TODO: impelement template format type ${l.typeInfo.format.name}`)),i=this._updateNode(new me(l,c[0])),this._exec.context.setVariable(t.toString(),l)}catch{i=o}if(s!==null&&i instanceof me){if(i.type.name!=="x32"&&s.getTypeName()!==i.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${i.type.name} to ${s.name}. Line:${this._currentLine}`);i.type=s,i.isScalar&&this._validateTypeRange(i.scalarValue,i.type)}else s===null&&i instanceof me&&(s=(e=i?.type)!==null&&e!==void 0?e:M.f32,s===M.x32&&(s=M.i32));let a=this._updateNode(new Xn(t.toString(),s,"","",i),n);return this._context.constants.set(a.name,a),a}_global_let_decl(){if(!this._match(p.keywords.let))return null;let e=this._currentLine,t=this._consume(p.tokens.name,"Expected variable name"),n=null;if(this._match(p.tokens.colon)){let i=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=i)}let s=null;if(this._match(p.tokens.equal)&&(s=this._const_expression()),n!==null&&s instanceof me){if(s.type.name!=="x32"&&n.getTypeName()!==s.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${s.type.name} to ${n.name}. Line:${this._currentLine}`);s.type=n}else n===null&&s instanceof me&&(n=s.type.name==="x32"?M.i32:s.type);return s instanceof me&&s.isScalar&&this._validateTypeRange(s.scalarValue,n),this._updateNode(new Gr(t.toString(),n,"","",s),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match(p.keywords.var))return null;let e=this._currentLine,t="",n="";this._match(p.tokens.less_than)&&(t=this._consume(p.storage_class,"Expected storage_class.").toString(),this._match(p.tokens.comma)&&(n=this._consume(p.access_mode,"Expected access_mode.").toString()),this._consume(p.tokens.greater_than,"Expected '>'."));let s=this._consume(p.tokens.name,"Expected variable name"),i=null;if(this._match(p.tokens.colon)){let o=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=o)}return this._updateNode(new ht(s.toString(),i,t,n,null),e)}_override_decl(){if(!this._match(p.keywords.override))return null;let e=this._consume(p.tokens.name,"Expected variable name"),t=null;if(this._match(p.tokens.colon)){let n=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=n)}return this._updateNode(new Xs(e.toString(),t,null))}_diagnostic(){this._consume(p.tokens.paren_left,"Expected '('");let e=this._consume(p.tokens.ident,"Expected severity control name.");this._consume(p.tokens.comma,"Expected ','");let t=this._consume(p.tokens.ident,"Expected diagnostic rule name.").toString();return this._match(p.tokens.period)&&(t+=`.${this._consume(p.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume(p.tokens.paren_right,"Expected ')'"),this._updateNode(new la(e.toString(),t))}_enable_directive(){let e=this._consume(p.tokens.ident,"identity expected.");return this._updateNode(new Lu(e.toString()))}_requires_directive(){let e=[this._consume(p.tokens.ident,"identity expected.").toString()];for(;this._match(p.tokens.comma);){let t=this._consume(p.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new Uu(e))}_type_alias(){let e=this._consume(p.tokens.ident,"identity expected.");this._consume(p.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(t===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);let n=this._updateNode(new qs(e.toString(),t));return this._context.aliases.set(n.name,n),n}_type_decl(){if(this._check([p.tokens.ident,...p.texel_format,p.keywords.bool,p.keywords.f32,p.keywords.i32,p.keywords.u32])){let n=this._advance().toString();if(this._context.structs.has(n))return this._context.structs.get(n);if(this._context.aliases.has(n))return this._context.aliases.get(n).type;if(!this._getType(n)){let s=this._updateNode(new ha(n));return this._forwardTypeCount++,s}return this._updateNode(new M(n))}let e=this._texture_sampler_types();if(e)return e;if(this._check(p.template_types)){let n=this._advance().toString(),s=null,i=null;return this._match(p.tokens.less_than)&&(s=this._type_decl(),i=null,this._match(p.tokens.comma)&&(i=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new A(n,s,i))}if(this._match(p.keywords.ptr)){let n=this._previous().toString();this._consume(p.tokens.less_than,"Expected '<' for pointer.");let s=this._consume(p.storage_class,"Expected storage_class for pointer");this._consume(p.tokens.comma,"Expected ',' for pointer.");let i=this._type_decl(),o=null;return this._match(p.tokens.comma)&&(o=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new js(n,s.toString(),i,o))}let t=this._attribute();if(this._match(p.keywords.array)){let n=null,s=-1,i=this._previous(),o=null;if(this._match(p.tokens.less_than)){n=this._type_decl(),this._context.aliases.has(n.name)&&(n=this._context.aliases.get(n.name).type);let c="";if(this._match(p.tokens.comma)){o=this._shift_expression();try{c=o.constEvaluate(this._exec).toString(),o=null}catch{c="1"}}this._consume(p.tokens.greater_than,"Expected '>' for array."),s=c?parseInt(c):0}let a=this._updateNode(new Qr(i.toString(),t,n,s));return o&&this._deferArrayCountEval.push({arrayType:a,countNode:o}),a}return null}_texture_sampler_types(){if(this._match(p.sampler_type))return this._updateNode(new Zr(this._previous().toString(),null,null));if(this._match(p.depth_texture_type))return this._updateNode(new Zr(this._previous().toString(),null,null));if(this._match(p.sampled_texture_type)||this._match(p.multisampled_texture_type)){let e=this._previous();this._consume(p.tokens.less_than,"Expected '<' for sampler type.");let t=this._type_decl();return this._consume(p.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new Zr(e.toString(),t,null))}if(this._match(p.storage_texture_type)){let e=this._previous();this._consume(p.tokens.less_than,"Expected '<' for sampler type.");let t=this._consume(p.texel_format,"Invalid texel format.").toString();this._consume(p.tokens.comma,"Expected ',' after texel format.");let n=this._consume(p.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(p.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new Zr(e.toString(),t,n))}return null}_attribute(){let e=[];for(;this._match(p.tokens.attr);){let t=this._consume(p.attribute_name,"Expected attribute name"),n=this._updateNode(new Ta(t.toString(),null));if(this._match(p.tokens.paren_left)){if(n.value=this._consume(p.literal_or_ident,"Expected attribute value").toString(),this._check(p.tokens.comma)){this._advance();do{let s=this._consume(p.literal_or_ident,"Expected attribute value").toString();n.value instanceof Array||(n.value=[n.value]),n.value.push(s)}while(this._match(p.tokens.comma))}this._consume(p.tokens.paren_right,"Expected ')'")}e.push(n)}return e.length==0?null:e}},Ea=class extends et{constructor(e){super(),e&&this.update(e)}update(e){let t=new Yu().parse(e);this.updateAST(t)}};function Ku(r){let e={attributes:[],bindings:[]},t;try{t=C0(r)}catch(i){return I.error(i.message)(),e}for(let i of t.uniforms){let o=[];for(let a of i.type?.members||[])o.push({name:a.name,type:cm(a.type)});e.bindings.push({type:"uniform",name:i.name,group:i.group,location:i.binding,members:o})}for(let i of t.textures)e.bindings.push({type:"texture",name:i.name,group:i.group,location:i.binding});for(let i of t.samplers)e.bindings.push({type:"sampler",name:i.name,group:i.group,location:i.binding});let n=t.entry.vertex[0],s=n?.inputs.length||0;for(let i=0;i<s;i++){let o=n.inputs[i];if(o.locationType==="location"){let a=cm(o.type);e.attributes.push({name:o.name,location:Number(o.location),type:a})}}return e}function cm(r){return r?.format?`${r.name}<${r.format.name}>`:r.name}function C0(r){try{return new Ea(r)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw typeof e=="object"&&e?.message&&(t+=`: ${e.message} `),typeof e=="object"&&e?.token&&(t+=e.token.line||""),new Error(t,{cause:e})}}var M0=1/Math.PI*180,O0=1/180*Math.PI,k0={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...k0}};var ge=globalThis.mathgl.config;function ei(r,{precision:e=ge.precision}={}){return r=N0(r),`${parseFloat(r.toPrecision(e))}`}function Qt(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Zn(r,e){return Zu(r,t=>t*O0,e)}function wr(r,e){return Zu(r,t=>t*M0,e)}function ee(r,e,t){return Zu(r,n=>Math.max(e,Math.min(t,n)))}function Jt(r,e,t){return Qt(r)?r.map((n,s)=>Jt(n,e[s],t)):t*e+(1-t)*r}function Xe(r,e,t){let n=ge.EPSILON;t&&(ge.EPSILON=t);try{if(r===e)return!0;if(Qt(r)&&Qt(e)){if(r.length!==e.length)return!1;for(let s=0;s<r.length;++s)if(!Xe(r[s],e[s]))return!1;return!0}return r&&r.equals?r.equals(e):e&&e.equals?e.equals(r):typeof r=="number"&&typeof e=="number"?Math.abs(r-e)<=ge.EPSILON*Math.max(1,Math.abs(r),Math.abs(e)):!1}finally{ge.EPSILON=n}}function N0(r){return Math.round(r/ge.EPSILON)*ge.EPSILON}function D0(r){return r.clone?r.clone():new Array(r.length)}function Zu(r,e,t){if(Qt(r)){let n=r;t=t||D0(n);for(let s=0;s<t.length&&s<n.length;++s){let i=typeof r=="number"?r:r[s];t[s]=e(i,s,t)}return t}return e(r)}var Gn=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}toArray(e=[],t=0){for(let n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Qt(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(ge)}formatString(e){let t="";for(let n=0;n<this.ELEMENTS;++n)t+=(n>0?", ":"")+ei(this[n],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!Xe(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,n){if(n===void 0)return this.lerp(this,e,t);for(let s=0;s<this.ELEMENTS;++s){let i=e[s],o=typeof t=="number"?t:t[s];this[s]=i+n*(o-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}add(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=t[n];return this.check()}subtract(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=t[n];return this.check()}scale(e){if(typeof e=="number")for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(ge.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),t);return this.check()}get elements(){return this}};function F0(r,e){if(r.length!==e)return!1;for(let t=0;t<r.length;++t)if(!Number.isFinite(r[t]))return!1;return!0}function Re(r){if(!Number.isFinite(r))throw new Error(`Invalid number ${JSON.stringify(r)}`);return r}function Ra(r,e,t=""){if(ge.debug&&!F0(r,e))throw new Error(`math.gl: ${t} some fields set to invalid numbers'`);return r}function Gu(r,e){if(!r)throw new Error(`math.gl assertion ${e}`)}var Ia=class extends Gn{get x(){return this[0]}set x(e){this[0]=Re(e)}get y(){return this[1]}set y(e){this[1]=Re(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let n=0;n<this.ELEMENTS;++n){let s=this[n]-e[n];t+=s*s}return Re(t)}dot(e){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return Re(t)}normalize(){let e=this.magnitude();if(e!==0)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]*=t[n];return this.check()}divide(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Gu(e>=0&&e<this.ELEMENTS,"index is out of range"),Re(this[e])}setComponent(e,t){return Gu(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}};var _e={};Ht(_e,{add:()=>z0,angle:()=>o1,ceil:()=>W0,clone:()=>B0,copy:()=>U0,create:()=>lm,cross:()=>J0,dist:()=>m1,distance:()=>dm,div:()=>p1,divide:()=>hm,dot:()=>Q0,equals:()=>u1,exactEquals:()=>l1,floor:()=>$0,forEach:()=>y1,fromValues:()=>L0,inverse:()=>Z0,len:()=>f1,length:()=>mm,lerp:()=>e1,max:()=>H0,min:()=>j0,mul:()=>d1,multiply:()=>fm,negate:()=>K0,normalize:()=>G0,random:()=>t1,rotate:()=>i1,round:()=>X0,scale:()=>Y0,scaleAndAdd:()=>q0,set:()=>V0,sqrDist:()=>g1,sqrLen:()=>_1,squaredDistance:()=>pm,squaredLength:()=>gm,str:()=>c1,sub:()=>h1,subtract:()=>um,transformMat2:()=>r1,transformMat2d:()=>n1,transformMat3:()=>s1,transformMat4:()=>Qu,zero:()=>a1});var fe=typeof Float32Array<"u"?Float32Array:Array,Mt=Math.random;function rt(r){return r>=0?Math.round(r):r%.5===0?Math.floor(r):Math.round(r)}var hM=Math.PI/180;function lm(){let r=new fe(2);return fe!=Float32Array&&(r[0]=0,r[1]=0),r}function B0(r){let e=new fe(2);return e[0]=r[0],e[1]=r[1],e}function L0(r,e){let t=new fe(2);return t[0]=r,t[1]=e,t}function U0(r,e){return r[0]=e[0],r[1]=e[1],r}function V0(r,e,t){return r[0]=e,r[1]=t,r}function z0(r,e,t){return r[0]=e[0]+t[0],r[1]=e[1]+t[1],r}function um(r,e,t){return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r}function fm(r,e,t){return r[0]=e[0]*t[0],r[1]=e[1]*t[1],r}function hm(r,e,t){return r[0]=e[0]/t[0],r[1]=e[1]/t[1],r}function W0(r,e){return r[0]=Math.ceil(e[0]),r[1]=Math.ceil(e[1]),r}function $0(r,e){return r[0]=Math.floor(e[0]),r[1]=Math.floor(e[1]),r}function j0(r,e,t){return r[0]=Math.min(e[0],t[0]),r[1]=Math.min(e[1],t[1]),r}function H0(r,e,t){return r[0]=Math.max(e[0],t[0]),r[1]=Math.max(e[1],t[1]),r}function X0(r,e){return r[0]=rt(e[0]),r[1]=rt(e[1]),r}function Y0(r,e,t){return r[0]=e[0]*t,r[1]=e[1]*t,r}function q0(r,e,t,n){return r[0]=e[0]+t[0]*n,r[1]=e[1]+t[1]*n,r}function dm(r,e){let t=e[0]-r[0],n=e[1]-r[1];return Math.sqrt(t*t+n*n)}function pm(r,e){let t=e[0]-r[0],n=e[1]-r[1];return t*t+n*n}function mm(r){let e=r[0],t=r[1];return Math.sqrt(e*e+t*t)}function gm(r){let e=r[0],t=r[1];return e*e+t*t}function K0(r,e){return r[0]=-e[0],r[1]=-e[1],r}function Z0(r,e){return r[0]=1/e[0],r[1]=1/e[1],r}function G0(r,e){let t=e[0],n=e[1],s=t*t+n*n;return s>0&&(s=1/Math.sqrt(s)),r[0]=e[0]*s,r[1]=e[1]*s,r}function Q0(r,e){return r[0]*e[0]+r[1]*e[1]}function J0(r,e,t){let n=e[0]*t[1]-e[1]*t[0];return r[0]=r[1]=0,r[2]=n,r}function e1(r,e,t,n){let s=e[0],i=e[1];return r[0]=s+n*(t[0]-s),r[1]=i+n*(t[1]-i),r}function t1(r,e){e=e===void 0?1:e;let t=Mt()*2*Math.PI;return r[0]=Math.cos(t)*e,r[1]=Math.sin(t)*e,r}function r1(r,e,t){let n=e[0],s=e[1];return r[0]=t[0]*n+t[2]*s,r[1]=t[1]*n+t[3]*s,r}function n1(r,e,t){let n=e[0],s=e[1];return r[0]=t[0]*n+t[2]*s+t[4],r[1]=t[1]*n+t[3]*s+t[5],r}function s1(r,e,t){let n=e[0],s=e[1];return r[0]=t[0]*n+t[3]*s+t[6],r[1]=t[1]*n+t[4]*s+t[7],r}function Qu(r,e,t){let n=e[0],s=e[1];return r[0]=t[0]*n+t[4]*s+t[12],r[1]=t[1]*n+t[5]*s+t[13],r}function i1(r,e,t,n){let s=e[0]-t[0],i=e[1]-t[1],o=Math.sin(n),a=Math.cos(n);return r[0]=s*a-i*o+t[0],r[1]=s*o+i*a+t[1],r}function o1(r,e){let t=r[0],n=r[1],s=e[0],i=e[1],o=Math.sqrt((t*t+n*n)*(s*s+i*i)),a=o&&(t*s+n*i)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function a1(r){return r[0]=0,r[1]=0,r}function c1(r){return`vec2(${r[0]}, ${r[1]})`}function l1(r,e){return r[0]===e[0]&&r[1]===e[1]}function u1(r,e){let t=r[0],n=r[1],s=e[0],i=e[1];return Math.abs(t-s)<=1e-6*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(n-i)<=1e-6*Math.max(1,Math.abs(n),Math.abs(i))}var f1=mm,h1=um,d1=fm,p1=hm,m1=dm,g1=pm,_1=gm,y1=function(){let r=lm();return function(e,t,n,s,i,o){let a,c;for(t||(t=2),n||(n=0),s?c=Math.min(s*t+n,e.length):c=e.length,a=n;a<c;a+=t)r[0]=e[a],r[1]=e[a+1],i(r,r,o),e[a]=r[0],e[a+1]=r[1];return e}}();function _m(r,e,t){let n=e[0],s=e[1],i=t[3]*n+t[7]*s||1;return r[0]=(t[0]*n+t[4]*s)/i,r[1]=(t[1]*n+t[5]*s)/i,r}function Ca(r,e,t){let n=e[0],s=e[1],i=e[2],o=t[3]*n+t[7]*s+t[11]*i||1;return r[0]=(t[0]*n+t[4]*s+t[8]*i)/o,r[1]=(t[1]*n+t[5]*s+t[9]*i)/o,r[2]=(t[2]*n+t[6]*s+t[10]*i)/o,r}function ym(r,e,t){let n=e[0],s=e[1];return r[0]=t[0]*n+t[2]*s,r[1]=t[1]*n+t[3]*s,r[2]=e[2],r}var Oe={};Ht(Oe,{add:()=>v1,angle:()=>af,bezier:()=>B1,ceil:()=>A1,clone:()=>x1,copy:()=>T1,create:()=>xm,cross:()=>ef,dist:()=>X1,distance:()=>vm,div:()=>H1,divide:()=>wm,dot:()=>Ju,equals:()=>W1,exactEquals:()=>z1,floor:()=>S1,forEach:()=>Z1,fromValues:()=>b1,hermite:()=>F1,inverse:()=>O1,len:()=>q1,length:()=>Ma,lerp:()=>N1,max:()=>R1,min:()=>E1,mul:()=>j1,multiply:()=>Tm,negate:()=>M1,normalize:()=>k1,random:()=>L1,rotateX:()=>nf,rotateY:()=>sf,rotateZ:()=>of,round:()=>I1,scale:()=>P1,scaleAndAdd:()=>C1,set:()=>w1,slerp:()=>D1,sqrDist:()=>Y1,sqrLen:()=>K1,squaredDistance:()=>Am,squaredLength:()=>Sm,str:()=>V1,sub:()=>$1,subtract:()=>bm,transformMat3:()=>tf,transformMat4:()=>ti,transformQuat:()=>rf,zero:()=>U1});function xm(){let r=new fe(3);return fe!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function x1(r){let e=new fe(3);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e}function Ma(r){let e=r[0],t=r[1],n=r[2];return Math.sqrt(e*e+t*t+n*n)}function b1(r,e,t){let n=new fe(3);return n[0]=r,n[1]=e,n[2]=t,n}function T1(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r}function w1(r,e,t,n){return r[0]=e,r[1]=t,r[2]=n,r}function v1(r,e,t){return r[0]=e[0]+t[0],r[1]=e[1]+t[1],r[2]=e[2]+t[2],r}function bm(r,e,t){return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],r}function Tm(r,e,t){return r[0]=e[0]*t[0],r[1]=e[1]*t[1],r[2]=e[2]*t[2],r}function wm(r,e,t){return r[0]=e[0]/t[0],r[1]=e[1]/t[1],r[2]=e[2]/t[2],r}function A1(r,e){return r[0]=Math.ceil(e[0]),r[1]=Math.ceil(e[1]),r[2]=Math.ceil(e[2]),r}function S1(r,e){return r[0]=Math.floor(e[0]),r[1]=Math.floor(e[1]),r[2]=Math.floor(e[2]),r}function E1(r,e,t){return r[0]=Math.min(e[0],t[0]),r[1]=Math.min(e[1],t[1]),r[2]=Math.min(e[2],t[2]),r}function R1(r,e,t){return r[0]=Math.max(e[0],t[0]),r[1]=Math.max(e[1],t[1]),r[2]=Math.max(e[2],t[2]),r}function I1(r,e){return r[0]=rt(e[0]),r[1]=rt(e[1]),r[2]=rt(e[2]),r}function P1(r,e,t){return r[0]=e[0]*t,r[1]=e[1]*t,r[2]=e[2]*t,r}function C1(r,e,t,n){return r[0]=e[0]+t[0]*n,r[1]=e[1]+t[1]*n,r[2]=e[2]+t[2]*n,r}function vm(r,e){let t=e[0]-r[0],n=e[1]-r[1],s=e[2]-r[2];return Math.sqrt(t*t+n*n+s*s)}function Am(r,e){let t=e[0]-r[0],n=e[1]-r[1],s=e[2]-r[2];return t*t+n*n+s*s}function Sm(r){let e=r[0],t=r[1],n=r[2];return e*e+t*t+n*n}function M1(r,e){return r[0]=-e[0],r[1]=-e[1],r[2]=-e[2],r}function O1(r,e){return r[0]=1/e[0],r[1]=1/e[1],r[2]=1/e[2],r}function k1(r,e){let t=e[0],n=e[1],s=e[2],i=t*t+n*n+s*s;return i>0&&(i=1/Math.sqrt(i)),r[0]=e[0]*i,r[1]=e[1]*i,r[2]=e[2]*i,r}function Ju(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]}function ef(r,e,t){let n=e[0],s=e[1],i=e[2],o=t[0],a=t[1],c=t[2];return r[0]=s*c-i*a,r[1]=i*o-n*c,r[2]=n*a-s*o,r}function N1(r,e,t,n){let s=e[0],i=e[1],o=e[2];return r[0]=s+n*(t[0]-s),r[1]=i+n*(t[1]-i),r[2]=o+n*(t[2]-o),r}function D1(r,e,t,n){let s=Math.acos(Math.min(Math.max(Ju(e,t),-1),1)),i=Math.sin(s),o=Math.sin((1-n)*s)/i,a=Math.sin(n*s)/i;return r[0]=o*e[0]+a*t[0],r[1]=o*e[1]+a*t[1],r[2]=o*e[2]+a*t[2],r}function F1(r,e,t,n,s,i){let o=i*i,a=o*(2*i-3)+1,c=o*(i-2)+i,l=o*(i-1),u=o*(3-2*i);return r[0]=e[0]*a+t[0]*c+n[0]*l+s[0]*u,r[1]=e[1]*a+t[1]*c+n[1]*l+s[1]*u,r[2]=e[2]*a+t[2]*c+n[2]*l+s[2]*u,r}function B1(r,e,t,n,s,i){let o=1-i,a=o*o,c=i*i,l=a*o,u=3*i*a,f=3*c*o,h=c*i;return r[0]=e[0]*l+t[0]*u+n[0]*f+s[0]*h,r[1]=e[1]*l+t[1]*u+n[1]*f+s[1]*h,r[2]=e[2]*l+t[2]*u+n[2]*f+s[2]*h,r}function L1(r,e){e=e===void 0?1:e;let t=Mt()*2*Math.PI,n=Mt()*2-1,s=Math.sqrt(1-n*n)*e;return r[0]=Math.cos(t)*s,r[1]=Math.sin(t)*s,r[2]=n*e,r}function ti(r,e,t){let n=e[0],s=e[1],i=e[2],o=t[3]*n+t[7]*s+t[11]*i+t[15];return o=o||1,r[0]=(t[0]*n+t[4]*s+t[8]*i+t[12])/o,r[1]=(t[1]*n+t[5]*s+t[9]*i+t[13])/o,r[2]=(t[2]*n+t[6]*s+t[10]*i+t[14])/o,r}function tf(r,e,t){let n=e[0],s=e[1],i=e[2];return r[0]=n*t[0]+s*t[3]+i*t[6],r[1]=n*t[1]+s*t[4]+i*t[7],r[2]=n*t[2]+s*t[5]+i*t[8],r}function rf(r,e,t){let n=t[0],s=t[1],i=t[2],o=t[3],a=e[0],c=e[1],l=e[2],u=s*l-i*c,f=i*a-n*l,h=n*c-s*a,d=s*h-i*f,m=i*u-n*h,y=n*f-s*u,_=o*2;return u*=_,f*=_,h*=_,d*=2,m*=2,y*=2,r[0]=a+u+d,r[1]=c+f+m,r[2]=l+h+y,r}function nf(r,e,t,n){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0],i[1]=s[1]*Math.cos(n)-s[2]*Math.sin(n),i[2]=s[1]*Math.sin(n)+s[2]*Math.cos(n),r[0]=i[0]+t[0],r[1]=i[1]+t[1],r[2]=i[2]+t[2],r}function sf(r,e,t,n){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[2]*Math.sin(n)+s[0]*Math.cos(n),i[1]=s[1],i[2]=s[2]*Math.cos(n)-s[0]*Math.sin(n),r[0]=i[0]+t[0],r[1]=i[1]+t[1],r[2]=i[2]+t[2],r}function of(r,e,t,n){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0]*Math.cos(n)-s[1]*Math.sin(n),i[1]=s[0]*Math.sin(n)+s[1]*Math.cos(n),i[2]=s[2],r[0]=i[0]+t[0],r[1]=i[1]+t[1],r[2]=i[2]+t[2],r}function af(r,e){let t=r[0],n=r[1],s=r[2],i=e[0],o=e[1],a=e[2],c=Math.sqrt((t*t+n*n+s*s)*(i*i+o*o+a*a)),l=c&&Ju(r,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function U1(r){return r[0]=0,r[1]=0,r[2]=0,r}function V1(r){return`vec3(${r[0]}, ${r[1]}, ${r[2]})`}function z1(r,e){return r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]}function W1(r,e){let t=r[0],n=r[1],s=r[2],i=e[0],o=e[1],a=e[2];return Math.abs(t-i)<=1e-6*Math.max(1,Math.abs(t),Math.abs(i))&&Math.abs(n-o)<=1e-6*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}var $1=bm,j1=Tm,H1=wm,X1=vm,Y1=Am,q1=Ma,K1=Sm,Z1=function(){let r=xm();return function(e,t,n,s,i,o){let a,c;for(t||(t=3),n||(n=0),s?c=Math.min(s*t+n,e.length):c=e.length,a=n;a<c;a+=t)r[0]=e[a],r[1]=e[a+1],r[2]=e[a+2],i(r,r,o),e[a]=r[0],e[a+1]=r[1],e[a+2]=r[2];return e}}();var cf=[0,0,0],Oa,G=class extends Ia{static get ZERO(){return Oa||(Oa=new G(0,0,0),Object.freeze(Oa)),Oa}constructor(e=0,t=0,n=0){super(-0,-0,-0),arguments.length===1&&Qt(e)?this.copy(e):(ge.debug&&(Re(e),Re(t),Re(n)),this[0]=e,this[1]=t,this[2]=n)}set(e,t,n){return this[0]=e,this[1]=t,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return ge.debug&&(Re(e.x),Re(e.y),Re(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=Re(e)}angle(e){return af(this,e)}cross(e){return ef(this,this,e),this.check()}rotateX({radians:e,origin:t=cf}){return nf(this,this,t,e),this.check()}rotateY({radians:e,origin:t=cf}){return sf(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=cf}){return of(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return ti(this,this,e),this.check()}transformAsVector(e){return Ca(this,this,e),this.check()}transformByMatrix3(e){return tf(this,this,e),this.check()}transformByMatrix2(e){return ym(this,this,e),this.check()}transformByQuaternion(e){return rf(this,this,e),this.check()}};var ka=class extends Gn{toString(){let e="[";if(ge.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+t]}`}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,n){return this[t*this.RANK+e]=Re(n),this}getColumn(e,t=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let s=0;s<this.RANK;++s)t[s]=this[n+s];return t}setColumn(e,t){let n=e*this.RANK;for(let s=0;s<this.RANK;++s)this[n+s]=t[s];return this}};var ye={};Ht(ye,{add:()=>TT,adjoint:()=>rT,clone:()=>Q1,copy:()=>J1,create:()=>G1,decompose:()=>hT,determinant:()=>ff,equals:()=>ST,exactEquals:()=>AT,frob:()=>bT,fromQuat:()=>yf,fromQuat2:()=>lT,fromRotation:()=>iT,fromRotationTranslation:()=>Rm,fromRotationTranslationScale:()=>dT,fromRotationTranslationScaleOrigin:()=>pT,fromScaling:()=>sT,fromTranslation:()=>nT,fromValues:()=>eT,fromXRotation:()=>oT,fromYRotation:()=>aT,fromZRotation:()=>cT,frustum:()=>xf,getRotation:()=>fT,getScaling:()=>Im,getTranslation:()=>uT,identity:()=>Em,invert:()=>uf,lookAt:()=>wf,mul:()=>ET,multiply:()=>ri,multiplyScalar:()=>wT,multiplyScalarAndAdd:()=>vT,ortho:()=>Tf,orthoNO:()=>Cm,orthoZO:()=>_T,perspective:()=>bf,perspectiveFromFieldOfView:()=>gT,perspectiveNO:()=>Pm,perspectiveZO:()=>mT,rotate:()=>pf,rotateX:()=>mf,rotateY:()=>gf,rotateZ:()=>_f,scale:()=>df,set:()=>tT,str:()=>xT,sub:()=>RT,subtract:()=>Mm,targetTo:()=>yT,translate:()=>hf,transpose:()=>lf});function G1(){let r=new fe(16);return fe!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0),r[0]=1,r[5]=1,r[10]=1,r[15]=1,r}function Q1(r){let e=new fe(16);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],e}function J1(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r}function eT(r,e,t,n,s,i,o,a,c,l,u,f,h,d,m,y){let _=new fe(16);return _[0]=r,_[1]=e,_[2]=t,_[3]=n,_[4]=s,_[5]=i,_[6]=o,_[7]=a,_[8]=c,_[9]=l,_[10]=u,_[11]=f,_[12]=h,_[13]=d,_[14]=m,_[15]=y,_}function tT(r,e,t,n,s,i,o,a,c,l,u,f,h,d,m,y,_){return r[0]=e,r[1]=t,r[2]=n,r[3]=s,r[4]=i,r[5]=o,r[6]=a,r[7]=c,r[8]=l,r[9]=u,r[10]=f,r[11]=h,r[12]=d,r[13]=m,r[14]=y,r[15]=_,r}function Em(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function lf(r,e){if(r===e){let t=e[1],n=e[2],s=e[3],i=e[6],o=e[7],a=e[11];r[1]=e[4],r[2]=e[8],r[3]=e[12],r[4]=t,r[6]=e[9],r[7]=e[13],r[8]=n,r[9]=i,r[11]=e[14],r[12]=s,r[13]=o,r[14]=a}else r[0]=e[0],r[1]=e[4],r[2]=e[8],r[3]=e[12],r[4]=e[1],r[5]=e[5],r[6]=e[9],r[7]=e[13],r[8]=e[2],r[9]=e[6],r[10]=e[10],r[11]=e[14],r[12]=e[3],r[13]=e[7],r[14]=e[11],r[15]=e[15];return r}function uf(r,e){let t=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],d=e[11],m=e[12],y=e[13],_=e[14],x=e[15],E=t*a-n*o,b=t*c-s*o,S=t*l-i*o,C=n*c-s*a,P=n*l-i*a,B=s*l-i*c,N=u*y-f*m,k=u*_-h*m,F=u*x-d*m,U=f*_-h*y,X=f*x-d*y,J=h*x-d*_,q=E*J-b*X+S*U+C*F-P*k+B*N;return q?(q=1/q,r[0]=(a*J-c*X+l*U)*q,r[1]=(s*X-n*J-i*U)*q,r[2]=(y*B-_*P+x*C)*q,r[3]=(h*P-f*B-d*C)*q,r[4]=(c*F-o*J-l*k)*q,r[5]=(t*J-s*F+i*k)*q,r[6]=(_*S-m*B-x*b)*q,r[7]=(u*B-h*S+d*b)*q,r[8]=(o*X-a*F+l*N)*q,r[9]=(n*F-t*X-i*N)*q,r[10]=(m*P-y*S+x*E)*q,r[11]=(f*S-u*P-d*E)*q,r[12]=(a*k-o*U-c*N)*q,r[13]=(t*U-n*k+s*N)*q,r[14]=(y*b-m*C-_*E)*q,r[15]=(u*C-f*b+h*E)*q,r):null}function rT(r,e){let t=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],d=e[11],m=e[12],y=e[13],_=e[14],x=e[15],E=t*a-n*o,b=t*c-s*o,S=t*l-i*o,C=n*c-s*a,P=n*l-i*a,B=s*l-i*c,N=u*y-f*m,k=u*_-h*m,F=u*x-d*m,U=f*_-h*y,X=f*x-d*y,J=h*x-d*_;return r[0]=a*J-c*X+l*U,r[1]=s*X-n*J-i*U,r[2]=y*B-_*P+x*C,r[3]=h*P-f*B-d*C,r[4]=c*F-o*J-l*k,r[5]=t*J-s*F+i*k,r[6]=_*S-m*B-x*b,r[7]=u*B-h*S+d*b,r[8]=o*X-a*F+l*N,r[9]=n*F-t*X-i*N,r[10]=m*P-y*S+x*E,r[11]=f*S-u*P-d*E,r[12]=a*k-o*U-c*N,r[13]=t*U-n*k+s*N,r[14]=y*b-m*C-_*E,r[15]=u*C-f*b+h*E,r}function ff(r){let e=r[0],t=r[1],n=r[2],s=r[3],i=r[4],o=r[5],a=r[6],c=r[7],l=r[8],u=r[9],f=r[10],h=r[11],d=r[12],m=r[13],y=r[14],_=r[15],x=e*o-t*i,E=e*a-n*i,b=t*a-n*o,S=l*m-u*d,C=l*y-f*d,P=u*y-f*m,B=e*P-t*C+n*S,N=i*P-o*C+a*S,k=l*b-u*E+f*x,F=d*b-m*E+y*x;return c*B-s*N+_*k-h*F}function ri(r,e,t){let n=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=e[9],d=e[10],m=e[11],y=e[12],_=e[13],x=e[14],E=e[15],b=t[0],S=t[1],C=t[2],P=t[3];return r[0]=b*n+S*a+C*f+P*y,r[1]=b*s+S*c+C*h+P*_,r[2]=b*i+S*l+C*d+P*x,r[3]=b*o+S*u+C*m+P*E,b=t[4],S=t[5],C=t[6],P=t[7],r[4]=b*n+S*a+C*f+P*y,r[5]=b*s+S*c+C*h+P*_,r[6]=b*i+S*l+C*d+P*x,r[7]=b*o+S*u+C*m+P*E,b=t[8],S=t[9],C=t[10],P=t[11],r[8]=b*n+S*a+C*f+P*y,r[9]=b*s+S*c+C*h+P*_,r[10]=b*i+S*l+C*d+P*x,r[11]=b*o+S*u+C*m+P*E,b=t[12],S=t[13],C=t[14],P=t[15],r[12]=b*n+S*a+C*f+P*y,r[13]=b*s+S*c+C*h+P*_,r[14]=b*i+S*l+C*d+P*x,r[15]=b*o+S*u+C*m+P*E,r}function hf(r,e,t){let n=t[0],s=t[1],i=t[2],o,a,c,l,u,f,h,d,m,y,_,x;return e===r?(r[12]=e[0]*n+e[4]*s+e[8]*i+e[12],r[13]=e[1]*n+e[5]*s+e[9]*i+e[13],r[14]=e[2]*n+e[6]*s+e[10]*i+e[14],r[15]=e[3]*n+e[7]*s+e[11]*i+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],u=e[4],f=e[5],h=e[6],d=e[7],m=e[8],y=e[9],_=e[10],x=e[11],r[0]=o,r[1]=a,r[2]=c,r[3]=l,r[4]=u,r[5]=f,r[6]=h,r[7]=d,r[8]=m,r[9]=y,r[10]=_,r[11]=x,r[12]=o*n+u*s+m*i+e[12],r[13]=a*n+f*s+y*i+e[13],r[14]=c*n+h*s+_*i+e[14],r[15]=l*n+d*s+x*i+e[15]),r}function df(r,e,t){let n=t[0],s=t[1],i=t[2];return r[0]=e[0]*n,r[1]=e[1]*n,r[2]=e[2]*n,r[3]=e[3]*n,r[4]=e[4]*s,r[5]=e[5]*s,r[6]=e[6]*s,r[7]=e[7]*s,r[8]=e[8]*i,r[9]=e[9]*i,r[10]=e[10]*i,r[11]=e[11]*i,r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r}function pf(r,e,t,n){let s=n[0],i=n[1],o=n[2],a=Math.sqrt(s*s+i*i+o*o),c,l,u,f,h,d,m,y,_,x,E,b,S,C,P,B,N,k,F,U,X,J,q,pe;return a<1e-6?null:(a=1/a,s*=a,i*=a,o*=a,l=Math.sin(t),c=Math.cos(t),u=1-c,f=e[0],h=e[1],d=e[2],m=e[3],y=e[4],_=e[5],x=e[6],E=e[7],b=e[8],S=e[9],C=e[10],P=e[11],B=s*s*u+c,N=i*s*u+o*l,k=o*s*u-i*l,F=s*i*u-o*l,U=i*i*u+c,X=o*i*u+s*l,J=s*o*u+i*l,q=i*o*u-s*l,pe=o*o*u+c,r[0]=f*B+y*N+b*k,r[1]=h*B+_*N+S*k,r[2]=d*B+x*N+C*k,r[3]=m*B+E*N+P*k,r[4]=f*F+y*U+b*X,r[5]=h*F+_*U+S*X,r[6]=d*F+x*U+C*X,r[7]=m*F+E*U+P*X,r[8]=f*J+y*q+b*pe,r[9]=h*J+_*q+S*pe,r[10]=d*J+x*q+C*pe,r[11]=m*J+E*q+P*pe,e!==r&&(r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r)}function mf(r,e,t){let n=Math.sin(t),s=Math.cos(t),i=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11];return e!==r&&(r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[4]=i*s+l*n,r[5]=o*s+u*n,r[6]=a*s+f*n,r[7]=c*s+h*n,r[8]=l*s-i*n,r[9]=u*s-o*n,r[10]=f*s-a*n,r[11]=h*s-c*n,r}function gf(r,e,t){let n=Math.sin(t),s=Math.cos(t),i=e[0],o=e[1],a=e[2],c=e[3],l=e[8],u=e[9],f=e[10],h=e[11];return e!==r&&(r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=i*s-l*n,r[1]=o*s-u*n,r[2]=a*s-f*n,r[3]=c*s-h*n,r[8]=i*n+l*s,r[9]=o*n+u*s,r[10]=a*n+f*s,r[11]=c*n+h*s,r}function _f(r,e,t){let n=Math.sin(t),s=Math.cos(t),i=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=e[5],f=e[6],h=e[7];return e!==r&&(r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=i*s+l*n,r[1]=o*s+u*n,r[2]=a*s+f*n,r[3]=c*s+h*n,r[4]=l*s-i*n,r[5]=u*s-o*n,r[6]=f*s-a*n,r[7]=h*s-c*n,r}function nT(r,e){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=e[0],r[13]=e[1],r[14]=e[2],r[15]=1,r}function sT(r,e){return r[0]=e[0],r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=e[1],r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=e[2],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function iT(r,e,t){let n=t[0],s=t[1],i=t[2],o=Math.sqrt(n*n+s*s+i*i),a,c,l;return o<1e-6?null:(o=1/o,n*=o,s*=o,i*=o,c=Math.sin(e),a=Math.cos(e),l=1-a,r[0]=n*n*l+a,r[1]=s*n*l+i*c,r[2]=i*n*l-s*c,r[3]=0,r[4]=n*s*l-i*c,r[5]=s*s*l+a,r[6]=i*s*l+n*c,r[7]=0,r[8]=n*i*l+s*c,r[9]=s*i*l-n*c,r[10]=i*i*l+a,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r)}function oT(r,e){let t=Math.sin(e),n=Math.cos(e);return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=n,r[6]=t,r[7]=0,r[8]=0,r[9]=-t,r[10]=n,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function aT(r,e){let t=Math.sin(e),n=Math.cos(e);return r[0]=n,r[1]=0,r[2]=-t,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=t,r[9]=0,r[10]=n,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function cT(r,e){let t=Math.sin(e),n=Math.cos(e);return r[0]=n,r[1]=t,r[2]=0,r[3]=0,r[4]=-t,r[5]=n,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function Rm(r,e,t){let n=e[0],s=e[1],i=e[2],o=e[3],a=n+n,c=s+s,l=i+i,u=n*a,f=n*c,h=n*l,d=s*c,m=s*l,y=i*l,_=o*a,x=o*c,E=o*l;return r[0]=1-(d+y),r[1]=f+E,r[2]=h-x,r[3]=0,r[4]=f-E,r[5]=1-(u+y),r[6]=m+_,r[7]=0,r[8]=h+x,r[9]=m-_,r[10]=1-(u+d),r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r}function lT(r,e){let t=new fe(3),n=-e[0],s=-e[1],i=-e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=n*n+s*s+i*i+o*o;return f>0?(t[0]=(a*o+u*n+c*i-l*s)*2/f,t[1]=(c*o+u*s+l*n-a*i)*2/f,t[2]=(l*o+u*i+a*s-c*n)*2/f):(t[0]=(a*o+u*n+c*i-l*s)*2,t[1]=(c*o+u*s+l*n-a*i)*2,t[2]=(l*o+u*i+a*s-c*n)*2),Rm(r,e,t),r}function uT(r,e){return r[0]=e[12],r[1]=e[13],r[2]=e[14],r}function Im(r,e){let t=e[0],n=e[1],s=e[2],i=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return r[0]=Math.sqrt(t*t+n*n+s*s),r[1]=Math.sqrt(i*i+o*o+a*a),r[2]=Math.sqrt(c*c+l*l+u*u),r}function fT(r,e){let t=new fe(3);Im(t,e);let n=1/t[0],s=1/t[1],i=1/t[2],o=e[0]*n,a=e[1]*s,c=e[2]*i,l=e[4]*n,u=e[5]*s,f=e[6]*i,h=e[8]*n,d=e[9]*s,m=e[10]*i,y=o+u+m,_=0;return y>0?(_=Math.sqrt(y+1)*2,r[3]=.25*_,r[0]=(f-d)/_,r[1]=(h-c)/_,r[2]=(a-l)/_):o>u&&o>m?(_=Math.sqrt(1+o-u-m)*2,r[3]=(f-d)/_,r[0]=.25*_,r[1]=(a+l)/_,r[2]=(h+c)/_):u>m?(_=Math.sqrt(1+u-o-m)*2,r[3]=(h-c)/_,r[0]=(a+l)/_,r[1]=.25*_,r[2]=(f+d)/_):(_=Math.sqrt(1+m-o-u)*2,r[3]=(a-l)/_,r[0]=(h+c)/_,r[1]=(f+d)/_,r[2]=.25*_),r}function hT(r,e,t,n){e[0]=n[12],e[1]=n[13],e[2]=n[14];let s=n[0],i=n[1],o=n[2],a=n[4],c=n[5],l=n[6],u=n[8],f=n[9],h=n[10];t[0]=Math.sqrt(s*s+i*i+o*o),t[1]=Math.sqrt(a*a+c*c+l*l),t[2]=Math.sqrt(u*u+f*f+h*h);let d=1/t[0],m=1/t[1],y=1/t[2],_=s*d,x=i*m,E=o*y,b=a*d,S=c*m,C=l*y,P=u*d,B=f*m,N=h*y,k=_+S+N,F=0;return k>0?(F=Math.sqrt(k+1)*2,r[3]=.25*F,r[0]=(C-B)/F,r[1]=(P-E)/F,r[2]=(x-b)/F):_>S&&_>N?(F=Math.sqrt(1+_-S-N)*2,r[3]=(C-B)/F,r[0]=.25*F,r[1]=(x+b)/F,r[2]=(P+E)/F):S>N?(F=Math.sqrt(1+S-_-N)*2,r[3]=(P-E)/F,r[0]=(x+b)/F,r[1]=.25*F,r[2]=(C+B)/F):(F=Math.sqrt(1+N-_-S)*2,r[3]=(x-b)/F,r[0]=(P+E)/F,r[1]=(C+B)/F,r[2]=.25*F),r}function dT(r,e,t,n){let s=e[0],i=e[1],o=e[2],a=e[3],c=s+s,l=i+i,u=o+o,f=s*c,h=s*l,d=s*u,m=i*l,y=i*u,_=o*u,x=a*c,E=a*l,b=a*u,S=n[0],C=n[1],P=n[2];return r[0]=(1-(m+_))*S,r[1]=(h+b)*S,r[2]=(d-E)*S,r[3]=0,r[4]=(h-b)*C,r[5]=(1-(f+_))*C,r[6]=(y+x)*C,r[7]=0,r[8]=(d+E)*P,r[9]=(y-x)*P,r[10]=(1-(f+m))*P,r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r}function pT(r,e,t,n,s){let i=e[0],o=e[1],a=e[2],c=e[3],l=i+i,u=o+o,f=a+a,h=i*l,d=i*u,m=i*f,y=o*u,_=o*f,x=a*f,E=c*l,b=c*u,S=c*f,C=n[0],P=n[1],B=n[2],N=s[0],k=s[1],F=s[2],U=(1-(y+x))*C,X=(d+S)*C,J=(m-b)*C,q=(d-S)*P,pe=(1-(h+x))*P,$t=(_+E)*P,jt=(m+b)*B,Pd=(_-E)*B,Cd=(1-(h+y))*B;return r[0]=U,r[1]=X,r[2]=J,r[3]=0,r[4]=q,r[5]=pe,r[6]=$t,r[7]=0,r[8]=jt,r[9]=Pd,r[10]=Cd,r[11]=0,r[12]=t[0]+N-(U*N+q*k+jt*F),r[13]=t[1]+k-(X*N+pe*k+Pd*F),r[14]=t[2]+F-(J*N+$t*k+Cd*F),r[15]=1,r}function yf(r,e){let t=e[0],n=e[1],s=e[2],i=e[3],o=t+t,a=n+n,c=s+s,l=t*o,u=n*o,f=n*a,h=s*o,d=s*a,m=s*c,y=i*o,_=i*a,x=i*c;return r[0]=1-f-m,r[1]=u+x,r[2]=h-_,r[3]=0,r[4]=u-x,r[5]=1-l-m,r[6]=d+y,r[7]=0,r[8]=h+_,r[9]=d-y,r[10]=1-l-f,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function xf(r,e,t,n,s,i,o){let a=1/(t-e),c=1/(s-n),l=1/(i-o);return r[0]=i*2*a,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=i*2*c,r[6]=0,r[7]=0,r[8]=(t+e)*a,r[9]=(s+n)*c,r[10]=(o+i)*l,r[11]=-1,r[12]=0,r[13]=0,r[14]=o*i*2*l,r[15]=0,r}function Pm(r,e,t,n,s){let i=1/Math.tan(e/2);if(r[0]=i/t,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=i,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,s!=null&&s!==1/0){let o=1/(n-s);r[10]=(s+n)*o,r[14]=2*s*n*o}else r[10]=-1,r[14]=-2*n;return r}var bf=Pm;function mT(r,e,t,n,s){let i=1/Math.tan(e/2);if(r[0]=i/t,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=i,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,s!=null&&s!==1/0){let o=1/(n-s);r[10]=s*o,r[14]=s*n*o}else r[10]=-1,r[14]=-n;return r}function gT(r,e,t,n){let s=Math.tan(e.upDegrees*Math.PI/180),i=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(s+i);return r[0]=c,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=l,r[6]=0,r[7]=0,r[8]=-((o-a)*c*.5),r[9]=(s-i)*l*.5,r[10]=n/(t-n),r[11]=-1,r[12]=0,r[13]=0,r[14]=n*t/(t-n),r[15]=0,r}function Cm(r,e,t,n,s,i,o){let a=1/(e-t),c=1/(n-s),l=1/(i-o);return r[0]=-2*a,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*c,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=2*l,r[11]=0,r[12]=(e+t)*a,r[13]=(s+n)*c,r[14]=(o+i)*l,r[15]=1,r}var Tf=Cm;function _T(r,e,t,n,s,i,o){let a=1/(e-t),c=1/(n-s),l=1/(i-o);return r[0]=-2*a,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*c,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=l,r[11]=0,r[12]=(e+t)*a,r[13]=(s+n)*c,r[14]=i*l,r[15]=1,r}function wf(r,e,t,n){let s,i,o,a,c,l,u,f,h,d,m=e[0],y=e[1],_=e[2],x=n[0],E=n[1],b=n[2],S=t[0],C=t[1],P=t[2];return Math.abs(m-S)<1e-6&&Math.abs(y-C)<1e-6&&Math.abs(_-P)<1e-6?Em(r):(f=m-S,h=y-C,d=_-P,s=1/Math.sqrt(f*f+h*h+d*d),f*=s,h*=s,d*=s,i=E*d-b*h,o=b*f-x*d,a=x*h-E*f,s=Math.sqrt(i*i+o*o+a*a),s?(s=1/s,i*=s,o*=s,a*=s):(i=0,o=0,a=0),c=h*a-d*o,l=d*i-f*a,u=f*o-h*i,s=Math.sqrt(c*c+l*l+u*u),s?(s=1/s,c*=s,l*=s,u*=s):(c=0,l=0,u=0),r[0]=i,r[1]=c,r[2]=f,r[3]=0,r[4]=o,r[5]=l,r[6]=h,r[7]=0,r[8]=a,r[9]=u,r[10]=d,r[11]=0,r[12]=-(i*m+o*y+a*_),r[13]=-(c*m+l*y+u*_),r[14]=-(f*m+h*y+d*_),r[15]=1,r)}function yT(r,e,t,n){let s=e[0],i=e[1],o=e[2],a=n[0],c=n[1],l=n[2],u=s-t[0],f=i-t[1],h=o-t[2],d=u*u+f*f+h*h;d>0&&(d=1/Math.sqrt(d),u*=d,f*=d,h*=d);let m=c*h-l*f,y=l*u-a*h,_=a*f-c*u;return d=m*m+y*y+_*_,d>0&&(d=1/Math.sqrt(d),m*=d,y*=d,_*=d),r[0]=m,r[1]=y,r[2]=_,r[3]=0,r[4]=f*_-h*y,r[5]=h*m-u*_,r[6]=u*y-f*m,r[7]=0,r[8]=u,r[9]=f,r[10]=h,r[11]=0,r[12]=s,r[13]=i,r[14]=o,r[15]=1,r}function xT(r){return`mat4(${r[0]}, ${r[1]}, ${r[2]}, ${r[3]}, ${r[4]}, ${r[5]}, ${r[6]}, ${r[7]}, ${r[8]}, ${r[9]}, ${r[10]}, ${r[11]}, ${r[12]}, ${r[13]}, ${r[14]}, ${r[15]})`}function bT(r){return Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]+r[3]*r[3]+r[4]*r[4]+r[5]*r[5]+r[6]*r[6]+r[7]*r[7]+r[8]*r[8]+r[9]*r[9]+r[10]*r[10]+r[11]*r[11]+r[12]*r[12]+r[13]*r[13]+r[14]*r[14]+r[15]*r[15])}function TT(r,e,t){return r[0]=e[0]+t[0],r[1]=e[1]+t[1],r[2]=e[2]+t[2],r[3]=e[3]+t[3],r[4]=e[4]+t[4],r[5]=e[5]+t[5],r[6]=e[6]+t[6],r[7]=e[7]+t[7],r[8]=e[8]+t[8],r[9]=e[9]+t[9],r[10]=e[10]+t[10],r[11]=e[11]+t[11],r[12]=e[12]+t[12],r[13]=e[13]+t[13],r[14]=e[14]+t[14],r[15]=e[15]+t[15],r}function Mm(r,e,t){return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],r[3]=e[3]-t[3],r[4]=e[4]-t[4],r[5]=e[5]-t[5],r[6]=e[6]-t[6],r[7]=e[7]-t[7],r[8]=e[8]-t[8],r[9]=e[9]-t[9],r[10]=e[10]-t[10],r[11]=e[11]-t[11],r[12]=e[12]-t[12],r[13]=e[13]-t[13],r[14]=e[14]-t[14],r[15]=e[15]-t[15],r}function wT(r,e,t){return r[0]=e[0]*t,r[1]=e[1]*t,r[2]=e[2]*t,r[3]=e[3]*t,r[4]=e[4]*t,r[5]=e[5]*t,r[6]=e[6]*t,r[7]=e[7]*t,r[8]=e[8]*t,r[9]=e[9]*t,r[10]=e[10]*t,r[11]=e[11]*t,r[12]=e[12]*t,r[13]=e[13]*t,r[14]=e[14]*t,r[15]=e[15]*t,r}function vT(r,e,t,n){return r[0]=e[0]+t[0]*n,r[1]=e[1]+t[1]*n,r[2]=e[2]+t[2]*n,r[3]=e[3]+t[3]*n,r[4]=e[4]+t[4]*n,r[5]=e[5]+t[5]*n,r[6]=e[6]+t[6]*n,r[7]=e[7]+t[7]*n,r[8]=e[8]+t[8]*n,r[9]=e[9]+t[9]*n,r[10]=e[10]+t[10]*n,r[11]=e[11]+t[11]*n,r[12]=e[12]+t[12]*n,r[13]=e[13]+t[13]*n,r[14]=e[14]+t[14]*n,r[15]=e[15]+t[15]*n,r}function AT(r,e){return r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]&&r[3]===e[3]&&r[4]===e[4]&&r[5]===e[5]&&r[6]===e[6]&&r[7]===e[7]&&r[8]===e[8]&&r[9]===e[9]&&r[10]===e[10]&&r[11]===e[11]&&r[12]===e[12]&&r[13]===e[13]&&r[14]===e[14]&&r[15]===e[15]}function ST(r,e){let t=r[0],n=r[1],s=r[2],i=r[3],o=r[4],a=r[5],c=r[6],l=r[7],u=r[8],f=r[9],h=r[10],d=r[11],m=r[12],y=r[13],_=r[14],x=r[15],E=e[0],b=e[1],S=e[2],C=e[3],P=e[4],B=e[5],N=e[6],k=e[7],F=e[8],U=e[9],X=e[10],J=e[11],q=e[12],pe=e[13],$t=e[14],jt=e[15];return Math.abs(t-E)<=1e-6*Math.max(1,Math.abs(t),Math.abs(E))&&Math.abs(n-b)<=1e-6*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(s-S)<=1e-6*Math.max(1,Math.abs(s),Math.abs(S))&&Math.abs(i-C)<=1e-6*Math.max(1,Math.abs(i),Math.abs(C))&&Math.abs(o-P)<=1e-6*Math.max(1,Math.abs(o),Math.abs(P))&&Math.abs(a-B)<=1e-6*Math.max(1,Math.abs(a),Math.abs(B))&&Math.abs(c-N)<=1e-6*Math.max(1,Math.abs(c),Math.abs(N))&&Math.abs(l-k)<=1e-6*Math.max(1,Math.abs(l),Math.abs(k))&&Math.abs(u-F)<=1e-6*Math.max(1,Math.abs(u),Math.abs(F))&&Math.abs(f-U)<=1e-6*Math.max(1,Math.abs(f),Math.abs(U))&&Math.abs(h-X)<=1e-6*Math.max(1,Math.abs(h),Math.abs(X))&&Math.abs(d-J)<=1e-6*Math.max(1,Math.abs(d),Math.abs(J))&&Math.abs(m-q)<=1e-6*Math.max(1,Math.abs(m),Math.abs(q))&&Math.abs(y-pe)<=1e-6*Math.max(1,Math.abs(y),Math.abs(pe))&&Math.abs(_-$t)<=1e-6*Math.max(1,Math.abs(_),Math.abs($t))&&Math.abs(x-jt)<=1e-6*Math.max(1,Math.abs(x),Math.abs(jt))}var ET=ri,RT=Mm;var ze={};Ht(ze,{add:()=>OT,ceil:()=>kT,clone:()=>IT,copy:()=>CT,create:()=>Om,cross:()=>jT,dist:()=>t3,distance:()=>Fm,div:()=>e3,divide:()=>Dm,dot:()=>$T,equals:()=>GT,exactEquals:()=>ZT,floor:()=>NT,forEach:()=>i3,fromValues:()=>PT,inverse:()=>zT,len:()=>n3,length:()=>Lm,lerp:()=>HT,max:()=>FT,min:()=>DT,mul:()=>JT,multiply:()=>Nm,negate:()=>VT,normalize:()=>WT,random:()=>XT,round:()=>BT,scale:()=>LT,scaleAndAdd:()=>UT,set:()=>MT,sqrDist:()=>r3,sqrLen:()=>s3,squaredDistance:()=>Bm,squaredLength:()=>Um,str:()=>KT,sub:()=>QT,subtract:()=>km,transformMat4:()=>vf,transformQuat:()=>YT,zero:()=>qT});function Om(){let r=new fe(4);return fe!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0,r[3]=0),r}function IT(r){let e=new fe(4);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e}function PT(r,e,t,n){let s=new fe(4);return s[0]=r,s[1]=e,s[2]=t,s[3]=n,s}function CT(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r}function MT(r,e,t,n,s){return r[0]=e,r[1]=t,r[2]=n,r[3]=s,r}function OT(r,e,t){return r[0]=e[0]+t[0],r[1]=e[1]+t[1],r[2]=e[2]+t[2],r[3]=e[3]+t[3],r}function km(r,e,t){return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],r[3]=e[3]-t[3],r}function Nm(r,e,t){return r[0]=e[0]*t[0],r[1]=e[1]*t[1],r[2]=e[2]*t[2],r[3]=e[3]*t[3],r}function Dm(r,e,t){return r[0]=e[0]/t[0],r[1]=e[1]/t[1],r[2]=e[2]/t[2],r[3]=e[3]/t[3],r}function kT(r,e){return r[0]=Math.ceil(e[0]),r[1]=Math.ceil(e[1]),r[2]=Math.ceil(e[2]),r[3]=Math.ceil(e[3]),r}function NT(r,e){return r[0]=Math.floor(e[0]),r[1]=Math.floor(e[1]),r[2]=Math.floor(e[2]),r[3]=Math.floor(e[3]),r}function DT(r,e,t){return r[0]=Math.min(e[0],t[0]),r[1]=Math.min(e[1],t[1]),r[2]=Math.min(e[2],t[2]),r[3]=Math.min(e[3],t[3]),r}function FT(r,e,t){return r[0]=Math.max(e[0],t[0]),r[1]=Math.max(e[1],t[1]),r[2]=Math.max(e[2],t[2]),r[3]=Math.max(e[3],t[3]),r}function BT(r,e){return r[0]=rt(e[0]),r[1]=rt(e[1]),r[2]=rt(e[2]),r[3]=rt(e[3]),r}function LT(r,e,t){return r[0]=e[0]*t,r[1]=e[1]*t,r[2]=e[2]*t,r[3]=e[3]*t,r}function UT(r,e,t,n){return r[0]=e[0]+t[0]*n,r[1]=e[1]+t[1]*n,r[2]=e[2]+t[2]*n,r[3]=e[3]+t[3]*n,r}function Fm(r,e){let t=e[0]-r[0],n=e[1]-r[1],s=e[2]-r[2],i=e[3]-r[3];return Math.sqrt(t*t+n*n+s*s+i*i)}function Bm(r,e){let t=e[0]-r[0],n=e[1]-r[1],s=e[2]-r[2],i=e[3]-r[3];return t*t+n*n+s*s+i*i}function Lm(r){let e=r[0],t=r[1],n=r[2],s=r[3];return Math.sqrt(e*e+t*t+n*n+s*s)}function Um(r){let e=r[0],t=r[1],n=r[2],s=r[3];return e*e+t*t+n*n+s*s}function VT(r,e){return r[0]=-e[0],r[1]=-e[1],r[2]=-e[2],r[3]=-e[3],r}function zT(r,e){return r[0]=1/e[0],r[1]=1/e[1],r[2]=1/e[2],r[3]=1/e[3],r}function WT(r,e){let t=e[0],n=e[1],s=e[2],i=e[3],o=t*t+n*n+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),r[0]=t*o,r[1]=n*o,r[2]=s*o,r[3]=i*o,r}function $T(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]+r[3]*e[3]}function jT(r,e,t,n){let s=t[0]*n[1]-t[1]*n[0],i=t[0]*n[2]-t[2]*n[0],o=t[0]*n[3]-t[3]*n[0],a=t[1]*n[2]-t[2]*n[1],c=t[1]*n[3]-t[3]*n[1],l=t[2]*n[3]-t[3]*n[2],u=e[0],f=e[1],h=e[2],d=e[3];return r[0]=f*l-h*c+d*a,r[1]=-(u*l)+h*o-d*i,r[2]=u*c-f*o+d*s,r[3]=-(u*a)+f*i-h*s,r}function HT(r,e,t,n){let s=e[0],i=e[1],o=e[2],a=e[3];return r[0]=s+n*(t[0]-s),r[1]=i+n*(t[1]-i),r[2]=o+n*(t[2]-o),r[3]=a+n*(t[3]-a),r}function XT(r,e){e=e===void 0?1:e;let t,n,s,i,o,a;do t=Mt()*2-1,n=Mt()*2-1,o=t*t+n*n;while(o>=1);do s=Mt()*2-1,i=Mt()*2-1,a=s*s+i*i;while(a>=1);let c=Math.sqrt((1-o)/a);return r[0]=e*t,r[1]=e*n,r[2]=e*s*c,r[3]=e*i*c,r}function vf(r,e,t){let n=e[0],s=e[1],i=e[2],o=e[3];return r[0]=t[0]*n+t[4]*s+t[8]*i+t[12]*o,r[1]=t[1]*n+t[5]*s+t[9]*i+t[13]*o,r[2]=t[2]*n+t[6]*s+t[10]*i+t[14]*o,r[3]=t[3]*n+t[7]*s+t[11]*i+t[15]*o,r}function YT(r,e,t){let n=e[0],s=e[1],i=e[2],o=t[0],a=t[1],c=t[2],l=t[3],u=l*n+a*i-c*s,f=l*s+c*n-o*i,h=l*i+o*s-a*n,d=-o*n-a*s-c*i;return r[0]=u*l+d*-o+f*-c-h*-a,r[1]=f*l+d*-a+h*-o-u*-c,r[2]=h*l+d*-c+u*-a-f*-o,r[3]=e[3],r}function qT(r){return r[0]=0,r[1]=0,r[2]=0,r[3]=0,r}function KT(r){return`vec4(${r[0]}, ${r[1]}, ${r[2]}, ${r[3]})`}function ZT(r,e){return r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]&&r[3]===e[3]}function GT(r,e){let t=r[0],n=r[1],s=r[2],i=r[3],o=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(t-o)<=1e-6*Math.max(1,Math.abs(t),Math.abs(o))&&Math.abs(n-a)<=1e-6*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(i-l)<=1e-6*Math.max(1,Math.abs(i),Math.abs(l))}var QT=km,JT=Nm,e3=Dm,t3=Fm,r3=Bm,n3=Lm,s3=Um,i3=function(){let r=Om();return function(e,t,n,s,i,o){let a,c;for(t||(t=4),n||(n=0),s?c=Math.min(s*t+n,e.length):c=e.length,a=n;a<c;a+=t)r[0]=e[a],r[1]=e[a+1],r[2]=e[a+2],r[3]=e[a+3],i(r,r,o),e[a]=r[0],e[a+1]=r[1],e[a+2]=r[2],e[a+3]=r[3];return e}}();var Ef;(function(r){r[r.COL0ROW0=0]="COL0ROW0",r[r.COL0ROW1=1]="COL0ROW1",r[r.COL0ROW2=2]="COL0ROW2",r[r.COL0ROW3=3]="COL0ROW3",r[r.COL1ROW0=4]="COL1ROW0",r[r.COL1ROW1=5]="COL1ROW1",r[r.COL1ROW2=6]="COL1ROW2",r[r.COL1ROW3=7]="COL1ROW3",r[r.COL2ROW0=8]="COL2ROW0",r[r.COL2ROW1=9]="COL2ROW1",r[r.COL2ROW2=10]="COL2ROW2",r[r.COL2ROW3=11]="COL2ROW3",r[r.COL3ROW0=12]="COL3ROW0",r[r.COL3ROW1=13]="COL3ROW1",r[r.COL3ROW2=14]="COL3ROW2",r[r.COL3ROW3=15]="COL3ROW3"})(Ef||(Ef={}));var o3=45*Math.PI/180,a3=1,Af=.1,Sf=500,c3=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Q=class extends ka{static get IDENTITY(){return u3()}static get ZERO(){return l3()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Ef}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,n,s,i,o,a,c,l,u,f,h,d,m,y,_){return this[0]=e,this[1]=t,this[2]=n,this[3]=s,this[4]=i,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=u,this[10]=f,this[11]=h,this[12]=d,this[13]=m,this[14]=y,this[15]=_,this.check()}setRowMajor(e,t,n,s,i,o,a,c,l,u,f,h,d,m,y,_){return this[0]=e,this[1]=i,this[2]=l,this[3]=d,this[4]=t,this[5]=o,this[6]=u,this[7]=m,this[8]=n,this[9]=a,this[10]=f,this[11]=y,this[12]=s,this[13]=c,this[14]=h,this[15]=_,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(c3)}fromObject(e){return this.check()}fromQuaternion(e){return yf(this,e),this.check()}frustum(e){let{left:t,right:n,bottom:s,top:i,near:o=Af,far:a=Sf}=e;return a===1/0?f3(this,t,n,s,i,o):xf(this,t,n,s,i,o,a),this.check()}lookAt(e){let{eye:t,center:n=[0,0,0],up:s=[0,1,0]}=e;return wf(this,t,n,s),this.check()}ortho(e){let{left:t,right:n,bottom:s,top:i,near:o=Af,far:a=Sf}=e;return Tf(this,t,n,s,i,o,a),this.check()}orthographic(e){let{fovy:t=o3,aspect:n=a3,focalDistance:s=1,near:i=Af,far:o=Sf}=e;Vm(t);let a=t/2,c=s*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:i,far:o})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:n=1,near:s=.1,far:i=500}=e;return Vm(t),bf(this,t,n,s,i),this.check()}determinant(){return ff(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let n=this.getScale(t),s=1/n[0],i=1/n[1],o=1/n[2];return e[0]=this[0]*s,e[1]=this[1]*i,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*s,e[5]=this[5]*i,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*s,e[9]=this[9]*i,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let n=this.getScale(t),s=1/n[0],i=1/n[1],o=1/n[2];return e[0]=this[0]*s,e[1]=this[1]*i,e[2]=this[2]*o,e[3]=this[4]*s,e[4]=this[5]*i,e[5]=this[6]*o,e[6]=this[8]*s,e[7]=this[9]*i,e[8]=this[10]*o,e}transpose(){return lf(this,this),this.check()}invert(){return uf(this,this),this.check()}multiplyLeft(e){return ri(this,e,this),this.check()}multiplyRight(e){return ri(this,this,e),this.check()}rotateX(e){return mf(this,this,e),this.check()}rotateY(e){return gf(this,this,e),this.check()}rotateZ(e){return _f(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return pf(this,this,e,t),this.check()}scale(e){return df(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return hf(this,this,e),this.check()}transform(e,t){return e.length===4?(t=vf(t||[-0,-0,-0,-0],e,this),Ra(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:n}=e,s;switch(n){case 2:s=Qu(t||[-0,-0],e,this);break;case 3:s=ti(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ra(s,e.length),s}transformAsVector(e,t){let n;switch(e.length){case 2:n=_m(t||[-0,-0],e,this);break;case 3:n=Ca(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ra(n,e.length),n}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,n){return this.identity().translate([e,t,n])}},Na,Da;function l3(){return Na||(Na=new Q([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Na)),Na}function u3(){return Da||(Da=new Q,Object.freeze(Da)),Da}function Vm(r){if(r>Math.PI*2)throw Error("expected radians")}function f3(r,e,t,n,s,i){let o=2*i/(t-e),a=2*i/(s-n),c=(t+e)/(t-e),l=(s+n)/(s-n),u=-1,f=-1,h=-2*i;return r[0]=o,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=a,r[6]=0,r[7]=0,r[8]=c,r[9]=l,r[10]=u,r[11]=f,r[12]=0,r[13]=0,r[14]=h,r[15]=0,r}var zm=1e-6,h3=6371e3,dt=class{constructor({phi:e=0,theta:t=0,radius:n=1,bearing:s,pitch:i,altitude:o,radiusScale:a=h3}={}){this.phi=e,this.theta=t,this.radius=n||o||1,this.radiusScale=a||1,s!==void 0&&(this.bearing=s),i!==void 0&&(this.pitch=i),this.check()}toString(){return this.formatString(ge)}formatString({printTypes:e=!1}){let t=ei;return`${e?"Spherical":""}[rho:${t(this.radius)},theta:${t(this.theta)},phi:${t(this.phi)}]`}equals(e){return Xe(this.radius,e.radius)&&Xe(this.theta,e.theta)&&Xe(this.phi,e.phi)}exactEquals(e){return this.radius===e.radius&&this.theta===e.theta&&this.phi===e.phi}get bearing(){return 180-wr(this.phi)}set bearing(e){this.phi=Math.PI-Zn(e)}get pitch(){return wr(this.theta)}set pitch(e){this.theta=Zn(e)}get longitude(){return wr(this.phi)}get latitude(){return wr(this.theta)}get lng(){return wr(this.phi)}get lat(){return wr(this.theta)}get z(){return(this.radius-1)*this.radiusScale}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this.check()}clone(){return new dt().copy(this)}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this.check()}fromLngLatZ([e,t,n]){return this.radius=1+n/this.radiusScale,this.phi=Zn(t),this.theta=Zn(e),this.check()}fromVector3(e){return this.radius=Ma(e),this.radius>0&&(this.theta=Math.atan2(e[0],e[1]),this.phi=Math.acos(ee(e[2]/this.radius,-1,1))),this.check()}toVector3(){return new G(0,0,this.radius).rotateX({radians:this.theta}).rotateZ({radians:this.phi})}makeSafe(){return this.phi=Math.max(zm,Math.min(Math.PI-zm,this.phi)),this}check(){if(!Number.isFinite(this.phi)||!Number.isFinite(this.theta)||!(this.radius>0))throw new Error("SphericalCoordinates: some fields set to invalid numbers");return this}};function Rf(r,e=[],t=0){let n=Math.fround(r),s=r-n;return e[t]=n,e[t+1]=s,e}function Wm(r){return r-Math.fround(r)}function $m(r){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let n=0;n<4;++n){let s=t*4+n;Rf(r[n*4+t],e,s*2)}return e}var d3=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
110
+ `&&e!=="\r"&&e!==" "&&e!=="\0"}_isNumeric(e){return e>="0"&&e<="9"}_isAlphaNumeric(e){return this._isAlpha(e)||this._isNumeric(e)||e==="_"}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){let t=this._source.substring(this._start,this._current);this._tokens.push(new Ra(e,t,this._line,this._start,this._current))}};function D(r){return Array.isArray(r)||r?.buffer instanceof ArrayBuffer}var Ia=new Float32Array(1),N0=new Uint32Array(Ia.buffer),D0=new Uint32Array(Ia.buffer),Pa=new Int32Array(1),F0=new Float32Array(Pa.buffer),B0=new Uint32Array(Pa.buffer),Ca=new Uint32Array(1),L0=new Float32Array(Ca.buffer),U0=new Int32Array(Ca.buffer);function mm(r,e,t){if(e===t)return r;if(e==="f32"){if(t==="i32"||t==="x32")return Ia[0]=r,N0[0];if(t==="u32")return Ia[0]=r,D0[0]}else if(e==="i32"||e==="x32"){if(t==="f32")return Pa[0]=r,F0[0];if(t==="u32")return Pa[0]=r,B0[0]}else if(e==="u32"){if(t==="f32")return Ca[0]=r,L0[0];if(t==="i32"||t==="x32")return Ca[0]=r,U0[0]}return console.error(`Unsupported cast from ${e} to ${t}`),r}var Gu=class{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}},qn=class{constructor(e,t){this.align=e,this.size=t}},Qe=class{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new ju,this.functions=[],this._types=new Map,this._functions=new Map}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}updateAST(e){for(let t of e)t instanceof en&&this._functions.set(t.name,new Gu(t));for(let t of e)if(t instanceof ct){let n=this.getTypeInfo(t,null);n instanceof Rt&&this.structs.push(n)}for(let t of e)if(t instanceof Zs)this.aliases.push(this._getAliasInfo(t));else if(t instanceof qs){let n=t,s=this._getAttributeNum(n.attributes,"id",0),i=n.type!=null?this.getTypeInfo(n.type,n.attributes):null;this.overrides.push(new zu(n.name,i,n.attributes,s))}else if(this._isUniformVar(t)){let n=t,s=this._getAttributeNum(n.attributes,"group",0),i=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=new Xn(n.name,o,s,i,n.attributes,yr.Uniform,n.access);a.access||(a.access="read"),this.uniforms.push(a)}else if(this._isStorageVar(t)){let n=t,s=this._getAttributeNum(n.attributes,"group",0),i=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=this._isStorageTexture(o),c=new Xn(n.name,o,s,i,n.attributes,a?yr.StorageTexture:yr.Storage,n.access);c.access||(c.access="read"),this.storage.push(c)}else if(this._isTextureVar(t)){let n=t,s=this._getAttributeNum(n.attributes,"group",0),i=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=this._isStorageTexture(o),c=new Xn(n.name,o,s,i,n.attributes,a?yr.StorageTexture:yr.Texture,n.access);c.access||(c.access="read"),a?this.storage.push(c):this.textures.push(c)}else if(this._isSamplerVar(t)){let n=t,s=this._getAttributeNum(n.attributes,"group",0),i=this._getAttributeNum(n.attributes,"binding",0),o=this.getTypeInfo(n.type,n.attributes),a=new Xn(n.name,o,s,i,n.attributes,yr.Sampler,n.access);this.samplers.push(a)}else if(t instanceof en){let n=this._getAttribute(t,"vertex"),s=this._getAttribute(t,"fragment"),i=this._getAttribute(t,"compute"),o=n||s||i,a=new $u(t.name,o?.name,t.attributes);a.attributes=t.attributes,a.startLine=t.startLine,a.endLine=t.endLine,this.functions.push(a),this._functions.get(t.name).info=a,o&&(this._functions.get(t.name).inUse=!0,a.inUse=!0,a.resources=this._findResources(t,!!o),a.inputs=this._getInputs(t.args),a.outputs=this._getOutputs(t.returnType),this.entry[o.name].push(a)),a.arguments=t.args.map(c=>new Wu(c.name,this.getTypeInfo(c.type,c.attributes),c.attributes)),a.returnType=t.returnType?this.getTypeInfo(t.returnType,t.attributes):null}for(let t of this._functions.values())t.info&&(t.info.inUse=t.inUse,this._addCalls(t.node,t.info.calls));for(let t of this._functions.values())t.node.search(n=>{var s,i,o;if(n instanceof Ea){if(n.value)if(D(n.value))for(let a of n.value)for(let c of this.overrides)a===c.name&&((s=t.info)===null||s===void 0||s.overrides.push(c));else for(let a of this.overrides)n.value===a.name&&((i=t.info)===null||i===void 0||i.overrides.push(a))}else if(n instanceof Me)for(let a of this.overrides)n.name===a.name&&((o=t.info)===null||o===void 0||o.overrides.push(a))});for(let t of this.uniforms)this._markStructsInUse(t.type);for(let t of this.storage)this._markStructsInUse(t.type)}getStructInfo(e){for(let t of this.structs)if(t.name==e)return t;return null}getOverrideInfo(e){for(let t of this.overrides)if(t.name==e)return t;return null}_markStructsInUse(e){if(e)if(e.isStruct){if(e.inUse=!0,e.members)for(let t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{let t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var n;for(let s of e.calls){let i=(n=this._functions.get(s.name))===null||n===void 0?void 0:n.info;i&&t.add(i)}}findResource(e,t,n){if(n){for(let s of this.entry.compute)if(s.name===n){for(let i of s.resources)if(i.group==e&&i.binding==t)return i}for(let s of this.entry.vertex)if(s.name===n){for(let i of s.resources)if(i.group==e&&i.binding==t)return i}for(let s of this.entry.fragment)if(s.name===n){for(let i of s.resources)if(i.group==e&&i.binding==t)return i}}for(let s of this.uniforms)if(s.group==e&&s.binding==t)return s;for(let s of this.storage)if(s.group==e&&s.binding==t)return s;for(let s of this.textures)if(s.group==e&&s.binding==t)return s;for(let s of this.samplers)if(s.group==e&&s.binding==t)return s;return null}_findResource(e){for(let t of this.uniforms)if(t.name==e)return t;for(let t of this.storage)if(t.name==e)return t;for(let t of this.textures)if(t.name==e)return t;for(let t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){let t=this.getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){let n=[],s=this,i=[];return e.search(o=>{if(o instanceof Gn)i.push({});else if(o instanceof Qn)i.pop();else if(o instanceof ut){let a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),i.length>0&&(i[i.length-1][a.name]=a)}else if(o instanceof Ge){let a=o;t&&a.type!==null&&this._markStructsFromAST(a.type)}else if(o instanceof Qr){let a=o;t&&a.type!==null&&this._markStructsFromAST(a.type),i.length>0&&(i[i.length-1][a.name]=a)}else if(o instanceof Me){let a=o;if(i.length>0&&i[i.length-1][a.name])return;let c=s._findResource(a.name);c&&n.push(c)}else if(o instanceof Gs){let a=o,c=s._functions.get(a.name);c&&(t&&(c.inUse=!0),e.calls.add(c.node),c.resources===null&&(c.resources=s._findResources(c.node,t)),n.push(...c.resources))}else if(o instanceof Ks){let a=o,c=s._functions.get(a.name);c&&(t&&(c.inUse=!0),e.calls.add(c.node),c.resources===null&&(c.resources=s._findResources(c.node,t)),n.push(...c.resources))}}),[...new Map(n.map(o=>[o.name,o])).values()]}getBindGroups(){let e=[];function t(n,s){n>=e.length&&(e.length=n+1),e[n]===void 0&&(e[n]=[]),s>=e[n].length&&(e[n].length=s+1)}for(let n of this.uniforms)t(n.group,n.binding),e[n.group][n.binding]=n;for(let n of this.storage)t(n.group,n.binding),e[n.group][n.binding]=n;for(let n of this.textures)t(n.group,n.binding),e[n.group][n.binding]=n;for(let n of this.samplers)t(n.group,n.binding),e[n.group][n.binding]=n;return e}_getOutputs(e,t=void 0){if(t===void 0&&(t=[]),e instanceof ct)this._getStructOutputs(e,t);else{let n=this._getOutputInfo(e);n!==null&&t.push(n)}return t}_getStructOutputs(e,t){for(let n of e.members)if(n.type instanceof ct)this._getStructOutputs(n.type,t);else{let s=this._getAttribute(n,"location")||this._getAttribute(n,"builtin");if(s!==null){let i=this.getTypeInfo(n.type,n.type.attributes),o=this._parseInt(s.value),a=new ia(n.name,i,s.name,o);t.push(a)}}}_getOutputInfo(e){let t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){let n=this.getTypeInfo(e,e.attributes),s=this._parseInt(t.value);return new ia("",n,t.name,s)}return null}_getInputs(e,t=void 0){t===void 0&&(t=[]);for(let n of e)if(n.type instanceof ct)this._getStructInputs(n.type,t);else{let s=this._getInputInfo(n);s!==null&&t.push(s)}return t}_getStructInputs(e,t){for(let n of e.members)if(n.type instanceof ct)this._getStructInputs(n.type,t);else{let s=this._getInputInfo(n);s!==null&&t.push(s)}}_getInputInfo(e){let t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(t!==null){let n=this._getAttribute(e,"interpolation"),s=this.getTypeInfo(e.type,e.attributes),i=this._parseInt(t.value),o=new Vu(e.name,s,t.name,i);return n!==null&&(o.interpolation=this._parseString(n.value)),o}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);let t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(let t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new Uu(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(let t of this.structs)if(t.name==e)return t;for(let t of this.aliases)if(t.name==e)return t.type;return null}getTypeInfo(e,t=null){if(this._types.has(e))return this._types.get(e);if(e instanceof Jr){let s=e,i=s.format?this.getTypeInfo(s.format,s.attributes):null,o=new It(s.name,t);return o.format=i,o.count=s.count,this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof ct){let s=e,i=new Rt(s.name,t);i.startLine=s.startLine,i.endLine=s.endLine;for(let o of s.members){let a=this.getTypeInfo(o.type,o.attributes);i.members.push(new sa(o.name,a,o.attributes))}return this._types.set(e,i),this._updateTypeInfo(i),i}if(e instanceof Gr){let s=e,i=s.format instanceof M,o=s.format?i?this.getTypeInfo(s.format,null):new Be(s.format,null):null,a=new Kt(s.name,o,t,s.access);return this._types.set(e,a),this._updateTypeInfo(a),a}if(e instanceof A){let s=e,i=s.format?this.getTypeInfo(s.format,null):null,o=new Kt(s.name,i,t,s.access);return this._types.set(e,o),this._updateTypeInfo(o),o}let n=new Be(e.name,t);return this._types.set(e,n),this._updateTypeInfo(n),n}_updateTypeInfo(e){var t,n,s;let i=this._getTypeSize(e);if(e.size=(t=i?.size)!==null&&t!==void 0?t:0,e instanceof It&&e.format){let o=this._getTypeSize(e.format);e.stride=Math.max((n=o?.size)!==null&&n!==void 0?n:0,(s=o?.align)!==null&&s!==void 0?s:0),this._updateTypeInfo(e.format)}e instanceof Rt&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let n=0,s=0,i=0,o=0;for(let a=0,c=e.members.length;a<c;++a){let l=e.members[a],u=this._getTypeSize(l);if(!u)continue;(t=this._getAlias(l.type.name))!==null&&t!==void 0||l.type;let f=u.align,h=u.size;n=this._roundUp(f,n+s),s=h,i=n,o=Math.max(o,f),l.offset=n,l.size=h,this._updateTypeInfo(l.type)}e.size=this._roundUp(o,i+s),e.align=o}_getTypeSize(e){var t,n;if(e==null)return null;let s=this._getAttributeNum(e.attributes,"size",0),i=this._getAttributeNum(e.attributes,"align",0);if(e instanceof sa&&(e=e.type),e instanceof Be){let o=this._getAlias(e.name);o!==null&&(e=o)}{let o=Qe._typeInfo[e.name];if(o!==void 0){let a=((t=e.format)===null||t===void 0?void 0:t.name)==="f16"?2:1;return new qn(Math.max(i,o.align/a),Math.max(s,o.size/a))}}{let o=Qe._typeInfo[e.name.substring(0,e.name.length-1)];if(o){let a=e.name[e.name.length-1]==="h"?2:1;return new qn(Math.max(i,o.align/a),Math.max(s,o.size/a))}}if(e instanceof It){let o=e,a=8,c=8,l=this._getTypeSize(o.format);return l!==null&&(c=l.size,a=l.align),c=o.count*this._getAttributeNum((n=e?.attributes)!==null&&n!==void 0?n:null,"stride",this._roundUp(a,c)),s&&(c=s),new qn(Math.max(i,a),Math.max(s,c))}if(e instanceof Rt){let o=0,a=0,c=0,l=0,u=0;for(let f of e.members){let h=this._getTypeSize(f.type);h!==null&&(o=Math.max(h.align,o),c=this._roundUp(h.align,c+l),l=h.size,u=c)}return a=this._roundUp(o,u+l),new qn(Math.max(i,o),Math.max(s,a))}return null}_isUniformVar(e){return e instanceof ut&&e.storage=="uniform"}_isStorageVar(e){return e instanceof ut&&e.storage=="storage"}_isTextureVar(e){return e instanceof ut&&e.type!==null&&Qe._textureTypes.indexOf(e.type.name)!=-1}_isSamplerVar(e){return e instanceof ut&&e.type!==null&&Qe._samplerTypes.indexOf(e.type.name)!=-1}_getAttribute(e,t){let n=e;if(!n||!n.attributes)return null;let s=n.attributes;for(let i of s)if(i.name==t)return i;return null}_getAttributeNum(e,t,n){if(e===null)return n;for(let s of e)if(s.name==t){let i=s!==null&&s.value!==null?s.value:n;return i instanceof Array&&(i=i[0]),typeof i=="number"?i:typeof i=="string"?parseInt(i):n}return n}_roundUp(e,t){return Math.ceil(t/e)*e}};Qe._typeInfo={f16:{align:2,size:2},i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},atomic:{align:4,size:4},vec2:{align:8,size:8},vec3:{align:16,size:12},vec4:{align:16,size:16},mat2x2:{align:8,size:16},mat3x2:{align:8,size:24},mat4x2:{align:8,size:32},mat2x3:{align:16,size:32},mat3x3:{align:16,size:48},mat4x3:{align:16,size:64},mat2x4:{align:16,size:32},mat3x4:{align:16,size:48},mat4x4:{align:16,size:64}},Qe._textureTypes=p.any_texture_type.map(r=>r.name),Qe._samplerTypes=p.sampler_type.map(r=>r.name);var Js=class{constructor(e,t,n){this.name=e,this.value=t,this.node=n}clone(){return new Js(this.name,this.value,this.node)}},ei=class{constructor(e){this.name=e.name,this.node=e}clone(){return new ei(this.node)}},ti=class{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var t;return this.variables.has(e)?(t=this.variables.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var t;return this.functions.has(e)?(t=this.functions.get(e))!==null&&t!==void 0?t:null:this.parent?this.parent.getFunction(e):null}createVariable(e,t,n){this.variables.set(e,new Js(e,t,n??null))}setVariable(e,t,n){let s=this.getVariable(e);s!==null?s.value=t:this.createVariable(e,t,n)}getVariableValue(e){var t;let n=this.getVariable(e);return(t=n?.value)!==null&&t!==void 0?t:null}clone(){return new ti(this)}},Qu=class{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}},Ju=class{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,t){let n=this.exec.evalExpression(e.args[0],t),s=!0;if(n instanceof g)return n.data.forEach(i=>{i||(s=!1)}),new T(s?1:0,this.getTypeInfo("bool"));throw new Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g){let s=n.data.some(i=>i);return new T(s?1:0,this.getTypeInfo("bool"))}throw new Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,t){let n=this.exec.evalExpression(e.args[2],t);if(!(n instanceof T))throw new Error(`Select() expects a bool condition. Line ${e.line}`);return n.value?this.exec.evalExpression(e.args[1],t):this.exec.evalExpression(e.args[0],t)}ArrayLength(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.evalExpression(n,t);if(s instanceof ce&&s.typeInfo.size===0){let i=s.typeInfo,o=s.buffer.byteLength/i.stride;return new T(o,this.getTypeInfo("u32"))}return new T(s.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.abs(i)),n.typeInfo);let s=n;return new T(Math.abs(s.value),s.typeInfo)}Acos(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.acos(i)),n.typeInfo);let s=n;return new T(Math.acos(s.value),n.typeInfo)}Acosh(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.acosh(i)),n.typeInfo);let s=n;return new T(Math.acosh(s.value),n.typeInfo)}Asin(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.asin(i)),n.typeInfo);let s=n;return new T(Math.asin(s.value),n.typeInfo)}Asinh(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.asinh(i)),n.typeInfo);let s=n;return new T(Math.asinh(s.value),n.typeInfo)}Atan(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.atan(i)),n.typeInfo);let s=n;return new T(Math.atan(s.value),n.typeInfo)}Atanh(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.atanh(i)),n.typeInfo);let s=n;return new T(Math.atanh(s.value),n.typeInfo)}Atan2(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g)return new g(n.data.map((a,c)=>Math.atan2(a,s.data[c])),n.typeInfo);let i=n,o=s;return new T(Math.atan2(i.value,o.value),n.typeInfo)}Ceil(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.ceil(i)),n.typeInfo);let s=n;return new T(Math.ceil(s.value),n.typeInfo)}_clamp(e,t,n){return Math.min(Math.max(e,t),n)}Clamp(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof g&&s instanceof g&&i instanceof g)return new g(n.data.map((l,u)=>this._clamp(l,s.data[u],i.data[u])),n.typeInfo);let o=n,a=s,c=i;return new T(this._clamp(o.value,a.value,c.value),n.typeInfo)}Cos(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.cos(i)),n.typeInfo);let s=n;return new T(Math.cos(s.value),n.typeInfo)}Cosh(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.cosh(i)),n.typeInfo);let s=n;return new T(Math.cos(s.value),n.typeInfo)}CountLeadingZeros(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.clz32(i)),n.typeInfo);let s=n;return new T(Math.clz32(s.value),n.typeInfo)}_countOneBits(e){let t=0;for(;e!==0;)1&e&&t++,e>>=1;return t}CountOneBits(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>this._countOneBits(i)),n.typeInfo);let s=n;return new T(this._countOneBits(s.value),n.typeInfo)}_countTrailingZeros(e){if(e===0)return 32;let t=0;for(;!(1&e);)e>>=1,t++;return t}CountTrailingZeros(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>this._countTrailingZeros(i)),n.typeInfo);let s=n;return new T(this._countTrailingZeros(s.value),n.typeInfo)}Cross(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g){if(n.data.length!==3||s.data.length!==3)return console.error(`Cross() expects 3D vectors. Line ${e.line}`),null;let i=n.data,o=s.data;return new g([i[1]*o[2]-o[1]*i[2],i[2]*o[0]-o[2]*i[0],i[0]*o[1]-o[0]*i[1]],n.typeInfo)}return console.error(`Cross() expects vector arguments. Line ${e.line}`),null}Degrees(e,t){let n=this.exec.evalExpression(e.args[0],t),s=180/Math.PI;return n instanceof g?new g(n.data.map(i=>i*s),n.typeInfo):new T(n.value*s,this.getTypeInfo("f32"))}Determinant(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof z){let s=n.data,i=n.typeInfo.getTypeName(),o=i.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if(i==="mat2x2"||i==="mat2x2f"||i==="mat2x2h")return new T(s[0]*s[3]-s[1]*s[2],o);if(i==="mat2x3"||i==="mat2x3f"||i==="mat2x3h")return new T(s[0]*(s[4]*s[8]-s[5]*s[7])-s[1]*(s[3]*s[8]-s[5]*s[6])+s[2]*(s[3]*s[7]-s[4]*s[6]),o);if(i==="mat2x4"||i==="mat2x4f"||i==="mat2x4h")console.error(`TODO: Determinant for ${i}`);else if(i==="mat3x2"||i==="mat3x2f"||i==="mat3x2h")console.error(`TODO: Determinant for ${i}`);else{if(i==="mat3x3"||i==="mat3x3f"||i==="mat3x3h")return new T(s[0]*(s[4]*s[8]-s[5]*s[7])-s[1]*(s[3]*s[8]-s[5]*s[6])+s[2]*(s[3]*s[7]-s[4]*s[6]),o);i==="mat3x4"||i==="mat3x4f"||i==="mat3x4h"||i==="mat4x2"||i==="mat4x2f"||i==="mat4x2h"||i==="mat4x3"||i==="mat4x3f"||i==="mat4x3h"?console.error(`TODO: Determinant for ${i}`):i!=="mat4x4"&&i!=="mat4x4f"&&i!=="mat4x4h"||console.error(`TODO: Determinant for ${i}`)}}return console.error(`Determinant expects a matrix argument. Line ${e.line}`),null}Distance(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g){let a=0;for(let c=0;c<n.data.length;++c)a+=(n.data[c]-s.data[c])*(n.data[c]-s.data[c]);return new T(Math.sqrt(a),this.getTypeInfo("f32"))}let i=n,o=s;return new T(Math.abs(i.value-o.value),n.typeInfo)}_dot(e,t){let n=0;for(let s=0;s<e.length;++s)n+=t[s]*e[s];return n}Dot(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);return n instanceof g&&s instanceof g?new T(this._dot(n.data,s.data),this.getTypeInfo("f32")):(console.error(`Dot() expects vector arguments. Line ${e.line}`),null)}Dot4U8Packed(e,t){return console.error(`TODO: dot4U8Packed. Line ${e.line}`),null}Dot4I8Packed(e,t){return console.error(`TODO: dot4I8Packed. Line ${e.line}`),null}Exp(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.exp(i)),n.typeInfo);let s=n;return new T(Math.exp(s.value),n.typeInfo)}Exp2(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.pow(2,i)),n.typeInfo);let s=n;return new T(Math.pow(2,s.value),n.typeInfo)}ExtractBits(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(s.typeInfo.name!=="u32"&&s.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 offset argument. Line ${e.line}`),null;if(i.typeInfo.name!=="u32"&&i.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 count argument. Line ${e.line}`),null;let o=s.value,a=i.value;if(n instanceof g)return new g(n.data.map(l=>l>>o&(1<<a)-1),n.typeInfo);if(n.typeInfo.name!=="i32"&&n.typeInfo.name!=="x32")return console.error(`ExtractBits() expects an i32 argument. Line ${e.line}`),null;let c=n.value;return new T(c>>o&(1<<a)-1,this.getTypeInfo("i32"))}FaceForward(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof g&&s instanceof g&&i instanceof g){let o=this._dot(s.data,i.data);return new g(o<0?Array.from(n.data):n.data.map(a=>-a),n.typeInfo)}return console.error(`FaceForward() expects vector arguments. Line ${e.line}`),null}_firstLeadingBit(e){return e===0?-1:31-Math.clz32(e)}FirstLeadingBit(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>this._firstLeadingBit(i)),n.typeInfo);let s=n;return new T(this._firstLeadingBit(s.value),n.typeInfo)}_firstTrailingBit(e){return e===0?-1:Math.log2(e&-e)}FirstTrailingBit(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>this._firstTrailingBit(i)),n.typeInfo);let s=n;return new T(this._firstTrailingBit(s.value),n.typeInfo)}Floor(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.floor(i)),n.typeInfo);let s=n;return new T(Math.floor(s.value),n.typeInfo)}Fma(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof g&&s instanceof g&&i instanceof g)return n.data.length!==s.data.length||n.data.length!==i.data.length?(console.error(`Fma() expects vectors of the same length. Line ${e.line}`),null):new g(n.data.map((l,u)=>l*s.data[u]+i.data[u]),n.typeInfo);let o=n,a=s,c=i;return new T(o.value*a.value+c.value,o.typeInfo)}Fract(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>i-Math.floor(i)),n.typeInfo);let s=n;return new T(s.value-Math.floor(s.value),n.typeInfo)}Frexp(e,t){return console.error(`TODO: frexp. Line ${e.line}`),null}InsertBits(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t),o=this.exec.evalExpression(e.args[3],t);if(i.typeInfo.name!=="u32"&&i.typeInfo.name!=="x32")return console.error(`InsertBits() expects an i32 offset argument. Line ${e.line}`),null;let a=i.value,c=(1<<o.value)-1<<a,l=~c;if(n instanceof g&&s instanceof g)return new g(n.data.map((h,d)=>h&l|s.data[d]<<a&c),n.typeInfo);let u=n.value,f=s.value;return new T(u&l|f<<a&c,n.typeInfo)}InverseSqrt(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>1/Math.sqrt(i)),n.typeInfo);let s=n;return new T(1/Math.sqrt(s.value),n.typeInfo)}Ldexp(e,t){return console.error(`TODO: ldexp. Line ${e.line}`),null}Length(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g){let i=0;return n.data.forEach(o=>{i+=o*o}),new T(Math.sqrt(i),this.getTypeInfo("f32"))}let s=n;return new T(Math.abs(s.value),n.typeInfo)}Log(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.log(i)),n.typeInfo);let s=n;return new T(Math.log(s.value),n.typeInfo)}Log2(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.log2(i)),n.typeInfo);let s=n;return new T(Math.log2(s.value),n.typeInfo)}Max(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g)return new g(n.data.map((a,c)=>Math.max(a,s.data[c])),n.typeInfo);let i=n,o=s;return new T(Math.max(i.value,o.value),n.typeInfo)}Min(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g)return new g(n.data.map((a,c)=>Math.min(a,s.data[c])),n.typeInfo);let i=n,o=s;return new T(Math.min(i.value,o.value),n.typeInfo)}Mix(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof g&&s instanceof g&&i instanceof g)return new g(n.data.map((c,l)=>n.data[l]*(1-i.data[l])+s.data[l]*i.data[l]),n.typeInfo);let o=s,a=i;return new T(n.value*(1-a.value)+o.value*a.value,n.typeInfo)}Modf(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g)return new g(n.data.map((o,a)=>o%s.data[a]),n.typeInfo);let i=s;return new T(n.value%i.value,n.typeInfo)}Normalize(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g){let s=this.Length(e,t).value;return new g(n.data.map(i=>i/s),n.typeInfo)}return console.error(`Normalize() expects a vector argument. Line ${e.line}`),null}Pow(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g)return new g(n.data.map((a,c)=>Math.pow(a,s.data[c])),n.typeInfo);let i=n,o=s;return new T(Math.pow(i.value,o.value),n.typeInfo)}QuantizeToF16(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof g?new g(n.data.map(s=>s),n.typeInfo):new T(n.value,n.typeInfo)}Radians(e,t){let n=this.exec.evalExpression(e.args[0],t);return n instanceof g?new g(n.data.map(s=>s*Math.PI/180),n.typeInfo):new T(n.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(n instanceof g&&s instanceof g){let i=this._dot(n.data,s.data);return new g(n.data.map((o,a)=>o-2*i*s.data[a]),n.typeInfo)}return console.error(`Reflect() expects vector arguments. Line ${e.line}`),null}Refract(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(n instanceof g&&s instanceof g&&i instanceof T){let o=this._dot(s.data,n.data);return new g(n.data.map((a,c)=>{let l=1-i.value*i.value*(1-o*o);if(l<0)return 0;let u=Math.sqrt(l);return i.value*a-(i.value*o+u)*s.data[c]}),n.typeInfo)}return console.error(`Refract() expects vector arguments and a scalar argument. Line ${e.line}`),null}ReverseBits(e,t){return console.error(`TODO: reverseBits. Line ${e.line}`),null}Round(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.round(i)),n.typeInfo);let s=n;return new T(Math.round(s.value),n.typeInfo)}Saturate(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.min(Math.max(i,0),1)),n.typeInfo);let s=n;return new T(Math.min(Math.max(s.value,0),1),n.typeInfo)}Sign(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.sign(i)),n.typeInfo);let s=n;return new T(Math.sign(s.value),n.typeInfo)}Sin(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.sin(i)),n.typeInfo);let s=n;return new T(Math.sin(s.value),n.typeInfo)}Sinh(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.sinh(i)),n.typeInfo);let s=n;return new T(Math.sinh(s.value),n.typeInfo)}_smoothstep(e,t,n){let s=Math.min(Math.max((n-e)/(t-e),0),1);return s*s*(3-2*s)}SmoothStep(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t),i=this.exec.evalExpression(e.args[2],t);if(i instanceof g&&n instanceof g&&s instanceof g)return new g(i.data.map((l,u)=>this._smoothstep(n.data[u],s.data[u],l)),i.typeInfo);let o=n,a=s,c=i;return new T(this._smoothstep(o.value,a.value,c.value),i.typeInfo)}Sqrt(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.sqrt(i)),n.typeInfo);let s=n;return new T(Math.sqrt(s.value),n.typeInfo)}Step(e,t){let n=this.exec.evalExpression(e.args[0],t),s=this.exec.evalExpression(e.args[1],t);if(s instanceof g&&n instanceof g)return new g(s.data.map((o,a)=>o<n.data[a]?0:1),s.typeInfo);let i=n;return new T(s.value<i.value?0:1,i.typeInfo)}Tan(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.tan(i)),n.typeInfo);let s=n;return new T(Math.tan(s.value),n.typeInfo)}Tanh(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.tanh(i)),n.typeInfo);let s=n;return new T(Math.tanh(s.value),n.typeInfo)}_getTransposeType(e){let t=e.getTypeName();return t==="mat2x2f"||t==="mat2x2h"?e:t==="mat2x3f"?this.getTypeInfo("mat3x2f"):t==="mat2x3h"?this.getTypeInfo("mat3x2h"):t==="mat2x4f"?this.getTypeInfo("mat4x2f"):t==="mat2x4h"?this.getTypeInfo("mat4x2h"):t==="mat3x2f"?this.getTypeInfo("mat2x3f"):t==="mat3x2h"?this.getTypeInfo("mat2x3h"):t==="mat3x3f"||t==="mat3x3h"?e:t==="mat3x4f"?this.getTypeInfo("mat4x3f"):t==="mat3x4h"?this.getTypeInfo("mat4x3h"):t==="mat4x2f"?this.getTypeInfo("mat2x4f"):t==="mat4x2h"?this.getTypeInfo("mat2x4h"):t==="mat4x3f"?this.getTypeInfo("mat3x4f"):t==="mat4x3h"?this.getTypeInfo("mat3x4h"):(t==="mat4x4f"||t==="mat4x4h"||console.error(`Invalid matrix type ${t}`),e)}Transpose(e,t){let n=this.exec.evalExpression(e.args[0],t);if(!(n instanceof z))return console.error(`Transpose() expects a matrix argument. Line ${e.line}`),null;let s=this._getTransposeType(n.typeInfo);if(n.typeInfo.name==="mat2x2"||n.typeInfo.name==="mat2x2f"||n.typeInfo.name==="mat2x2h"){let i=n.data;return new z([i[0],i[2],i[1],i[3]],s)}if(n.typeInfo.name==="mat2x3"||n.typeInfo.name==="mat2x3f"||n.typeInfo.name==="mat2x3h"){let i=n.data;return new z([i[0],i[3],i[6],i[1],i[4],i[7]],s)}if(n.typeInfo.name==="mat2x4"||n.typeInfo.name==="mat2x4f"||n.typeInfo.name==="mat2x4h"){let i=n.data;return new z([i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13]],s)}if(n.typeInfo.name==="mat3x2"||n.typeInfo.name==="mat3x2f"||n.typeInfo.name==="mat3x2h"){let i=n.data;return new z([i[0],i[3],i[1],i[4],i[2],i[5]],s)}if(n.typeInfo.name==="mat3x3"||n.typeInfo.name==="mat3x3f"||n.typeInfo.name==="mat3x3h"){let i=n.data;return new z([i[0],i[3],i[6],i[1],i[4],i[7],i[2],i[5],i[8]],s)}if(n.typeInfo.name==="mat3x4"||n.typeInfo.name==="mat3x4f"||n.typeInfo.name==="mat3x4h"){let i=n.data;return new z([i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13],i[2],i[6],i[10],i[14]],s)}if(n.typeInfo.name==="mat4x2"||n.typeInfo.name==="mat4x2f"||n.typeInfo.name==="mat4x2h"){let i=n.data;return new z([i[0],i[4],i[1],i[5],i[2],i[6]],s)}if(n.typeInfo.name==="mat4x3"||n.typeInfo.name==="mat4x3f"||n.typeInfo.name==="mat4x3h"){let i=n.data;return new z([i[0],i[4],i[8],i[1],i[5],i[9],i[2],i[6],i[10]],s)}if(n.typeInfo.name==="mat4x4"||n.typeInfo.name==="mat4x4f"||n.typeInfo.name==="mat4x4h"){let i=n.data;return new z([i[0],i[4],i[8],i[12],i[1],i[5],i[9],i[13],i[2],i[6],i[10],i[14],i[3],i[7],i[11],i[15]],s)}return console.error(`Invalid matrix type ${n.typeInfo.name}`),null}Trunc(e,t){let n=this.exec.evalExpression(e.args[0],t);if(n instanceof g)return new g(n.data.map(i=>Math.trunc(i)),n.typeInfo);let s=n;return new T(Math.trunc(s.value),n.typeInfo)}Dpdx(e,t){return console.error(`TODO: dpdx. Line ${e.line}`),null}DpdxCoarse(e,t){return console.error(`TODO: dpdxCoarse. Line ${e.line}`),null}DpdxFine(e,t){return console.error("TODO: dpdxFine"),null}Dpdy(e,t){return console.error("TODO: dpdy"),null}DpdyCoarse(e,t){return console.error("TODO: dpdyCoarse"),null}DpdyFine(e,t){return console.error("TODO: dpdyFine"),null}Fwidth(e,t){return console.error("TODO: fwidth"),null}FwidthCoarse(e,t){return console.error("TODO: fwidthCoarse"),null}FwidthFine(e,t){return console.error("TODO: fwidthFine"),null}TextureDimensions(e,t){let n=e.args[0],s=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(n instanceof Me){let i=n.name,o=t.getVariableValue(i);if(o instanceof lt){if(s<0||s>=o.mipLevelCount)return console.error(`Invalid mip level for textureDimensions. Line ${e.line}`),null;let a=o.getMipLevelSize(s),c=o.dimension;return c==="1d"?new T(a[0],this.getTypeInfo("u32")):c==="3d"?new g(a,this.getTypeInfo("vec3u")):c==="2d"?new g(a.slice(0,2),this.getTypeInfo("vec2u")):(console.error(`Invalid texture dimension ${c} not found. Line ${e.line}`),null)}return console.error(`Texture ${i} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureDimensions. Line ${e.line}`),null}TextureGather(e,t){return console.error("TODO: textureGather"),null}TextureGatherCompare(e,t){return console.error("TODO: textureGatherCompare"),null}TextureLoad(e,t){let n=e.args[0],s=this.exec.evalExpression(e.args[1],t),i=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(s instanceof g)||s.data.length!==2)return console.error(`Invalid UV argument for textureLoad. Line ${e.line}`),null;if(n instanceof Me){let o=n.name,a=t.getVariableValue(o);if(a instanceof lt){let c=Math.floor(s.data[0]),l=Math.floor(s.data[1]);if(c<0||c>=a.width||l<0||l>=a.height)return console.error(`Texture ${o} out of bounds. Line ${e.line}`),null;let u=a.getPixel(c,l,0,i);return u===null?(console.error(`Invalid texture format for textureLoad. Line ${e.line}`),null):new g(u,this.getTypeInfo("vec4f"))}return console.error(`Texture ${o} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureLoad. Line ${e.line}`),null}TextureNumLayers(e,t){let n=e.args[0];if(n instanceof Me){let s=n.name,i=t.getVariableValue(s);return i instanceof lt?new T(i.depthOrArrayLayers,this.getTypeInfo("u32")):(console.error(`Texture ${s} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLayers. Line ${e.line}`),null}TextureNumLevels(e,t){let n=e.args[0];if(n instanceof Me){let s=n.name,i=t.getVariableValue(s);return i instanceof lt?new T(i.mipLevelCount,this.getTypeInfo("u32")):(console.error(`Texture ${s} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLevels. Line ${e.line}`),null}TextureNumSamples(e,t){let n=e.args[0];if(n instanceof Me){let s=n.name,i=t.getVariableValue(s);return i instanceof lt?new T(i.sampleCount,this.getTypeInfo("u32")):(console.error(`Texture ${s} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumSamples. Line ${e.line}`),null}TextureSample(e,t){return console.error("TODO: textureSample"),null}TextureSampleBias(e,t){return console.error("TODO: textureSampleBias"),null}TextureSampleCompare(e,t){return console.error("TODO: textureSampleCompare"),null}TextureSampleCompareLevel(e,t){return console.error("TODO: textureSampleCompareLevel"),null}TextureSampleGrad(e,t){return console.error("TODO: textureSampleGrad"),null}TextureSampleLevel(e,t){return console.error("TODO: textureSampleLevel"),null}TextureSampleBaseClampToEdge(e,t){return console.error("TODO: textureSampleBaseClampToEdge"),null}TextureStore(e,t){let n=e.args[0],s=this.exec.evalExpression(e.args[1],t),i=e.args.length===4?this.exec.evalExpression(e.args[2],t).value:0,o=e.args.length===4?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(o.length!==4)return console.error(`Invalid value argument for textureStore. Line ${e.line}`),null;if(!(s instanceof g)||s.data.length!==2)return console.error(`Invalid UV argument for textureStore. Line ${e.line}`),null;if(n instanceof Me){let a=n.name,c=t.getVariableValue(a);if(c instanceof lt){let l=c.getMipLevelSize(0),u=Math.floor(s.data[0]),f=Math.floor(s.data[1]);return u<0||u>=l[0]||f<0||f>=l[1]?(console.error(`Texture ${a} out of bounds. Line ${e.line}`),null):(c.setPixel(u,f,0,i,Array.from(o)),null)}return console.error(`Texture ${a} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureStore. Line ${e.line}`),null}AtomicLoad(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t);return t.getVariable(s).value.getSubData(this.exec,n.postfix,t)}AtomicStore(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t);return c instanceof T&&a instanceof T&&(c.value=a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),null}AtomicAdd(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value+=a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicSub(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value-=a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicMax(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value=Math.max(c.value,a.value)),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicMin(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value=Math.min(c.value,a.value)),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicAnd(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value=c.value&a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicOr(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value=c.value|a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicXor(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value=c.value^a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicExchange(e,t){let n=e.args[0];n instanceof ue&&(n=n.right);let s=this.exec.getVariableName(n,t),i=t.getVariable(s),o=e.args[1],a=this.exec.evalExpression(o,t),c=i.value.getSubData(this.exec,n.postfix,t),l=new T(c.value,c.typeInfo);return c instanceof T&&a instanceof T&&(c.value=a.value),i.value instanceof ce&&i.value.setDataValue(this.exec,c,n.postfix,t),l}AtomicCompareExchangeWeak(e,t){return console.error("TODO: atomicCompareExchangeWeak"),null}Pack4x8snorm(e,t){return console.error("TODO: pack4x8snorm"),null}Pack4x8unorm(e,t){return console.error("TODO: pack4x8unorm"),null}Pack4xI8(e,t){return console.error("TODO: pack4xI8"),null}Pack4xU8(e,t){return console.error("TODO: pack4xU8"),null}Pack4x8Clamp(e,t){return console.error("TODO: pack4x8Clamp"),null}Pack4xU8Clamp(e,t){return console.error("TODO: pack4xU8Clamp"),null}Pack2x16snorm(e,t){return console.error("TODO: pack2x16snorm"),null}Pack2x16unorm(e,t){return console.error("TODO: pack2x16unorm"),null}Pack2x16float(e,t){return console.error("TODO: pack2x16float"),null}Unpack4x8snorm(e,t){return console.error("TODO: unpack4x8snorm"),null}Unpack4x8unorm(e,t){return console.error("TODO: unpack4x8unorm"),null}Unpack4xI8(e,t){return console.error("TODO: unpack4xI8"),null}Unpack4xU8(e,t){return console.error("TODO: unpack4xU8"),null}Unpack2x16snorm(e,t){return console.error("TODO: unpack2x16snorm"),null}Unpack2x16unorm(e,t){return console.error("TODO: unpack2x16unorm"),null}Unpack2x16float(e,t){return console.error("TODO: unpack2x16float"),null}StorageBarrier(e,t){return null}TextureBarrier(e,t){return null}WorkgroupBarrier(e,t){return null}WorkgroupUniformLoad(e,t){return null}SubgroupAdd(e,t){return console.error("TODO: subgroupAdd"),null}SubgroupExclusiveAdd(e,t){return console.error("TODO: subgroupExclusiveAdd"),null}SubgroupInclusiveAdd(e,t){return console.error("TODO: subgroupInclusiveAdd"),null}SubgroupAll(e,t){return console.error("TODO: subgroupAll"),null}SubgroupAnd(e,t){return console.error("TODO: subgroupAnd"),null}SubgroupAny(e,t){return console.error("TODO: subgroupAny"),null}SubgroupBallot(e,t){return console.error("TODO: subgroupBallot"),null}SubgroupBroadcast(e,t){return console.error("TODO: subgroupBroadcast"),null}SubgroupBroadcastFirst(e,t){return console.error("TODO: subgroupBroadcastFirst"),null}SubgroupElect(e,t){return console.error("TODO: subgroupElect"),null}SubgroupMax(e,t){return console.error("TODO: subgroupMax"),null}SubgroupMin(e,t){return console.error("TODO: subgroupMin"),null}SubgroupMul(e,t){return console.error("TODO: subgroupMul"),null}SubgroupExclusiveMul(e,t){return console.error("TODO: subgroupExclusiveMul"),null}SubgroupInclusiveMul(e,t){return console.error("TODO: subgroupInclusiveMul"),null}SubgroupOr(e,t){return console.error("TODO: subgroupOr"),null}SubgroupShuffle(e,t){return console.error("TODO: subgroupShuffle"),null}SubgroupShuffleDown(e,t){return console.error("TODO: subgroupShuffleDown"),null}SubgroupShuffleUp(e,t){return console.error("TODO: subgroupShuffleUp"),null}SubgroupShuffleXor(e,t){return console.error("TODO: subgroupShuffleXor"),null}SubgroupXor(e,t){return console.error("TODO: subgroupXor"),null}QuadBroadcast(e,t){return console.error("TODO: quadBroadcast"),null}QuadSwapDiagonal(e,t){return console.error("TODO: quadSwapDiagonal"),null}QuadSwapX(e,t){return console.error("TODO: quadSwapX"),null}QuadSwapY(e,t){return console.error("TODO: quadSwapY"),null}},Lu={vec2:2,vec2f:2,vec2i:2,vec2u:2,vec2b:2,vec2h:2,vec3:3,vec3f:3,vec3i:3,vec3u:3,vec3b:3,vec3h:3,vec4:4,vec4f:4,vec4i:4,vec4u:4,vec4b:4,vec4h:4},Ce={mat2x2:[2,2,4],mat2x2f:[2,2,4],mat2x2h:[2,2,4],mat2x3:[2,3,6],mat2x3f:[2,3,6],mat2x3h:[2,3,6],mat2x4:[2,4,8],mat2x4f:[2,4,8],mat2x4h:[2,4,8],mat3x2:[3,2,6],mat3x2f:[3,2,6],mat3x2h:[3,2,6],mat3x3:[3,3,9],mat3x3f:[3,3,9],mat3x3h:[3,3,9],mat3x4:[3,4,12],mat3x4f:[3,4,12],mat3x4h:[3,4,12],mat4x2:[4,2,8],mat4x2f:[4,2,8],mat4x2h:[4,2,8],mat4x3:[4,3,12],mat4x3f:[4,3,12],mat4x3h:[4,3,12],mat4x4:[4,4,16],mat4x4f:[4,4,16],mat4x4h:[4,4,16]},we=class extends Qu{constructor(e,t){var n;super(),this.ast=e??[],this.reflection=new Qe,this.reflection.updateAST(this.ast),this.context=(n=t?.clone())!==null&&n!==void 0?n:new ti,this.builtins=new Ju(this),this.typeInfo={bool:this.getTypeInfo(M.bool),i32:this.getTypeInfo(M.i32),u32:this.getTypeInfo(M.u32),f32:this.getTypeInfo(M.f32),f16:this.getTypeInfo(M.f16),vec2f:this.getTypeInfo(A.vec2f),vec2u:this.getTypeInfo(A.vec2u),vec2i:this.getTypeInfo(A.vec2i),vec2h:this.getTypeInfo(A.vec2h),vec3f:this.getTypeInfo(A.vec3f),vec3u:this.getTypeInfo(A.vec3u),vec3i:this.getTypeInfo(A.vec3i),vec3h:this.getTypeInfo(A.vec3h),vec4f:this.getTypeInfo(A.vec4f),vec4u:this.getTypeInfo(A.vec4u),vec4i:this.getTypeInfo(A.vec4i),vec4h:this.getTypeInfo(A.vec4h),mat2x2f:this.getTypeInfo(A.mat2x2f),mat2x3f:this.getTypeInfo(A.mat2x3f),mat2x4f:this.getTypeInfo(A.mat2x4f),mat3x2f:this.getTypeInfo(A.mat3x2f),mat3x3f:this.getTypeInfo(A.mat3x3f),mat3x4f:this.getTypeInfo(A.mat3x4f),mat4x2f:this.getTypeInfo(A.mat4x2f),mat4x3f:this.getTypeInfo(A.mat4x3f),mat4x4f:this.getTypeInfo(A.mat4x4f)}}getVariableValue(e){var t,n;let s=(n=(t=this.context.getVariable(e))===null||t===void 0?void 0:t.value)!==null&&n!==void 0?n:null;if(s===null)return null;if(s instanceof T)return s.value;if(s instanceof g||s instanceof z)return Array.from(s.data);if(s instanceof ce&&s.typeInfo instanceof It){if(s.typeInfo.format.name==="u32")return Array.from(new Uint32Array(s.buffer,s.offset,s.typeInfo.count));if(s.typeInfo.format.name==="i32")return Array.from(new Int32Array(s.buffer,s.offset,s.typeInfo.count));if(s.typeInfo.format.name==="f32")return Array.from(new Float32Array(s.buffer,s.offset,s.typeInfo.count))}return console.error(`Unsupported return variable type ${s.typeInfo.name}`),null}execute(e){(e=e??{}).constants&&this._setOverrides(e.constants,this.context),this._execStatements(this.ast,this.context)}dispatchWorkgroups(e,t,n,s){let i=this.context.clone();(s=s??{}).constants&&this._setOverrides(s.constants,i),this._execStatements(this.ast,i);let o=i.getFunction(e);if(!o)return void console.error(`Function ${e} not found`);if(typeof t=="number")t=[t,1,1];else{if(t.length===0)return void console.error("Invalid dispatch count");t.length===1?t=[t[0],1,1]:t.length===2?t=[t[0],t[1],1]:t.length>3&&(t=[t[0],t[1],t[2]])}let a=t[0],c=t[1],l=t[2],u=this.getTypeInfo("vec3u");i.setVariable("@num_workgroups",new g(t,u));for(let f in n)for(let h in n[f]){let d=n[f][h];i.variables.forEach(m=>{var y;let _=m.node;if(_?.attributes){let x=null,E=null;for(let b of _.attributes)b.name==="binding"?x=b.value:b.name==="group"&&(E=b.value);if(h==x&&f==E)if(d.texture!==void 0&&d.descriptor!==void 0){let b=new lt(d.texture,this.getTypeInfo(_.type),d.descriptor,(y=d.texture.view)!==null&&y!==void 0?y:null);m.value=b}else d.uniform!==void 0?m.value=new ce(d.uniform,this.getTypeInfo(_.type)):m.value=new ce(d,this.getTypeInfo(_.type))}})}for(let f=0;f<l;++f)for(let h=0;h<c;++h)for(let d=0;d<a;++d)i.setVariable("@workgroup_id",new g([d,h,f],this.getTypeInfo("vec3u"))),this._dispatchWorkgroup(o,[d,h,f],i)}execStatement(e,t){if(e instanceof da)return this.evalExpression(e.value,t);if(e instanceof ma){if(e.condition){let n=this.evalExpression(e.condition,t);if(!(n instanceof T))throw new Error("Invalid break-if condition");if(!n.value)return null}return we._breakObj}if(e instanceof ga)return we._continueObj;if(e instanceof Qr)this._let(e,t);else if(e instanceof ut)this._var(e,t);else if(e instanceof Kn)this._const(e,t);else if(e instanceof en)this._function(e,t);else{if(e instanceof ha)return this._if(e,t);if(e instanceof fa)return this._switch(e,t);if(e instanceof aa)return this._for(e,t);if(e instanceof oa)return this._while(e,t);if(e instanceof ua)return this._loop(e,t);if(e instanceof Ys){let n=t.clone();return n.currentFunctionName=t.currentFunctionName,this._execStatements(e.body,n)}if(e instanceof la)this._assign(e,t);else if(e instanceof ca)this._increment(e,t);else{if(e instanceof ct)return null;if(e instanceof qs){let n=e.name;t.getVariable(n)===null&&t.setVariable(n,new T(0,this.getTypeInfo("u32")))}else if(e instanceof Ks)this._call(e,t);else{if(e instanceof pa||e instanceof Zs)return null;console.error("Invalid statement type.",e,`Line ${e.line}`)}}}return null}evalExpression(e,t){return e instanceof je?this._evalBinaryOp(e,t):e instanceof me?this._evalLiteral(e,t):e instanceof Me?this._evalVariable(e,t):e instanceof Gs?this._evalCall(e,t):e instanceof Ge?this._evalCreate(e,t):e instanceof ya?this._evalConst(e,t):e instanceof xa?this._evalBitcast(e,t):e instanceof ue?this._evalUnaryOp(e,t):(console.error("Invalid expression type",e,`Line ${e.line}`),null)}getTypeInfo(e){var t;if(e instanceof M){let s=this.reflection.getTypeInfo(e);if(s!==null)return s}let n=(t=this.typeInfo[e])!==null&&t!==void 0?t:null;return n!==null||(n=this.reflection.getTypeInfoByName(e)),n}_setOverrides(e,t){for(let n in e){let s=e[n],i=this.reflection.getOverrideInfo(n);i!==null?(i.type===null&&(i.type=this.getTypeInfo("u32")),i.type.name==="u32"||i.type.name==="i32"||i.type.name==="f32"||i.type.name==="f16"?t.setVariable(n,new T(s,i.type)):i.type.name==="bool"?t.setVariable(n,new T(s?1:0,i.type)):i.type.name==="vec2"||i.type.name==="vec3"||i.type.name==="vec4"||i.type.name==="vec2f"||i.type.name==="vec3f"||i.type.name==="vec4f"||i.type.name==="vec2i"||i.type.name==="vec3i"||i.type.name==="vec4i"||i.type.name==="vec2u"||i.type.name==="vec3u"||i.type.name==="vec4u"||i.type.name==="vec2h"||i.type.name==="vec3h"||i.type.name==="vec4h"?t.setVariable(n,new g(s,i.type)):console.error(`Invalid constant type for ${n}`)):console.error(`Override ${n} does not exist in the shader.`)}}_dispatchWorkgroup(e,t,n){let s=[1,1,1];for(let u of e.node.attributes)if(u.name==="workgroup_size"){if(u.value.length>0){let f=n.getVariableValue(u.value[0]);s[0]=f instanceof T?f.value:parseInt(u.value[0])}if(u.value.length>1){let f=n.getVariableValue(u.value[1]);s[1]=f instanceof T?f.value:parseInt(u.value[1])}if(u.value.length>2){let f=n.getVariableValue(u.value[2]);s[2]=f instanceof T?f.value:parseInt(u.value[2])}}let i=this.getTypeInfo("vec3u"),o=this.getTypeInfo("u32");n.setVariable("@workgroup_size",new g(s,i));let a=s[0],c=s[1],l=s[2];for(let u=0,f=0;u<l;++u)for(let h=0;h<c;++h)for(let d=0;d<a;++d,++f){let m=[d,h,u],y=[d+t[0]*s[0],h+t[1]*s[1],u+t[2]*s[2]];n.setVariable("@local_invocation_id",new g(m,i)),n.setVariable("@global_invocation_id",new g(y,i)),n.setVariable("@local_invocation_index",new T(f,o)),this._dispatchExec(e,n)}}_dispatchExec(e,t){for(let n of e.node.args)for(let s of n.attributes)if(s.name==="builtin"){let i=`@${s.value}`,o=t.getVariable(i);o!==void 0&&t.variables.set(n.name,o)}this._execStatements(e.node.body,t)}getVariableName(e,t){for(;e instanceof ue;)e=e.right;return e instanceof Me?e.name:(console.error("Unknown variable type",e,"Line",e.line),null)}_execStatements(e,t){for(let n of e){if(n instanceof Array){let i=t.clone(),o=this._execStatements(n,i);if(o)return o;continue}let s=this.execStatement(n,t);if(s)return s}return null}_call(e,t){let n=t.clone();n.currentFunctionName=e.name;let s=t.getFunction(e.name);if(s){for(let i=0;i<s.node.args.length;++i){let o=s.node.args[i],a=this.evalExpression(e.args[i],n);n.setVariable(o.name,a,o)}this._execStatements(s.node.body,n)}else e.isBuiltin?this._callBuiltinFunction(e,n):this.getTypeInfo(e.name)&&this._evalCreate(e,t)}_increment(e,t){let n=this.getVariableName(e.variable,t),s=t.getVariable(n);s?e.operator==="++"?s.value instanceof T?s.value.value++:console.error(`Variable ${n} is not a scalar. Line ${e.line}`):e.operator==="--"?s.value instanceof T?s.value.value--:console.error(`Variable ${n} is not a scalar. Line ${e.line}`):console.error(`Unknown increment operator ${e.operator}. Line ${e.line}`):console.error(`Variable ${n} not found. Line ${e.line}`)}_getVariableData(e,t){if(e instanceof Me){let n=this.getVariableName(e,t),s=t.getVariable(n);return s===null?(console.error(`Variable ${n} not found. Line ${e.line}`),null):s.value.getSubData(this,e.postfix,t)}if(e instanceof ue){if(e.operator==="*"){let n=this._getVariableData(e.right,t);return n instanceof xr?n.reference.getSubData(this,e.postfix,t):(console.error(`Variable ${e.right} is not a pointer. Line ${e.line}`),null)}if(e.operator==="&"){let n=this._getVariableData(e.right,t);return new xr(n)}}return null}_assign(e,t){let n=null,s="<var>",i=null;if(e.variable instanceof ue){let c=this._getVariableData(e.variable,t),l=this.evalExpression(e.value,t),u=e.operator;if(u==="="){if(c instanceof T||c instanceof g||c instanceof z){if(l instanceof T||l instanceof g||l instanceof z&&c.data.length===l.data.length)return void c.data.set(l.data);console.error(`Invalid assignment. Line ${e.line}`)}else if(c instanceof ce&&l instanceof ce&&c.buffer.byteLength-c.offset>=l.buffer.byteLength-l.offset)return void(c.buffer.byteLength%4==0?new Uint32Array(c.buffer,c.offset,c.typeInfo.size/4).set(new Uint32Array(l.buffer,l.offset,l.typeInfo.size/4)):new Uint8Array(c.buffer,c.offset,c.typeInfo.size).set(new Uint8Array(l.buffer,l.offset,l.typeInfo.size)));return console.error(`Invalid assignment. Line ${e.line}`),null}if(u==="+=")return c instanceof T||c instanceof g||c instanceof z?l instanceof T||l instanceof g||l instanceof z?void c.data.set(l.data.map((f,h)=>c.data[h]+f)):void console.error(`Invalid assignment . Line ${e.line}`):void console.error(`Invalid assignment. Line ${e.line}`);if(u==="-=")return(c instanceof T||c instanceof g||c instanceof z)&&(l instanceof T||l instanceof g||l instanceof z)?void c.data.set(l.data.map((f,h)=>c.data[h]-f)):void console.error(`Invalid assignment. Line ${e.line}`)}if(e.variable instanceof ue){if(e.variable.operator==="*"){s=this.getVariableName(e.variable.right,t);let c=t.getVariable(s);if(!(c&&c.value instanceof xr))return void console.error(`Variable ${s} is not a pointer. Line ${e.line}`);n=c.value.reference;let l=e.variable.postfix;if(!l){let u=e.variable.right;for(;u instanceof ue;){if(u.postfix){l=u.postfix;break}u=u.right}}l&&(n=n.getSubData(this,l,t))}}else{i=e.variable.postfix,s=this.getVariableName(e.variable,t);let c=t.getVariable(s);if(c===null)return void console.error(`Variable ${s} not found. Line ${e.line}`);n=c.value}if(n instanceof xr&&(n=n.reference),n===null)return void console.error(`Variable ${s} not found. Line ${e.line}`);let o=this.evalExpression(e.value,t),a=e.operator;if(a==="=")if(n instanceof ce)n.setDataValue(this,o,i,t);else if(i){if(!(n instanceof g||n instanceof z))return void console.error(`Variable ${s} is not a vector or matrix. Line ${e.line}`);if(i instanceof br){let c=this.evalExpression(i.index,t).value;if(n instanceof g){if(!(o instanceof T))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[c]=o.value}else{if(!(n instanceof z))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);{let l=this.evalExpression(i.index,t).value;if(l<0)return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);if(!(o instanceof g))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);{let u=n.typeInfo.getTypeName();if(u==="mat2x2"||u==="mat2x2f"||u==="mat2x2h"){if(!(l<2&&o.data.length===2))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[2*l]=o.data[0],n.data[2*l+1]=o.data[1]}else if(u==="mat2x3"||u==="mat2x3f"||u==="mat2x3h"){if(!(l<2&&o.data.length===3))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[3*l]=o.data[0],n.data[3*l+1]=o.data[1],n.data[3*l+2]=o.data[2]}else if(u==="mat2x4"||u==="mat2x4f"||u==="mat2x4h"){if(!(l<2&&o.data.length===4))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[4*l]=o.data[0],n.data[4*l+1]=o.data[1],n.data[4*l+2]=o.data[2],n.data[4*l+3]=o.data[3]}else if(u==="mat3x2"||u==="mat3x2f"||u==="mat3x2h"){if(!(l<3&&o.data.length===2))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[2*l]=o.data[0],n.data[2*l+1]=o.data[1]}else if(u==="mat3x3"||u==="mat3x3f"||u==="mat3x3h"){if(!(l<3&&o.data.length===3))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[3*l]=o.data[0],n.data[3*l+1]=o.data[1],n.data[3*l+2]=o.data[2]}else if(u==="mat3x4"||u==="mat3x4f"||u==="mat3x4h"){if(!(l<3&&o.data.length===4))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[4*l]=o.data[0],n.data[4*l+1]=o.data[1],n.data[4*l+2]=o.data[2],n.data[4*l+3]=o.data[3]}else if(u==="mat4x2"||u==="mat4x2f"||u==="mat4x2h"){if(!(l<4&&o.data.length===2))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[2*l]=o.data[0],n.data[2*l+1]=o.data[1]}else if(u==="mat4x3"||u==="mat4x3f"||u==="mat4x3h"){if(!(l<4&&o.data.length===3))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[3*l]=o.data[0],n.data[3*l+1]=o.data[1],n.data[3*l+2]=o.data[2]}else{if(u!=="mat4x4"&&u!=="mat4x4f"&&u!=="mat4x4h")return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);if(!(l<4&&o.data.length===4))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);n.data[4*l]=o.data[0],n.data[4*l+1]=o.data[1],n.data[4*l+2]=o.data[2],n.data[4*l+3]=o.data[3]}}}}}else if(i instanceof Zt){let c=i.value;if(!(n instanceof g))return void console.error(`Invalid assignment to ${c}. Variable ${s} is not a vector. Line ${e.line}`);if(o instanceof T){if(c.length>1)return void console.error(`Invalid assignment to ${c} for variable ${s}. Line ${e.line}`);if(c==="x")n.data[0]=o.value;else if(c==="y"){if(n.data.length<2)return void console.error(`Invalid assignment to ${c} for variable ${s}. Line ${e.line}`);n.data[1]=o.value}else if(c==="z"){if(n.data.length<3)return void console.error(`Invalid assignment to ${c} for variable ${s}. Line ${e.line}`);n.data[2]=o.value}else if(c==="w"){if(n.data.length<4)return void console.error(`Invalid assignment to ${c} for variable ${s}. Line ${e.line}`);n.data[3]=o.value}}else{if(!(o instanceof g))return void console.error(`Invalid assignment to ${s}. Line ${e.line}`);if(c.length!==o.data.length)return void console.error(`Invalid assignment to ${c} for variable ${s}. Line ${e.line}`);for(let l=0;l<c.length;++l){let u=c[l];if(u==="x"||u==="r")n.data[0]=o.data[l];else if(u==="y"||u==="g"){if(o.data.length<2)return void console.error(`Invalid assignment to ${u} for variable ${s}. Line ${e.line}`);n.data[1]=o.data[l]}else if(u==="z"||u==="b"){if(o.data.length<3)return void console.error(`Invalid assignment to ${u} for variable ${s}. Line ${e.line}`);n.data[2]=o.data[l]}else{if(u!=="w"&&u!=="a")return void console.error(`Invalid assignment to ${u} for variable ${s}. Line ${e.line}`);if(o.data.length<4)return void console.error(`Invalid assignment to ${u} for variable ${s}. Line ${e.line}`);n.data[3]=o.data[l]}}}}}else n instanceof T&&o instanceof T?n.value=o.value:n instanceof g&&o instanceof g||n instanceof z&&o instanceof z?n.data.set(o.data):console.error(`Invalid assignment to ${s}. Line ${e.line}`);else{let c=n.getSubData(this,i,t);if(c instanceof g&&o instanceof T){let l=c.data,u=o.value;if(a==="+=")for(let f=0;f<l.length;++f)l[f]+=u;else if(a==="-=")for(let f=0;f<l.length;++f)l[f]-=u;else if(a==="*=")for(let f=0;f<l.length;++f)l[f]*=u;else if(a==="/=")for(let f=0;f<l.length;++f)l[f]/=u;else if(a==="%=")for(let f=0;f<l.length;++f)l[f]%=u;else if(a==="&=")for(let f=0;f<l.length;++f)l[f]&=u;else if(a==="|=")for(let f=0;f<l.length;++f)l[f]|=u;else if(a==="^=")for(let f=0;f<l.length;++f)l[f]^=u;else if(a==="<<=")for(let f=0;f<l.length;++f)l[f]<<=u;else if(a===">>=")for(let f=0;f<l.length;++f)l[f]>>=u;else console.error(`Invalid operator ${a}. Line ${e.line}`)}else if(c instanceof g&&o instanceof g){let l=c.data,u=o.data;if(l.length!==u.length)return void console.error(`Vector length mismatch. Line ${e.line}`);if(a==="+=")for(let f=0;f<l.length;++f)l[f]+=u[f];else if(a==="-=")for(let f=0;f<l.length;++f)l[f]-=u[f];else if(a==="*=")for(let f=0;f<l.length;++f)l[f]*=u[f];else if(a==="/=")for(let f=0;f<l.length;++f)l[f]/=u[f];else if(a==="%=")for(let f=0;f<l.length;++f)l[f]%=u[f];else if(a==="&=")for(let f=0;f<l.length;++f)l[f]&=u[f];else if(a==="|=")for(let f=0;f<l.length;++f)l[f]|=u[f];else if(a==="^=")for(let f=0;f<l.length;++f)l[f]^=u[f];else if(a==="<<=")for(let f=0;f<l.length;++f)l[f]<<=u[f];else if(a===">>=")for(let f=0;f<l.length;++f)l[f]>>=u[f];else console.error(`Invalid operator ${a}. Line ${e.line}`)}else{if(!(c instanceof T&&o instanceof T))return void console.error(`Invalid type for ${e.operator} operator. Line ${e.line}`);a==="+="?c.value+=o.value:a==="-="?c.value-=o.value:a==="*="?c.value*=o.value:a==="/="?c.value/=o.value:a==="%="?c.value%=o.value:a==="&="?c.value&=o.value:a==="|="?c.value|=o.value:a==="^="?c.value^=o.value:a==="<<="?c.value<<=o.value:a===">>="?c.value>>=o.value:console.error(`Invalid operator ${a}. Line ${e.line}`)}n instanceof ce&&n.setDataValue(this,c,i,t)}}_function(e,t){let n=new ei(e);t.functions.set(e.name,n)}_const(e,t){let n=null;e.value!==null&&(n=this.evalExpression(e.value,t)),t.createVariable(e.name,n,e)}_let(e,t){let n=null;if(e.value!==null){if(n=this.evalExpression(e.value,t),n===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof ue||(n=n.clone())}else{let s=e.type.name;if(s==="f32"||s==="i32"||s==="u32"||s==="bool"||s==="f16"||s==="vec2"||s==="vec3"||s==="vec4"||s==="vec2f"||s==="vec3f"||s==="vec4f"||s==="vec2i"||s==="vec3i"||s==="vec4i"||s==="vec2u"||s==="vec3u"||s==="vec4u"||s==="vec2h"||s==="vec3h"||s==="vec4h"||s==="vec2b"||s==="vec3b"||s==="vec4b"||s==="mat2x2"||s==="mat2x3"||s==="mat2x4"||s==="mat3x2"||s==="mat3x3"||s==="mat3x4"||s==="mat4x2"||s==="mat4x3"||s==="mat4x4"||s==="mat2x2f"||s==="mat2x3f"||s==="mat2x4f"||s==="mat3x2f"||s==="mat3x3f"||s==="mat3x4f"||s==="mat4x2f"||s==="mat4x3f"||s==="mat4x4f"||s==="mat2x2h"||s==="mat2x3h"||s==="mat2x4h"||s==="mat3x2h"||s==="mat3x3h"||s==="mat3x4h"||s==="mat4x2h"||s==="mat4x3h"||s==="mat4x4h"||s==="array"){let i=new Ge(e.type,[]);n=this._evalCreate(i,t)}}t.createVariable(e.name,n,e)}_var(e,t){let n=null;if(e.value!==null){if(n=this.evalExpression(e.value,t),n===null)return void console.error(`Invalid value for variable ${e.name}. Line ${e.line}`);e.value instanceof ue||(n=n.clone())}else{if(e.type===null)return void console.error(`Variable ${e.name} has no type. Line ${e.line}`);let s=e.type.name;if(s==="f32"||s==="i32"||s==="u32"||s==="bool"||s==="f16"||s==="vec2"||s==="vec3"||s==="vec4"||s==="vec2f"||s==="vec3f"||s==="vec4f"||s==="vec2i"||s==="vec3i"||s==="vec4i"||s==="vec2u"||s==="vec3u"||s==="vec4u"||s==="vec2h"||s==="vec3h"||s==="vec4h"||s==="vec2b"||s==="vec3b"||s==="vec4b"||s==="mat2x2"||s==="mat2x3"||s==="mat2x4"||s==="mat3x2"||s==="mat3x3"||s==="mat3x4"||s==="mat4x2"||s==="mat4x3"||s==="mat4x4"||s==="mat2x2f"||s==="mat2x3f"||s==="mat2x4f"||s==="mat3x2f"||s==="mat3x3f"||s==="mat3x4f"||s==="mat4x2f"||s==="mat4x3f"||s==="mat4x4f"||s==="mat2x2h"||s==="mat2x3h"||s==="mat2x4h"||s==="mat3x2h"||s==="mat3x3h"||s==="mat3x4h"||s==="mat4x2h"||s==="mat4x3h"||s==="mat4x4h"||e.type instanceof Jr||e.type instanceof ct||e.type instanceof A){let i=new Ge(e.type,[]);n=this._evalCreate(i,t)}}t.createVariable(e.name,n,e)}_switch(e,t){t=t.clone();let n=this.evalExpression(e.condition,t);if(!(n instanceof T))return console.error(`Invalid if condition. Line ${e.line}`),null;let s=null;for(let i of e.cases)if(i instanceof wa)for(let o of i.selectors){if(o instanceof Zn){s=i;continue}let a=this.evalExpression(o,t);if(!(a instanceof T))return console.error(`Invalid case selector. Line ${e.line}`),null;if(a.value===n.value)return this._execStatements(i.body,t)}else i instanceof va&&(s=i);return s?this._execStatements(s.body,t):null}_if(e,t){t=t.clone();let n=this.evalExpression(e.condition,t);if(!(n instanceof T))return console.error(`Invalid if condition. Line ${e.line}`),null;if(n.value)return this._execStatements(e.body,t);for(let s of e.elseif){let i=this.evalExpression(s.condition,t);if(!(i instanceof T))return console.error(`Invalid if condition. Line ${e.line}`),null;if(i.value)return this._execStatements(s.body,t)}return e.else?this._execStatements(e.else,t):null}_getScalarValue(e){return e instanceof T?e.value:(console.error("Expected scalar value.",e),0)}_for(e,t){for(t=t.clone(),this.execStatement(e.init,t);this._getScalarValue(this.evalExpression(e.condition,t));){let n=this._execStatements(e.body,t);if(n===we._breakObj)break;if(n!==null&&n!==we._continueObj)return n;this.execStatement(e.increment,t)}return null}_loop(e,t){for(t=t.clone();;){let n=this._execStatements(e.body,t);if(n===we._breakObj)break;if(n===we._continueObj){if(e.continuing&&this._execStatements(e.continuing.body,t)===we._breakObj)break}else if(n!==null)return n}return null}_while(e,t){for(t=t.clone();this._getScalarValue(this.evalExpression(e.condition,t));){let n=this._execStatements(e.body,t);if(n===we._breakObj)break;if(n!==we._continueObj&&n!==null)return n}return null}_evalBitcast(e,t){let n=this.evalExpression(e.value,t),s=e.type;if(n instanceof T){let i=mm(n.value,n.typeInfo.name,s.name);return new T(i,this.getTypeInfo(s))}if(n instanceof g){let i=n.typeInfo.getTypeName(),o="";if(i.endsWith("f"))o="f32";else if(i.endsWith("i"))o="i32";else if(i.endsWith("u"))o="u32";else if(i.endsWith("b"))o="bool";else{if(!i.endsWith("h"))return console.error(`Unknown vector type ${i}. Line ${e.line}`),null;o="f16"}let a=s.getTypeName(),c="";if(a.endsWith("f"))c="f32";else if(a.endsWith("i"))c="i32";else if(a.endsWith("u"))c="u32";else if(a.endsWith("b"))c="bool";else{if(!a.endsWith("h"))return console.error(`Unknown vector type ${c}. Line ${e.line}`),null;c="f16"}let l=function(u,f,h){if(f===h)return u;let d=new Array(u.length);for(let m=0;m<u.length;m++)d[m]=mm(u[m],f,h);return d}(Array.from(n.data),o,c);return new g(l,this.getTypeInfo(s))}return console.error(`TODO: bitcast for ${n.typeInfo.name}. Line ${e.line}`),null}_evalConst(e,t){return t.getVariableValue(e.name).clone().getSubData(this,e.postfix,t)}_evalCreate(e,t){var n;if(e instanceof Ge){if(e.type===null)return Qs.void;switch(e.type.getTypeName()){case"bool":case"i32":case"u32":case"f32":case"f16":return this._callConstructorValue(e,t);case"vec2":case"vec3":case"vec4":case"vec2f":case"vec3f":case"vec4f":case"vec2h":case"vec3h":case"vec4h":case"vec2i":case"vec3i":case"vec4i":case"vec2u":case"vec3u":case"vec4u":case"vec2b":case"vec3b":case"vec4b":return this._callConstructorVec(e,t);case"mat2x2":case"mat2x2f":case"mat2x2h":case"mat2x3":case"mat2x3f":case"mat2x3h":case"mat2x4":case"mat2x4f":case"mat2x4h":case"mat3x2":case"mat3x2f":case"mat3x2h":case"mat3x3":case"mat3x3f":case"mat3x3h":case"mat3x4":case"mat3x4f":case"mat3x4h":case"mat4x2":case"mat4x2f":case"mat4x2h":case"mat4x3":case"mat4x3f":case"mat4x3h":case"mat4x4":case"mat4x4f":case"mat4x4h":return this._callConstructorMatrix(e,t)}}let s=e instanceof Ge?e.type.name:e.name,i=e instanceof Ge?this.getTypeInfo(e.type):this.getTypeInfo(e.name);if(i===null)return console.error(`Unknown type ${s}. Line ${e.line}`),null;if(i.size===0)return null;let o=new ce(new ArrayBuffer(i.size),i,0);if(i instanceof Rt){if(e.args)for(let a=0;a<e.args.length;++a){let c=i.members[a],l=e.args[a],u=this.evalExpression(l,t);o.setData(this,u,c.type,c.offset,t)}}else if(i instanceof It){let a=0;if(e.args)for(let c=0;c<e.args.length;++c){let l=e.args[c],u=this.evalExpression(l,t);i.format===null&&(((n=u.typeInfo)===null||n===void 0?void 0:n.name)==="x32"?i.format=this.getTypeInfo("i32"):i.format=u.typeInfo),o.setData(this,u,i.format,a,t),a+=i.stride}}else console.error(`Unknown type "${s}". Line ${e.line}`);return e instanceof Ge?o.getSubData(this,e.postfix,t):o}_evalLiteral(e,t){let n=this.getTypeInfo(e.type),s=n.name;return s==="x32"||s==="u32"||s==="f32"||s==="f16"||s==="i32"||s==="bool"?new T(e.scalarValue,n):s==="vec2"||s==="vec3"||s==="vec4"||s==="vec2f"||s==="vec3f"||s==="vec4f"||s==="vec2h"||s==="vec3h"||s==="vec4h"||s==="vec2i"||s==="vec3i"||s==="vec4i"||s==="vec2u"||s==="vec3u"||s==="vec4u"?this._callConstructorVec(e,t):s==="mat2x2"||s==="mat2x3"||s==="mat2x4"||s==="mat3x2"||s==="mat3x3"||s==="mat3x4"||s==="mat4x2"||s==="mat4x3"||s==="mat4x4"||s==="mat2x2f"||s==="mat2x3f"||s==="mat2x4f"||s==="mat3x2f"||s==="mat3x3f"||s==="mat3x4f"||s==="mat4x2f"||s==="mat4x3f"||s==="mat4x4f"||s==="mat2x2h"||s==="mat2x3h"||s==="mat2x4h"||s==="mat3x2h"||s==="mat3x3h"||s==="mat3x4h"||s==="mat4x2h"||s==="mat4x3h"||s==="mat4x4h"?this._callConstructorMatrix(e,t):e.value}_evalVariable(e,t){let n=t.getVariableValue(e.name);return n===null?n:n.getSubData(this,e.postfix,t)}_maxFormatTypeInfo(e){let t=e[0];if(t.name==="f32")return t;for(let n=1;n<e.length;++n){let s=we._priority.get(t.name);we._priority.get(e[n].name)<s&&(t=e[n])}return t.name==="x32"?this.getTypeInfo("i32"):t}_evalUnaryOp(e,t){let n=this.evalExpression(e.right,t);if(e.operator==="&")return new xr(n);if(e.operator==="*")return n instanceof xr?n.reference.getSubData(this,e.postfix,t):(console.error(`Invalid dereference. Line ${e.line}`),null);let s=n instanceof T?n.value:n instanceof g?Array.from(n.data):null;switch(e.operator){case"+":{if(D(s)){let a=s.map((c,l)=>+c);return new g(a,n.typeInfo)}let i=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new T(+i,o)}case"-":{if(D(s)){let a=s.map((c,l)=>-c);return new g(a,n.typeInfo)}let i=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new T(-i,o)}case"!":{if(D(s)){let a=s.map((c,l)=>c?0:1);return new g(a,n.typeInfo)}let i=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new T(i?0:1,o)}case"~":{if(D(s)){let a=s.map((c,l)=>~c);return new g(a,n.typeInfo)}let i=s,o=this._maxFormatTypeInfo([n.typeInfo,n.typeInfo]);return new T(~i,o)}}return console.error(`Invalid unary operator ${e.operator}. Line ${e.line}`),null}_evalBinaryOp(e,t){let n=this.evalExpression(e.left,t),s=this.evalExpression(e.right,t),i=n instanceof T?n.value:n instanceof g||n instanceof z?Array.from(n.data):null,o=s instanceof T?s.value:s instanceof g||s instanceof z?Array.from(s.data):null;switch(e.operator){case"+":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d+f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h+u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u+h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a+c,l)}case"-":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d-f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h-u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u-h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a-c,l)}case"*":{if(D(i)&&D(o)){let u=i,f=o;if(n instanceof z&&s instanceof z){let h=function(_,x,E,b){if(Ce[x.name]===void 0||Ce[b.name]===void 0)return null;let S=Ce[x.name][0],C=Ce[x.name][1],P=Ce[b.name][0];if(S!==Ce[b.name][1])return null;let B=new Array(P*C);for(let N=0;N<C;N++)for(let k=0;k<P;k++){let F=0;for(let U=0;U<S;U++)F+=_[U*C+N]*E[k*S+U];B[N*P+k]=F}return B}(u,n.typeInfo,f,s.typeInfo);if(h===null)return console.error(`Matrix multiplication failed. Line ${e.line}.`),null;let d=Ce[s.typeInfo.name][0],m=Ce[n.typeInfo.name][1],y=this.getTypeInfo(`mat${d}x${m}f`);return new z(h,y)}if(n instanceof z&&s instanceof g){let h=function(d,m,y,_){if(Ce[m.name]===void 0||Lu[_.name]===void 0)return null;let x=Ce[m.name][0],E=Ce[m.name][1];if(x!==y.length)return null;let b=new Array(E);for(let S=0;S<E;S++){let C=0;for(let P=0;P<x;P++)C+=d[P*E+S]*y[P];b[S]=C}return b}(u,n.typeInfo,f,s.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new g(h,s.typeInfo)}if(n instanceof g&&s instanceof z){let h=function(d,m,y,_){if(Lu[m.name]===void 0||Ce[_.name]===void 0)return null;let x=Ce[_.name][0],E=Ce[_.name][1];if(E!==d.length)return null;let b=[];for(let S=0;S<x;S++){let C=0;for(let P=0;P<E;P++)C+=d[P]*y[P*x+S];b[S]=C}return b}(u,n.typeInfo,f,s.typeInfo);return h===null?(console.error(`Matrix vector multiplication failed. Line ${e.line}.`),null):new g(h,n.typeInfo)}{if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d*f[m]);return new g(h,n.typeInfo)}}if(D(i)){let u=o,f=i.map((h,d)=>h*u);return n instanceof z?new z(f,n.typeInfo):new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u*h);return s instanceof z?new z(f,s.typeInfo):new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a*c,l)}case"%":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d%f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h%u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u%h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a%c,l)}case"/":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d/f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h/u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u/h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a/c,l)}case"&":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d&f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h&u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u&h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a&c,l)}case"|":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d|f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h|u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u|h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a|c,l)}case"^":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d^f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h^u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u^h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a^c,l)}case"<<":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d<<f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h<<u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u<<h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a<<c,l)}case">>":{if(D(i)&&D(o)){let u=i,f=o;if(u.length!==f.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let h=u.map((d,m)=>d>>f[m]);return new g(h,n.typeInfo)}if(D(i)){let u=o,f=i.map((h,d)=>h>>u);return new g(f,n.typeInfo)}if(D(o)){let u=i,f=o.map((h,d)=>u>>h);return new g(f,s.typeInfo)}let a=i,c=o,l=this._maxFormatTypeInfo([n.typeInfo,s.typeInfo]);return new T(a>>c,l)}case">":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u>c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l>a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a>l?1:0);return new g(c,s.typeInfo)}return new T(i>o?1:0,this.getTypeInfo("bool"));case"<":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u<c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l<a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a<l?1:0);return new g(c,s.typeInfo)}return new T(i<o?1:0,this.getTypeInfo("bool"));case"==":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u===c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l==a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a==l?1:0);return new g(c,s.typeInfo)}return new T(i===o?1:0,this.getTypeInfo("bool"));case"!=":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u!==c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l!==a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a!==l?1:0);return new g(c,s.typeInfo)}return new T(i!==o?1:0,this.getTypeInfo("bool"));case">=":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u>=c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l>=a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a>=l?1:0);return new g(c,s.typeInfo)}return new T(i>=o?1:0,this.getTypeInfo("bool"));case"<=":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u<=c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l<=a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a<=l?1:0);return new g(c,s.typeInfo)}return new T(i<=o?1:0,this.getTypeInfo("bool"));case"&&":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u&&c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l&&a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a&&l?1:0);return new g(c,s.typeInfo)}return new T(i&&o?1:0,this.getTypeInfo("bool"));case"||":if(D(i)&&D(o)){let a=i,c=o;if(a.length!==c.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;let l=a.map((u,f)=>u||c[f]?1:0);return new g(l,n.typeInfo)}if(D(i)){let a=o,c=i.map((l,u)=>l||a?1:0);return new g(c,n.typeInfo)}if(D(o)){let a=i,c=o.map((l,u)=>a||l?1:0);return new g(c,s.typeInfo)}return new T(i||o?1:0,this.getTypeInfo("bool"))}return console.error(`Unknown operator ${e.operator}. Line ${e.line}`),null}_evalCall(e,t){if(e.cachedReturnValue!==null)return e.cachedReturnValue;let n=t.clone();n.currentFunctionName=e.name;let s=t.getFunction(e.name);if(!s)return e.isBuiltin?this._callBuiltinFunction(e,n):this.getTypeInfo(e.name)?this._evalCreate(e,t):(console.error(`Unknown function "${e.name}". Line ${e.line}`),null);for(let i=0;i<s.node.args.length;++i){let o=s.node.args[i],a=this.evalExpression(e.args[i],n);n.createVariable(o.name,a,o)}return this._execStatements(s.node.body,n)}_callBuiltinFunction(e,t){switch(e.name){case"all":return this.builtins.All(e,t);case"any":return this.builtins.Any(e,t);case"select":return this.builtins.Select(e,t);case"arrayLength":return this.builtins.ArrayLength(e,t);case"abs":return this.builtins.Abs(e,t);case"acos":return this.builtins.Acos(e,t);case"acosh":return this.builtins.Acosh(e,t);case"asin":return this.builtins.Asin(e,t);case"asinh":return this.builtins.Asinh(e,t);case"atan":return this.builtins.Atan(e,t);case"atanh":return this.builtins.Atanh(e,t);case"atan2":return this.builtins.Atan2(e,t);case"ceil":return this.builtins.Ceil(e,t);case"clamp":return this.builtins.Clamp(e,t);case"cos":return this.builtins.Cos(e,t);case"cosh":return this.builtins.Cosh(e,t);case"countLeadingZeros":return this.builtins.CountLeadingZeros(e,t);case"countOneBits":return this.builtins.CountOneBits(e,t);case"countTrailingZeros":return this.builtins.CountTrailingZeros(e,t);case"cross":return this.builtins.Cross(e,t);case"degrees":return this.builtins.Degrees(e,t);case"determinant":return this.builtins.Determinant(e,t);case"distance":return this.builtins.Distance(e,t);case"dot":return this.builtins.Dot(e,t);case"dot4U8Packed":return this.builtins.Dot4U8Packed(e,t);case"dot4I8Packed":return this.builtins.Dot4I8Packed(e,t);case"exp":return this.builtins.Exp(e,t);case"exp2":return this.builtins.Exp2(e,t);case"extractBits":return this.builtins.ExtractBits(e,t);case"faceForward":return this.builtins.FaceForward(e,t);case"firstLeadingBit":return this.builtins.FirstLeadingBit(e,t);case"firstTrailingBit":return this.builtins.FirstTrailingBit(e,t);case"floor":return this.builtins.Floor(e,t);case"fma":return this.builtins.Fma(e,t);case"fract":return this.builtins.Fract(e,t);case"frexp":return this.builtins.Frexp(e,t);case"insertBits":return this.builtins.InsertBits(e,t);case"inverseSqrt":return this.builtins.InverseSqrt(e,t);case"ldexp":return this.builtins.Ldexp(e,t);case"length":return this.builtins.Length(e,t);case"log":return this.builtins.Log(e,t);case"log2":return this.builtins.Log2(e,t);case"max":return this.builtins.Max(e,t);case"min":return this.builtins.Min(e,t);case"mix":return this.builtins.Mix(e,t);case"modf":return this.builtins.Modf(e,t);case"normalize":return this.builtins.Normalize(e,t);case"pow":return this.builtins.Pow(e,t);case"quantizeToF16":return this.builtins.QuantizeToF16(e,t);case"radians":return this.builtins.Radians(e,t);case"reflect":return this.builtins.Reflect(e,t);case"refract":return this.builtins.Refract(e,t);case"reverseBits":return this.builtins.ReverseBits(e,t);case"round":return this.builtins.Round(e,t);case"saturate":return this.builtins.Saturate(e,t);case"sign":return this.builtins.Sign(e,t);case"sin":return this.builtins.Sin(e,t);case"sinh":return this.builtins.Sinh(e,t);case"smoothStep":return this.builtins.SmoothStep(e,t);case"sqrt":return this.builtins.Sqrt(e,t);case"step":return this.builtins.Step(e,t);case"tan":return this.builtins.Tan(e,t);case"tanh":return this.builtins.Tanh(e,t);case"transpose":return this.builtins.Transpose(e,t);case"trunc":return this.builtins.Trunc(e,t);case"dpdx":return this.builtins.Dpdx(e,t);case"dpdxCoarse":return this.builtins.DpdxCoarse(e,t);case"dpdxFine":return this.builtins.DpdxFine(e,t);case"dpdy":return this.builtins.Dpdy(e,t);case"dpdyCoarse":return this.builtins.DpdyCoarse(e,t);case"dpdyFine":return this.builtins.DpdyFine(e,t);case"fwidth":return this.builtins.Fwidth(e,t);case"fwidthCoarse":return this.builtins.FwidthCoarse(e,t);case"fwidthFine":return this.builtins.FwidthFine(e,t);case"textureDimensions":return this.builtins.TextureDimensions(e,t);case"textureGather":return this.builtins.TextureGather(e,t);case"textureGatherCompare":return this.builtins.TextureGatherCompare(e,t);case"textureLoad":return this.builtins.TextureLoad(e,t);case"textureNumLayers":return this.builtins.TextureNumLayers(e,t);case"textureNumLevels":return this.builtins.TextureNumLevels(e,t);case"textureNumSamples":return this.builtins.TextureNumSamples(e,t);case"textureSample":return this.builtins.TextureSample(e,t);case"textureSampleBias":return this.builtins.TextureSampleBias(e,t);case"textureSampleCompare":return this.builtins.TextureSampleCompare(e,t);case"textureSampleCompareLevel":return this.builtins.TextureSampleCompareLevel(e,t);case"textureSampleGrad":return this.builtins.TextureSampleGrad(e,t);case"textureSampleLevel":return this.builtins.TextureSampleLevel(e,t);case"textureSampleBaseClampToEdge":return this.builtins.TextureSampleBaseClampToEdge(e,t);case"textureStore":return this.builtins.TextureStore(e,t);case"atomicLoad":return this.builtins.AtomicLoad(e,t);case"atomicStore":return this.builtins.AtomicStore(e,t);case"atomicAdd":return this.builtins.AtomicAdd(e,t);case"atomicSub":return this.builtins.AtomicSub(e,t);case"atomicMax":return this.builtins.AtomicMax(e,t);case"atomicMin":return this.builtins.AtomicMin(e,t);case"atomicAnd":return this.builtins.AtomicAnd(e,t);case"atomicOr":return this.builtins.AtomicOr(e,t);case"atomicXor":return this.builtins.AtomicXor(e,t);case"atomicExchange":return this.builtins.AtomicExchange(e,t);case"atomicCompareExchangeWeak":return this.builtins.AtomicCompareExchangeWeak(e,t);case"pack4x8snorm":return this.builtins.Pack4x8snorm(e,t);case"pack4x8unorm":return this.builtins.Pack4x8unorm(e,t);case"pack4xI8":return this.builtins.Pack4xI8(e,t);case"pack4xU8":return this.builtins.Pack4xU8(e,t);case"pack4x8Clamp":return this.builtins.Pack4x8Clamp(e,t);case"pack4xU8Clamp":return this.builtins.Pack4xU8Clamp(e,t);case"pack2x16snorm":return this.builtins.Pack2x16snorm(e,t);case"pack2x16unorm":return this.builtins.Pack2x16unorm(e,t);case"pack2x16float":return this.builtins.Pack2x16float(e,t);case"unpack4x8snorm":return this.builtins.Unpack4x8snorm(e,t);case"unpack4x8unorm":return this.builtins.Unpack4x8unorm(e,t);case"unpack4xI8":return this.builtins.Unpack4xI8(e,t);case"unpack4xU8":return this.builtins.Unpack4xU8(e,t);case"unpack2x16snorm":return this.builtins.Unpack2x16snorm(e,t);case"unpack2x16unorm":return this.builtins.Unpack2x16unorm(e,t);case"unpack2x16float":return this.builtins.Unpack2x16float(e,t);case"storageBarrier":return this.builtins.StorageBarrier(e,t);case"textureBarrier":return this.builtins.TextureBarrier(e,t);case"workgroupBarrier":return this.builtins.WorkgroupBarrier(e,t);case"workgroupUniformLoad":return this.builtins.WorkgroupUniformLoad(e,t);case"subgroupAdd":return this.builtins.SubgroupAdd(e,t);case"subgroupExclusiveAdd":return this.builtins.SubgroupExclusiveAdd(e,t);case"subgroupInclusiveAdd":return this.builtins.SubgroupInclusiveAdd(e,t);case"subgroupAll":return this.builtins.SubgroupAll(e,t);case"subgroupAnd":return this.builtins.SubgroupAnd(e,t);case"subgroupAny":return this.builtins.SubgroupAny(e,t);case"subgroupBallot":return this.builtins.SubgroupBallot(e,t);case"subgroupBroadcast":return this.builtins.SubgroupBroadcast(e,t);case"subgroupBroadcastFirst":return this.builtins.SubgroupBroadcastFirst(e,t);case"subgroupElect":return this.builtins.SubgroupElect(e,t);case"subgroupMax":return this.builtins.SubgroupMax(e,t);case"subgroupMin":return this.builtins.SubgroupMin(e,t);case"subgroupMul":return this.builtins.SubgroupMul(e,t);case"subgroupExclusiveMul":return this.builtins.SubgroupExclusiveMul(e,t);case"subgroupInclusiveMul":return this.builtins.SubgroupInclusiveMul(e,t);case"subgroupOr":return this.builtins.SubgroupOr(e,t);case"subgroupShuffle":return this.builtins.SubgroupShuffle(e,t);case"subgroupShuffleDown":return this.builtins.SubgroupShuffleDown(e,t);case"subgroupShuffleUp":return this.builtins.SubgroupShuffleUp(e,t);case"subgroupShuffleXor":return this.builtins.SubgroupShuffleXor(e,t);case"subgroupXor":return this.builtins.SubgroupXor(e,t);case"quadBroadcast":return this.builtins.QuadBroadcast(e,t);case"quadSwapDiagonal":return this.builtins.QuadSwapDiagonal(e,t);case"quadSwapX":return this.builtins.QuadSwapX(e,t);case"quadSwapY":return this.builtins.QuadSwapY(e,t)}let n=t.getFunction(e.name);if(n){let s=t.clone();for(let i=0;i<n.node.args.length;++i){let o=n.node.args[i],a=this.evalExpression(e.args[i],s);s.setVariable(o.name,a,o)}return this._execStatements(n.node.body,s)}return null}_callConstructorValue(e,t){if(!e.args||e.args.length===0)return new T(0,this.getTypeInfo(e.type));let n=this.evalExpression(e.args[0],t);return n.typeInfo=this.getTypeInfo(e.type),n.getSubData(this,e.postfix,t).clone()}_callConstructorVec(e,t){let n=this.getTypeInfo(e.type),s=e.type.getTypeName(),i=Lu[s];if(i===void 0)return console.error(`Invalid vec constructor ${s}. Line ${e.line}`),null;let o=[];if(e instanceof me)if(e.isVector){let a=e.vectorValue;for(let c of a)o.push(c)}else o.push(e.scalarValue);else if(e.args)for(let a of e.args){let c=this.evalExpression(a,t);if(c instanceof g){let l=c.data;for(let u=0;u<l.length;++u){let f=l[u];o.push(f)}}else if(c instanceof T){let l=c.value;o.push(l)}}if(e.type instanceof A&&e.type.format===null&&(e.type.format=A.f32),o.length===0){let a=new Array(i).fill(0);return new g(a,n).getSubData(this,e.postfix,t)}if(o.length===1)for(;o.length<i;)o.push(o[0]);return o.length<i?(console.error(`Invalid vec constructor. Line ${e.line}`),null):new g(o.length>i?o.slice(0,i):o,n).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){let n=this.getTypeInfo(e.type),s=e.type.getTypeName(),i=Ce[s];if(i===void 0)return console.error(`Invalid matrix constructor ${s}. Line ${e.line}`),null;let o=[];if(e instanceof me)if(e.isVector){let a=e.vectorValue;for(let c of a)o.push(c)}else o.push(e.scalarValue);else if(e.args)for(let a of e.args){let c=this.evalExpression(a,t);c instanceof g?o.push(...c.data):c instanceof T?o.push(c.value):c instanceof z&&o.push(...c.data)}if(n instanceof Kt&&n.format===null&&(n.format=this.getTypeInfo("f32")),o.length===0){let a=new Array(i[2]).fill(0);return new z(a,n).getSubData(this,e.postfix,t)}return o.length!==i[2]?(console.error(`Invalid matrix constructor. Line ${e.line}`),null):new z(o,n).getSubData(this,e.postfix,t)}};we._breakObj=new Ue(new Be("BREAK",null),null),we._continueObj=new Ue(new Be("CONTINUE",null),null),we._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);var ef=class{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}},tf=class{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new ef,this._exec=new we,this._forwardTypeCount=0}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;let t=[];for(;!this._isAtEnd();){let n=this._global_decl_or_directive();if(!n)break;t.push(n)}if(this._deferArrayCountEval.length>0){for(let n of this._deferArrayCountEval){let s=n.arrayType,i=n.countNode;if(i instanceof Me){let o=i.name,a=this._context.constants.get(o);if(a)try{let c=a.constEvaluate(this._exec);s.count=c}catch{}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(let n of t)n.search(s=>{s instanceof Sa||s instanceof Xs?s.type=this._forwardType(s.type):s instanceof Jr?s.format=this._forwardType(s.format):s instanceof ut||s instanceof Qr||s instanceof Kn?s.type=this._forwardType(s.type):s instanceof en?s.returnType=this._forwardType(s.returnType):s instanceof Aa&&(s.type=this._forwardType(s.type))});return t}_forwardType(e){if(e instanceof _a){let t=this._getType(e.name);if(t)return t}else e instanceof Xs?e.type=this._forwardType(e.type):e instanceof Jr&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if(typeof e=="string"){let t=new Zu(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_updateNode(e,t){return e.line=t??this._currentLine,e}_error(e,t){return{token:e,message:t,toString:()=>`${t}`}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==p.eof}_match(e){if(e instanceof w)return!!this._check(e)&&(this._advance(),!0);for(let t=0,n=e.length;t<n;++t){let s=e[t];if(this._check(s))return this._advance(),!0}return!1}_consume(e,t){if(this._check(e))return this._advance();throw this._error(this._peek(),`${t}. Line:${this._currentLine}`)}_check(e){if(this._isAtEnd())return!1;let t=this._peek();if(e instanceof Array){let n=t.type,s=!1;for(let i of e){if(n===i)return!0;i===p.tokens.name&&(s=!0)}if(s){let i=p.tokens.name.rule.exec(t.lexeme);if(i&&i.index==0&&i[0]==t.lexeme)return!0}return!1}if(t.type===e)return!0;if(e===p.tokens.name){let n=p.tokens.name.rule.exec(t.lexeme);return n&&n.index==0&&n[0]==t.lexeme}return!1}_advance(){var e,t;return this._currentLine=(t=(e=this._peek())===null||e===void 0?void 0:e.line)!==null&&t!==void 0?t:-1,this._isAtEnd()||this._current++,this._previous()}_peek(){return this._tokens[this._current]}_previous(){return this._tokens[this._current-1]}_global_decl_or_directive(){for(;this._match(p.tokens.semicolon)&&!this._isAtEnd(););if(this._match(p.keywords.alias)){let t=this._type_alias();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.diagnostic)){let t=this._diagnostic();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.requires)){let t=this._requires_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}if(this._match(p.keywords.enable)){let t=this._enable_directive();return this._consume(p.tokens.semicolon,"Expected ';'"),this._exec.reflection.updateAST([t]),t}let e=this._attribute();if(this._check(p.keywords.var)){let t=this._global_variable_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.override)){let t=this._override_variable_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.let)){let t=this._global_let_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.const)){let t=this._global_const_decl();return t!=null&&(t.attributes=e),this._consume(p.tokens.semicolon,"Expected ';'."),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.struct)){let t=this._struct_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}if(this._check(p.keywords.fn)){let t=this._function_decl();return t!=null&&(t.attributes=e),this._exec.reflection.updateAST([t]),t}return null}_function_decl(){if(!this._match(p.keywords.fn))return null;let e=this._currentLine,t=this._consume(p.tokens.ident,"Expected function name.").toString();this._consume(p.tokens.paren_left,"Expected '(' for function arguments.");let n=[];if(!this._check(p.tokens.paren_right))do{if(this._check(p.tokens.paren_right))break;let a=this._attribute(),c=this._consume(p.tokens.name,"Expected argument name.").toString();this._consume(p.tokens.colon,"Expected ':' for argument type.");let l=this._attribute(),u=this._type_decl();u!=null&&(u.attributes=l,n.push(this._updateNode(new Aa(c,u,a))))}while(this._match(p.tokens.comma));this._consume(p.tokens.paren_right,"Expected ')' after function arguments.");let s=null;if(this._match(p.tokens.arrow)){let a=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=a)}let i=this._compound_statement(),o=this._currentLine;return this._updateNode(new en(t,n,s,i,e,o),e)}_compound_statement(){let e=[];for(this._consume(p.tokens.brace_left,"Expected '{' for block.");!this._check(p.tokens.brace_right);){let t=this._statement();t!==null&&e.push(t)}return this._consume(p.tokens.brace_right,"Expected '}' for block."),e}_statement(){for(;this._match(p.tokens.semicolon)&&!this._isAtEnd(););if(this._check(p.tokens.attr)&&this._attribute(),this._check(p.keywords.if))return this._if_statement();if(this._check(p.keywords.switch))return this._switch_statement();if(this._check(p.keywords.loop))return this._loop_statement();if(this._check(p.keywords.for))return this._for_statement();if(this._check(p.keywords.while))return this._while_statement();if(this._check(p.keywords.continuing))return this._continuing_statement();if(this._check(p.keywords.static_assert))return this._static_assert_statement();if(this._check(p.tokens.brace_left))return this._compound_statement();let e=null;if(this._check(p.keywords.return))e=this._return_statement();else if(this._check([p.keywords.var,p.keywords.let,p.keywords.const]))e=this._variable_statement();else if(this._match(p.keywords.discard))e=this._updateNode(new qu);else if(this._match(p.keywords.break)){let t=this._updateNode(new ma);if(this._currentLoop.length>0){let n=this._currentLoop[this._currentLoop.length-1];t.loopId=n.id}e=t,this._check(p.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match(p.keywords.continue)){let t=this._updateNode(new ga);if(!(this._currentLoop.length>0))throw this._error(this._peek(),`Continue statement must be inside a loop. Line: ${t.line}`);{let n=this._currentLoop[this._currentLoop.length-1];t.loopId=n.id}e=t}else e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement();return e!=null&&this._consume(p.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match(p.keywords.static_assert))return null;let e=this._currentLine,t=this._optional_paren_expression();return this._updateNode(new Hu(t),e)}_while_statement(){if(!this._match(p.keywords.while))return null;let e=this._updateNode(new oa(null,null));return this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(p.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_continuing_statement(){let e=this._currentLoop.length>0?this._currentLoop[this._currentLoop.length-1].id:-1;if(!this._match(p.keywords.continuing))return null;let t=this._currentLine,n=this._compound_statement();return this._updateNode(new Ys(n,e),t)}_for_statement(){if(!this._match(p.keywords.for))return null;this._consume(p.tokens.paren_left,"Expected '('.");let e=this._updateNode(new aa(null,null,null,null));return this._currentLoop.push(e),e.init=this._check(p.tokens.semicolon)?null:this._for_init(),this._consume(p.tokens.semicolon,"Expected ';'."),e.condition=this._check(p.tokens.semicolon)?null:this._short_circuit_or_expression(),this._consume(p.tokens.semicolon,"Expected ';'."),e.increment=this._check(p.tokens.paren_right)?null:this._for_increment(),this._consume(p.tokens.paren_right,"Expected ')'."),this._check(p.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(p.keywords.var)){let e=this._variable_decl();if(e===null)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match(p.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new ut(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match(p.keywords.let)){let e=this._currentLine,t=this._consume(p.tokens.name,"Expected name for let.").toString(),n=null;if(this._match(p.tokens.colon)){let i=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=i)}this._consume(p.tokens.equal,"Expected '=' for let.");let s=this._short_circuit_or_expression();return this._updateNode(new Qr(t,n,null,null,s),e)}if(this._match(p.keywords.const)){let e=this._currentLine,t=this._consume(p.tokens.name,"Expected name for const.").toString(),n=null;if(this._match(p.tokens.colon)){let i=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=i)}this._consume(p.tokens.equal,"Expected '=' for const.");let s=this._short_circuit_or_expression();return n===null&&s instanceof me&&(n=s.type),this._updateNode(new Kn(t,n,null,null,s),e)}return null}_increment_decrement_statement(){let e=this._current,t=this._unary_expression();if(t==null)return null;if(!this._check(p.increment_operators))return this._current=e,null;let n=this._consume(p.increment_operators,"Expected increment operator");return this._updateNode(new ca(n.type===p.tokens.plus_plus?Yn.increment:Yn.decrement,t))}_assignment_statement(){let e=null,t=this._currentLine;if(this._check(p.tokens.brace_right))return null;let n=this._match(p.tokens.underscore);if(n||(e=this._unary_expression()),!n&&e==null)return null;let s=this._consume(p.assignment_operators,"Expected assignment operator."),i=this._short_circuit_or_expression();return this._updateNode(new la(Hs.parse(s.lexeme),e,i),t)}_func_call_statement(){if(!this._check(p.tokens.ident))return null;let e=this._currentLine,t=this._current,n=this._consume(p.tokens.ident,"Expected function name."),s=this._argument_expression_list();return s===null?(this._current=t,null):this._updateNode(new Ks(n.lexeme,s),e)}_loop_statement(){if(!this._match(p.keywords.loop))return null;this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Expected '{' for loop.");let e=this._updateNode(new ua([],null));this._currentLoop.push(e);let t=this._statement();for(;t!==null;){if(Array.isArray(t))for(let n of t)e.body.push(n);else e.body.push(t);if(t instanceof Ys){e.continuing=t;break}t=this._statement()}return this._currentLoop.pop(),this._consume(p.tokens.brace_right,"Expected '}' for loop."),e}_switch_statement(){if(!this._match(p.keywords.switch))return null;let e=this._updateNode(new fa(null,[]));if(this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Expected '{' for switch."),e.cases=this._switch_body(),e.cases==null||e.cases.length==0)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(p.tokens.brace_right,"Expected '}' for switch."),this._currentLoop.pop(),e}_switch_body(){let e=[],t=!1;for(;this._check([p.keywords.default,p.keywords.case]);){if(this._match(p.keywords.case)){let n=this._case_selectors();for(let i of n)if(i instanceof Zn){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!0;break}this._match(p.tokens.colon),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Exected '{' for switch case.");let s=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new wa(n,s)))}if(this._match(p.keywords.default)){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");this._match(p.tokens.colon),this._check(p.tokens.attr)&&this._attribute(),this._consume(p.tokens.brace_left,"Exected '{' for switch default.");let n=this._case_body();this._consume(p.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new va(n)))}}return e}_case_selectors(){let e=[];for(this._match(p.keywords.default)?e.push(this._updateNode(new Zn)):e.push(this._shift_expression());this._match(p.tokens.comma);)this._match(p.keywords.default)?e.push(this._updateNode(new Zn)):e.push(this._shift_expression());return e}_case_body(){if(this._match(p.keywords.fallthrough))return this._consume(p.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(e==null)return[];e instanceof Array||(e=[e]);let t=this._case_body();return t.length==0?e:[...e,t[0]]}_if_statement(){if(!this._match(p.keywords.if))return null;let e=this._currentLine,t=this._optional_paren_expression();this._check(p.tokens.attr)&&this._attribute();let n=this._compound_statement(),s=[];this._match_elseif()&&(this._check(p.tokens.attr)&&this._attribute(),s=this._elseif_statement(s));let i=null;return this._match(p.keywords.else)&&(this._check(p.tokens.attr)&&this._attribute(),i=this._compound_statement()),this._updateNode(new ha(t,n,s,i),e)}_match_elseif(){return this._tokens[this._current].type===p.keywords.else&&this._tokens[this._current+1].type===p.keywords.if&&(this._advance(),this._advance(),!0)}_elseif_statement(e=[]){let t=this._optional_paren_expression(),n=this._compound_statement();return e.push(this._updateNode(new Ku(t,n))),this._match_elseif()&&(this._check(p.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match(p.keywords.return))return null;let e=this._short_circuit_or_expression();return this._updateNode(new da(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(p.tokens.or_or);)e=this._updateNode(new je(this._previous().toString(),e,this._short_circuit_and_expr()));return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(p.tokens.and_and);)e=this._updateNode(new je(this._previous().toString(),e,this._inclusive_or_expression()));return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(p.tokens.or);)e=this._updateNode(new je(this._previous().toString(),e,this._exclusive_or_expression()));return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(p.tokens.xor);)e=this._updateNode(new je(this._previous().toString(),e,this._and_expression()));return e}_and_expression(){let e=this._equality_expression();for(;this._match(p.tokens.and);)e=this._updateNode(new je(this._previous().toString(),e,this._equality_expression()));return e}_equality_expression(){let e=this._relational_expression();return this._match([p.tokens.equal_equal,p.tokens.not_equal])?this._updateNode(new je(this._previous().toString(),e,this._relational_expression())):e}_relational_expression(){let e=this._shift_expression();for(;this._match([p.tokens.less_than,p.tokens.greater_than,p.tokens.less_than_equal,p.tokens.greater_than_equal]);)e=this._updateNode(new je(this._previous().toString(),e,this._shift_expression()));return e}_shift_expression(){let e=this._additive_expression();for(;this._match([p.tokens.shift_left,p.tokens.shift_right]);)e=this._updateNode(new je(this._previous().toString(),e,this._additive_expression()));return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([p.tokens.plus,p.tokens.minus]);)e=this._updateNode(new je(this._previous().toString(),e,this._multiplicative_expression()));return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([p.tokens.star,p.tokens.forward_slash,p.tokens.modulo]);)e=this._updateNode(new je(this._previous().toString(),e,this._unary_expression()));return e}_unary_expression(){return this._match([p.tokens.minus,p.tokens.bang,p.tokens.tilde,p.tokens.star,p.tokens.and])?this._updateNode(new ue(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){let e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match(p.tokens.bracket_left)){let e=this._short_circuit_or_expression();this._consume(p.tokens.bracket_right,"Expected ']'.");let t=this._updateNode(new br(e)),n=this._postfix_expression();return n&&(t.postfix=n),t}if(this._match(p.tokens.period)){let e=this._consume(p.tokens.name,"Expected member name."),t=this._postfix_expression(),n=this._updateNode(new Zt(e.lexeme));return t&&(n.postfix=t),n}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_getType(e){let t=this._getStruct(e);if(t!==null)return t;switch(e){case"void":return M.void;case"bool":return M.bool;case"i32":return M.i32;case"u32":return M.u32;case"f32":return M.f32;case"f16":return M.f16;case"vec2f":return A.vec2f;case"vec3f":return A.vec3f;case"vec4f":return A.vec4f;case"vec2i":return A.vec2i;case"vec3i":return A.vec3i;case"vec4i":return A.vec4i;case"vec2u":return A.vec2u;case"vec3u":return A.vec3u;case"vec4u":return A.vec4u;case"vec2h":return A.vec2h;case"vec3h":return A.vec3h;case"vec4h":return A.vec4h;case"mat2x2f":return A.mat2x2f;case"mat2x3f":return A.mat2x3f;case"mat2x4f":return A.mat2x4f;case"mat3x2f":return A.mat3x2f;case"mat3x3f":return A.mat3x3f;case"mat3x4f":return A.mat3x4f;case"mat4x2f":return A.mat4x2f;case"mat4x3f":return A.mat4x3f;case"mat4x4f":return A.mat4x4f;case"mat2x2h":return A.mat2x2h;case"mat2x3h":return A.mat2x3h;case"mat2x4h":return A.mat2x4h;case"mat3x2h":return A.mat3x2h;case"mat3x3h":return A.mat3x3h;case"mat3x4h":return A.mat3x4h;case"mat4x2h":return A.mat4x2h;case"mat4x3h":return A.mat4x3h;case"mat4x4h":return A.mat4x4h;case"mat2x2i":return A.mat2x2i;case"mat2x3i":return A.mat2x3i;case"mat2x4i":return A.mat2x4i;case"mat3x2i":return A.mat3x2i;case"mat3x3i":return A.mat3x3i;case"mat3x4i":return A.mat3x4i;case"mat4x2i":return A.mat4x2i;case"mat4x3i":return A.mat4x3i;case"mat4x4i":return A.mat4x4i;case"mat2x2u":return A.mat2x2u;case"mat2x3u":return A.mat2x3u;case"mat2x4u":return A.mat2x4u;case"mat3x2u":return A.mat3x2u;case"mat3x3u":return A.mat3x3u;case"mat3x4u":return A.mat3x4u;case"mat4x2u":return A.mat4x2u;case"mat4x3u":return A.mat4x3u;case"mat4x4u":return A.mat4x4u}return null}_validateTypeRange(e,t){if(t.name==="i32"){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}. Line: ${this._currentLine}.`)}else if(t.name==="u32"&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}. Line: ${this._currentLine}.`)}_primary_expression(){if(this._match(p.tokens.ident)){let n=this._previous().toString();if(this._check(p.tokens.paren_left)){let s=this._argument_expression_list(),i=this._getType(n);return i!==null?this._updateNode(new Ge(i,s)):this._updateNode(new Gs(n,s))}if(this._context.constants.has(n)){let s=this._context.constants.get(n);return this._updateNode(new ya(n,s.value))}return this._updateNode(new Me(n))}if(this._match(p.tokens.int_literal)){let n=this._previous().toString(),s=n.endsWith("i")||n.endsWith("i")?M.i32:n.endsWith("u")||n.endsWith("U")?M.u32:M.x32,i=parseInt(n);return this._validateTypeRange(i,s),this._updateNode(new me(new T(i,this._exec.getTypeInfo(s)),s))}if(this._match(p.tokens.uint_literal)){let n=parseInt(this._previous().toString());return this._validateTypeRange(n,M.u32),this._updateNode(new me(new T(n,this._exec.getTypeInfo(M.u32)),M.u32))}if(this._match([p.tokens.decimal_float_literal,p.tokens.hex_float_literal])){let n=this._previous().toString(),s=n.endsWith("h");s&&(n=n.substring(0,n.length-1));let i=parseFloat(n);this._validateTypeRange(i,s?M.f16:M.f32);let o=s?M.f16:M.f32;return this._updateNode(new me(new T(i,this._exec.getTypeInfo(o)),o))}if(this._match([p.keywords.true,p.keywords.false])){let n=this._previous().toString()===p.keywords.true.rule;return this._updateNode(new me(new T(n?1:0,this._exec.getTypeInfo(M.bool)),M.bool))}if(this._check(p.tokens.paren_left))return this._paren_expression();if(this._match(p.keywords.bitcast)){this._consume(p.tokens.less_than,"Expected '<'.");let n=this._type_decl();this._consume(p.tokens.greater_than,"Expected '>'.");let s=this._paren_expression();return this._updateNode(new xa(n,s))}let e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new Ge(e,t))}_argument_expression_list(){if(!this._match(p.tokens.paren_left))return null;let e=[];do{if(this._check(p.tokens.paren_right))break;let t=this._short_circuit_or_expression();e.push(t)}while(this._match(p.tokens.comma));return this._consume(p.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(p.tokens.paren_left);let e=this._short_circuit_or_expression();return this._match(p.tokens.paren_right),e}_paren_expression(){this._consume(p.tokens.paren_left,"Expected '('.");let e=this._short_circuit_or_expression();return this._consume(p.tokens.paren_right,"Expected ')'."),e}_struct_decl(){if(!this._match(p.keywords.struct))return null;let e=this._currentLine,t=this._consume(p.tokens.ident,"Expected name for struct.").toString();this._consume(p.tokens.brace_left,"Expected '{' for struct body.");let n=[];for(;!this._check(p.tokens.brace_right);){let o=this._attribute(),a=this._consume(p.tokens.name,"Expected variable name.").toString();this._consume(p.tokens.colon,"Expected ':' for struct member type.");let c=this._attribute(),l=this._type_decl();l!=null&&(l.attributes=c),this._check(p.tokens.brace_right)?this._match(p.tokens.comma):this._consume(p.tokens.comma,"Expected ',' for struct member."),n.push(this._updateNode(new Sa(a,l,o)))}this._consume(p.tokens.brace_right,"Expected '}' after struct body.");let s=this._currentLine,i=this._updateNode(new ct(t,n,e,s),e);return this._context.structs.set(t,i),i}_global_variable_decl(){let e=this._variable_decl();if(!e)return null;if(this._match(p.tokens.equal)){let t=this._const_expression();e.value=t}if(e.type!==null&&e.value instanceof me){if(e.value.type.name!=="x32"&&e.type.getTypeName()!==e.value.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${e.value.type.name} to ${e.type.name}. Line:${this._currentLine}`);e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else e.type===null&&e.value instanceof me&&(e.type=e.value.type.name==="x32"?M.i32:e.value.type,e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type));return e}_override_variable_decl(){let e=this._override_decl();return e&&this._match(p.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){var e;if(!this._match(p.keywords.const))return null;let t=this._consume(p.tokens.name,"Expected variable name"),n=this._currentLine,s=null;if(this._match(p.tokens.colon)){let c=this._attribute();s=this._type_decl(),s!=null&&(s.attributes=c)}let i=null;this._consume(p.tokens.equal,"const declarations require an assignment");let o=this._short_circuit_or_expression();try{let c=[M.f32],l=o.constEvaluate(this._exec,c);l instanceof T&&this._validateTypeRange(l.value,c[0]),c[0]instanceof A&&c[0].format===null&&l.typeInfo instanceof Kt&&l.typeInfo.format!==null&&(l.typeInfo.format.name==="f16"?c[0].format=M.f16:l.typeInfo.format.name==="f32"?c[0].format=M.f32:l.typeInfo.format.name==="i32"?c[0].format=M.i32:l.typeInfo.format.name==="u32"?c[0].format=M.u32:l.typeInfo.format.name==="bool"?c[0].format=M.bool:console.error(`TODO: impelement template format type ${l.typeInfo.format.name}`)),i=this._updateNode(new me(l,c[0])),this._exec.context.setVariable(t.toString(),l)}catch{i=o}if(s!==null&&i instanceof me){if(i.type.name!=="x32"&&s.getTypeName()!==i.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${i.type.name} to ${s.name}. Line:${this._currentLine}`);i.type=s,i.isScalar&&this._validateTypeRange(i.scalarValue,i.type)}else s===null&&i instanceof me&&(s=(e=i?.type)!==null&&e!==void 0?e:M.f32,s===M.x32&&(s=M.i32));let a=this._updateNode(new Kn(t.toString(),s,"","",i),n);return this._context.constants.set(a.name,a),a}_global_let_decl(){if(!this._match(p.keywords.let))return null;let e=this._currentLine,t=this._consume(p.tokens.name,"Expected variable name"),n=null;if(this._match(p.tokens.colon)){let i=this._attribute();n=this._type_decl(),n!=null&&(n.attributes=i)}let s=null;if(this._match(p.tokens.equal)&&(s=this._const_expression()),n!==null&&s instanceof me){if(s.type.name!=="x32"&&n.getTypeName()!==s.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${s.type.name} to ${n.name}. Line:${this._currentLine}`);s.type=n}else n===null&&s instanceof me&&(n=s.type.name==="x32"?M.i32:s.type);return s instanceof me&&s.isScalar&&this._validateTypeRange(s.scalarValue,n),this._updateNode(new Qr(t.toString(),n,"","",s),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match(p.keywords.var))return null;let e=this._currentLine,t="",n="";this._match(p.tokens.less_than)&&(t=this._consume(p.storage_class,"Expected storage_class.").toString(),this._match(p.tokens.comma)&&(n=this._consume(p.access_mode,"Expected access_mode.").toString()),this._consume(p.tokens.greater_than,"Expected '>'."));let s=this._consume(p.tokens.name,"Expected variable name"),i=null;if(this._match(p.tokens.colon)){let o=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=o)}return this._updateNode(new ut(s.toString(),i,t,n,null),e)}_override_decl(){if(!this._match(p.keywords.override))return null;let e=this._consume(p.tokens.name,"Expected variable name"),t=null;if(this._match(p.tokens.colon)){let n=this._attribute();t=this._type_decl(),t!=null&&(t.attributes=n)}return this._updateNode(new qs(e.toString(),t,null))}_diagnostic(){this._consume(p.tokens.paren_left,"Expected '('");let e=this._consume(p.tokens.ident,"Expected severity control name.");this._consume(p.tokens.comma,"Expected ','");let t=this._consume(p.tokens.ident,"Expected diagnostic rule name.").toString();return this._match(p.tokens.period)&&(t+=`.${this._consume(p.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume(p.tokens.paren_right,"Expected ')'"),this._updateNode(new pa(e.toString(),t))}_enable_directive(){let e=this._consume(p.tokens.ident,"identity expected.");return this._updateNode(new Xu(e.toString()))}_requires_directive(){let e=[this._consume(p.tokens.ident,"identity expected.").toString()];for(;this._match(p.tokens.comma);){let t=this._consume(p.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new Yu(e))}_type_alias(){let e=this._consume(p.tokens.ident,"identity expected.");this._consume(p.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(t===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);let n=this._updateNode(new Zs(e.toString(),t));return this._context.aliases.set(n.name,n),n}_type_decl(){if(this._check([p.tokens.ident,...p.texel_format,p.keywords.bool,p.keywords.f32,p.keywords.i32,p.keywords.u32])){let n=this._advance().toString();if(this._context.structs.has(n))return this._context.structs.get(n);if(this._context.aliases.has(n))return this._context.aliases.get(n).type;if(!this._getType(n)){let s=this._updateNode(new _a(n));return this._forwardTypeCount++,s}return this._updateNode(new M(n))}let e=this._texture_sampler_types();if(e)return e;if(this._check(p.template_types)){let n=this._advance().toString(),s=null,i=null;return this._match(p.tokens.less_than)&&(s=this._type_decl(),i=null,this._match(p.tokens.comma)&&(i=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new A(n,s,i))}if(this._match(p.keywords.ptr)){let n=this._previous().toString();this._consume(p.tokens.less_than,"Expected '<' for pointer.");let s=this._consume(p.storage_class,"Expected storage_class for pointer");this._consume(p.tokens.comma,"Expected ',' for pointer.");let i=this._type_decl(),o=null;return this._match(p.tokens.comma)&&(o=this._consume(p.access_mode,"Expected access_mode for pointer").toString()),this._consume(p.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new Xs(n,s.toString(),i,o))}let t=this._attribute();if(this._match(p.keywords.array)){let n=null,s=-1,i=this._previous(),o=null;if(this._match(p.tokens.less_than)){n=this._type_decl(),this._context.aliases.has(n.name)&&(n=this._context.aliases.get(n.name).type);let c="";if(this._match(p.tokens.comma)){o=this._shift_expression();try{c=o.constEvaluate(this._exec).toString(),o=null}catch{c="1"}}this._consume(p.tokens.greater_than,"Expected '>' for array."),s=c?parseInt(c):0}let a=this._updateNode(new Jr(i.toString(),t,n,s));return o&&this._deferArrayCountEval.push({arrayType:a,countNode:o}),a}return null}_texture_sampler_types(){if(this._match(p.sampler_type))return this._updateNode(new Gr(this._previous().toString(),null,null));if(this._match(p.depth_texture_type))return this._updateNode(new Gr(this._previous().toString(),null,null));if(this._match(p.sampled_texture_type)||this._match(p.multisampled_texture_type)){let e=this._previous();this._consume(p.tokens.less_than,"Expected '<' for sampler type.");let t=this._type_decl();return this._consume(p.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new Gr(e.toString(),t,null))}if(this._match(p.storage_texture_type)){let e=this._previous();this._consume(p.tokens.less_than,"Expected '<' for sampler type.");let t=this._consume(p.texel_format,"Invalid texel format.").toString();this._consume(p.tokens.comma,"Expected ',' after texel format.");let n=this._consume(p.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(p.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new Gr(e.toString(),t,n))}return null}_attribute(){let e=[];for(;this._match(p.tokens.attr);){let t=this._consume(p.attribute_name,"Expected attribute name"),n=this._updateNode(new Ea(t.toString(),null));if(this._match(p.tokens.paren_left)){if(n.value=this._consume(p.literal_or_ident,"Expected attribute value").toString(),this._check(p.tokens.comma)){this._advance();do{let s=this._consume(p.literal_or_ident,"Expected attribute value").toString();n.value instanceof Array||(n.value=[n.value]),n.value.push(s)}while(this._match(p.tokens.comma))}this._consume(p.tokens.paren_right,"Expected ')'")}e.push(n)}return e.length==0?null:e}},Ma=class extends Qe{constructor(e){super(),e&&this.update(e)}update(e){let t=new tf().parse(e);this.updateAST(t)}};function nf(r){let e={attributes:[],bindings:[]},t;try{t=V0(r)}catch(i){return I.error(i.message)(),e}for(let i of t.uniforms){let o=[];for(let a of i.type?.members||[])o.push({name:a.name,type:xm(a.type)});e.bindings.push({type:"uniform",name:i.name,group:i.group,location:i.binding,members:o})}for(let i of t.textures)e.bindings.push({type:"texture",name:i.name,group:i.group,location:i.binding});for(let i of t.samplers)e.bindings.push({type:"sampler",name:i.name,group:i.group,location:i.binding});let n=t.entry.vertex[0],s=n?.inputs.length||0;for(let i=0;i<s;i++){let o=n.inputs[i];if(o.locationType==="location"){let a=xm(o.type);e.attributes.push({name:o.name,location:Number(o.location),type:a})}}return e}function xm(r){return r?.format?`${r.name}<${r.format.name}>`:r.name}function V0(r){try{return new Ma(r)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw typeof e=="object"&&e?.message&&(t+=`: ${e.message} `),typeof e=="object"&&e?.token&&(t+=e.token.line||""),new Error(t,{cause:e})}}var z0=1/Math.PI*180,W0=1/180*Math.PI,$0={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...$0}};var ge=globalThis.mathgl.config;function ri(r,{precision:e=ge.precision}={}){return r=j0(r),`${parseFloat(r.toPrecision(e))}`}function Gt(r){return Array.isArray(r)||ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Jn(r,e){return sf(r,t=>t*W0,e)}function Tr(r,e){return sf(r,t=>t*z0,e)}function ee(r,e,t){return sf(r,n=>Math.max(e,Math.min(t,n)))}function Qt(r,e,t){return Gt(r)?r.map((n,s)=>Qt(n,e[s],t)):t*e+(1-t)*r}function He(r,e,t){let n=ge.EPSILON;t&&(ge.EPSILON=t);try{if(r===e)return!0;if(Gt(r)&&Gt(e)){if(r.length!==e.length)return!1;for(let s=0;s<r.length;++s)if(!He(r[s],e[s]))return!1;return!0}return r&&r.equals?r.equals(e):e&&e.equals?e.equals(r):typeof r=="number"&&typeof e=="number"?Math.abs(r-e)<=ge.EPSILON*Math.max(1,Math.abs(r),Math.abs(e)):!1}finally{ge.EPSILON=n}}function j0(r){return Math.round(r/ge.EPSILON)*ge.EPSILON}function H0(r){return r.clone?r.clone():new Array(r.length)}function sf(r,e,t){if(Gt(r)){let n=r;t=t||H0(n);for(let s=0;s<t.length&&s<n.length;++s){let i=typeof r=="number"?r:r[s];t[s]=e(i,s,t)}return t}return e(r)}var es=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,t=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=e[n+t];return this.check()}toArray(e=[],t=0){for(let n=0;n<this.ELEMENTS;++n)e[t+n]=this[n];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Gt(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(ge)}formatString(e){let t="";for(let n=0;n<this.ELEMENTS;++n)t+=(n>0?", ":"")+ri(this[n],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!He(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,n){if(n===void 0)return this.lerp(this,e,t);for(let s=0;s<this.ELEMENTS;++s){let i=e[s],o=typeof t=="number"?t:t[s];this[s]=i+n*(o-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e[n]),t[n]);return this.check()}add(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]+=t[n];return this.check()}subtract(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]-=t[n];return this.check()}scale(e){if(typeof e=="number")for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(ge.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],e),t);return this.check()}get elements(){return this}};function X0(r,e){if(r.length!==e)return!1;for(let t=0;t<r.length;++t)if(!Number.isFinite(r[t]))return!1;return!0}function Re(r){if(!Number.isFinite(r))throw new Error(`Invalid number ${JSON.stringify(r)}`);return r}function Oa(r,e,t=""){if(ge.debug&&!X0(r,e))throw new Error(`math.gl: ${t} some fields set to invalid numbers'`);return r}function of(r,e){if(!r)throw new Error(`math.gl assertion ${e}`)}var ka=class extends es{get x(){return this[0]}set x(e){this[0]=Re(e)}get y(){return this[1]}set y(e){this[1]=Re(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let n=0;n<this.ELEMENTS;++n){let s=this[n]-e[n];t+=s*s}return Re(t)}dot(e){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*e[n];return Re(t)}normalize(){let e=this.magnitude();if(e!==0)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]*=t[n];return this.check()}divide(...e){for(let t of e)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return of(e>=0&&e<this.ELEMENTS,"index is out of range"),Re(this[e])}setComponent(e,t){return of(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}};var _e={};$t(_e,{add:()=>G0,angle:()=>g1,ceil:()=>Q0,clone:()=>Y0,copy:()=>K0,create:()=>bm,cross:()=>l1,dist:()=>S1,distance:()=>Am,div:()=>A1,divide:()=>vm,dot:()=>c1,equals:()=>b1,exactEquals:()=>x1,floor:()=>J0,forEach:()=>I1,fromValues:()=>q0,inverse:()=>o1,len:()=>T1,length:()=>Em,lerp:()=>u1,max:()=>t1,min:()=>e1,mul:()=>v1,multiply:()=>wm,negate:()=>i1,normalize:()=>a1,random:()=>f1,rotate:()=>m1,round:()=>r1,scale:()=>n1,scaleAndAdd:()=>s1,set:()=>Z0,sqrDist:()=>E1,sqrLen:()=>R1,squaredDistance:()=>Sm,squaredLength:()=>Rm,str:()=>y1,sub:()=>w1,subtract:()=>Tm,transformMat2:()=>h1,transformMat2d:()=>d1,transformMat3:()=>p1,transformMat4:()=>af,zero:()=>_1});var fe=typeof Float32Array<"u"?Float32Array:Array,Pt=Math.random;function et(r){return r>=0?Math.round(r):r%.5===0?Math.floor(r):Math.round(r)}var BM=Math.PI/180;function bm(){let r=new fe(2);return fe!=Float32Array&&(r[0]=0,r[1]=0),r}function Y0(r){let e=new fe(2);return e[0]=r[0],e[1]=r[1],e}function q0(r,e){let t=new fe(2);return t[0]=r,t[1]=e,t}function K0(r,e){return r[0]=e[0],r[1]=e[1],r}function Z0(r,e,t){return r[0]=e,r[1]=t,r}function G0(r,e,t){return r[0]=e[0]+t[0],r[1]=e[1]+t[1],r}function Tm(r,e,t){return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r}function wm(r,e,t){return r[0]=e[0]*t[0],r[1]=e[1]*t[1],r}function vm(r,e,t){return r[0]=e[0]/t[0],r[1]=e[1]/t[1],r}function Q0(r,e){return r[0]=Math.ceil(e[0]),r[1]=Math.ceil(e[1]),r}function J0(r,e){return r[0]=Math.floor(e[0]),r[1]=Math.floor(e[1]),r}function e1(r,e,t){return r[0]=Math.min(e[0],t[0]),r[1]=Math.min(e[1],t[1]),r}function t1(r,e,t){return r[0]=Math.max(e[0],t[0]),r[1]=Math.max(e[1],t[1]),r}function r1(r,e){return r[0]=et(e[0]),r[1]=et(e[1]),r}function n1(r,e,t){return r[0]=e[0]*t,r[1]=e[1]*t,r}function s1(r,e,t,n){return r[0]=e[0]+t[0]*n,r[1]=e[1]+t[1]*n,r}function Am(r,e){let t=e[0]-r[0],n=e[1]-r[1];return Math.sqrt(t*t+n*n)}function Sm(r,e){let t=e[0]-r[0],n=e[1]-r[1];return t*t+n*n}function Em(r){let e=r[0],t=r[1];return Math.sqrt(e*e+t*t)}function Rm(r){let e=r[0],t=r[1];return e*e+t*t}function i1(r,e){return r[0]=-e[0],r[1]=-e[1],r}function o1(r,e){return r[0]=1/e[0],r[1]=1/e[1],r}function a1(r,e){let t=e[0],n=e[1],s=t*t+n*n;return s>0&&(s=1/Math.sqrt(s)),r[0]=e[0]*s,r[1]=e[1]*s,r}function c1(r,e){return r[0]*e[0]+r[1]*e[1]}function l1(r,e,t){let n=e[0]*t[1]-e[1]*t[0];return r[0]=r[1]=0,r[2]=n,r}function u1(r,e,t,n){let s=e[0],i=e[1];return r[0]=s+n*(t[0]-s),r[1]=i+n*(t[1]-i),r}function f1(r,e){e=e===void 0?1:e;let t=Pt()*2*Math.PI;return r[0]=Math.cos(t)*e,r[1]=Math.sin(t)*e,r}function h1(r,e,t){let n=e[0],s=e[1];return r[0]=t[0]*n+t[2]*s,r[1]=t[1]*n+t[3]*s,r}function d1(r,e,t){let n=e[0],s=e[1];return r[0]=t[0]*n+t[2]*s+t[4],r[1]=t[1]*n+t[3]*s+t[5],r}function p1(r,e,t){let n=e[0],s=e[1];return r[0]=t[0]*n+t[3]*s+t[6],r[1]=t[1]*n+t[4]*s+t[7],r}function af(r,e,t){let n=e[0],s=e[1];return r[0]=t[0]*n+t[4]*s+t[12],r[1]=t[1]*n+t[5]*s+t[13],r}function m1(r,e,t,n){let s=e[0]-t[0],i=e[1]-t[1],o=Math.sin(n),a=Math.cos(n);return r[0]=s*a-i*o+t[0],r[1]=s*o+i*a+t[1],r}function g1(r,e){let t=r[0],n=r[1],s=e[0],i=e[1],o=Math.sqrt((t*t+n*n)*(s*s+i*i)),a=o&&(t*s+n*i)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function _1(r){return r[0]=0,r[1]=0,r}function y1(r){return`vec2(${r[0]}, ${r[1]})`}function x1(r,e){return r[0]===e[0]&&r[1]===e[1]}function b1(r,e){let t=r[0],n=r[1],s=e[0],i=e[1];return Math.abs(t-s)<=1e-6*Math.max(1,Math.abs(t),Math.abs(s))&&Math.abs(n-i)<=1e-6*Math.max(1,Math.abs(n),Math.abs(i))}var T1=Em,w1=Tm,v1=wm,A1=vm,S1=Am,E1=Sm,R1=Rm,I1=function(){let r=bm();return function(e,t,n,s,i,o){let a,c;for(t||(t=2),n||(n=0),s?c=Math.min(s*t+n,e.length):c=e.length,a=n;a<c;a+=t)r[0]=e[a],r[1]=e[a+1],i(r,r,o),e[a]=r[0],e[a+1]=r[1];return e}}();function Im(r,e,t){let n=e[0],s=e[1],i=t[3]*n+t[7]*s||1;return r[0]=(t[0]*n+t[4]*s)/i,r[1]=(t[1]*n+t[5]*s)/i,r}function Da(r,e,t){let n=e[0],s=e[1],i=e[2],o=t[3]*n+t[7]*s+t[11]*i||1;return r[0]=(t[0]*n+t[4]*s+t[8]*i)/o,r[1]=(t[1]*n+t[5]*s+t[9]*i)/o,r[2]=(t[2]*n+t[6]*s+t[10]*i)/o,r}function Pm(r,e,t){let n=e[0],s=e[1];return r[0]=t[0]*n+t[2]*s,r[1]=t[1]*n+t[3]*s,r[2]=e[2],r}var Oe={};$t(Oe,{add:()=>k1,angle:()=>mf,bezier:()=>Y1,ceil:()=>N1,clone:()=>P1,copy:()=>M1,create:()=>Cm,cross:()=>lf,dist:()=>rT,distance:()=>Nm,div:()=>tT,divide:()=>km,dot:()=>cf,equals:()=>Q1,exactEquals:()=>G1,floor:()=>D1,forEach:()=>oT,fromValues:()=>C1,hermite:()=>X1,inverse:()=>W1,len:()=>sT,length:()=>Fa,lerp:()=>j1,max:()=>B1,min:()=>F1,mul:()=>eT,multiply:()=>Om,negate:()=>z1,normalize:()=>$1,random:()=>q1,rotateX:()=>hf,rotateY:()=>df,rotateZ:()=>pf,round:()=>L1,scale:()=>U1,scaleAndAdd:()=>V1,set:()=>O1,slerp:()=>H1,sqrDist:()=>nT,sqrLen:()=>iT,squaredDistance:()=>Dm,squaredLength:()=>Fm,str:()=>Z1,sub:()=>J1,subtract:()=>Mm,transformMat3:()=>uf,transformMat4:()=>ni,transformQuat:()=>ff,zero:()=>K1});function Cm(){let r=new fe(3);return fe!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0),r}function P1(r){let e=new fe(3);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e}function Fa(r){let e=r[0],t=r[1],n=r[2];return Math.sqrt(e*e+t*t+n*n)}function C1(r,e,t){let n=new fe(3);return n[0]=r,n[1]=e,n[2]=t,n}function M1(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r}function O1(r,e,t,n){return r[0]=e,r[1]=t,r[2]=n,r}function k1(r,e,t){return r[0]=e[0]+t[0],r[1]=e[1]+t[1],r[2]=e[2]+t[2],r}function Mm(r,e,t){return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],r}function Om(r,e,t){return r[0]=e[0]*t[0],r[1]=e[1]*t[1],r[2]=e[2]*t[2],r}function km(r,e,t){return r[0]=e[0]/t[0],r[1]=e[1]/t[1],r[2]=e[2]/t[2],r}function N1(r,e){return r[0]=Math.ceil(e[0]),r[1]=Math.ceil(e[1]),r[2]=Math.ceil(e[2]),r}function D1(r,e){return r[0]=Math.floor(e[0]),r[1]=Math.floor(e[1]),r[2]=Math.floor(e[2]),r}function F1(r,e,t){return r[0]=Math.min(e[0],t[0]),r[1]=Math.min(e[1],t[1]),r[2]=Math.min(e[2],t[2]),r}function B1(r,e,t){return r[0]=Math.max(e[0],t[0]),r[1]=Math.max(e[1],t[1]),r[2]=Math.max(e[2],t[2]),r}function L1(r,e){return r[0]=et(e[0]),r[1]=et(e[1]),r[2]=et(e[2]),r}function U1(r,e,t){return r[0]=e[0]*t,r[1]=e[1]*t,r[2]=e[2]*t,r}function V1(r,e,t,n){return r[0]=e[0]+t[0]*n,r[1]=e[1]+t[1]*n,r[2]=e[2]+t[2]*n,r}function Nm(r,e){let t=e[0]-r[0],n=e[1]-r[1],s=e[2]-r[2];return Math.sqrt(t*t+n*n+s*s)}function Dm(r,e){let t=e[0]-r[0],n=e[1]-r[1],s=e[2]-r[2];return t*t+n*n+s*s}function Fm(r){let e=r[0],t=r[1],n=r[2];return e*e+t*t+n*n}function z1(r,e){return r[0]=-e[0],r[1]=-e[1],r[2]=-e[2],r}function W1(r,e){return r[0]=1/e[0],r[1]=1/e[1],r[2]=1/e[2],r}function $1(r,e){let t=e[0],n=e[1],s=e[2],i=t*t+n*n+s*s;return i>0&&(i=1/Math.sqrt(i)),r[0]=e[0]*i,r[1]=e[1]*i,r[2]=e[2]*i,r}function cf(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]}function lf(r,e,t){let n=e[0],s=e[1],i=e[2],o=t[0],a=t[1],c=t[2];return r[0]=s*c-i*a,r[1]=i*o-n*c,r[2]=n*a-s*o,r}function j1(r,e,t,n){let s=e[0],i=e[1],o=e[2];return r[0]=s+n*(t[0]-s),r[1]=i+n*(t[1]-i),r[2]=o+n*(t[2]-o),r}function H1(r,e,t,n){let s=Math.acos(Math.min(Math.max(cf(e,t),-1),1)),i=Math.sin(s),o=Math.sin((1-n)*s)/i,a=Math.sin(n*s)/i;return r[0]=o*e[0]+a*t[0],r[1]=o*e[1]+a*t[1],r[2]=o*e[2]+a*t[2],r}function X1(r,e,t,n,s,i){let o=i*i,a=o*(2*i-3)+1,c=o*(i-2)+i,l=o*(i-1),u=o*(3-2*i);return r[0]=e[0]*a+t[0]*c+n[0]*l+s[0]*u,r[1]=e[1]*a+t[1]*c+n[1]*l+s[1]*u,r[2]=e[2]*a+t[2]*c+n[2]*l+s[2]*u,r}function Y1(r,e,t,n,s,i){let o=1-i,a=o*o,c=i*i,l=a*o,u=3*i*a,f=3*c*o,h=c*i;return r[0]=e[0]*l+t[0]*u+n[0]*f+s[0]*h,r[1]=e[1]*l+t[1]*u+n[1]*f+s[1]*h,r[2]=e[2]*l+t[2]*u+n[2]*f+s[2]*h,r}function q1(r,e){e=e===void 0?1:e;let t=Pt()*2*Math.PI,n=Pt()*2-1,s=Math.sqrt(1-n*n)*e;return r[0]=Math.cos(t)*s,r[1]=Math.sin(t)*s,r[2]=n*e,r}function ni(r,e,t){let n=e[0],s=e[1],i=e[2],o=t[3]*n+t[7]*s+t[11]*i+t[15];return o=o||1,r[0]=(t[0]*n+t[4]*s+t[8]*i+t[12])/o,r[1]=(t[1]*n+t[5]*s+t[9]*i+t[13])/o,r[2]=(t[2]*n+t[6]*s+t[10]*i+t[14])/o,r}function uf(r,e,t){let n=e[0],s=e[1],i=e[2];return r[0]=n*t[0]+s*t[3]+i*t[6],r[1]=n*t[1]+s*t[4]+i*t[7],r[2]=n*t[2]+s*t[5]+i*t[8],r}function ff(r,e,t){let n=t[0],s=t[1],i=t[2],o=t[3],a=e[0],c=e[1],l=e[2],u=s*l-i*c,f=i*a-n*l,h=n*c-s*a,d=s*h-i*f,m=i*u-n*h,y=n*f-s*u,_=o*2;return u*=_,f*=_,h*=_,d*=2,m*=2,y*=2,r[0]=a+u+d,r[1]=c+f+m,r[2]=l+h+y,r}function hf(r,e,t,n){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0],i[1]=s[1]*Math.cos(n)-s[2]*Math.sin(n),i[2]=s[1]*Math.sin(n)+s[2]*Math.cos(n),r[0]=i[0]+t[0],r[1]=i[1]+t[1],r[2]=i[2]+t[2],r}function df(r,e,t,n){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[2]*Math.sin(n)+s[0]*Math.cos(n),i[1]=s[1],i[2]=s[2]*Math.cos(n)-s[0]*Math.sin(n),r[0]=i[0]+t[0],r[1]=i[1]+t[1],r[2]=i[2]+t[2],r}function pf(r,e,t,n){let s=[],i=[];return s[0]=e[0]-t[0],s[1]=e[1]-t[1],s[2]=e[2]-t[2],i[0]=s[0]*Math.cos(n)-s[1]*Math.sin(n),i[1]=s[0]*Math.sin(n)+s[1]*Math.cos(n),i[2]=s[2],r[0]=i[0]+t[0],r[1]=i[1]+t[1],r[2]=i[2]+t[2],r}function mf(r,e){let t=r[0],n=r[1],s=r[2],i=e[0],o=e[1],a=e[2],c=Math.sqrt((t*t+n*n+s*s)*(i*i+o*o+a*a)),l=c&&cf(r,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function K1(r){return r[0]=0,r[1]=0,r[2]=0,r}function Z1(r){return`vec3(${r[0]}, ${r[1]}, ${r[2]})`}function G1(r,e){return r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]}function Q1(r,e){let t=r[0],n=r[1],s=r[2],i=e[0],o=e[1],a=e[2];return Math.abs(t-i)<=1e-6*Math.max(1,Math.abs(t),Math.abs(i))&&Math.abs(n-o)<=1e-6*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}var J1=Mm,eT=Om,tT=km,rT=Nm,nT=Dm,sT=Fa,iT=Fm,oT=function(){let r=Cm();return function(e,t,n,s,i,o){let a,c;for(t||(t=3),n||(n=0),s?c=Math.min(s*t+n,e.length):c=e.length,a=n;a<c;a+=t)r[0]=e[a],r[1]=e[a+1],r[2]=e[a+2],i(r,r,o),e[a]=r[0],e[a+1]=r[1],e[a+2]=r[2];return e}}();var gf=[0,0,0],Ba,G=class extends ka{static get ZERO(){return Ba||(Ba=new G(0,0,0),Object.freeze(Ba)),Ba}constructor(e=0,t=0,n=0){super(-0,-0,-0),arguments.length===1&&Gt(e)?this.copy(e):(ge.debug&&(Re(e),Re(t),Re(n)),this[0]=e,this[1]=t,this[2]=n)}set(e,t,n){return this[0]=e,this[1]=t,this[2]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return ge.debug&&(Re(e.x),Re(e.y),Re(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=Re(e)}angle(e){return mf(this,e)}cross(e){return lf(this,this,e),this.check()}rotateX({radians:e,origin:t=gf}){return hf(this,this,t,e),this.check()}rotateY({radians:e,origin:t=gf}){return df(this,this,t,e),this.check()}rotateZ({radians:e,origin:t=gf}){return pf(this,this,t,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return ni(this,this,e),this.check()}transformAsVector(e){return Da(this,this,e),this.check()}transformByMatrix3(e){return uf(this,this,e),this.check()}transformByMatrix2(e){return Pm(this,this,e),this.check()}transformByQuaternion(e){return ff(this,this,e),this.check()}};var La=class extends es{toString(){let e="[";if(ge.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let n=0;n<this.RANK;++n)e+=` ${this[n*this.RANK+t]}`}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=` ${this[t]}`}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,n){return this[t*this.RANK+e]=Re(n),this}getColumn(e,t=new Array(this.RANK).fill(-0)){let n=e*this.RANK;for(let s=0;s<this.RANK;++s)t[s]=this[n+s];return t}setColumn(e,t){let n=e*this.RANK;for(let s=0;s<this.RANK;++s)this[n+s]=t[s];return this}};var ye={};$t(ye,{add:()=>MT,adjoint:()=>hT,clone:()=>cT,copy:()=>lT,create:()=>aT,decompose:()=>wT,determinant:()=>xf,equals:()=>DT,exactEquals:()=>NT,frob:()=>CT,fromQuat:()=>Ef,fromQuat2:()=>xT,fromRotation:()=>mT,fromRotationTranslation:()=>Lm,fromRotationTranslationScale:()=>vT,fromRotationTranslationScaleOrigin:()=>AT,fromScaling:()=>pT,fromTranslation:()=>dT,fromValues:()=>uT,fromXRotation:()=>gT,fromYRotation:()=>_T,fromZRotation:()=>yT,frustum:()=>Rf,getRotation:()=>TT,getScaling:()=>Um,getTranslation:()=>bT,identity:()=>Bm,invert:()=>yf,lookAt:()=>Cf,mul:()=>FT,multiply:()=>si,multiplyScalar:()=>OT,multiplyScalarAndAdd:()=>kT,ortho:()=>Pf,orthoNO:()=>zm,orthoZO:()=>RT,perspective:()=>If,perspectiveFromFieldOfView:()=>ET,perspectiveNO:()=>Vm,perspectiveZO:()=>ST,rotate:()=>wf,rotateX:()=>vf,rotateY:()=>Af,rotateZ:()=>Sf,scale:()=>Tf,set:()=>fT,str:()=>PT,sub:()=>BT,subtract:()=>Wm,targetTo:()=>IT,translate:()=>bf,transpose:()=>_f});function aT(){let r=new fe(16);return fe!=Float32Array&&(r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=0,r[12]=0,r[13]=0,r[14]=0),r[0]=1,r[5]=1,r[10]=1,r[15]=1,r}function cT(r){let e=new fe(16);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e[4]=r[4],e[5]=r[5],e[6]=r[6],e[7]=r[7],e[8]=r[8],e[9]=r[9],e[10]=r[10],e[11]=r[11],e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],e}function lT(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r}function uT(r,e,t,n,s,i,o,a,c,l,u,f,h,d,m,y){let _=new fe(16);return _[0]=r,_[1]=e,_[2]=t,_[3]=n,_[4]=s,_[5]=i,_[6]=o,_[7]=a,_[8]=c,_[9]=l,_[10]=u,_[11]=f,_[12]=h,_[13]=d,_[14]=m,_[15]=y,_}function fT(r,e,t,n,s,i,o,a,c,l,u,f,h,d,m,y,_){return r[0]=e,r[1]=t,r[2]=n,r[3]=s,r[4]=i,r[5]=o,r[6]=a,r[7]=c,r[8]=l,r[9]=u,r[10]=f,r[11]=h,r[12]=d,r[13]=m,r[14]=y,r[15]=_,r}function Bm(r){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function _f(r,e){if(r===e){let t=e[1],n=e[2],s=e[3],i=e[6],o=e[7],a=e[11];r[1]=e[4],r[2]=e[8],r[3]=e[12],r[4]=t,r[6]=e[9],r[7]=e[13],r[8]=n,r[9]=i,r[11]=e[14],r[12]=s,r[13]=o,r[14]=a}else r[0]=e[0],r[1]=e[4],r[2]=e[8],r[3]=e[12],r[4]=e[1],r[5]=e[5],r[6]=e[9],r[7]=e[13],r[8]=e[2],r[9]=e[6],r[10]=e[10],r[11]=e[14],r[12]=e[3],r[13]=e[7],r[14]=e[11],r[15]=e[15];return r}function yf(r,e){let t=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],d=e[11],m=e[12],y=e[13],_=e[14],x=e[15],E=t*a-n*o,b=t*c-s*o,S=t*l-i*o,C=n*c-s*a,P=n*l-i*a,B=s*l-i*c,N=u*y-f*m,k=u*_-h*m,F=u*x-d*m,U=f*_-h*y,X=f*x-d*y,J=h*x-d*_,q=E*J-b*X+S*U+C*F-P*k+B*N;return q?(q=1/q,r[0]=(a*J-c*X+l*U)*q,r[1]=(s*X-n*J-i*U)*q,r[2]=(y*B-_*P+x*C)*q,r[3]=(h*P-f*B-d*C)*q,r[4]=(c*F-o*J-l*k)*q,r[5]=(t*J-s*F+i*k)*q,r[6]=(_*S-m*B-x*b)*q,r[7]=(u*B-h*S+d*b)*q,r[8]=(o*X-a*F+l*N)*q,r[9]=(n*F-t*X-i*N)*q,r[10]=(m*P-y*S+x*E)*q,r[11]=(f*S-u*P-d*E)*q,r[12]=(a*k-o*U-c*N)*q,r[13]=(t*U-n*k+s*N)*q,r[14]=(y*b-m*C-_*E)*q,r[15]=(u*C-f*b+h*E)*q,r):null}function hT(r,e){let t=e[0],n=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],d=e[11],m=e[12],y=e[13],_=e[14],x=e[15],E=t*a-n*o,b=t*c-s*o,S=t*l-i*o,C=n*c-s*a,P=n*l-i*a,B=s*l-i*c,N=u*y-f*m,k=u*_-h*m,F=u*x-d*m,U=f*_-h*y,X=f*x-d*y,J=h*x-d*_;return r[0]=a*J-c*X+l*U,r[1]=s*X-n*J-i*U,r[2]=y*B-_*P+x*C,r[3]=h*P-f*B-d*C,r[4]=c*F-o*J-l*k,r[5]=t*J-s*F+i*k,r[6]=_*S-m*B-x*b,r[7]=u*B-h*S+d*b,r[8]=o*X-a*F+l*N,r[9]=n*F-t*X-i*N,r[10]=m*P-y*S+x*E,r[11]=f*S-u*P-d*E,r[12]=a*k-o*U-c*N,r[13]=t*U-n*k+s*N,r[14]=y*b-m*C-_*E,r[15]=u*C-f*b+h*E,r}function xf(r){let e=r[0],t=r[1],n=r[2],s=r[3],i=r[4],o=r[5],a=r[6],c=r[7],l=r[8],u=r[9],f=r[10],h=r[11],d=r[12],m=r[13],y=r[14],_=r[15],x=e*o-t*i,E=e*a-n*i,b=t*a-n*o,S=l*m-u*d,C=l*y-f*d,P=u*y-f*m,B=e*P-t*C+n*S,N=i*P-o*C+a*S,k=l*b-u*E+f*x,F=d*b-m*E+y*x;return c*B-s*N+_*k-h*F}function si(r,e,t){let n=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=e[8],h=e[9],d=e[10],m=e[11],y=e[12],_=e[13],x=e[14],E=e[15],b=t[0],S=t[1],C=t[2],P=t[3];return r[0]=b*n+S*a+C*f+P*y,r[1]=b*s+S*c+C*h+P*_,r[2]=b*i+S*l+C*d+P*x,r[3]=b*o+S*u+C*m+P*E,b=t[4],S=t[5],C=t[6],P=t[7],r[4]=b*n+S*a+C*f+P*y,r[5]=b*s+S*c+C*h+P*_,r[6]=b*i+S*l+C*d+P*x,r[7]=b*o+S*u+C*m+P*E,b=t[8],S=t[9],C=t[10],P=t[11],r[8]=b*n+S*a+C*f+P*y,r[9]=b*s+S*c+C*h+P*_,r[10]=b*i+S*l+C*d+P*x,r[11]=b*o+S*u+C*m+P*E,b=t[12],S=t[13],C=t[14],P=t[15],r[12]=b*n+S*a+C*f+P*y,r[13]=b*s+S*c+C*h+P*_,r[14]=b*i+S*l+C*d+P*x,r[15]=b*o+S*u+C*m+P*E,r}function bf(r,e,t){let n=t[0],s=t[1],i=t[2],o,a,c,l,u,f,h,d,m,y,_,x;return e===r?(r[12]=e[0]*n+e[4]*s+e[8]*i+e[12],r[13]=e[1]*n+e[5]*s+e[9]*i+e[13],r[14]=e[2]*n+e[6]*s+e[10]*i+e[14],r[15]=e[3]*n+e[7]*s+e[11]*i+e[15]):(o=e[0],a=e[1],c=e[2],l=e[3],u=e[4],f=e[5],h=e[6],d=e[7],m=e[8],y=e[9],_=e[10],x=e[11],r[0]=o,r[1]=a,r[2]=c,r[3]=l,r[4]=u,r[5]=f,r[6]=h,r[7]=d,r[8]=m,r[9]=y,r[10]=_,r[11]=x,r[12]=o*n+u*s+m*i+e[12],r[13]=a*n+f*s+y*i+e[13],r[14]=c*n+h*s+_*i+e[14],r[15]=l*n+d*s+x*i+e[15]),r}function Tf(r,e,t){let n=t[0],s=t[1],i=t[2];return r[0]=e[0]*n,r[1]=e[1]*n,r[2]=e[2]*n,r[3]=e[3]*n,r[4]=e[4]*s,r[5]=e[5]*s,r[6]=e[6]*s,r[7]=e[7]*s,r[8]=e[8]*i,r[9]=e[9]*i,r[10]=e[10]*i,r[11]=e[11]*i,r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r}function wf(r,e,t,n){let s=n[0],i=n[1],o=n[2],a=Math.sqrt(s*s+i*i+o*o),c,l,u,f,h,d,m,y,_,x,E,b,S,C,P,B,N,k,F,U,X,J,q,pe;return a<1e-6?null:(a=1/a,s*=a,i*=a,o*=a,l=Math.sin(t),c=Math.cos(t),u=1-c,f=e[0],h=e[1],d=e[2],m=e[3],y=e[4],_=e[5],x=e[6],E=e[7],b=e[8],S=e[9],C=e[10],P=e[11],B=s*s*u+c,N=i*s*u+o*l,k=o*s*u-i*l,F=s*i*u-o*l,U=i*i*u+c,X=o*i*u+s*l,J=s*o*u+i*l,q=i*o*u-s*l,pe=o*o*u+c,r[0]=f*B+y*N+b*k,r[1]=h*B+_*N+S*k,r[2]=d*B+x*N+C*k,r[3]=m*B+E*N+P*k,r[4]=f*F+y*U+b*X,r[5]=h*F+_*U+S*X,r[6]=d*F+x*U+C*X,r[7]=m*F+E*U+P*X,r[8]=f*J+y*q+b*pe,r[9]=h*J+_*q+S*pe,r[10]=d*J+x*q+C*pe,r[11]=m*J+E*q+P*pe,e!==r&&(r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r)}function vf(r,e,t){let n=Math.sin(t),s=Math.cos(t),i=e[4],o=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11];return e!==r&&(r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[4]=i*s+l*n,r[5]=o*s+u*n,r[6]=a*s+f*n,r[7]=c*s+h*n,r[8]=l*s-i*n,r[9]=u*s-o*n,r[10]=f*s-a*n,r[11]=h*s-c*n,r}function Af(r,e,t){let n=Math.sin(t),s=Math.cos(t),i=e[0],o=e[1],a=e[2],c=e[3],l=e[8],u=e[9],f=e[10],h=e[11];return e!==r&&(r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=i*s-l*n,r[1]=o*s-u*n,r[2]=a*s-f*n,r[3]=c*s-h*n,r[8]=i*n+l*s,r[9]=o*n+u*s,r[10]=a*n+f*s,r[11]=c*n+h*s,r}function Sf(r,e,t){let n=Math.sin(t),s=Math.cos(t),i=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=e[5],f=e[6],h=e[7];return e!==r&&(r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15]),r[0]=i*s+l*n,r[1]=o*s+u*n,r[2]=a*s+f*n,r[3]=c*s+h*n,r[4]=l*s-i*n,r[5]=u*s-o*n,r[6]=f*s-a*n,r[7]=h*s-c*n,r}function dT(r,e){return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=e[0],r[13]=e[1],r[14]=e[2],r[15]=1,r}function pT(r,e){return r[0]=e[0],r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=e[1],r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=e[2],r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function mT(r,e,t){let n=t[0],s=t[1],i=t[2],o=Math.sqrt(n*n+s*s+i*i),a,c,l;return o<1e-6?null:(o=1/o,n*=o,s*=o,i*=o,c=Math.sin(e),a=Math.cos(e),l=1-a,r[0]=n*n*l+a,r[1]=s*n*l+i*c,r[2]=i*n*l-s*c,r[3]=0,r[4]=n*s*l-i*c,r[5]=s*s*l+a,r[6]=i*s*l+n*c,r[7]=0,r[8]=n*i*l+s*c,r[9]=s*i*l-n*c,r[10]=i*i*l+a,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r)}function gT(r,e){let t=Math.sin(e),n=Math.cos(e);return r[0]=1,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=n,r[6]=t,r[7]=0,r[8]=0,r[9]=-t,r[10]=n,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function _T(r,e){let t=Math.sin(e),n=Math.cos(e);return r[0]=n,r[1]=0,r[2]=-t,r[3]=0,r[4]=0,r[5]=1,r[6]=0,r[7]=0,r[8]=t,r[9]=0,r[10]=n,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function yT(r,e){let t=Math.sin(e),n=Math.cos(e);return r[0]=n,r[1]=t,r[2]=0,r[3]=0,r[4]=-t,r[5]=n,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=1,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function Lm(r,e,t){let n=e[0],s=e[1],i=e[2],o=e[3],a=n+n,c=s+s,l=i+i,u=n*a,f=n*c,h=n*l,d=s*c,m=s*l,y=i*l,_=o*a,x=o*c,E=o*l;return r[0]=1-(d+y),r[1]=f+E,r[2]=h-x,r[3]=0,r[4]=f-E,r[5]=1-(u+y),r[6]=m+_,r[7]=0,r[8]=h+x,r[9]=m-_,r[10]=1-(u+d),r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r}function xT(r,e){let t=new fe(3),n=-e[0],s=-e[1],i=-e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],f=n*n+s*s+i*i+o*o;return f>0?(t[0]=(a*o+u*n+c*i-l*s)*2/f,t[1]=(c*o+u*s+l*n-a*i)*2/f,t[2]=(l*o+u*i+a*s-c*n)*2/f):(t[0]=(a*o+u*n+c*i-l*s)*2,t[1]=(c*o+u*s+l*n-a*i)*2,t[2]=(l*o+u*i+a*s-c*n)*2),Lm(r,e,t),r}function bT(r,e){return r[0]=e[12],r[1]=e[13],r[2]=e[14],r}function Um(r,e){let t=e[0],n=e[1],s=e[2],i=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return r[0]=Math.sqrt(t*t+n*n+s*s),r[1]=Math.sqrt(i*i+o*o+a*a),r[2]=Math.sqrt(c*c+l*l+u*u),r}function TT(r,e){let t=new fe(3);Um(t,e);let n=1/t[0],s=1/t[1],i=1/t[2],o=e[0]*n,a=e[1]*s,c=e[2]*i,l=e[4]*n,u=e[5]*s,f=e[6]*i,h=e[8]*n,d=e[9]*s,m=e[10]*i,y=o+u+m,_=0;return y>0?(_=Math.sqrt(y+1)*2,r[3]=.25*_,r[0]=(f-d)/_,r[1]=(h-c)/_,r[2]=(a-l)/_):o>u&&o>m?(_=Math.sqrt(1+o-u-m)*2,r[3]=(f-d)/_,r[0]=.25*_,r[1]=(a+l)/_,r[2]=(h+c)/_):u>m?(_=Math.sqrt(1+u-o-m)*2,r[3]=(h-c)/_,r[0]=(a+l)/_,r[1]=.25*_,r[2]=(f+d)/_):(_=Math.sqrt(1+m-o-u)*2,r[3]=(a-l)/_,r[0]=(h+c)/_,r[1]=(f+d)/_,r[2]=.25*_),r}function wT(r,e,t,n){e[0]=n[12],e[1]=n[13],e[2]=n[14];let s=n[0],i=n[1],o=n[2],a=n[4],c=n[5],l=n[6],u=n[8],f=n[9],h=n[10];t[0]=Math.sqrt(s*s+i*i+o*o),t[1]=Math.sqrt(a*a+c*c+l*l),t[2]=Math.sqrt(u*u+f*f+h*h);let d=1/t[0],m=1/t[1],y=1/t[2],_=s*d,x=i*m,E=o*y,b=a*d,S=c*m,C=l*y,P=u*d,B=f*m,N=h*y,k=_+S+N,F=0;return k>0?(F=Math.sqrt(k+1)*2,r[3]=.25*F,r[0]=(C-B)/F,r[1]=(P-E)/F,r[2]=(x-b)/F):_>S&&_>N?(F=Math.sqrt(1+_-S-N)*2,r[3]=(C-B)/F,r[0]=.25*F,r[1]=(x+b)/F,r[2]=(P+E)/F):S>N?(F=Math.sqrt(1+S-_-N)*2,r[3]=(P-E)/F,r[0]=(x+b)/F,r[1]=.25*F,r[2]=(C+B)/F):(F=Math.sqrt(1+N-_-S)*2,r[3]=(x-b)/F,r[0]=(P+E)/F,r[1]=(C+B)/F,r[2]=.25*F),r}function vT(r,e,t,n){let s=e[0],i=e[1],o=e[2],a=e[3],c=s+s,l=i+i,u=o+o,f=s*c,h=s*l,d=s*u,m=i*l,y=i*u,_=o*u,x=a*c,E=a*l,b=a*u,S=n[0],C=n[1],P=n[2];return r[0]=(1-(m+_))*S,r[1]=(h+b)*S,r[2]=(d-E)*S,r[3]=0,r[4]=(h-b)*C,r[5]=(1-(f+_))*C,r[6]=(y+x)*C,r[7]=0,r[8]=(d+E)*P,r[9]=(y-x)*P,r[10]=(1-(f+m))*P,r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r}function AT(r,e,t,n,s){let i=e[0],o=e[1],a=e[2],c=e[3],l=i+i,u=o+o,f=a+a,h=i*l,d=i*u,m=i*f,y=o*u,_=o*f,x=a*f,E=c*l,b=c*u,S=c*f,C=n[0],P=n[1],B=n[2],N=s[0],k=s[1],F=s[2],U=(1-(y+x))*C,X=(d+S)*C,J=(m-b)*C,q=(d-S)*P,pe=(1-(h+x))*P,zt=(_+E)*P,Wt=(m+b)*B,Bd=(_-E)*B,Ld=(1-(h+y))*B;return r[0]=U,r[1]=X,r[2]=J,r[3]=0,r[4]=q,r[5]=pe,r[6]=zt,r[7]=0,r[8]=Wt,r[9]=Bd,r[10]=Ld,r[11]=0,r[12]=t[0]+N-(U*N+q*k+Wt*F),r[13]=t[1]+k-(X*N+pe*k+Bd*F),r[14]=t[2]+F-(J*N+zt*k+Ld*F),r[15]=1,r}function Ef(r,e){let t=e[0],n=e[1],s=e[2],i=e[3],o=t+t,a=n+n,c=s+s,l=t*o,u=n*o,f=n*a,h=s*o,d=s*a,m=s*c,y=i*o,_=i*a,x=i*c;return r[0]=1-f-m,r[1]=u+x,r[2]=h-_,r[3]=0,r[4]=u-x,r[5]=1-l-m,r[6]=d+y,r[7]=0,r[8]=h+_,r[9]=d-y,r[10]=1-l-f,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}function Rf(r,e,t,n,s,i,o){let a=1/(t-e),c=1/(s-n),l=1/(i-o);return r[0]=i*2*a,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=i*2*c,r[6]=0,r[7]=0,r[8]=(t+e)*a,r[9]=(s+n)*c,r[10]=(o+i)*l,r[11]=-1,r[12]=0,r[13]=0,r[14]=o*i*2*l,r[15]=0,r}function Vm(r,e,t,n,s){let i=1/Math.tan(e/2);if(r[0]=i/t,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=i,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,s!=null&&s!==1/0){let o=1/(n-s);r[10]=(s+n)*o,r[14]=2*s*n*o}else r[10]=-1,r[14]=-2*n;return r}var If=Vm;function ST(r,e,t,n,s){let i=1/Math.tan(e/2);if(r[0]=i/t,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=i,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=-1,r[12]=0,r[13]=0,r[15]=0,s!=null&&s!==1/0){let o=1/(n-s);r[10]=s*o,r[14]=s*n*o}else r[10]=-1,r[14]=-n;return r}function ET(r,e,t,n){let s=Math.tan(e.upDegrees*Math.PI/180),i=Math.tan(e.downDegrees*Math.PI/180),o=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(s+i);return r[0]=c,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=l,r[6]=0,r[7]=0,r[8]=-((o-a)*c*.5),r[9]=(s-i)*l*.5,r[10]=n/(t-n),r[11]=-1,r[12]=0,r[13]=0,r[14]=n*t/(t-n),r[15]=0,r}function zm(r,e,t,n,s,i,o){let a=1/(e-t),c=1/(n-s),l=1/(i-o);return r[0]=-2*a,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*c,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=2*l,r[11]=0,r[12]=(e+t)*a,r[13]=(s+n)*c,r[14]=(o+i)*l,r[15]=1,r}var Pf=zm;function RT(r,e,t,n,s,i,o){let a=1/(e-t),c=1/(n-s),l=1/(i-o);return r[0]=-2*a,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=-2*c,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[10]=l,r[11]=0,r[12]=(e+t)*a,r[13]=(s+n)*c,r[14]=i*l,r[15]=1,r}function Cf(r,e,t,n){let s,i,o,a,c,l,u,f,h,d,m=e[0],y=e[1],_=e[2],x=n[0],E=n[1],b=n[2],S=t[0],C=t[1],P=t[2];return Math.abs(m-S)<1e-6&&Math.abs(y-C)<1e-6&&Math.abs(_-P)<1e-6?Bm(r):(f=m-S,h=y-C,d=_-P,s=1/Math.sqrt(f*f+h*h+d*d),f*=s,h*=s,d*=s,i=E*d-b*h,o=b*f-x*d,a=x*h-E*f,s=Math.sqrt(i*i+o*o+a*a),s?(s=1/s,i*=s,o*=s,a*=s):(i=0,o=0,a=0),c=h*a-d*o,l=d*i-f*a,u=f*o-h*i,s=Math.sqrt(c*c+l*l+u*u),s?(s=1/s,c*=s,l*=s,u*=s):(c=0,l=0,u=0),r[0]=i,r[1]=c,r[2]=f,r[3]=0,r[4]=o,r[5]=l,r[6]=h,r[7]=0,r[8]=a,r[9]=u,r[10]=d,r[11]=0,r[12]=-(i*m+o*y+a*_),r[13]=-(c*m+l*y+u*_),r[14]=-(f*m+h*y+d*_),r[15]=1,r)}function IT(r,e,t,n){let s=e[0],i=e[1],o=e[2],a=n[0],c=n[1],l=n[2],u=s-t[0],f=i-t[1],h=o-t[2],d=u*u+f*f+h*h;d>0&&(d=1/Math.sqrt(d),u*=d,f*=d,h*=d);let m=c*h-l*f,y=l*u-a*h,_=a*f-c*u;return d=m*m+y*y+_*_,d>0&&(d=1/Math.sqrt(d),m*=d,y*=d,_*=d),r[0]=m,r[1]=y,r[2]=_,r[3]=0,r[4]=f*_-h*y,r[5]=h*m-u*_,r[6]=u*y-f*m,r[7]=0,r[8]=u,r[9]=f,r[10]=h,r[11]=0,r[12]=s,r[13]=i,r[14]=o,r[15]=1,r}function PT(r){return`mat4(${r[0]}, ${r[1]}, ${r[2]}, ${r[3]}, ${r[4]}, ${r[5]}, ${r[6]}, ${r[7]}, ${r[8]}, ${r[9]}, ${r[10]}, ${r[11]}, ${r[12]}, ${r[13]}, ${r[14]}, ${r[15]})`}function CT(r){return Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]+r[3]*r[3]+r[4]*r[4]+r[5]*r[5]+r[6]*r[6]+r[7]*r[7]+r[8]*r[8]+r[9]*r[9]+r[10]*r[10]+r[11]*r[11]+r[12]*r[12]+r[13]*r[13]+r[14]*r[14]+r[15]*r[15])}function MT(r,e,t){return r[0]=e[0]+t[0],r[1]=e[1]+t[1],r[2]=e[2]+t[2],r[3]=e[3]+t[3],r[4]=e[4]+t[4],r[5]=e[5]+t[5],r[6]=e[6]+t[6],r[7]=e[7]+t[7],r[8]=e[8]+t[8],r[9]=e[9]+t[9],r[10]=e[10]+t[10],r[11]=e[11]+t[11],r[12]=e[12]+t[12],r[13]=e[13]+t[13],r[14]=e[14]+t[14],r[15]=e[15]+t[15],r}function Wm(r,e,t){return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],r[3]=e[3]-t[3],r[4]=e[4]-t[4],r[5]=e[5]-t[5],r[6]=e[6]-t[6],r[7]=e[7]-t[7],r[8]=e[8]-t[8],r[9]=e[9]-t[9],r[10]=e[10]-t[10],r[11]=e[11]-t[11],r[12]=e[12]-t[12],r[13]=e[13]-t[13],r[14]=e[14]-t[14],r[15]=e[15]-t[15],r}function OT(r,e,t){return r[0]=e[0]*t,r[1]=e[1]*t,r[2]=e[2]*t,r[3]=e[3]*t,r[4]=e[4]*t,r[5]=e[5]*t,r[6]=e[6]*t,r[7]=e[7]*t,r[8]=e[8]*t,r[9]=e[9]*t,r[10]=e[10]*t,r[11]=e[11]*t,r[12]=e[12]*t,r[13]=e[13]*t,r[14]=e[14]*t,r[15]=e[15]*t,r}function kT(r,e,t,n){return r[0]=e[0]+t[0]*n,r[1]=e[1]+t[1]*n,r[2]=e[2]+t[2]*n,r[3]=e[3]+t[3]*n,r[4]=e[4]+t[4]*n,r[5]=e[5]+t[5]*n,r[6]=e[6]+t[6]*n,r[7]=e[7]+t[7]*n,r[8]=e[8]+t[8]*n,r[9]=e[9]+t[9]*n,r[10]=e[10]+t[10]*n,r[11]=e[11]+t[11]*n,r[12]=e[12]+t[12]*n,r[13]=e[13]+t[13]*n,r[14]=e[14]+t[14]*n,r[15]=e[15]+t[15]*n,r}function NT(r,e){return r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]&&r[3]===e[3]&&r[4]===e[4]&&r[5]===e[5]&&r[6]===e[6]&&r[7]===e[7]&&r[8]===e[8]&&r[9]===e[9]&&r[10]===e[10]&&r[11]===e[11]&&r[12]===e[12]&&r[13]===e[13]&&r[14]===e[14]&&r[15]===e[15]}function DT(r,e){let t=r[0],n=r[1],s=r[2],i=r[3],o=r[4],a=r[5],c=r[6],l=r[7],u=r[8],f=r[9],h=r[10],d=r[11],m=r[12],y=r[13],_=r[14],x=r[15],E=e[0],b=e[1],S=e[2],C=e[3],P=e[4],B=e[5],N=e[6],k=e[7],F=e[8],U=e[9],X=e[10],J=e[11],q=e[12],pe=e[13],zt=e[14],Wt=e[15];return Math.abs(t-E)<=1e-6*Math.max(1,Math.abs(t),Math.abs(E))&&Math.abs(n-b)<=1e-6*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(s-S)<=1e-6*Math.max(1,Math.abs(s),Math.abs(S))&&Math.abs(i-C)<=1e-6*Math.max(1,Math.abs(i),Math.abs(C))&&Math.abs(o-P)<=1e-6*Math.max(1,Math.abs(o),Math.abs(P))&&Math.abs(a-B)<=1e-6*Math.max(1,Math.abs(a),Math.abs(B))&&Math.abs(c-N)<=1e-6*Math.max(1,Math.abs(c),Math.abs(N))&&Math.abs(l-k)<=1e-6*Math.max(1,Math.abs(l),Math.abs(k))&&Math.abs(u-F)<=1e-6*Math.max(1,Math.abs(u),Math.abs(F))&&Math.abs(f-U)<=1e-6*Math.max(1,Math.abs(f),Math.abs(U))&&Math.abs(h-X)<=1e-6*Math.max(1,Math.abs(h),Math.abs(X))&&Math.abs(d-J)<=1e-6*Math.max(1,Math.abs(d),Math.abs(J))&&Math.abs(m-q)<=1e-6*Math.max(1,Math.abs(m),Math.abs(q))&&Math.abs(y-pe)<=1e-6*Math.max(1,Math.abs(y),Math.abs(pe))&&Math.abs(_-zt)<=1e-6*Math.max(1,Math.abs(_),Math.abs(zt))&&Math.abs(x-Wt)<=1e-6*Math.max(1,Math.abs(x),Math.abs(Wt))}var FT=si,BT=Wm;var Ve={};$t(Ve,{add:()=>WT,ceil:()=>$T,clone:()=>LT,copy:()=>VT,create:()=>$m,cross:()=>e3,dist:()=>f3,distance:()=>Ym,div:()=>u3,divide:()=>Xm,dot:()=>JT,equals:()=>a3,exactEquals:()=>o3,floor:()=>jT,forEach:()=>m3,fromValues:()=>UT,inverse:()=>GT,len:()=>d3,length:()=>Km,lerp:()=>t3,max:()=>XT,min:()=>HT,mul:()=>l3,multiply:()=>Hm,negate:()=>ZT,normalize:()=>QT,random:()=>r3,round:()=>YT,scale:()=>qT,scaleAndAdd:()=>KT,set:()=>zT,sqrDist:()=>h3,sqrLen:()=>p3,squaredDistance:()=>qm,squaredLength:()=>Zm,str:()=>i3,sub:()=>c3,subtract:()=>jm,transformMat4:()=>Mf,transformQuat:()=>n3,zero:()=>s3});function $m(){let r=new fe(4);return fe!=Float32Array&&(r[0]=0,r[1]=0,r[2]=0,r[3]=0),r}function LT(r){let e=new fe(4);return e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],e}function UT(r,e,t,n){let s=new fe(4);return s[0]=r,s[1]=e,s[2]=t,s[3]=n,s}function VT(r,e){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r}function zT(r,e,t,n,s){return r[0]=e,r[1]=t,r[2]=n,r[3]=s,r}function WT(r,e,t){return r[0]=e[0]+t[0],r[1]=e[1]+t[1],r[2]=e[2]+t[2],r[3]=e[3]+t[3],r}function jm(r,e,t){return r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],r[3]=e[3]-t[3],r}function Hm(r,e,t){return r[0]=e[0]*t[0],r[1]=e[1]*t[1],r[2]=e[2]*t[2],r[3]=e[3]*t[3],r}function Xm(r,e,t){return r[0]=e[0]/t[0],r[1]=e[1]/t[1],r[2]=e[2]/t[2],r[3]=e[3]/t[3],r}function $T(r,e){return r[0]=Math.ceil(e[0]),r[1]=Math.ceil(e[1]),r[2]=Math.ceil(e[2]),r[3]=Math.ceil(e[3]),r}function jT(r,e){return r[0]=Math.floor(e[0]),r[1]=Math.floor(e[1]),r[2]=Math.floor(e[2]),r[3]=Math.floor(e[3]),r}function HT(r,e,t){return r[0]=Math.min(e[0],t[0]),r[1]=Math.min(e[1],t[1]),r[2]=Math.min(e[2],t[2]),r[3]=Math.min(e[3],t[3]),r}function XT(r,e,t){return r[0]=Math.max(e[0],t[0]),r[1]=Math.max(e[1],t[1]),r[2]=Math.max(e[2],t[2]),r[3]=Math.max(e[3],t[3]),r}function YT(r,e){return r[0]=et(e[0]),r[1]=et(e[1]),r[2]=et(e[2]),r[3]=et(e[3]),r}function qT(r,e,t){return r[0]=e[0]*t,r[1]=e[1]*t,r[2]=e[2]*t,r[3]=e[3]*t,r}function KT(r,e,t,n){return r[0]=e[0]+t[0]*n,r[1]=e[1]+t[1]*n,r[2]=e[2]+t[2]*n,r[3]=e[3]+t[3]*n,r}function Ym(r,e){let t=e[0]-r[0],n=e[1]-r[1],s=e[2]-r[2],i=e[3]-r[3];return Math.sqrt(t*t+n*n+s*s+i*i)}function qm(r,e){let t=e[0]-r[0],n=e[1]-r[1],s=e[2]-r[2],i=e[3]-r[3];return t*t+n*n+s*s+i*i}function Km(r){let e=r[0],t=r[1],n=r[2],s=r[3];return Math.sqrt(e*e+t*t+n*n+s*s)}function Zm(r){let e=r[0],t=r[1],n=r[2],s=r[3];return e*e+t*t+n*n+s*s}function ZT(r,e){return r[0]=-e[0],r[1]=-e[1],r[2]=-e[2],r[3]=-e[3],r}function GT(r,e){return r[0]=1/e[0],r[1]=1/e[1],r[2]=1/e[2],r[3]=1/e[3],r}function QT(r,e){let t=e[0],n=e[1],s=e[2],i=e[3],o=t*t+n*n+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),r[0]=t*o,r[1]=n*o,r[2]=s*o,r[3]=i*o,r}function JT(r,e){return r[0]*e[0]+r[1]*e[1]+r[2]*e[2]+r[3]*e[3]}function e3(r,e,t,n){let s=t[0]*n[1]-t[1]*n[0],i=t[0]*n[2]-t[2]*n[0],o=t[0]*n[3]-t[3]*n[0],a=t[1]*n[2]-t[2]*n[1],c=t[1]*n[3]-t[3]*n[1],l=t[2]*n[3]-t[3]*n[2],u=e[0],f=e[1],h=e[2],d=e[3];return r[0]=f*l-h*c+d*a,r[1]=-(u*l)+h*o-d*i,r[2]=u*c-f*o+d*s,r[3]=-(u*a)+f*i-h*s,r}function t3(r,e,t,n){let s=e[0],i=e[1],o=e[2],a=e[3];return r[0]=s+n*(t[0]-s),r[1]=i+n*(t[1]-i),r[2]=o+n*(t[2]-o),r[3]=a+n*(t[3]-a),r}function r3(r,e){e=e===void 0?1:e;let t,n,s,i,o,a;do t=Pt()*2-1,n=Pt()*2-1,o=t*t+n*n;while(o>=1);do s=Pt()*2-1,i=Pt()*2-1,a=s*s+i*i;while(a>=1);let c=Math.sqrt((1-o)/a);return r[0]=e*t,r[1]=e*n,r[2]=e*s*c,r[3]=e*i*c,r}function Mf(r,e,t){let n=e[0],s=e[1],i=e[2],o=e[3];return r[0]=t[0]*n+t[4]*s+t[8]*i+t[12]*o,r[1]=t[1]*n+t[5]*s+t[9]*i+t[13]*o,r[2]=t[2]*n+t[6]*s+t[10]*i+t[14]*o,r[3]=t[3]*n+t[7]*s+t[11]*i+t[15]*o,r}function n3(r,e,t){let n=e[0],s=e[1],i=e[2],o=t[0],a=t[1],c=t[2],l=t[3],u=l*n+a*i-c*s,f=l*s+c*n-o*i,h=l*i+o*s-a*n,d=-o*n-a*s-c*i;return r[0]=u*l+d*-o+f*-c-h*-a,r[1]=f*l+d*-a+h*-o-u*-c,r[2]=h*l+d*-c+u*-a-f*-o,r[3]=e[3],r}function s3(r){return r[0]=0,r[1]=0,r[2]=0,r[3]=0,r}function i3(r){return`vec4(${r[0]}, ${r[1]}, ${r[2]}, ${r[3]})`}function o3(r,e){return r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]&&r[3]===e[3]}function a3(r,e){let t=r[0],n=r[1],s=r[2],i=r[3],o=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(t-o)<=1e-6*Math.max(1,Math.abs(t),Math.abs(o))&&Math.abs(n-a)<=1e-6*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))&&Math.abs(i-l)<=1e-6*Math.max(1,Math.abs(i),Math.abs(l))}var c3=jm,l3=Hm,u3=Xm,f3=Ym,h3=qm,d3=Km,p3=Zm,m3=function(){let r=$m();return function(e,t,n,s,i,o){let a,c;for(t||(t=4),n||(n=0),s?c=Math.min(s*t+n,e.length):c=e.length,a=n;a<c;a+=t)r[0]=e[a],r[1]=e[a+1],r[2]=e[a+2],r[3]=e[a+3],i(r,r,o),e[a]=r[0],e[a+1]=r[1],e[a+2]=r[2],e[a+3]=r[3];return e}}();var Nf;(function(r){r[r.COL0ROW0=0]="COL0ROW0",r[r.COL0ROW1=1]="COL0ROW1",r[r.COL0ROW2=2]="COL0ROW2",r[r.COL0ROW3=3]="COL0ROW3",r[r.COL1ROW0=4]="COL1ROW0",r[r.COL1ROW1=5]="COL1ROW1",r[r.COL1ROW2=6]="COL1ROW2",r[r.COL1ROW3=7]="COL1ROW3",r[r.COL2ROW0=8]="COL2ROW0",r[r.COL2ROW1=9]="COL2ROW1",r[r.COL2ROW2=10]="COL2ROW2",r[r.COL2ROW3=11]="COL2ROW3",r[r.COL3ROW0=12]="COL3ROW0",r[r.COL3ROW1=13]="COL3ROW1",r[r.COL3ROW2=14]="COL3ROW2",r[r.COL3ROW3=15]="COL3ROW3"})(Nf||(Nf={}));var g3=45*Math.PI/180,_3=1,Of=.1,kf=500,y3=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Q=class extends La{static get IDENTITY(){return b3()}static get ZERO(){return x3()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Nf}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,n,s,i,o,a,c,l,u,f,h,d,m,y,_){return this[0]=e,this[1]=t,this[2]=n,this[3]=s,this[4]=i,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=u,this[10]=f,this[11]=h,this[12]=d,this[13]=m,this[14]=y,this[15]=_,this.check()}setRowMajor(e,t,n,s,i,o,a,c,l,u,f,h,d,m,y,_){return this[0]=e,this[1]=i,this[2]=l,this[3]=d,this[4]=t,this[5]=o,this[6]=u,this[7]=m,this[8]=n,this[9]=a,this[10]=f,this[11]=y,this[12]=s,this[13]=c,this[14]=h,this[15]=_,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(y3)}fromObject(e){return this.check()}fromQuaternion(e){return Ef(this,e),this.check()}frustum(e){let{left:t,right:n,bottom:s,top:i,near:o=Of,far:a=kf}=e;return a===1/0?T3(this,t,n,s,i,o):Rf(this,t,n,s,i,o,a),this.check()}lookAt(e){let{eye:t,center:n=[0,0,0],up:s=[0,1,0]}=e;return Cf(this,t,n,s),this.check()}ortho(e){let{left:t,right:n,bottom:s,top:i,near:o=Of,far:a=kf}=e;return Pf(this,t,n,s,i,o,a),this.check()}orthographic(e){let{fovy:t=g3,aspect:n=_3,focalDistance:s=1,near:i=Of,far:o=kf}=e;Gm(t);let a=t/2,c=s*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:i,far:o})}perspective(e){let{fovy:t=45*Math.PI/180,aspect:n=1,near:s=.1,far:i=500}=e;return Gm(t),If(this,t,n,s,i),this.check()}determinant(){return xf(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let n=this.getScale(t),s=1/n[0],i=1/n[1],o=1/n[2];return e[0]=this[0]*s,e[1]=this[1]*i,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*s,e[5]=this[5]*i,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*s,e[9]=this[9]*i,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];let n=this.getScale(t),s=1/n[0],i=1/n[1],o=1/n[2];return e[0]=this[0]*s,e[1]=this[1]*i,e[2]=this[2]*o,e[3]=this[4]*s,e[4]=this[5]*i,e[5]=this[6]*o,e[6]=this[8]*s,e[7]=this[9]*i,e[8]=this[10]*o,e}transpose(){return _f(this,this),this.check()}invert(){return yf(this,this),this.check()}multiplyLeft(e){return si(this,e,this),this.check()}multiplyRight(e){return si(this,this,e),this.check()}rotateX(e){return vf(this,this,e),this.check()}rotateY(e){return Af(this,this,e),this.check()}rotateZ(e){return Sf(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return wf(this,this,e,t),this.check()}scale(e){return Tf(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return bf(this,this,e),this.check()}transform(e,t){return e.length===4?(t=Mf(t||[-0,-0,-0,-0],e,this),Oa(t,4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){let{length:n}=e,s;switch(n){case 2:s=af(t||[-0,-0],e,this);break;case 3:s=ni(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Oa(s,e.length),s}transformAsVector(e,t){let n;switch(e.length){case 2:n=Im(t||[-0,-0],e,this);break;case 3:n=Da(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Oa(n,e.length),n}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,n){return this.identity().translate([e,t,n])}},Ua,Va;function x3(){return Ua||(Ua=new Q([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Ua)),Ua}function b3(){return Va||(Va=new Q,Object.freeze(Va)),Va}function Gm(r){if(r>Math.PI*2)throw Error("expected radians")}function T3(r,e,t,n,s,i){let o=2*i/(t-e),a=2*i/(s-n),c=(t+e)/(t-e),l=(s+n)/(s-n),u=-1,f=-1,h=-2*i;return r[0]=o,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=a,r[6]=0,r[7]=0,r[8]=c,r[9]=l,r[10]=u,r[11]=f,r[12]=0,r[13]=0,r[14]=h,r[15]=0,r}var Qm=1e-6,w3=6371e3,ft=class{constructor({phi:e=0,theta:t=0,radius:n=1,bearing:s,pitch:i,altitude:o,radiusScale:a=w3}={}){this.phi=e,this.theta=t,this.radius=n||o||1,this.radiusScale=a||1,s!==void 0&&(this.bearing=s),i!==void 0&&(this.pitch=i),this.check()}toString(){return this.formatString(ge)}formatString({printTypes:e=!1}){let t=ri;return`${e?"Spherical":""}[rho:${t(this.radius)},theta:${t(this.theta)},phi:${t(this.phi)}]`}equals(e){return He(this.radius,e.radius)&&He(this.theta,e.theta)&&He(this.phi,e.phi)}exactEquals(e){return this.radius===e.radius&&this.theta===e.theta&&this.phi===e.phi}get bearing(){return 180-Tr(this.phi)}set bearing(e){this.phi=Math.PI-Jn(e)}get pitch(){return Tr(this.theta)}set pitch(e){this.theta=Jn(e)}get longitude(){return Tr(this.phi)}get latitude(){return Tr(this.theta)}get lng(){return Tr(this.phi)}get lat(){return Tr(this.theta)}get z(){return(this.radius-1)*this.radiusScale}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this.check()}clone(){return new ft().copy(this)}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this.check()}fromLngLatZ([e,t,n]){return this.radius=1+n/this.radiusScale,this.phi=Jn(t),this.theta=Jn(e),this.check()}fromVector3(e){return this.radius=Fa(e),this.radius>0&&(this.theta=Math.atan2(e[0],e[1]),this.phi=Math.acos(ee(e[2]/this.radius,-1,1))),this.check()}toVector3(){return new G(0,0,this.radius).rotateX({radians:this.theta}).rotateZ({radians:this.phi})}makeSafe(){return this.phi=Math.max(Qm,Math.min(Math.PI-Qm,this.phi)),this}check(){if(!Number.isFinite(this.phi)||!Number.isFinite(this.theta)||!(this.radius>0))throw new Error("SphericalCoordinates: some fields set to invalid numbers");return this}};function Df(r,e=[],t=0){let n=Math.fround(r),s=r-n;return e[t]=n,e[t+1]=s,e}function Jm(r){return r-Math.fround(r)}function eg(r){let e=new Float32Array(32);for(let t=0;t<4;++t)for(let n=0;n<4;++n){let s=t*4+n;Df(r[n*4+t],e,s*2)}return e}var v3=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
111
111
 
112
112
  // All these functions are for substituting tan() function from Intel GPU only
113
113
  const float TWO_PI = 6.2831854820251465;
@@ -257,7 +257,7 @@ float tan_fp32(float a) {
257
257
  return tan(a);
258
258
  #endif
259
259
  }
260
- `,If={name:"fp32",vs:d3};var jm=`
260
+ `,Ff={name:"fp32",vs:v3};var tg=`
261
261
  uniform fp64arithmeticUniforms {
262
262
  uniform float ONE;
263
263
  } fp64;
@@ -425,7 +425,7 @@ vec2 sqrt_fp64(vec2 a) {
425
425
  return sum_fp64(vec2(yn, 0.0), prod);
426
426
  #endif
427
427
  }
428
- `;var p3={ONE:1},Pf={name:"fp64arithmetic",vs:jm,defaultUniforms:p3,uniformTypes:{ONE:"f32"},fp64ify:Rf,fp64LowPart:Wm,fp64ifyMatrix4:$m};var m3=[0,1,1,1],g3=`uniform pickingUniforms {
428
+ `;var A3={ONE:1},Bf={name:"fp64arithmetic",vs:tg,defaultUniforms:A3,uniformTypes:{ONE:"f32"},fp64ify:Df,fp64LowPart:Jm,fp64ifyMatrix4:eg};var S3=[0,1,1,1],E3=`uniform pickingUniforms {
429
429
  float isActive;
430
430
  float isAttribute;
431
431
  float isHighlightActive;
@@ -496,7 +496,7 @@ void picking_setPickingAttribute(vec3 value) {
496
496
  picking_vRGBcolor_Avalid.rgb = value;
497
497
  }
498
498
  }
499
- `,_3=`uniform pickingUniforms {
499
+ `,R3=`uniform pickingUniforms {
500
500
  float isActive;
501
501
  float isAttribute;
502
502
  float isHighlightActive;
@@ -552,7 +552,7 @@ vec4 picking_filterColor(vec4 color) {
552
552
  vec4 highlightColor = picking_filterHighlightColor(color);
553
553
  return picking_filterPickingColor(highlightColor);
554
554
  }
555
- `,Fa={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:m3},vs:g3,fs:_3,getUniforms:y3};function y3(r={},e){let t={};if(r.highlightedObjectColor!==void 0)if(r.highlightedObjectColor===null)t.isHighlightActive=!1;else{t.isHighlightActive=!0;let n=r.highlightedObjectColor.slice(0,3);t.highlightedObjectColor=n}if(r.highlightColor){let n=Array.from(r.highlightColor,s=>s/255);Number.isFinite(n[3])||(n[3]=1),t.highlightColor=n}return r.isActive!==void 0&&(t.isActive=Boolean(r.isActive),t.isAttribute=Boolean(r.isAttribute)),r.useFloatColors!==void 0&&(t.useFloatColors=Boolean(r.useFloatColors)),t}H();var Cf=`precision highp int;
555
+ `,za={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:S3},vs:E3,fs:R3,getUniforms:I3};function I3(r={},e){let t={};if(r.highlightedObjectColor!==void 0)if(r.highlightedObjectColor===null)t.isHighlightActive=!1;else{t.isHighlightActive=!0;let n=r.highlightedObjectColor.slice(0,3);t.highlightedObjectColor=n}if(r.highlightColor){let n=Array.from(r.highlightColor,s=>s/255);Number.isFinite(n[3])||(n[3]=1),t.highlightColor=n}return r.isActive!==void 0&&(t.isActive=Boolean(r.isActive),t.isAttribute=Boolean(r.isAttribute)),r.useFloatColors!==void 0&&(t.useFloatColors=Boolean(r.useFloatColors)),t}H();var Lf=`precision highp int;
556
556
 
557
557
  // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
558
558
  struct AmbientLight {
@@ -626,7 +626,7 @@ float getPointLightAttenuation(PointLight pointLight, float distance) {
626
626
  }
627
627
 
628
628
  // #endif
629
- `;var Hm=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
629
+ `;var rg=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
630
630
  struct AmbientLight {
631
631
  color: vec3<f32>,
632
632
  };
@@ -677,13 +677,13 @@ fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
677
677
  + pointLight.attenuation.y * distance
678
678
  + pointLight.attenuation.z * distance * distance;
679
679
  }
680
- `;var x3=5,b3=255,ni;(function(r){r[r.POINT=0]="POINT",r[r.DIRECTIONAL=1]="DIRECTIONAL"})(ni||(ni={}));var en={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",lightType:"i32",directionalLightCount:"i32",pointLightCount:"i32",ambientColor:"vec3<f32>",lightColor0:"vec3<f32>",lightPosition0:"vec3<f32>",lightDirection0:"vec3<f32>",lightAttenuation0:"vec3<f32>",lightColor1:"vec3<f32>",lightPosition1:"vec3<f32>",lightDirection1:"vec3<f32>",lightAttenuation1:"vec3<f32>",lightColor2:"vec3<f32>",lightPosition2:"vec3<f32>",lightDirection2:"vec3<f32>",lightAttenuation2:"vec3<f32>"},defaultUniforms:{enabled:1,lightType:ni.POINT,directionalLightCount:0,pointLightCount:0,ambientColor:[.1,.1,.1],lightColor0:[1,1,1],lightPosition0:[1,1,2],lightDirection0:[1,1,1],lightAttenuation0:[1,0,0],lightColor1:[1,1,1],lightPosition1:[1,1,2],lightDirection1:[1,1,1],lightAttenuation1:[1,0,0],lightColor2:[1,1,1],lightPosition2:[1,1,2],lightDirection2:[1,1,1],lightAttenuation2:[1,0,0]},source:Hm,vs:Cf,fs:Cf,getUniforms:T3};function T3(r,e={}){if(r=r&&{...r},!r)return{...en.defaultUniforms};r.lights&&(r={...r,...v3(r.lights),lights:void 0});let{ambientLight:t,pointLights:n,directionalLights:s}=r||{};if(!(t||n&&n.length>0||s&&s.length>0))return{...en.defaultUniforms,enabled:0};let o={...en.defaultUniforms,...e,...w3({ambientLight:t,pointLights:n,directionalLights:s})};return r.enabled!==void 0&&(o.enabled=r.enabled?1:0),o}function w3({ambientLight:r,pointLights:e=[],directionalLights:t=[]}){let n={};n.ambientColor=Mf(r);let s=0;for(let i of e){n.lightType=ni.POINT;let o=s;n[`lightColor${o}`]=Mf(i),n[`lightPosition${o}`]=i.position,n[`lightAttenuation${o}`]=i.attenuation||[1,0,0],s++}for(let i of t){n.lightType=ni.DIRECTIONAL;let o=s;n[`lightColor${o}`]=Mf(i),n[`lightDirection${o}`]=i.direction,s++}return s>x3&&I.warn("MAX_LIGHTS exceeded")(),n.directionalLightCount=t.length,n.pointLightCount=e.length,n}function v3(r){let e={pointLights:[],directionalLights:[]};for(let t of r||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;default:}return e}function Mf(r={}){let{color:e=[0,0,0],intensity:t=1}=r;return e.map(n=>n*t/b3)}var Ba=`uniform phongMaterialUniforms {
680
+ `;var P3=5,C3=255,ii;(function(r){r[r.POINT=0]="POINT",r[r.DIRECTIONAL=1]="DIRECTIONAL"})(ii||(ii={}));var tn={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",lightType:"i32",directionalLightCount:"i32",pointLightCount:"i32",ambientColor:"vec3<f32>",lightColor0:"vec3<f32>",lightPosition0:"vec3<f32>",lightDirection0:"vec3<f32>",lightAttenuation0:"vec3<f32>",lightColor1:"vec3<f32>",lightPosition1:"vec3<f32>",lightDirection1:"vec3<f32>",lightAttenuation1:"vec3<f32>",lightColor2:"vec3<f32>",lightPosition2:"vec3<f32>",lightDirection2:"vec3<f32>",lightAttenuation2:"vec3<f32>"},defaultUniforms:{enabled:1,lightType:ii.POINT,directionalLightCount:0,pointLightCount:0,ambientColor:[.1,.1,.1],lightColor0:[1,1,1],lightPosition0:[1,1,2],lightDirection0:[1,1,1],lightAttenuation0:[1,0,0],lightColor1:[1,1,1],lightPosition1:[1,1,2],lightDirection1:[1,1,1],lightAttenuation1:[1,0,0],lightColor2:[1,1,1],lightPosition2:[1,1,2],lightDirection2:[1,1,1],lightAttenuation2:[1,0,0]},source:rg,vs:Lf,fs:Lf,getUniforms:M3};function M3(r,e={}){if(r=r&&{...r},!r)return{...tn.defaultUniforms};r.lights&&(r={...r,...k3(r.lights),lights:void 0});let{ambientLight:t,pointLights:n,directionalLights:s}=r||{};if(!(t||n&&n.length>0||s&&s.length>0))return{...tn.defaultUniforms,enabled:0};let o={...tn.defaultUniforms,...e,...O3({ambientLight:t,pointLights:n,directionalLights:s})};return r.enabled!==void 0&&(o.enabled=r.enabled?1:0),o}function O3({ambientLight:r,pointLights:e=[],directionalLights:t=[]}){let n={};n.ambientColor=Uf(r);let s=0;for(let i of e){n.lightType=ii.POINT;let o=s;n[`lightColor${o}`]=Uf(i),n[`lightPosition${o}`]=i.position,n[`lightAttenuation${o}`]=i.attenuation||[1,0,0],s++}for(let i of t){n.lightType=ii.DIRECTIONAL;let o=s;n[`lightColor${o}`]=Uf(i),n[`lightDirection${o}`]=i.direction,s++}return s>P3&&I.warn("MAX_LIGHTS exceeded")(),n.directionalLightCount=t.length,n.pointLightCount=e.length,n}function k3(r){let e={pointLights:[],directionalLights:[]};for(let t of r||[])switch(t.type){case"ambient":e.ambientLight=t;break;case"directional":e.directionalLights?.push(t);break;case"point":e.pointLights?.push(t);break;default:}return e}function Uf(r={}){let{color:e=[0,0,0],intensity:t=1}=r;return e.map(n=>n*t/C3)}var Wa=`uniform phongMaterialUniforms {
681
681
  uniform float ambient;
682
682
  uniform float diffuse;
683
683
  uniform float shininess;
684
684
  uniform vec3 specularColor;
685
685
  } material;
686
- `,La=`#define MAX_LIGHTS 3
686
+ `,$a=`#define MAX_LIGHTS 3
687
687
 
688
688
  uniform phongMaterialUniforms {
689
689
  uniform float ambient;
@@ -730,7 +730,7 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positio
730
730
 
731
731
  return lightColor;
732
732
  }
733
- `;var Ua=`struct phongMaterialUniforms {
733
+ `;var ja=`struct phongMaterialUniforms {
734
734
  ambient: f32,
735
735
  diffuse: f32,
736
736
  shininess: f32,
@@ -815,7 +815,7 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
815
815
  }
816
816
  return lightColor;
817
817
  }
818
- `;var si={props:{},name:"gouraudMaterial",vs:La.replace("phongMaterial","gouraudMaterial"),fs:Ba.replace("phongMaterial","gouraudMaterial"),source:Ua.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[en],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(r){let e={...r};return e.specularColor&&(e.specularColor=e.specularColor.map(t=>t/255)),{...si.defaultUniforms,...e}}};var ii={name:"phongMaterial",dependencies:[en],source:Ua,vs:Ba,fs:La,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(r){let e={...r};return e.specularColor&&(e.specularColor=e.specularColor.map(t=>t/255)),{...ii.defaultUniforms,...e}}};H();var Of={};function xe(r="id"){Of[r]=Of[r]||1;let e=Of[r]++;return`${r}-${e}`}var Va=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||xe("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&W.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}};function Xm(r,e){if(e instanceof Va)return e;let t=A3(r,e),{attributes:n,bufferLayout:s}=S3(r,e);return new Va({topology:e.topology||"triangle-list",bufferLayout:s,vertexCount:e.vertexCount,indices:t,attributes:n})}function A3(r,e){if(!e.indices)return;let t=e.indices.value;return r.createBuffer({usage:W.INDEX,data:t})}function S3(r,e){let t=[],n={};for(let[i,o]of Object.entries(e.attributes)){let a=i;switch(i){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}if(o){n[a]=r.createBuffer({data:o.value,id:`${i}-buffer`});let{value:c,size:l,normalized:u}=o;t.push({name:a,format:ql(c,l,u)})}}let s=e._calculateVertexCount(e.attributes,e.indices);return{attributes:n,bufferLayout:t,vertexCount:s}}H();var kf=class{static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new kf(e),e._lumaData.defaultPipelineFactory}device;cachingEnabled;destroyPolicy;debug;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e,this.cachingEnabled=e.props._cachePipelines,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=e.props.debugFactories}createRenderPipeline(e){if(!this.cachingEnabled)return this.device.createRenderPipeline(e);let t={...Qe.defaultProps,...e},n=this._renderPipelineCache,s=this._hashRenderPipeline(t),i=n[s]?.pipeline;return i?(n[s].useCount++,this.debug&&I.log(3,`${this}: ${n[s].pipeline} reused, count=${n[s].useCount}, (id=${e.id})`)()):(i=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:xe("unnamed-cached")}),i.hash=s,n[s]={pipeline:i,useCount:1},this.debug&&I.log(3,`${this}: ${i} created, count=${n[s].useCount}`)()),i}createComputePipeline(e){if(!this.cachingEnabled)return this.device.createComputePipeline(e);let t={...Yr.defaultProps,...e},n=this._computePipelineCache,s=this._hashComputePipeline(t),i=n[s]?.pipeline;return i?(n[s].useCount++,this.debug&&I.log(3,`${this}: ${n[s].pipeline} reused, count=${n[s].useCount}, (id=${e.id})`)()):(i=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),i.hash=s,n[s]={pipeline:i,useCount:1},this.debug&&I.log(3,`${this}: ${i} created, count=${n[s].useCount}`)()),i}release(e){if(!this.cachingEnabled){e.destroy();return}let t=this._getCache(e),n=e.hash;t[n].useCount--,t[n].useCount===0?(this._destroyPipeline(e),this.debug&&I.log(3,`${this}: ${e} released and destroyed`)()):t[n].useCount<0?(I.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[n].useCount=0):this.debug&&I.log(3,`${this}: ${e} released, count=${t[n].useCount}`)()}_destroyPipeline(e){let t=this._getCache(e);switch(this.destroyPolicy){case"never":return!1;case"unused":return delete t[e.hash],e.destroy(),!0}}_getCache(e){let t;if(e instanceof Yr&&(t=this._computePipelineCache),e instanceof Qe&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){let{type:t}=this.device,n=this._getHash(e.shader.source);return`${t}/C/${n}`}_hashRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,n=e.fs?this._getHash(e.fs.source):0,s="-",i=this._getHash(JSON.stringify(e.bufferLayout)),{type:o}=this.device;switch(o){case"webgl":return`${o}/R/${t}/${n}V${s}BL${i}`;case"webgpu":default:let a=this._getHash(JSON.stringify(e.parameters));return`${o}/R/${t}/${n}V${s}T${e.topology}P${a}BL${i}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}},oi=kf;L(oi,"defaultProps",{...Qe.defaultProps});H();var Nf=class{static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new Nf(e),e._lumaData.defaultShaderFactory}device;cachingEnabled;destroyPolicy;debug;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e,this.cachingEnabled=e.props._cacheShaders,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=!0}createShader(e){if(!this.cachingEnabled)return this.device.createShader(e);let t=this._hashShader(e),n=this._cache[t];if(n)n.useCount++,this.debug&&I.log(3,`${this}: Reusing shader ${n.shader.id} count=${n.useCount}`)();else{let s=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=n={shader:s,useCount:1},this.debug&&I.log(3,`${this}: Created new shader ${s.id}`)()}return n.shader}release(e){if(!this.cachingEnabled){e.destroy();return}let t=this._hashShader(e),n=this._cache[t];if(n)if(n.useCount--,n.useCount===0)this.destroyPolicy==="unused"&&(delete this._cache[t],n.shader.destroy(),this.debug&&I.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(n.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.debug&&I.log(3,`${this}: Releasing shader ${e.id} count=${n.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}},ai=Nf;L(ai,"defaultProps",{..._r.defaultProps});function Ym(r,e){let t={},n="Values";if(r.attributes.length===0&&!r.varyings?.length)return{"No attributes or varyings":{[n]:"N/A"}};for(let s of r.attributes)if(s){let i=`${s.location} ${s.name}: ${s.type}`;t[`in ${i}`]={[n]:s.stepMode||"vertex"}}for(let s of r.varyings||[]){let i=`${s.location} ${s.name}`;t[`out ${i}`]={[n]:JSON.stringify(s)}}return t}var ve=null,Df=null;function qm(r,{id:e,minimap:t,opaque:n,top:s="0",left:i="0",rgbaScale:o=1}){ve||(ve=document.createElement("canvas"),ve.id=e,ve.title=e,ve.style.zIndex="100",ve.style.position="absolute",ve.style.top=s,ve.style.left=i,ve.style.border="blue 5px solid",ve.style.transform="scaleY(-1)",document.body.appendChild(ve),Df=ve.getContext("2d")),(ve.width!==r.width||ve.height!==r.height)&&(ve.width=r.width/2,ve.height=r.height/2,ve.style.width="400px",ve.style.height="400px");let a=r.device.readPixelsToArrayWebGL(r),c=Df?.createImageData(r.width,r.height);if(c){for(let u=0;u<a.length;u+=4)c.data[0+u+0]=a[u+0]*o,c.data[0+u+1]=a[u+1]*o,c.data[0+u+2]=a[u+2]*o,c.data[0+u+3]=n?255:a[u+3]*o;Df?.putImageData(c,0,0)}}function za(r,e,t){if(r===e)return!0;if(!t||!r||!e)return!1;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(let n=0;n<r.length;n++)if(!za(r[n],e[n],t-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof r=="object"&&typeof e=="object"){let n=Object.keys(r),s=Object.keys(e);if(n.length!==s.length)return!1;for(let i of n)if(!e.hasOwnProperty(i)||!za(r[i],e[i],t-1))return!1;return!0}return!1}H();var Qn=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(t=>t.attribute):[e.name]}mergeBufferLayouts(e,t){let n=[...e];for(let s of t){let i=n.findIndex(o=>o.name===s.name);i<0?n.push(s):n[i]=s}return n}getBufferIndex(e){let t=this.bufferLayouts.findIndex(n=>n.name===e);return t===-1&&I.warn(`BufferLayout: Missing buffer for "${e}".`)(),t}};function Km(r,e){let t=Object.fromEntries(r.attributes.map(s=>[s.name,s.location])),n=e.slice();return n.sort((s,i)=>{let o=s.attributes?s.attributes.map(u=>u.attribute):[s.name],a=i.attributes?i.attributes.map(u=>u.attribute):[i.name],c=Math.min(...o.map(u=>t[u])),l=Math.min(...a.map(u=>t[u]));return c-l}),n}H();function Zm(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Gm(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number":!1}function Ff(r){return Zm(r)||Gm(r)}function E3(r){return Ff(r)||typeof r=="number"||typeof r=="boolean"}function Qm(r){let e={bindings:{},uniforms:{}};return Object.keys(r).forEach(t=>{let n=r[t];E3(n)?e.uniforms[t]=n:e.bindings[t]=n}),e}var Wa=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,t){Object.assign(this.options,t);let n=zn(Object.values(e).filter(s=>s.dependencies));for(let s of n)e[s.name]=s;I.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[s,i]of Object.entries(e))this._addModule(i),i.name&&s!==i.name&&!this.options.disableWarnings&&I.warn(`Module name: ${s} vs ${i.name}`)()}destroy(){}setProps(e){for(let t of Object.keys(e)){let n=t,s=e[n]||{},i=this.modules[n];if(!i){this.options.disableWarnings||I.warn(`Module ${t} not found`)();continue}let o=this.moduleUniforms[n],a=this.moduleBindings[n],c=i.getUniforms?.(s,o)||s,{uniforms:l,bindings:u}=Qm(c);this.moduleUniforms[n]={...o,...l},this.moduleBindings[n]={...a,...u}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){let e={};for(let[t,n]of Object.entries(this.moduleUniforms))for(let[s,i]of Object.entries(n))e[`${t}.${s}`]={type:this.modules[t].uniformTypes?.[s],value:String(i)};return e}_addModule(e){let t=e.name;this.moduleUniforms[t]=e.defaultUniforms||{},this.moduleBindings[t]={}}};H();var R3="";async function Jm(r,e){let t=new Image;return t.crossOrigin=e?.crossOrigin||"anonymous",t.src=r.startsWith("http")?r:R3+r,await t.decode(),e?await createImageBitmap(t,e):await createImageBitmap(t)}var I3=["+X","-X","+Y","-Y","+Z","-Z"];var P3=["+X","-X","+Y","-Y","+Z","-Z"],Bf=class{device;id;props;texture;sampler;view;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get[Symbol.toStringTag](){return"AsyncTexture"}toString(){return`AsyncTexture:"${this.id}"(${this.isReady?"ready":"loading"})`}constructor(e,t){this.device=e;let n=xe("async-texture");this.props={...Bf.defaultProps,id:n,...t},this.id=this.props.id,t={...t},typeof t?.data=="string"&&t.dimension==="2d"&&(t.data=Jm(t.data)),t.mipmaps&&(t.mipLevels="auto"),this.ready=new Promise((s,i)=>{this.resolveReady=()=>{this.isReady=!0,s()},this.rejectReady=i}),this.initAsync(t)}async initAsync(e){let t=e.data,n=await eg(t).then(void 0,this.rejectReady);if(this.destroyed)return;let s=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:this.getTextureDataSize(n);if(!s)throw new Error("Texture size could not be determined");let i={...s,...e,data:void 0,mipLevels:1},o=this.device.getMipLevelCount(i.width,i.height);if(i.mipLevels=this.props.mipLevels==="auto"?o:Math.min(o,this.props.mipLevels),this.texture=this.device.createTexture(i),this.sampler=this.texture.sampler,this.view=this.texture.view,e.data)switch(this.props.dimension){case"1d":this._setTexture1DData(this.texture,n);break;case"2d":this._setTexture2DData(n);break;case"3d":this._setTexture3DData(this.texture,n);break;case"2d-array":this._setTextureArrayData(this.texture,n);break;case"cube":this._setTextureCubeData(this.texture,n);break;case"cube-array":this._setTextureCubeArrayData(this.texture,n);break}this.props.mipmaps&&this.generateMipmaps(),I.info(1,`${this} loaded`),this.resolveReady()}destroy(){this.texture&&(this.texture.destroy(),this.texture=null),this.destroyed=!0}generateMipmaps(){this.texture.generateMipmapsWebGL()}setSampler(e={}){this.texture.setSampler(e instanceof Ge?e:this.device.createSampler(e))}resize(e){if(!this.isReady)throw new Error("Cannot resize texture before it is ready");if(e.width===this.texture.width&&e.height===this.texture.height)return!1;if(this.texture){let t=this.texture;this.texture=t.clone(e),t.destroy()}return!0}isTextureLevelData(e){let t=e?.data;return ArrayBuffer.isView(t)}getTextureDataSize(e){if(!e||ArrayBuffer.isView(e))return null;if(Array.isArray(e))return this.getTextureDataSize(e[0]);if(this.device.isExternalImage(e))return this.device.getExternalImageSize(e);if(e&&typeof e=="object"&&e.constructor===Object){let n=Object.values(e)[0];return{width:n.width,height:n.height}}throw new Error("texture size deduction failed")}getCubeFaceDepth(e){switch(e){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(e)}}setTextureData(e){}_setTexture1DData(e,t){throw new Error("setTexture1DData not supported in WebGL.")}_setTexture2DData(e,t=0){if(!this.texture)throw new Error("Texture not initialized");let n=this._normalizeTextureData(e);n.length>1&&this.props.mipmaps!==!1&&I.warn(`Texture ${this.id} mipmap and multiple LODs.`)();for(let s=0;s<n.length;s++){let i=n[s];this.device.isExternalImage(i)?this.texture.copyExternalImage({image:i,depth:t,mipLevel:s,flipY:!0}):this.texture.copyImageData({data:i.data,mipLevel:s})}}_setTexture3DData(e,t){if(this.texture?.props.dimension!=="3d")throw new Error(this.id);for(let n=0;n<t.length;n++)this._setTexture2DData(t[n],n)}_setTextureCubeData(e,t){if(this.texture?.props.dimension!=="cube")throw new Error(this.id);for(let[n,s]of Object.entries(t)){let i=P3.indexOf(n);this._setTexture2DData(s,i)}}_setTextureArrayData(e,t){if(this.texture?.props.dimension!=="2d-array")throw new Error(this.id);for(let n=0;n<t.length;n++)this._setTexture2DData(t[n],n)}_setTextureCubeArrayData(e,t){throw new Error("setTextureCubeArrayData not supported in WebGL2.")}_setTextureCubeFaceData(e,t,n,s=0){Array.isArray(t)&&t.length>1&&this.props.mipmaps!==!1&&I.warn(`${this.id} has mipmap and multiple LODs.`)();let i=I3.indexOf(n);this._setTexture2DData(t,i)}_normalizeTextureData(e){let t=this.texture,n;return ArrayBuffer.isView(e)?n=[{data:e,width:t.width,height:t.height}]:Array.isArray(e)?n=e:n=[e],n}},tn=Bf;L(tn,"defaultProps",{...K.defaultProps,data:null,mipmaps:!1});async function eg(r){if(r=await r,Array.isArray(r))return await Promise.all(r.map(eg));if(r&&typeof r=="object"&&r.constructor===Object){let e=r,t=await Promise.all(Object.values(e)),n=Object.keys(e),s={};for(let i=0;i<n.length;i++)s[n[i]]=t[i];return s}return r}var rn=2,C3=1e4,Lf=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,t){this.props={...Lf.defaultProps,...t},t=this.props,this.id=t.id||xe("model"),this.device=e,Object.assign(this.userData,t.userData);let n=Object.fromEntries(this.props.modules?.map(c=>[c.name,c])||[]),s=t.shaderInputs||new Wa(n,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(s);let i=O3(e),o=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){let{source:c,getUniforms:l}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:i,...this.props,modules:o});this.source=c,this._getModuleUniforms=l,this.props.shaderLayout||=Ku(this.source)}else{let{vs:c,fs:l,getUniforms:u}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:i,...this.props,modules:o});this.vs=c,this.fs=l,this._getModuleUniforms=u}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||oi.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||ai.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let t=this._areBindingsLoading();if(t)return I.info(rn,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let n;try{e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();let s=this._getBindings();this.pipeline.setBindings(s,{disableWarnings:this.props.disableWarnings});let{indexBuffer:i}=this.vertexArray,o=i?i.byteLength/(i.indexType==="uint32"?4:2):void 0;n=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:o,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),n?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",n}setGeometry(e){this._gpuGeometry?.destroy();let t=e&&Xm(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");let n=new Qn(this.bufferLayout);this.bufferLayout=n.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let t=new Qn(this.bufferLayout);this.bufferLayout=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){za(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Us(this.shaderInputs.modules);for(let[t,n]of Object.entries(this.shaderInputs.modules))if(M3(n)){let s=this._uniformStore.getManagedUniformBuffer(this.device,t);this.bindings[`${t}Uniforms`]=s}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindingValues()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){let n=t?.disableWarnings??this.props.disableWarnings;e.indices&&I.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=Km(this.pipeline.shaderLayout,this.bufferLayout);let s=new Qn(this.bufferLayout);for(let[i,o]of Object.entries(e)){let a=s.getBufferLayout(i);if(!a){n||I.warn(`Model(${this.id}): Missing layout for buffer "${i}".`)();continue}let c=s.getAttributeNamesForBuffer(a),l=!1;for(let u of c){let f=this._attributeInfos[u];if(f){let h=this.device.type==="webgpu"?s.getBufferIndex(f.bufferName):f.location;this.vertexArray.setBuffer(h,o),l=!0}}!l&&!n&&I.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${i}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(let[n,s]of Object.entries(e)){let i=this._attributeInfos[n];i?this.vertexArray.setConstantWebGL(i.location,s):(t?.disableWarnings??this.props.disableWarnings)||I.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(e instanceof tn&&!e.isReady)return e.id;return!1}_getBindings(){let e={};for(let[t,n]of Object.entries(this.bindings))n instanceof tn?n.isReady&&(e[t]=n.texture):e[t]=n;return e}_getBindingsUpdateTimestamp(){let e=0;for(let t of Object.values(this.bindings))t instanceof gr?e=Math.max(e,t.texture.updateTimestamp):t instanceof W||t instanceof K?e=Math.max(e,t.updateTimestamp):t instanceof tn?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof Ge||(e=Math.max(e,t.buffer.updateTimestamp));return e}_setGeometryAttributes(e){let t={...e.attributes};for(let[n]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(s=>s.name===n)&&n!=="positions"&&delete t[n];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(I.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),s=null;this.source?s=n:this.fs&&(s=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindings:this._getBindings(),vs:n,fs:s}),this._attributeInfos=Yo(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=I.level>3?0:C3;I.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,I.group(rn,`>>> DRAWING MODEL ${this.id}`,{collapsed:I.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=Ym(this.pipeline.shaderLayout,this.id);I.table(rn,e)();let t=this.shaderInputs.getDebugTable();I.table(rn,t)();let n=this._getAttributeDebugTable();I.table(rn,this._attributeInfos)(),I.table(rn,n)(),I.groupEnd(rn)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;let n=e.props.framebuffer;n&&qm(n,{id:n.id,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[t,n]of Object.entries(this._attributeInfos)){let s=this.vertexArray.attributes[n.location];e[n.location]={name:t,type:n.shaderType,values:s?this._getBufferOrConstantValues(s,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:t}=this.vertexArray,n=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:n.toString()}}return e}_getBufferOrConstantValues(e,t){let n=jr(t);return(e instanceof W?new n(e.debugData):e).toString()}},Ye=Lf;L(Ye,"defaultProps",{...Qe.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:yr.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function M3(r){return Boolean(r.uniformTypes&&!k3(r.uniformTypes))}function O3(r){return{type:r.type,shaderLanguage:r.info.shadingLanguage,shaderLanguageVersion:r.info.shadingLanguageVersion,gpu:r.info.gpu,features:r.features}}function k3(r){for(let e in r)return!1;return!0}H();var $a=class{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,t=$a.defaultProps){if(!$a.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new Ye(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||Ws(),topology:t.topology||"point-list",varyings:t.outputs||t.varyings,...t}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let t=this.device.beginRenderPass(e);this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let t=this.getBuffer(e);if(!t)throw new Error("BufferTransform#getBuffer");if(t instanceof W)return t.readAsync();let{buffer:n,byteOffset:s=0,byteLength:i=n.byteLength}=t;return n.readAsync(s,i)}},pt=$a;L(pt,"defaultProps",{...Ye.defaultProps,outputs:void 0,feedbackBuffers:void 0});var N3="transform_output",ci=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,t){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new Ye(this.device,{id:t.id||xe("texture-transform-model"),fs:t.fs||Ws({input:t.targetTextureVarying,inputChannels:t.targetTextureChannels,output:N3}),vertexCount:t.vertexCount,...t}),this._initialize(t),Object.seal(this)}destroy(){this.model.destroy();for(let e of this.bindings)e.framebuffer?.destroy()}delete(){this.destroy()}run(e){let{framebuffer:t}=this.bindings[this.currentIndex],n=this.device.beginRenderPass({framebuffer:t,...e});this.model.draw(n),n.end(),this.device.submit()}getTargetTexture(){let{targetTexture:e}=this.bindings[this.currentIndex];return e}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(e){this._updateBindings(e)}_updateBindings(e){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e)}_updateBinding(e,{sourceBuffers:t,sourceTextures:n,targetTexture:s}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,n),Object.assign(e.sourceBuffers,t),s){e.targetTexture=s;let{width:i,height:o}=s;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:i,height:o,colorAttachments:[s]}),e.framebuffer.resize({width:i,height:o})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:t}=this.bindings[e];for(let n in t)t[n].sampler=this.sampler}};var mt=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:t={},indices:n=null,vertexCount:s=null}=e;this.id=e.id||xe("geometry"),this.topology=e.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(let[i,o]of Object.entries(t)){let a=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(i)}: must be typed array or object with value as typed array`);if((i==="POSITION"||i==="positions")&&!a.size&&(a.size=3),i==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else this.attributes[i]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=s||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let n=1/0;for(let s of Object.values(e)){let{value:i,size:o,constant:a}=s;!a&&i&&o!==void 0&&o>=1&&(n=Math.min(n,i.length/o))}return n}};var D3=`struct VertexInputs {
818
+ `;var oi={props:{},name:"gouraudMaterial",vs:$a.replace("phongMaterial","gouraudMaterial"),fs:Wa.replace("phongMaterial","gouraudMaterial"),source:ja.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[tn],uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(r){let e={...r};return e.specularColor&&(e.specularColor=e.specularColor.map(t=>t/255)),{...oi.defaultUniforms,...e}}};var ai={name:"phongMaterial",dependencies:[tn],source:ja,vs:Wa,fs:$a,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(r){let e={...r};return e.specularColor&&(e.specularColor=e.specularColor.map(t=>t/255)),{...ai.defaultUniforms,...e}}};H();var Vf={};function xe(r="id"){Vf[r]=Vf[r]||1;let e=Vf[r]++;return`${r}-${e}`}var Ha=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||xe("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&!(this.indices.usage&W.INDEX))throw new Error("Index buffer must have INDEX usage")}destroy(){this.indices?.destroy();for(let e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices||null}_calculateVertexCount(e){return e.byteLength/12}};function ng(r,e){if(e instanceof Ha)return e;let t=N3(r,e),{attributes:n,bufferLayout:s}=D3(r,e);return new Ha({topology:e.topology||"triangle-list",bufferLayout:s,vertexCount:e.vertexCount,indices:t,attributes:n})}function N3(r,e){if(!e.indices)return;let t=e.indices.value;return r.createBuffer({usage:W.INDEX,data:t})}function D3(r,e){let t=[],n={};for(let[i,o]of Object.entries(e.attributes)){let a=i;switch(i){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"COLOR_0":a="colors";break}if(o){n[a]=r.createBuffer({data:o.value,id:`${i}-buffer`});let{value:c,size:l,normalized:u}=o;t.push({name:a,format:Jl(c,l,u)})}}let s=e._calculateVertexCount(e.attributes,e.indices);return{attributes:n,bufferLayout:t,vertexCount:s}}H();var zf=class{static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new zf(e),e._lumaData.defaultPipelineFactory}device;cachingEnabled;destroyPolicy;debug;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e,this.cachingEnabled=e.props._cachePipelines,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=e.props.debugFactories}createRenderPipeline(e){if(!this.cachingEnabled)return this.device.createRenderPipeline(e);let t={...Ze.defaultProps,...e},n=this._renderPipelineCache,s=this._hashRenderPipeline(t),i=n[s]?.pipeline;return i?(n[s].useCount++,this.debug&&I.log(3,`${this}: ${n[s].pipeline} reused, count=${n[s].useCount}, (id=${e.id})`)()):(i=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:xe("unnamed-cached")}),i.hash=s,n[s]={pipeline:i,useCount:1},this.debug&&I.log(3,`${this}: ${i} created, count=${n[s].useCount}`)()),i}createComputePipeline(e){if(!this.cachingEnabled)return this.device.createComputePipeline(e);let t={...qr.defaultProps,...e},n=this._computePipelineCache,s=this._hashComputePipeline(t),i=n[s]?.pipeline;return i?(n[s].useCount++,this.debug&&I.log(3,`${this}: ${n[s].pipeline} reused, count=${n[s].useCount}, (id=${e.id})`)()):(i=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0}),i.hash=s,n[s]={pipeline:i,useCount:1},this.debug&&I.log(3,`${this}: ${i} created, count=${n[s].useCount}`)()),i}release(e){if(!this.cachingEnabled){e.destroy();return}let t=this._getCache(e),n=e.hash;t[n].useCount--,t[n].useCount===0?(this._destroyPipeline(e),this.debug&&I.log(3,`${this}: ${e} released and destroyed`)()):t[n].useCount<0?(I.error(`${this}: ${e} released, useCount < 0, resetting`)(),t[n].useCount=0):this.debug&&I.log(3,`${this}: ${e} released, count=${t[n].useCount}`)()}_destroyPipeline(e){let t=this._getCache(e);switch(this.destroyPolicy){case"never":return!1;case"unused":return delete t[e.hash],e.destroy(),!0}}_getCache(e){let t;if(e instanceof qr&&(t=this._computePipelineCache),e instanceof Ze&&(t=this._renderPipelineCache),!t)throw new Error(`${this}`);if(!t[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return t}_hashComputePipeline(e){let{type:t}=this.device,n=this._getHash(e.shader.source);return`${t}/C/${n}`}_hashRenderPipeline(e){let t=e.vs?this._getHash(e.vs.source):0,n=e.fs?this._getHash(e.fs.source):0,s="-",i=this._getHash(JSON.stringify(e.bufferLayout)),{type:o}=this.device;switch(o){case"webgl":return`${o}/R/${t}/${n}V${s}BL${i}`;case"webgpu":default:let a=this._getHash(JSON.stringify(e.parameters));return`${o}/R/${t}/${n}V${s}T${e.topology}P${a}BL${i}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}},ci=zf;L(ci,"defaultProps",{...Ze.defaultProps});H();var Wf=class{static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new Wf(e),e._lumaData.defaultShaderFactory}device;cachingEnabled;destroyPolicy;debug;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e,this.cachingEnabled=e.props._cacheShaders,this.destroyPolicy=e.props._cacheDestroyPolicy,this.debug=!0}createShader(e){if(!this.cachingEnabled)return this.device.createShader(e);let t=this._hashShader(e),n=this._cache[t];if(n)n.useCount++,this.debug&&I.log(3,`${this}: Reusing shader ${n.shader.id} count=${n.useCount}`)();else{let s=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=n={shader:s,useCount:1},this.debug&&I.log(3,`${this}: Created new shader ${s.id}`)()}return n.shader}release(e){if(!this.cachingEnabled){e.destroy();return}let t=this._hashShader(e),n=this._cache[t];if(n)if(n.useCount--,n.useCount===0)this.destroyPolicy==="unused"&&(delete this._cache[t],n.shader.destroy(),this.debug&&I.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(n.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.debug&&I.log(3,`${this}: Releasing shader ${e.id} count=${n.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}},li=Wf;L(li,"defaultProps",{...gr.defaultProps});function sg(r,e){let t={},n="Values";if(r.attributes.length===0&&!r.varyings?.length)return{"No attributes or varyings":{[n]:"N/A"}};for(let s of r.attributes)if(s){let i=`${s.location} ${s.name}: ${s.type}`;t[`in ${i}`]={[n]:s.stepMode||"vertex"}}for(let s of r.varyings||[]){let i=`${s.location} ${s.name}`;t[`out ${i}`]={[n]:JSON.stringify(s)}}return t}var ve=null,$f=null;function ig(r,{id:e,minimap:t,opaque:n,top:s="0",left:i="0",rgbaScale:o=1}){ve||(ve=document.createElement("canvas"),ve.id=e,ve.title=e,ve.style.zIndex="100",ve.style.position="absolute",ve.style.top=s,ve.style.left=i,ve.style.border="blue 5px solid",ve.style.transform="scaleY(-1)",document.body.appendChild(ve),$f=ve.getContext("2d")),(ve.width!==r.width||ve.height!==r.height)&&(ve.width=r.width/2,ve.height=r.height/2,ve.style.width="400px",ve.style.height="400px");let a=r.device.readPixelsToArrayWebGL(r),c=$f?.createImageData(r.width,r.height);if(c){for(let u=0;u<a.length;u+=4)c.data[0+u+0]=a[u+0]*o,c.data[0+u+1]=a[u+1]*o,c.data[0+u+2]=a[u+2]*o,c.data[0+u+3]=n?255:a[u+3]*o;$f?.putImageData(c,0,0)}}function Xa(r,e,t){if(r===e)return!0;if(!t||!r||!e)return!1;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(let n=0;n<r.length;n++)if(!Xa(r[n],e[n],t-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof r=="object"&&typeof e=="object"){let n=Object.keys(r),s=Object.keys(e);if(n.length!==s.length)return!1;for(let i of n)if(!e.hasOwnProperty(i)||!Xa(r[i],e[i],t-1))return!1;return!0}return!1}H();var ts=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(t=>t.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(t=>t.attribute):[e.name]}mergeBufferLayouts(e,t){let n=[...e];for(let s of t){let i=n.findIndex(o=>o.name===s.name);i<0?n.push(s):n[i]=s}return n}getBufferIndex(e){let t=this.bufferLayouts.findIndex(n=>n.name===e);return t===-1&&I.warn(`BufferLayout: Missing buffer for "${e}".`)(),t}};function og(r,e){let t=Object.fromEntries(r.attributes.map(s=>[s.name,s.location])),n=e.slice();return n.sort((s,i)=>{let o=s.attributes?s.attributes.map(u=>u.attribute):[s.name],a=i.attributes?i.attributes.map(u=>u.attribute):[i.name],c=Math.min(...o.map(u=>t[u])),l=Math.min(...a.map(u=>t[u]));return c-l}),n}H();function ag(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function cg(r){return Array.isArray(r)?r.length===0||typeof r[0]=="number":!1}function jf(r){return ag(r)||cg(r)}function F3(r){return jf(r)||typeof r=="number"||typeof r=="boolean"}function lg(r){let e={bindings:{},uniforms:{}};return Object.keys(r).forEach(t=>{let n=r[t];F3(n)?e.uniforms[t]=n:e.bindings[t]=n}),e}var Ya=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,t){Object.assign(this.options,t);let n=jn(Object.values(e).filter(s=>s.dependencies));for(let s of n)e[s.name]=s;I.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[s,i]of Object.entries(e))this._addModule(i),i.name&&s!==i.name&&!this.options.disableWarnings&&I.warn(`Module name: ${s} vs ${i.name}`)()}destroy(){}setProps(e){for(let t of Object.keys(e)){let n=t,s=e[n]||{},i=this.modules[n];if(!i){this.options.disableWarnings||I.warn(`Module ${t} not found`)();continue}let o=this.moduleUniforms[n],a=this.moduleBindings[n],c=i.getUniforms?.(s,o)||s,{uniforms:l,bindings:u}=lg(c);this.moduleUniforms[n]={...o,...l},this.moduleBindings[n]={...a,...u}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){let e={};for(let[t,n]of Object.entries(this.moduleUniforms))for(let[s,i]of Object.entries(n))e[`${t}.${s}`]={type:this.modules[t].uniformTypes?.[s],value:String(i)};return e}_addModule(e){let t=e.name;this.moduleUniforms[t]=e.defaultUniforms||{},this.moduleBindings[t]={}}};H();var B3="";async function ug(r,e){let t=new Image;return t.crossOrigin=e?.crossOrigin||"anonymous",t.src=r.startsWith("http")?r:B3+r,await t.decode(),e?await createImageBitmap(t,e):await createImageBitmap(t)}var L3=["+X","-X","+Y","-Y","+Z","-Z"];var U3=["+X","-X","+Y","-Y","+Z","-Z"],Hf=class{device;id;props;texture;sampler;view;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get[Symbol.toStringTag](){return"AsyncTexture"}toString(){return`AsyncTexture:"${this.id}"(${this.isReady?"ready":"loading"})`}constructor(e,t){this.device=e;let n=xe("async-texture");this.props={...Hf.defaultProps,id:n,...t},this.id=this.props.id,t={...t},typeof t?.data=="string"&&t.dimension==="2d"&&(t.data=ug(t.data)),t.mipmaps&&(t.mipLevels="auto"),this.ready=new Promise((s,i)=>{this.resolveReady=()=>{this.isReady=!0,s()},this.rejectReady=i}),this.initAsync(t)}async initAsync(e){let t=e.data,n=await fg(t).then(void 0,this.rejectReady);if(this.destroyed)return;let s=this.props.width&&this.props.height?{width:this.props.width,height:this.props.height}:this.getTextureDataSize(n);if(!s)throw new Error("Texture size could not be determined");let i={...s,...e,data:void 0,mipLevels:1},o=this.device.getMipLevelCount(i.width,i.height);if(i.mipLevels=this.props.mipLevels==="auto"?o:Math.min(o,this.props.mipLevels),this.texture=this.device.createTexture(i),this.sampler=this.texture.sampler,this.view=this.texture.view,e.data)switch(this.props.dimension){case"1d":this._setTexture1DData(this.texture,n);break;case"2d":this._setTexture2DData(n);break;case"3d":this._setTexture3DData(this.texture,n);break;case"2d-array":this._setTextureArrayData(this.texture,n);break;case"cube":this._setTextureCubeData(this.texture,n);break;case"cube-array":this._setTextureCubeArrayData(this.texture,n);break}this.props.mipmaps&&this.generateMipmaps(),I.info(1,`${this} loaded`),this.resolveReady()}destroy(){this.texture&&(this.texture.destroy(),this.texture=null),this.destroyed=!0}generateMipmaps(){this.texture.generateMipmapsWebGL()}setSampler(e={}){this.texture.setSampler(e instanceof Ke?e:this.device.createSampler(e))}resize(e){if(!this.isReady)throw new Error("Cannot resize texture before it is ready");if(e.width===this.texture.width&&e.height===this.texture.height)return!1;if(this.texture){let t=this.texture;this.texture=t.clone(e),t.destroy()}return!0}isTextureLevelData(e){let t=e?.data;return ArrayBuffer.isView(t)}getTextureDataSize(e){if(!e||ArrayBuffer.isView(e))return null;if(Array.isArray(e))return this.getTextureDataSize(e[0]);if(this.device.isExternalImage(e))return this.device.getExternalImageSize(e);if(e&&typeof e=="object"&&e.constructor===Object){let n=Object.values(e)[0];return{width:n.width,height:n.height}}throw new Error("texture size deduction failed")}getCubeFaceDepth(e){switch(e){case"+X":return 0;case"-X":return 1;case"+Y":return 2;case"-Y":return 3;case"+Z":return 4;case"-Z":return 5;default:throw new Error(e)}}setTextureData(e){}_setTexture1DData(e,t){throw new Error("setTexture1DData not supported in WebGL.")}_setTexture2DData(e,t=0){if(!this.texture)throw new Error("Texture not initialized");let n=this._normalizeTextureData(e);n.length>1&&this.props.mipmaps!==!1&&I.warn(`Texture ${this.id} mipmap and multiple LODs.`)();for(let s=0;s<n.length;s++){let i=n[s];this.device.isExternalImage(i)?this.texture.copyExternalImage({image:i,depth:t,mipLevel:s,flipY:!0}):this.texture.copyImageData({data:i.data,mipLevel:s})}}_setTexture3DData(e,t){if(this.texture?.props.dimension!=="3d")throw new Error(this.id);for(let n=0;n<t.length;n++)this._setTexture2DData(t[n],n)}_setTextureCubeData(e,t){if(this.texture?.props.dimension!=="cube")throw new Error(this.id);for(let[n,s]of Object.entries(t)){let i=U3.indexOf(n);this._setTexture2DData(s,i)}}_setTextureArrayData(e,t){if(this.texture?.props.dimension!=="2d-array")throw new Error(this.id);for(let n=0;n<t.length;n++)this._setTexture2DData(t[n],n)}_setTextureCubeArrayData(e,t){throw new Error("setTextureCubeArrayData not supported in WebGL2.")}_setTextureCubeFaceData(e,t,n,s=0){Array.isArray(t)&&t.length>1&&this.props.mipmaps!==!1&&I.warn(`${this.id} has mipmap and multiple LODs.`)();let i=L3.indexOf(n);this._setTexture2DData(t,i)}_normalizeTextureData(e){let t=this.texture,n;return ArrayBuffer.isView(e)?n=[{data:e,width:t.width,height:t.height}]:Array.isArray(e)?n=e:n=[e],n}},rn=Hf;L(rn,"defaultProps",{...K.defaultProps,data:null,mipmaps:!1});async function fg(r){if(r=await r,Array.isArray(r))return await Promise.all(r.map(fg));if(r&&typeof r=="object"&&r.constructor===Object){let e=r,t=await Promise.all(Object.values(e)),n=Object.keys(e),s={};for(let i=0;i<n.length;i++)s[n[i]]=t[i];return s}return r}var nn=2,V3=1e4,Xf=class{device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,t){this.props={...Xf.defaultProps,...t},t=this.props,this.id=t.id||xe("model"),this.device=e,Object.assign(this.userData,t.userData);let n=Object.fromEntries(this.props.modules?.map(c=>[c.name,c])||[]),s=t.shaderInputs||new Ya(n,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(s);let i=W3(e),o=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){let{source:c,getUniforms:l}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:i,...this.props,modules:o});this.source=c,this._getModuleUniforms=l,this.props.shaderLayout||=nf(this.source)}else{let{vs:c,fs:l,getUniforms:u}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:i,...this.props,modules:o});this.vs=c,this.fs=l,this._getModuleUniforms=u}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||ci.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||li.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");let e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let t=this._areBindingsLoading();if(t)return I.info(nn,`>>> DRAWING ABORTED ${this.id}: ${t} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let n;try{e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline();let s=this._getBindings();this.pipeline.setBindings(s,{disableWarnings:this.props.disableWarnings});let{indexBuffer:i}=this.vertexArray,o=i?i.byteLength/(i.indexType==="uint32"?4:2):void 0;n=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:o,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),n?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",n}setGeometry(e){this._gpuGeometry?.destroy();let t=e&&ng(this.device,e);if(t){this.setTopology(t.topology||"triangle-list");let n=new ts(this.bufferLayout);this.bufferLayout=n.mergeBufferLayouts(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)}this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let t=new ts(this.bufferLayout);this.bufferLayout=this._gpuGeometry?t.mergeBufferLayouts(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({shaderLayout:this.pipeline.shaderLayout,bufferLayout:this.pipeline.bufferLayout}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){Xa(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new zs(this.shaderInputs.modules);for(let[t,n]of Object.entries(this.shaderInputs.modules))if(z3(n)){let s=this._uniformStore.getManagedUniformBuffer(this.device,t);this.bindings[`${t}Uniforms`]=s}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindingValues()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){let n=t?.disableWarnings??this.props.disableWarnings;e.indices&&I.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=og(this.pipeline.shaderLayout,this.bufferLayout);let s=new ts(this.bufferLayout);for(let[i,o]of Object.entries(e)){let a=s.getBufferLayout(i);if(!a){n||I.warn(`Model(${this.id}): Missing layout for buffer "${i}".`)();continue}let c=s.getAttributeNamesForBuffer(a),l=!1;for(let u of c){let f=this._attributeInfos[u];if(f){let h=this.device.type==="webgpu"?s.getBufferIndex(f.bufferName):f.location;this.vertexArray.setBuffer(h,o),l=!0}}!l&&!n&&I.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${i}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(let[n,s]of Object.entries(e)){let i=this._attributeInfos[n];i?this.vertexArray.setConstantWebGL(i.location,s):(t?.disableWarnings??this.props.disableWarnings)||I.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${n}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(e instanceof rn&&!e.isReady)return e.id;return!1}_getBindings(){let e={};for(let[t,n]of Object.entries(this.bindings))n instanceof rn?n.isReady&&(e[t]=n.texture):e[t]=n;return e}_getBindingsUpdateTimestamp(){let e=0;for(let t of Object.values(this.bindings))t instanceof mr?e=Math.max(e,t.texture.updateTimestamp):t instanceof W||t instanceof K?e=Math.max(e,t.updateTimestamp):t instanceof rn?e=t.texture?Math.max(e,t.texture.updateTimestamp):1/0:t instanceof Ke||(e=Math.max(e,t.buffer.updateTimestamp));return e}_setGeometryAttributes(e){let t={...e.attributes};for(let[n]of Object.entries(t))!this.pipeline.shaderLayout.attributes.find(s=>s.name===n)&&n!=="positions"&&delete t[n];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(I.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let n=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),s=null;this.source?s=n:this.fs&&(s=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debugShaders:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindings:this._getBindings(),vs:n,fs:s}),this._attributeInfos=Qo(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=I.level>3?0:V3;I.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,I.group(nn,`>>> DRAWING MODEL ${this.id}`,{collapsed:I.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=sg(this.pipeline.shaderLayout,this.id);I.table(nn,e)();let t=this.shaderInputs.getDebugTable();I.table(nn,t)();let n=this._getAttributeDebugTable();I.table(nn,this._attributeInfos)(),I.table(nn,n)(),I.groupEnd(nn)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let t=this.device.props.debugFramebuffers;if(this._drawCount++,!t)return;let n=e.props.framebuffer;n&&ig(n,{id:n.id,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[t,n]of Object.entries(this._attributeInfos)){let s=this.vertexArray.attributes[n.location];e[n.location]={name:t,type:n.shaderType,values:s?this._getBufferOrConstantValues(s,n.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:t}=this.vertexArray,n=t.indexType==="uint32"?new Uint32Array(t.debugData):new Uint16Array(t.debugData);e.indices={name:"indices",type:t.indexType,values:n.toString()}}return e}_getBufferOrConstantValues(e,t){let n=Hr(t);return(e instanceof W?new n(e.debugData):e).toString()}},Xe=Xf;L(Xe,"defaultProps",{...Ze.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:_r.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function z3(r){return Boolean(r.uniformTypes&&!$3(r.uniformTypes))}function W3(r){return{type:r.type,shaderLanguage:r.info.shadingLanguage,shaderLanguageVersion:r.info.shadingLanguageVersion,gpu:r.info.gpu,features:r.features}}function $3(r){for(let e in r)return!1;return!0}H();var qa=class{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,t=qa.defaultProps){if(!qa.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new Xe(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||js(),topology:t.topology||"point-list",varyings:t.outputs||t.varyings,...t}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){e?.inputBuffers&&this.model.setAttributes(e.inputBuffers),e?.outputBuffers&&this.transformFeedback.setBuffers(e.outputBuffers);let t=this.device.beginRenderPass(e);this.model.draw(t),t.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let t=this.getBuffer(e);if(!t)throw new Error("BufferTransform#getBuffer");if(t instanceof W)return t.readAsync();let{buffer:n,byteOffset:s=0,byteLength:i=n.byteLength}=t;return n.readAsync(s,i)}},ht=qa;L(ht,"defaultProps",{...Xe.defaultProps,outputs:void 0,feedbackBuffers:void 0});var j3="transform_output",ui=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,t){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new Xe(this.device,{id:t.id||xe("texture-transform-model"),fs:t.fs||js({input:t.targetTextureVarying,inputChannels:t.targetTextureChannels,output:j3}),vertexCount:t.vertexCount,...t}),this._initialize(t),Object.seal(this)}destroy(){this.model.destroy();for(let e of this.bindings)e.framebuffer?.destroy()}delete(){this.destroy()}run(e){let{framebuffer:t}=this.bindings[this.currentIndex],n=this.device.beginRenderPass({framebuffer:t,...e});this.model.draw(n),n.end(),this.device.submit()}getTargetTexture(){let{targetTexture:e}=this.bindings[this.currentIndex];return e}getFramebuffer(){return this.bindings[this.currentIndex].framebuffer}_initialize(e){this._updateBindings(e)}_updateBindings(e){this.bindings[this.currentIndex]=this._updateBinding(this.bindings[this.currentIndex],e)}_updateBinding(e,{sourceBuffers:t,sourceTextures:n,targetTexture:s}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,n),Object.assign(e.sourceBuffers,t),s){e.targetTexture=s;let{width:i,height:o}=s;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:i,height:o,colorAttachments:[s]}),e.framebuffer.resize({width:i,height:o})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:t}=this.bindings[e];for(let n in t)t[n].sampler=this.sampler}};var dt=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:t={},indices:n=null,vertexCount:s=null}=e;this.id=e.id||xe("geometry"),this.topology=e.topology,n&&(this.indices=ArrayBuffer.isView(n)?{value:n,size:1}:n),this.attributes={};for(let[i,o]of Object.entries(t)){let a=ArrayBuffer.isView(o)?{value:o}:o;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(i)}: must be typed array or object with value as typed array`);if((i==="POSITION"||i==="positions")&&!a.size&&(a.size=3),i==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else this.attributes[i]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=s||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let n=1/0;for(let s of Object.values(e)){let{value:i,size:o,constant:a}=s;!a&&i&&o!==void 0&&o>=1&&(n=Math.min(n,i.length/o))}return n}};var H3=`struct VertexInputs {
819
819
  @location(0) clipSpacePosition: vec2<f32>,
820
820
  @location(1) texCoord: vec2<f32>,
821
821
  @location(2) coordinate: vec2<f32>
@@ -837,7 +837,7 @@ fn vertexMain(inputs: VertexInputs) -> FragmentInputs {
837
837
  outputs.uv = inputs.texCoord;
838
838
  return outputs;
839
839
  }
840
- `,F3=`#version 300 es
840
+ `,X3=`#version 300 es
841
841
  in vec2 clipSpacePositions;
842
842
  in vec2 texCoords;
843
843
  in vec2 coordinates;
@@ -852,16 +852,16 @@ void main(void) {
852
852
  coordinate = coordinates;
853
853
  uv = texCoords;
854
854
  }
855
- `,tg=[-1,-1,1,-1,-1,1,1,1],li=class extends Ye{constructor(e,t){let n=tg.map(s=>s===-1?0:s);t.source&&(t={...t,source:`${D3}
856
- ${t.source}`}),super(e,{id:t.id||xe("clip-space"),...t,vs:F3,vertexCount:4,geometry:new mt({topology:"triangle-strip",vertexCount:4,attributes:{clipSpacePositions:{size:2,value:new Float32Array(tg)},texCoords:{size:2,value:new Float32Array(n)},coordinates:{size:2,value:new Float32Array(n)}}})})}};var Ot=class{id;matrix=new Q;display=!0;position=new G;rotation=new G;scale=new G(1,1,1);userData={};props={};constructor(e={}){let{id:t}=e;this.id=t||xe(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return this.position=e,this}setRotation(e){return this.rotation=e,this}setScale(e){return this.scale=e,this}setMatrix(e,t=!0){t?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){let{position:t,rotation:n,scale:s,update:i=!0}=e;return t&&this.setPosition(t),n&&this.setRotation(n),s&&this.setScale(s),i&&this.updateMatrix(),this}updateMatrix(){let e=this.position,t=this.rotation,n=this.scale;return this.matrix.identity(),this.matrix.translate(e),this.matrix.rotateXYZ(t),this.matrix.scale(n),this}update(e={}){let{position:t,rotation:n,scale:s}=e;return t&&this.setPosition(t),n&&this.setRotation(n),s&&this.setScale(s),this.updateMatrix(),this}getCoordinateUniforms(e,t){t=t||this.matrix;let n=new Q(e).multiplyRight(t),s=n.invert(),i=s.transpose();return{viewMatrix:e,modelMatrix:t,objectMatrix:t,worldMatrix:n,worldInverseMatrix:s,worldInverseTransposeMatrix:i}}_setScenegraphNodeProps(e){"position"in e&&this.setPosition(e.position),"rotation"in e&&this.setRotation(e.rotation),"scale"in e&&this.setScale(e.scale),"matrix"in e&&this.setMatrix(e.matrix),Object.assign(this.props,e)}};H();var nn=class extends Ot{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;let{children:t=[]}=e;I.assert(t.every(n=>n instanceof Ot),"every child must an instance of ScenegraphNode"),super(e),this.children=t}getBounds(){let e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((t,{worldMatrix:n})=>{let s=t.getBounds();if(!s)return;let[i,o]=s,a=new G(i).add(o).divide([2,2,2]);n.transformAsPoint(a,a);let c=new G(o).subtract(i).divide([2,2,2]);n.transformAsVector(c,c);for(let l=0;l<8;l++){let u=new G(l&1?-1:1,l&2?-1:1,l&4?-1:1).multiply(c).add(a);for(let f=0;f<3;f++)e[0][f]=Math.min(e[0][f],u[f]),e[1][f]=Math.max(e[1][f],u[f])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(let t of e)Array.isArray(t)?this.add(...t):this.children.push(t);return this}remove(e){let t=this.children,n=t.indexOf(e);return n>-1&&t.splice(n,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:t=new Q}={}){let n=new Q(t).multiplyRight(this.matrix);for(let s of this.children)s instanceof nn?s.traverse(e,{worldMatrix:n}):e(s,{worldMatrix:n})}};var ui=class extends Ot{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}getBounds(){return this.bounds}draw(e){return this.model.draw(e)}};var fi=class extends mt{constructor(e={}){let{id:t=xe("cube-geometry"),indices:n=!0}=e;super(n?{...e,id:t,topology:"triangle-list",indices:{size:1,value:B3},attributes:{...j3,...e.attributes}}:{...e,id:t,topology:"triangle-list",indices:void 0,attributes:{...H3,...e.attributes}})}},B3=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),L3=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),U3=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),V3=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),z3=new Float32Array([1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1]),W3=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),$3=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),j3={POSITION:{size:3,value:L3},NORMAL:{size:3,value:U3},TEXCOORD_0:{size:2,value:V3}},H3={POSITION:{size:3,value:z3},TEXCOORD_0:{size:2,value:W3},COLOR_0:{size:3,value:$3}};var hi=class extends mt{constructor(e={}){let{id:t=xe("sphere-geometry")}=e,{indices:n,attributes:s}=X3(e);super({...e,id:t,topology:"triangle-list",indices:n,attributes:{...s,...e.attributes}})}};function X3(r){let{nlat:e=10,nlong:t=10}=r,i=Math.PI-0,o=0,c=2*Math.PI-o,l=(e+1)*(t+1),u=(x,E,b,S,C)=>r.radius||1,f=new Float32Array(l*3),h=new Float32Array(l*3),d=new Float32Array(l*2),m=l>65535?Uint32Array:Uint16Array,y=new m(e*t*6);for(let x=0;x<=e;x++)for(let E=0;E<=t;E++){let b=E/t,S=x/e,C=E+x*(t+1),P=C*2,B=C*3,N=c*b,k=i*S,F=Math.sin(N),U=Math.cos(N),X=Math.sin(k),J=Math.cos(k),q=U*X,pe=J,$t=F*X,jt=u(q,pe,$t,b,S);f[B+0]=jt*q,f[B+1]=jt*pe,f[B+2]=jt*$t,h[B+0]=q,h[B+1]=pe,h[B+2]=$t,d[P+0]=b,d[P+1]=1-S}let _=t+1;for(let x=0;x<t;x++)for(let E=0;E<e;E++){let b=(x*e+E)*6;y[b+0]=E*_+x,y[b+1]=E*_+x+1,y[b+2]=(E+1)*_+x,y[b+3]=(E+1)*_+x,y[b+4]=E*_+x+1,y[b+5]=(E+1)*_+x+1}return{indices:{size:1,value:y},attributes:{POSITION:{size:3,value:f},NORMAL:{size:3,value:h},TEXCOORD_0:{size:2,value:d}}}}var{stats:Y3,getSupportedAdapters:q3,setDefaultDeviceProps:K3,attachDevice:Z3,createDevice:G3,enforceWebGL2:Q3}=mr;var hh={};Ht(hh,{fetchFile:()=>ts,load:()=>Rr,parse:()=>Er,registerLoaders:()=>bi});function vr(r,e){if(!r)throw new Error(e||"loader assertion failed.")}var kt={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},J3=kt.self||kt.window||kt.global||{},ew=kt.window||kt.self||kt.global||{},tw=kt.global||kt.self||kt.window||{},rw=kt.document||{};var sn=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var rg=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),nw=rg&&parseFloat(rg[1])||0;Ps();var Vf="4.3.3",sw=Vf[0]>="0"&&Vf[0]<="9"?`v${Vf}`:"";function iw(){let r=new Fe({id:"loaders.gl"});return globalThis.loaders=globalThis.loaders||{},globalThis.loaders.log=r,globalThis.loaders.version=sw,globalThis.probe=globalThis.probe||{},globalThis.probe.loaders=r,r}var zf=iw();function Wf(r,e){return ng(r||{},e)}function ng(r,e,t=0){if(t>3)return e;let n={...r};for(let[s,i]of Object.entries(e))i&&typeof i=="object"&&!Array.isArray(i)?n[s]=ng(n[s]||{},e[s],t+1):n[s]=e[s];return n}var sg="latest";function ow(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version}var $f=ow();function ke(r,e){if(!r)throw new Error(e||"loaders.gl assertion failed.")}var Nt={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},IN=Nt.self||Nt.window||Nt.global||{},PN=Nt.window||Nt.self||Nt.global||{},CN=Nt.global||Nt.self||Nt.window||{},MN=Nt.document||{};var nt=typeof process!="object"||String(process)!=="[object process]"||process.browser;var og=typeof window<"u"&&typeof window.orientation<"u",ig=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),ON=ig&&parseFloat(ig[1])||0;var di=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((n,s)=>{this._resolve=n,this._reject=s})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){ke(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){ke(this.isRunning),this.isRunning=!1,this._reject(e)}};var Jn=class{terminate(){}};var jf=new Map;function ag(r){ke(r.source&&!r.url||!r.source&&r.url);let e=jf.get(r.source||r.url);return e||(r.url&&(e=aw(r.url),jf.set(r.url,e)),r.source&&(e=cg(r.source),jf.set(r.source,e))),ke(e),e}function aw(r){if(!r.startsWith("http"))return r;let e=cw(r);return cg(e)}function cg(r){let e=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(e)}function cw(r){return`try {
855
+ `,hg=[-1,-1,1,-1,-1,1,1,1],fi=class extends Xe{constructor(e,t){let n=hg.map(s=>s===-1?0:s);t.source&&(t={...t,source:`${H3}
856
+ ${t.source}`}),super(e,{id:t.id||xe("clip-space"),...t,vs:X3,vertexCount:4,geometry:new dt({topology:"triangle-strip",vertexCount:4,attributes:{clipSpacePositions:{size:2,value:new Float32Array(hg)},texCoords:{size:2,value:new Float32Array(n)},coordinates:{size:2,value:new Float32Array(n)}}})})}};var Ct=class{id;matrix=new Q;display=!0;position=new G;rotation=new G;scale=new G(1,1,1);userData={};props={};constructor(e={}){let{id:t}=e;this.id=t||xe(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return this.position=e,this}setRotation(e){return this.rotation=e,this}setScale(e){return this.scale=e,this}setMatrix(e,t=!0){t?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){let{position:t,rotation:n,scale:s,update:i=!0}=e;return t&&this.setPosition(t),n&&this.setRotation(n),s&&this.setScale(s),i&&this.updateMatrix(),this}updateMatrix(){let e=this.position,t=this.rotation,n=this.scale;return this.matrix.identity(),this.matrix.translate(e),this.matrix.rotateXYZ(t),this.matrix.scale(n),this}update(e={}){let{position:t,rotation:n,scale:s}=e;return t&&this.setPosition(t),n&&this.setRotation(n),s&&this.setScale(s),this.updateMatrix(),this}getCoordinateUniforms(e,t){t=t||this.matrix;let n=new Q(e).multiplyRight(t),s=n.invert(),i=s.transpose();return{viewMatrix:e,modelMatrix:t,objectMatrix:t,worldMatrix:n,worldInverseMatrix:s,worldInverseTransposeMatrix:i}}_setScenegraphNodeProps(e){"position"in e&&this.setPosition(e.position),"rotation"in e&&this.setRotation(e.rotation),"scale"in e&&this.setScale(e.scale),"matrix"in e&&this.setMatrix(e.matrix),Object.assign(this.props,e)}};H();var sn=class extends Ct{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;let{children:t=[]}=e;I.assert(t.every(n=>n instanceof Ct),"every child must an instance of ScenegraphNode"),super(e),this.children=t}getBounds(){let e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((t,{worldMatrix:n})=>{let s=t.getBounds();if(!s)return;let[i,o]=s,a=new G(i).add(o).divide([2,2,2]);n.transformAsPoint(a,a);let c=new G(o).subtract(i).divide([2,2,2]);n.transformAsVector(c,c);for(let l=0;l<8;l++){let u=new G(l&1?-1:1,l&2?-1:1,l&4?-1:1).multiply(c).add(a);for(let f=0;f<3;f++)e[0][f]=Math.min(e[0][f],u[f]),e[1][f]=Math.max(e[1][f],u[f])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(let t of e)Array.isArray(t)?this.add(...t):this.children.push(t);return this}remove(e){let t=this.children,n=t.indexOf(e);return n>-1&&t.splice(n,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:t=new Q}={}){let n=new Q(t).multiplyRight(this.matrix);for(let s of this.children)s instanceof sn?s.traverse(e,{worldMatrix:n}):e(s,{worldMatrix:n})}};var hi=class extends Ct{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}getBounds(){return this.bounds}draw(e){return this.model.draw(e)}};var di=class extends dt{constructor(e={}){let{id:t=xe("cube-geometry"),indices:n=!0}=e;super(n?{...e,id:t,topology:"triangle-list",indices:{size:1,value:Y3},attributes:{...ew,...e.attributes}}:{...e,id:t,topology:"triangle-list",indices:void 0,attributes:{...tw,...e.attributes}})}},Y3=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),q3=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),K3=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),Z3=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),G3=new Float32Array([1,-1,1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1]),Q3=new Float32Array([1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,1,0,0]),J3=new Float32Array([1,0,1,1,0,0,1,1,0,0,0,1,1,0,0,1,1,0,1,1,0,0,0,1,1,1,1,1,1,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,1,0,0,1,0,1,1,1,1,1,1,1,1,1,0,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,1,1,0,1,1,1,0,1,0,1,0,0,0,1,0,0,1,1,0,1,0,1,1,1,1,1,0,1,1,1,0,0,1,1,0,0,1,1,1,0,1,1,1,1,1,1,1,0,0,1,0,0,0,1,0,1,0,1,1,1,0,1,1,0,0,1,0,1,0,1]),ew={POSITION:{size:3,value:q3},NORMAL:{size:3,value:K3},TEXCOORD_0:{size:2,value:Z3}},tw={POSITION:{size:3,value:G3},TEXCOORD_0:{size:2,value:Q3},COLOR_0:{size:3,value:J3}};var pi=class extends dt{constructor(e={}){let{id:t=xe("sphere-geometry")}=e,{indices:n,attributes:s}=rw(e);super({...e,id:t,topology:"triangle-list",indices:n,attributes:{...s,...e.attributes}})}};function rw(r){let{nlat:e=10,nlong:t=10}=r,i=Math.PI-0,o=0,c=2*Math.PI-o,l=(e+1)*(t+1),u=(x,E,b,S,C)=>r.radius||1,f=new Float32Array(l*3),h=new Float32Array(l*3),d=new Float32Array(l*2),m=l>65535?Uint32Array:Uint16Array,y=new m(e*t*6);for(let x=0;x<=e;x++)for(let E=0;E<=t;E++){let b=E/t,S=x/e,C=E+x*(t+1),P=C*2,B=C*3,N=c*b,k=i*S,F=Math.sin(N),U=Math.cos(N),X=Math.sin(k),J=Math.cos(k),q=U*X,pe=J,zt=F*X,Wt=u(q,pe,zt,b,S);f[B+0]=Wt*q,f[B+1]=Wt*pe,f[B+2]=Wt*zt,h[B+0]=q,h[B+1]=pe,h[B+2]=zt,d[P+0]=b,d[P+1]=1-S}let _=t+1;for(let x=0;x<t;x++)for(let E=0;E<e;E++){let b=(x*e+E)*6;y[b+0]=E*_+x,y[b+1]=E*_+x+1,y[b+2]=(E+1)*_+x,y[b+3]=(E+1)*_+x,y[b+4]=E*_+x+1,y[b+5]=(E+1)*_+x+1}return{indices:{size:1,value:y},attributes:{POSITION:{size:3,value:f},NORMAL:{size:3,value:h},TEXCOORD_0:{size:2,value:d}}}}var{stats:nw,getSupportedAdapters:sw,setDefaultDeviceProps:iw,attachDevice:ow,createDevice:aw,enforceWebGL2:cw}=pr;var bh={};$t(bh,{fetchFile:()=>ss,load:()=>Er,parse:()=>Sr,registerLoaders:()=>wi});function wr(r,e){if(!r)throw new Error(e||"loader assertion failed.")}var Mt={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},lw=Mt.self||Mt.window||Mt.global||{},uw=Mt.window||Mt.self||Mt.global||{},fw=Mt.global||Mt.self||Mt.window||{},hw=Mt.document||{};var on=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var dg=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),dw=dg&&parseFloat(dg[1])||0;Cs();var qf="4.3.3",pw=qf[0]>="0"&&qf[0]<="9"?`v${qf}`:"";function mw(){let r=new Ie({id:"loaders.gl"});return globalThis.loaders=globalThis.loaders||{},globalThis.loaders.log=r,globalThis.loaders.version=pw,globalThis.probe=globalThis.probe||{},globalThis.probe.loaders=r,r}var Kf=mw();function Zf(r,e){return pg(r||{},e)}function pg(r,e,t=0){if(t>3)return e;let n={...r};for(let[s,i]of Object.entries(e))i&&typeof i=="object"&&!Array.isArray(i)?n[s]=pg(n[s]||{},e[s],t+1):n[s]=e[s];return n}var mg="latest";function gw(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version}var Gf=gw();function ke(r,e){if(!r)throw new Error(e||"loaders.gl assertion failed.")}var Ot={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},JN=Ot.self||Ot.window||Ot.global||{},e4=Ot.window||Ot.self||Ot.global||{},t4=Ot.global||Ot.self||Ot.window||{},r4=Ot.document||{};var tt=typeof process!="object"||String(process)!=="[object process]"||process.browser;var _g=typeof window<"u"&&typeof window.orientation<"u",gg=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),n4=gg&&parseFloat(gg[1])||0;var mi=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((n,s)=>{this._resolve=n,this._reject=s})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){ke(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){ke(this.isRunning),this.isRunning=!1,this._reject(e)}};var rs=class{terminate(){}};var Qf=new Map;function yg(r){ke(r.source&&!r.url||!r.source&&r.url);let e=Qf.get(r.source||r.url);return e||(r.url&&(e=_w(r.url),Qf.set(r.url,e)),r.source&&(e=xg(r.source),Qf.set(r.source,e))),ke(e),e}function _w(r){if(!r.startsWith("http"))return r;let e=yw(r);return xg(e)}function xg(r){let e=new Blob([r],{type:"application/javascript"});return URL.createObjectURL(e)}function yw(r){return`try {
857
857
  importScripts('${r}');
858
858
  } catch (error) {
859
859
  console.error(error);
860
860
  throw error;
861
- }`}function Hf(r,e=!0,t){let n=t||new Set;if(r){if(lg(r))n.add(r);else if(lg(r.buffer))n.add(r.buffer);else if(!ArrayBuffer.isView(r)){if(e&&typeof r=="object")for(let s in r)Hf(r[s],e,n)}}return t===void 0?Array.from(n):[]}function lg(r){return r?r instanceof ArrayBuffer||typeof MessagePort<"u"&&r instanceof MessagePort||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas:!1}var Xf=()=>{},Ar=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&nt||typeof Jn<"u"&&!nt}constructor(e){let{name:t,source:n,url:s}=e;ke(n||s),this.name=t,this.source=n,this.url=s,this.onMessage=Xf,this.onError=i=>console.log(i),this.worker=nt?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Xf,this.onError=Xf,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||Hf(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=ag({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=t=>{t.data?this.onMessage(t.data):this.onError(new Error("No data received"))},e.onerror=t=>{this.onError(this._getErrorFromErrorEvent(t)),this.terminated=!0},e.onmessageerror=t=>console.error(t),e}_createNodeWorker(){let e;if(this.url){let n=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;e=new Jn(n,{eval:!1})}else if(this.source)e=new Jn(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",t=>{this.onMessage(t)}),e.on("error",t=>{this.onError(t)}),e.on("exit",t=>{}),e}};var pi=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return Ar.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,t=(s,i,o)=>s.done(o),n=(s,i)=>s.error(i)){let s=new Promise(i=>(this.jobQueue.push({name:e,onMessage:t,onError:n,onStart:i}),this));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});let n=new di(t.name,e);e.onMessage=s=>t.onMessage(n,s.type,s.payload),e.onError=s=>t.onError(n,s),t.onStart(n);try{await n.result}catch(s){console.error(`Worker exception: ${s}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!nt||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;let e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new Ar({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return og?this.maxMobileConcurrency:this.maxConcurrency}};var lw={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},on=class{props;workerPools=new Map;static isSupported(){return Ar.isSupported()}static getWorkerFarm(e={}){return on._workerFarm=on._workerFarm||new on({}),on._workerFarm.setProps(e),on._workerFarm}constructor(e){this.props={...lw},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:t,source:n,url:s}=e,i=this.workerPools.get(t);return i||(i=new pi({name:t,source:n,url:s}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},Sr=on;L(Sr,"_workerFarm");function Yf(r,e={}){let t=e[r.id]||{},n=nt?`${r.id}-worker.js`:`${r.id}-worker-node.js`,s=t.workerUrl;if(!s&&r.id==="compression"&&(s=e.workerUrl),e._workerType==="test"&&(nt?s=`modules/${r.module}/dist/${n}`:s=`modules/${r.module}/src/workers/${r.id}-worker-node.ts`),!s){let i=r.version;i==="latest"&&(i=sg);let o=i?`@${i}`:"";s=`https://unpkg.com/@loaders.gl/${r.module}${o}/dist/${n}`}return ke(s),s}function qf(r,e=$f){ke(r,"no worker provided");let t=r.version;return!(!e||!t)}function Kf(r,e){return!Sr.isSupported()||!nt&&!e?._nodeWorkers?!1:r.worker&&e?.worker}async function Zf(r,e,t,n,s){let i=r.id,o=Yf(r,t),c=Sr.getWorkerFarm(t).getWorkerPool({name:i,url:o});t=JSON.parse(JSON.stringify(t)),n=JSON.parse(JSON.stringify(n||{}));let l=await c.startJob("process-on-worker",uw.bind(null,s));return l.postMessage("process",{input:e,options:t,context:n}),await(await l.result).result}async function uw(r,e,t,n){switch(t){case"done":e.done(n);break;case"error":e.error(new Error(n.error));break;case"process":let{id:s,input:i,options:o}=n;try{let a=await r(i,o);e.postMessage("done",{id:s,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:s,error:c})}break;default:console.warn(`parse-with-worker unknown message ${t}`)}}function Gf(r,e,t){if(t=t||r.byteLength,r.byteLength<t||e.byteLength<t)return!1;let n=new Uint8Array(r),s=new Uint8Array(e);for(let i=0;i<n.length;++i)if(n[i]!==s[i])return!1;return!0}function Qf(...r){return ug(r)}function ug(r){let e=r.map(i=>i instanceof ArrayBuffer?new Uint8Array(i):i),t=e.reduce((i,o)=>i+o.byteLength,0),n=new Uint8Array(t),s=0;for(let i of e)n.set(i,s),s+=i.byteLength;return n.buffer}async function Jf(r){let e=[];for await(let t of r)e.push(t);return Qf(...e)}var fw="",fg={};function eh(r){for(let e in fg)if(r.startsWith(e)){let t=fg[e];r=r.replace(e,t)}return!r.startsWith("http://")&&!r.startsWith("https://")&&(r=`${fw}${r}`),r}function hg(r){return r&&typeof r=="object"&&r.isBuffer}function ja(r){if(hg(r))return r;if(r instanceof ArrayBuffer)return r;if(ArrayBuffer.isView(r))return r.byteOffset===0&&r.byteLength===r.buffer.byteLength?r.buffer:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);if(typeof r=="string"){let e=r;return new TextEncoder().encode(e).buffer}if(r&&typeof r=="object"&&r._toArrayBuffer)return r._toArrayBuffer();throw new Error("toArrayBuffer")}var an={};Ht(an,{dirname:()=>dw,filename:()=>hw,join:()=>pw,resolve:()=>mw});function dg(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let r=window.location?.pathname;return r?.slice(0,r.lastIndexOf("/")+1)||""}function hw(r){let e=r?r.lastIndexOf("/"):-1;return e>=0?r.substr(e+1):""}function dw(r){let e=r?r.lastIndexOf("/"):-1;return e>=0?r.substr(0,e):""}function pw(...r){let e="/";return r=r.map((t,n)=>(n&&(t=t.replace(new RegExp(`^${e}`),"")),n!==r.length-1&&(t=t.replace(new RegExp(`${e}$`),"")),t)),r.join(e)}function mw(...r){let e=[];for(let i=0;i<r.length;i++)e[i]=r[i];let t="",n=!1,s;for(let i=e.length-1;i>=-1&&!n;i--){let o;i>=0?o=e[i]:(s===void 0&&(s=dg()),o=s),o.length!==0&&(t=`${o}/${t}`,n=o.charCodeAt(0)===mi)}return t=gw(t,!n),n?`/${t}`:t.length>0?t:"."}var mi=47,th=46;function gw(r,e){let t="",n=-1,s=0,i,o=!1;for(let a=0;a<=r.length;++a){if(a<r.length)i=r.charCodeAt(a);else{if(i===mi)break;i=mi}if(i===mi){if(!(n===a-1||s===1))if(n!==a-1&&s===2){if(t.length<2||!o||t.charCodeAt(t.length-1)!==th||t.charCodeAt(t.length-2)!==th){if(t.length>2){let c=t.length-1,l=c;for(;l>=0&&t.charCodeAt(l)!==mi;--l);if(l!==c){t=l===-1?"":t.slice(0,l),n=a,s=0,o=!1;continue}}else if(t.length===2||t.length===1){t="",n=a,s=0,o=!1;continue}}e&&(t.length>0?t+="/..":t="..",o=!0)}else{let c=r.slice(n+1,a);t.length>0?t+=`/${c}`:t=c,o=!1}n=a,s=0}else i===th&&s!==-1?++s:s=-1}return t}var _w=r=>typeof r=="boolean",gi=r=>typeof r=="function",cn=r=>r!==null&&typeof r=="object",rh=r=>cn(r)&&r.constructor==={}.constructor;var pg=r=>Boolean(r)&&typeof r[Symbol.iterator]=="function",mg=r=>r&&typeof r[Symbol.asyncIterator]=="function";var st=r=>typeof Response<"u"&&r instanceof Response||r&&r.arrayBuffer&&r.text&&r.json;var it=r=>typeof Blob<"u"&&r instanceof Blob,gg=r=>r&&typeof r=="object"&&r.isBuffer;var yw=r=>typeof ReadableStream<"u"&&r instanceof ReadableStream||cn(r)&&gi(r.tee)&&gi(r.cancel)&&gi(r.getReader);var xw=r=>cn(r)&&gi(r.read)&&gi(r.pipe)&&_w(r.readable),Ha=r=>yw(r)||xw(r);var Xa=class extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response};var bw=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,Tw=/^([-\w.]+\/[-\w.+]+)/;function nh(r,e){return r.toLowerCase()===e.toLowerCase()}function _g(r){let e=Tw.exec(r);return e?e[1]:r}function sh(r){let e=bw.exec(r);return e?e[1]:""}var yg=/\?.*/;function xg(r){let e=r.match(yg);return e&&e[0]}function es(r){return r.replace(yg,"")}function bg(r){if(r.length<50)return r;let e=r.slice(r.length-15);return`${r.substr(0,32)}...${e}`}function ln(r){return st(r)?r.url:it(r)?r.name||"":typeof r=="string"?r:""}function _i(r){if(st(r)){let e=r,t=e.headers.get("content-type")||"",n=es(e.url);return _g(t)||sh(n)}return it(r)?r.type||"":typeof r=="string"?sh(r):""}function Tg(r){return st(r)?r.headers["content-length"]||-1:it(r)?r.size:typeof r=="string"?r.length:r instanceof ArrayBuffer||ArrayBuffer.isView(r)?r.byteLength:-1}async function Ya(r){if(st(r))return r;let e={},t=Tg(r);t>=0&&(e["content-length"]=String(t));let n=ln(r),s=_i(r);s&&(e["content-type"]=s);let i=await vw(r);i&&(e["x-first-bytes"]=i),typeof r=="string"&&(r=new TextEncoder().encode(r));let o=new Response(r,{headers:e});return Object.defineProperty(o,"url",{value:n}),o}async function wg(r){if(!r.ok)throw await ww(r)}async function ww(r){let e=bg(r.url),t=`Failed to fetch resource (${r.status}) ${r.statusText}: ${e}`;t=t.length>100?`${t.slice(0,100)}...`:t;let n={reason:r.statusText,url:r.url,response:r};try{let s=r.headers.get("Content-Type");n.reason=!r.bodyUsed&&s?.includes("application/json")?await r.json():await r.text()}catch{}return new Xa(t,n)}async function vw(r){if(typeof r=="string")return`data:,${r.slice(0,5)}`;if(r instanceof Blob){let t=r.slice(0,5);return await new Promise(n=>{let s=new FileReader;s.onload=i=>n(i?.target?.result),s.readAsDataURL(t)})}if(r instanceof ArrayBuffer){let t=r.slice(0,5);return`data:base64,${Aw(t)}`}return null}function Aw(r){let e="",t=new Uint8Array(r);for(let n=0;n<t.byteLength;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function Sw(r){return!Ew(r)&&!Rw(r)}function Ew(r){return r.startsWith("http:")||r.startsWith("https:")}function Rw(r){return r.startsWith("data:")}async function ts(r,e){if(typeof r=="string"){let t=eh(r);return Sw(t)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(t,e):await fetch(t,e)}return await Ya(r)}Ps();var ih=new Fe({id:"loaders.gl"}),qa=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},Ka=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var oh={fetch:null,mimeType:void 0,nothrow:!1,log:new Ka,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:sn,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},vg={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function ah(){globalThis.loaders=globalThis.loaders||{};let{loaders:r}=globalThis;return r._state||(r._state={}),r._state}function ch(){let r=ah();return r.globalOptions=r.globalOptions||{...oh},r.globalOptions}function Eg(r,e,t,n){return t=t||[],t=Array.isArray(t)?t:[t],Iw(r,t),Cw(e,r,n)}function Iw(r,e){Ag(r,null,oh,vg,e);for(let t of e){let n=r&&r[t.id]||{},s=t.options&&t.options[t.id]||{},i=t.deprecatedOptions&&t.deprecatedOptions[t.id]||{};Ag(n,t.id,s,i,e)}}function Ag(r,e,t,n,s){let i=e||"Top level",o=e?`${e}.`:"";for(let a in r){let c=!e&&cn(r[a]),l=a==="baseUri"&&!e,u=a==="workerUrl"&&e;if(!(a in t)&&!l&&!u){if(a in n)ih.warn(`${i} loader option '${o}${a}' no longer supported, use '${n[a]}'`)();else if(!c){let f=Pw(a,s);ih.warn(`${i} loader option '${o}${a}' not recognized. ${f}`)()}}}}function Pw(r,e){let t=r.toLowerCase(),n="";for(let s of e)for(let i in s.options){if(r===i)return`Did you mean '${s.id}.${i}'?`;let o=i.toLowerCase();(t.startsWith(o)||o.startsWith(t))&&(n=n||`Did you mean '${s.id}.${i}'?`)}return n}function Cw(r,e,t){let s={...r.options||{}};return Mw(s,t),s.log===null&&(s.log=new qa),Sg(s,ch()),Sg(s,e),s}function Sg(r,e){for(let t in e)if(t in e){let n=e[t];rh(n)&&rh(r[t])?r[t]={...r[t],...e[t]}:r[t]=e[t]}}function Mw(r,e){e&&!("baseUri"in r)&&(r.baseUri=e)}function yi(r){return r?(Array.isArray(r)&&(r=r[0]),Array.isArray(r?.extensions)):!1}function xi(r){vr(r,"null loader"),vr(yi(r),"invalid loader");let e;return Array.isArray(r)&&(e=r[1],r=r[0],r={...r,options:{...r.options,...e}}),(r?.parseTextSync||r?.parseText)&&(r.text=!0),r.text||(r.binary=!0),r}var Rg=()=>{let r=ah();return r.loaderRegistry=r.loaderRegistry||[],r.loaderRegistry};function bi(r){let e=Rg();r=Array.isArray(r)?r:[r];for(let t of r){let n=xi(t);e.find(s=>n===s)||e.unshift(n)}}function Ig(){return Rg()}var Ow=/\.([^.]+)$/;async function Mg(r,e=[],t,n){if(!Og(r))return null;let s=Pg(r,e,{...t,nothrow:!0},n);if(s)return s;if(it(r)&&(r=await r.slice(0,10).arrayBuffer(),s=Pg(r,e,t,n)),!s&&!t?.nothrow)throw new Error(kg(r));return s}function Pg(r,e=[],t,n){if(!Og(r))return null;if(e&&!Array.isArray(e))return xi(e);let s=[];e&&(s=s.concat(e)),t?.ignoreRegisteredLoaders||s.push(...Ig()),Nw(s);let i=kw(r,s,t,n);if(!i&&!t?.nothrow)throw new Error(kg(r));return i}function kw(r,e,t,n){let s=ln(r),i=_i(r),o=es(s)||n?.url,a=null,c="";return t?.mimeType&&(a=lh(e,t?.mimeType),c=`match forced by supplied MIME type ${t?.mimeType}`),a=a||Dw(e,o),c=c||(a?`matched url ${o}`:""),a=a||lh(e,i),c=c||(a?`matched MIME type ${i}`:""),a=a||Bw(e,r),c=c||(a?`matched initial data ${Ng(r)}`:""),t?.fallbackMimeType&&(a=a||lh(e,t?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${i}`:"")),c&&zf.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function Og(r){return!(r instanceof Response&&r.status===204)}function kg(r){let e=ln(r),t=_i(r),n="No valid loader found (";n+=e?`${an.filename(e)}, `:"no url provided, ",n+=`MIME type: ${t?`"${t}"`:"not provided"}, `;let s=r?Ng(r):"";return n+=s?` first bytes: "${s}"`:"first bytes: not available",n+=")",n}function Nw(r){for(let e of r)xi(e)}function Dw(r,e){let t=e&&Ow.exec(e),n=t&&t[1];return n?Fw(r,n):null}function Fw(r,e){e=e.toLowerCase();for(let t of r)for(let n of t.extensions)if(n.toLowerCase()===e)return t;return null}function lh(r,e){for(let t of r)if(t.mimeTypes?.some(n=>nh(e,n))||nh(e,`application/x.${t.id}`))return t;return null}function Bw(r,e){if(!e)return null;for(let t of r)if(typeof e=="string"){if(Lw(e,t))return t}else if(ArrayBuffer.isView(e)){if(Cg(e.buffer,e.byteOffset,t))return t}else if(e instanceof ArrayBuffer&&Cg(e,0,t))return t;return null}function Lw(r,e){return e.testText?e.testText(r):(Array.isArray(e.tests)?e.tests:[e.tests]).some(n=>r.startsWith(n))}function Cg(r,e,t){return(Array.isArray(t.tests)?t.tests:[t.tests]).some(s=>Uw(r,e,t,s))}function Uw(r,e,t,n){if(n instanceof ArrayBuffer)return Gf(n,r,n.byteLength);switch(typeof n){case"function":return n(r);case"string":let s=uh(r,e,n.length);return n===s;default:return!1}}function Ng(r,e=5){return typeof r=="string"?r.slice(0,e):ArrayBuffer.isView(r)?uh(r.buffer,r.byteOffset,e):r instanceof ArrayBuffer?uh(r,0,e):""}function uh(r,e,t){if(r.byteLength<e+t)return"";let n=new DataView(r),s="";for(let i=0;i<t;i++)s+=String.fromCharCode(n.getUint8(e+i));return s}function*Dg(r,e){let t=e?.chunkSize||262144,n=0,s=new TextEncoder;for(;n<r.length;){let i=Math.min(r.length-n,t),o=r.slice(n,n+i);n+=i,yield s.encode(o)}}function*Fg(r,e={}){let{chunkSize:t=262144}=e,n=0;for(;n<r.byteLength;){let s=Math.min(r.byteLength-n,t),i=new ArrayBuffer(s),o=new Uint8Array(r,n,s);new Uint8Array(i).set(o),n+=s,yield i}}async function*Bg(r,e){let t=e?.chunkSize||1048576,n=0;for(;n<r.size;){let s=n+t,i=await r.slice(n,s).arrayBuffer();n=s,yield i}}function fh(r,e){return sn?Vw(r,e):zw(r,e)}async function*Vw(r,e){let t=r.getReader(),n;try{for(;;){let s=n||t.read();e?._streamReadAhead&&(n=t.read());let{done:i,value:o}=await s;if(i)return;yield ja(o)}}catch{t.releaseLock()}}async function*zw(r,e){for await(let t of r)yield ja(t)}function Lg(r,e){if(typeof r=="string")return Dg(r,e);if(r instanceof ArrayBuffer)return Fg(r,e);if(it(r))return Bg(r,e);if(Ha(r))return fh(r,e);if(st(r))return fh(r.body,e);throw new Error("makeIterator")}var Ug="Cannot convert supplied data type";function Ww(r,e,t){if(e.text&&typeof r=="string")return r;if(gg(r)&&(r=r.buffer),r instanceof ArrayBuffer){let n=r;return e.text&&!e.binary?new TextDecoder("utf8").decode(n):n}if(ArrayBuffer.isView(r)){if(e.text&&!e.binary)return new TextDecoder("utf8").decode(r);let n=r.buffer,s=r.byteLength||r.length;return(r.byteOffset!==0||s!==n.byteLength)&&(n=n.slice(r.byteOffset,r.byteOffset+s)),n}throw new Error(Ug)}async function Vg(r,e,t){let n=r instanceof ArrayBuffer||ArrayBuffer.isView(r);if(typeof r=="string"||n)return Ww(r,e,t);if(it(r)&&(r=await Ya(r)),st(r)){let s=r;return await wg(s),e.binary?await s.arrayBuffer():await s.text()}if(Ha(r)&&(r=Lg(r,t)),pg(r)||mg(r))return Jf(r);throw new Error(Ug)}function Za(r,e){let t=ch(),n=r||t;return typeof n.fetch=="function"?n.fetch:cn(n.fetch)?s=>ts(s,n.fetch):e?.fetch?e?.fetch:ts}function zg(r,e,t){if(t)return t;let n={fetch:Za(e,r),...r};if(n.url){let s=es(n.url);n.baseUrl=s,n.queryString=xg(n.url),n.filename=an.filename(s),n.baseUrl=an.dirname(s)}return Array.isArray(n.loaders)||(n.loaders=null),n}function Wg(r,e){if(r&&!Array.isArray(r))return r;let t;if(r&&(t=Array.isArray(r)?r:[r]),e&&e.loaders){let n=Array.isArray(e.loaders)?e.loaders:[e.loaders];t=t?[...t,...n]:n}return t&&t.length?t:void 0}async function Er(r,e,t,n){e&&!Array.isArray(e)&&!yi(e)&&(n=void 0,t=e,e=void 0),r=await r,t=t||{};let s=ln(r),o=Wg(e,n),a=await Mg(r,o,t);return a?(t=Eg(t,a,o,s),n=zg({url:s,_parse:Er,loaders:o},t,n||null),await $w(a,r,t,n)):null}async function $w(r,e,t,n){if(qf(r),t=Wf(r.options,t),st(e)){let i=e,{ok:o,redirected:a,status:c,statusText:l,type:u,url:f}=i,h=Object.fromEntries(i.headers.entries());n.response={headers:h,ok:o,redirected:a,status:c,statusText:l,type:u,url:f}}e=await Vg(e,r,t);let s=r;if(s.parseTextSync&&typeof e=="string")return s.parseTextSync(e,t,n);if(Kf(r,t))return await Zf(r,e,t,n,Er);if(s.parseText&&typeof e=="string")return await s.parseText(e,t,n);if(s.parse)return await s.parse(e,t,n);throw ke(!s.parseSync),new Error(`${r.id} loader - no parser found and worker is disabled`)}async function Rr(r,e,t,n){let s,i;!Array.isArray(e)&&!yi(e)?(s=[],i=e,n=void 0):(s=e,i=t);let o=Za(i),a=r;return typeof r=="string"&&(a=await o(r)),it(r)&&(a=await o(r)),Array.isArray(s)?await Er(a,s,i):await Er(a,s,i)}var $g="4.3.3";var jw=globalThis.loaders?.parseImageNode,dh=typeof Image<"u",ph=typeof ImageBitmap<"u",Hw=Boolean(jw),mh=sn?!0:Hw;function jg(r){switch(r){case"auto":return ph||dh||mh;case"imagebitmap":return ph;case"image":return dh;case"data":return mh;default:throw new Error(`@loaders.gl/images: image ${r} not supported in this environment`)}}function Hg(){if(ph)return"imagebitmap";if(dh)return"image";if(mh)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function Xw(r){let e=Yw(r);if(!e)throw new Error("Not an image");return e}function Xg(r){switch(Xw(r)){case"data":return r;case"image":case"imagebitmap":let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)throw new Error("getImageData");return e.width=r.width,e.height=r.height,t.drawImage(r,0,0),t.getImageData(0,0,r.width,r.height);default:throw new Error("getImageData")}}function Yw(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&r instanceof Image?"image":r&&typeof r=="object"&&r.data&&r.width&&r.height?"data":null}var qw=/^data:image\/svg\+xml/,Kw=/\.svg((\?|#).*)?$/;function Ga(r){return r&&(qw.test(r)||Kw.test(r))}function Yg(r,e){if(Ga(e)){let n=new TextDecoder().decode(r);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(n=unescape(encodeURIComponent(n)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(n)}`}return gh(r,e)}function gh(r,e){if(Ga(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(r)])}async function Qa(r,e,t){let n=Yg(r,t),s=self.URL||self.webkitURL,i=typeof n!="string"&&s.createObjectURL(n);try{return await Zw(i||n,e)}finally{i&&s.revokeObjectURL(i)}}async function Zw(r,e){let t=new Image;return t.src=r,e.image&&e.image.decode&&t.decode?(await t.decode(),t):await new Promise((n,s)=>{try{t.onload=()=>n(t),t.onerror=i=>{let o=i instanceof Error?i.message:"error";s(new Error(o))}}catch(i){s(i)}})}var Gw={},qg=!0;async function Kg(r,e,t){let n;Ga(t)?n=await Qa(r,e,t):n=gh(r,t);let s=e&&e.imagebitmap;return await Qw(n,s)}async function Qw(r,e=null){if((Jw(e)||!qg)&&(e=null),e)try{return await createImageBitmap(r,e)}catch(t){console.warn(t),qg=!1}return await createImageBitmap(r)}function Jw(r){for(let e in r||Gw)return!1;return!0}function Zg(r){return!n2(r,"ftyp",4)||!(r[8]&96)?null:e2(r)}function e2(r){switch(t2(r,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function t2(r,e,t){return String.fromCharCode(...r.slice(e,t))}function r2(r){return[...r].map(e=>e.charCodeAt(0))}function n2(r,e,t=0){let n=r2(e);for(let s=0;s<n.length;++s)if(n[s]!==r[s+t])return!1;return!0}var Dt=!1,Ti=!0;function Ja(r){let e=wi(r);return i2(e)||c2(e)||o2(e)||a2(e)||s2(e)}function s2(r){let e=new Uint8Array(r instanceof DataView?r.buffer:r),t=Zg(e);return t?{mimeType:t.mimeType,width:0,height:0}:null}function i2(r){let e=wi(r);return e.byteLength>=24&&e.getUint32(0,Dt)===2303741511?{mimeType:"image/png",width:e.getUint32(16,Dt),height:e.getUint32(20,Dt)}:null}function o2(r){let e=wi(r);return e.byteLength>=10&&e.getUint32(0,Dt)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,Ti),height:e.getUint16(8,Ti)}:null}function a2(r){let e=wi(r);return e.byteLength>=14&&e.getUint16(0,Dt)===16973&&e.getUint32(2,Ti)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,Ti),height:e.getUint32(22,Ti)}:null}function c2(r){let e=wi(r);if(!(e.byteLength>=3&&e.getUint16(0,Dt)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:s}=l2(),i=2;for(;i+9<e.byteLength;){let o=e.getUint16(i,Dt);if(s.has(o))return{mimeType:"image/jpeg",height:e.getUint16(i+5,Dt),width:e.getUint16(i+7,Dt)};if(!n.has(o))return null;i+=2,i+=e.getUint16(i,Dt)}return null}function l2(){let r=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)r.add(t);return{tableMarkers:r,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function wi(r){if(r instanceof DataView)return r;if(ArrayBuffer.isView(r))return new DataView(r.buffer);if(r instanceof ArrayBuffer)return new DataView(r);throw new Error("toDataView")}async function Gg(r,e){let{mimeType:t}=Ja(r)||{},n=globalThis.loaders?.parseImageNode;return vr(n),await n(r,t)}async function Qg(r,e,t){e=e||{};let s=(e.image||{}).type||"auto",{url:i}=t||{},o=u2(s),a;switch(o){case"imagebitmap":a=await Kg(r,e,i);break;case"image":a=await Qa(r,e,i);break;case"data":a=await Gg(r,e);break;default:vr(!1)}return s==="data"&&(a=Xg(a)),a}function u2(r){switch(r){case"auto":case"data":return Hg();default:return jg(r),r}}var f2=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],h2=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],d2={image:{type:"auto",decode:!0}},_h={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:$g,mimeTypes:h2,extensions:f2,parse:Qg,tests:[r=>Boolean(Ja(new DataView(r)))],options:d2};Ps();var p2=new Fe({id:"deck"}),$=p2;var yh={};function ec(r){yh=r}function he(r,e,t,n){$.level>0&&yh[r]&&yh[r].call(null,e,t,n)}function m2(r){let e=r[0],t=r[r.length-1];return e==="{"&&t==="}"||e==="["&&t==="]"}var Jg={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:m2,parseTextSync:JSON.parse};function g2(){let r="9.2.8",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==r)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${r}`);return e||($.log(1,`deck.gl ${r}`)(),globalThis.deck={...globalThis.deck,VERSION:r,version:r,log:$,_registerLoggers:ec},bi([Jg,[_h,{imagebitmap:{premultiplyAlpha:"none"}}]])),r}var tc=g2();var e_=`uniform layerUniforms {
861
+ }`}function Jf(r,e=!0,t){let n=t||new Set;if(r){if(bg(r))n.add(r);else if(bg(r.buffer))n.add(r.buffer);else if(!ArrayBuffer.isView(r)){if(e&&typeof r=="object")for(let s in r)Jf(r[s],e,n)}}return t===void 0?Array.from(n):[]}function bg(r){return r?r instanceof ArrayBuffer||typeof MessagePort<"u"&&r instanceof MessagePort||typeof ImageBitmap<"u"&&r instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&r instanceof OffscreenCanvas:!1}var eh=()=>{},vr=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&tt||typeof rs<"u"&&!tt}constructor(e){let{name:t,source:n,url:s}=e;ke(n||s),this.name=t,this.source=n,this.url=s,this.onMessage=eh,this.onError=i=>console.log(i),this.worker=tt?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=eh,this.onError=eh,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||Jf(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=yg({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=t=>{t.data?this.onMessage(t.data):this.onError(new Error("No data received"))},e.onerror=t=>{this.onError(this._getErrorFromErrorEvent(t)),this.terminated=!0},e.onmessageerror=t=>console.error(t),e}_createNodeWorker(){let e;if(this.url){let n=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;e=new rs(n,{eval:!1})}else if(this.source)e=new rs(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",t=>{this.onMessage(t)}),e.on("error",t=>{this.onError(t)}),e.on("exit",t=>{}),e}};var gi=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return vr.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},e.name!==void 0&&(this.name=e.name),e.maxConcurrency!==void 0&&(this.maxConcurrency=e.maxConcurrency),e.maxMobileConcurrency!==void 0&&(this.maxMobileConcurrency=e.maxMobileConcurrency),e.reuseWorkers!==void 0&&(this.reuseWorkers=e.reuseWorkers),e.onDebug!==void 0&&(this.onDebug=e.onDebug)}async startJob(e,t=(s,i,o)=>s.done(o),n=(s,i)=>s.error(i)){let s=new Promise(i=>(this.jobQueue.push({name:e,onMessage:t,onError:n,onStart:i}),this));return this._startQueuedJob(),await s}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});let n=new mi(t.name,e);e.onMessage=s=>t.onMessage(n,s.type,s.payload),e.onError=s=>t.onError(n,s),t.onStart(n);try{await n.result}catch(s){console.error(`Worker exception: ${s}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!tt||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;let e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new vr({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return _g?this.maxMobileConcurrency:this.maxConcurrency}};var xw={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},an=class{props;workerPools=new Map;static isSupported(){return vr.isSupported()}static getWorkerFarm(e={}){return an._workerFarm=an._workerFarm||new an({}),an._workerFarm.setProps(e),an._workerFarm}constructor(e){this.props={...xw},this.setProps(e),this.workerPools=new Map}destroy(){for(let e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(let t of this.workerPools.values())t.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:t,source:n,url:s}=e,i=this.workerPools.get(t);return i||(i=new gi({name:t,source:n,url:s}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},Ar=an;L(Ar,"_workerFarm");function th(r,e={}){let t=e[r.id]||{},n=tt?`${r.id}-worker.js`:`${r.id}-worker-node.js`,s=t.workerUrl;if(!s&&r.id==="compression"&&(s=e.workerUrl),e._workerType==="test"&&(tt?s=`modules/${r.module}/dist/${n}`:s=`modules/${r.module}/src/workers/${r.id}-worker-node.ts`),!s){let i=r.version;i==="latest"&&(i=mg);let o=i?`@${i}`:"";s=`https://unpkg.com/@loaders.gl/${r.module}${o}/dist/${n}`}return ke(s),s}function rh(r,e=Gf){ke(r,"no worker provided");let t=r.version;return!(!e||!t)}function nh(r,e){return!Ar.isSupported()||!tt&&!e?._nodeWorkers?!1:r.worker&&e?.worker}async function sh(r,e,t,n,s){let i=r.id,o=th(r,t),c=Ar.getWorkerFarm(t).getWorkerPool({name:i,url:o});t=JSON.parse(JSON.stringify(t)),n=JSON.parse(JSON.stringify(n||{}));let l=await c.startJob("process-on-worker",bw.bind(null,s));return l.postMessage("process",{input:e,options:t,context:n}),await(await l.result).result}async function bw(r,e,t,n){switch(t){case"done":e.done(n);break;case"error":e.error(new Error(n.error));break;case"process":let{id:s,input:i,options:o}=n;try{let a=await r(i,o);e.postMessage("done",{id:s,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:s,error:c})}break;default:console.warn(`parse-with-worker unknown message ${t}`)}}function ih(r,e,t){if(t=t||r.byteLength,r.byteLength<t||e.byteLength<t)return!1;let n=new Uint8Array(r),s=new Uint8Array(e);for(let i=0;i<n.length;++i)if(n[i]!==s[i])return!1;return!0}function oh(...r){return Tg(r)}function Tg(r){let e=r.map(i=>i instanceof ArrayBuffer?new Uint8Array(i):i),t=e.reduce((i,o)=>i+o.byteLength,0),n=new Uint8Array(t),s=0;for(let i of e)n.set(i,s),s+=i.byteLength;return n.buffer}async function ah(r){let e=[];for await(let t of r)e.push(t);return oh(...e)}var Tw="",wg={};function ch(r){for(let e in wg)if(r.startsWith(e)){let t=wg[e];r=r.replace(e,t)}return!r.startsWith("http://")&&!r.startsWith("https://")&&(r=`${Tw}${r}`),r}function vg(r){return r&&typeof r=="object"&&r.isBuffer}function Ka(r){if(vg(r))return r;if(r instanceof ArrayBuffer)return r;if(ArrayBuffer.isView(r))return r.byteOffset===0&&r.byteLength===r.buffer.byteLength?r.buffer:r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength);if(typeof r=="string"){let e=r;return new TextEncoder().encode(e).buffer}if(r&&typeof r=="object"&&r._toArrayBuffer)return r._toArrayBuffer();throw new Error("toArrayBuffer")}var cn={};$t(cn,{dirname:()=>vw,filename:()=>ww,join:()=>Aw,resolve:()=>Sw});function Ag(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let r=window.location?.pathname;return r?.slice(0,r.lastIndexOf("/")+1)||""}function ww(r){let e=r?r.lastIndexOf("/"):-1;return e>=0?r.substr(e+1):""}function vw(r){let e=r?r.lastIndexOf("/"):-1;return e>=0?r.substr(0,e):""}function Aw(...r){let e="/";return r=r.map((t,n)=>(n&&(t=t.replace(new RegExp(`^${e}`),"")),n!==r.length-1&&(t=t.replace(new RegExp(`${e}$`),"")),t)),r.join(e)}function Sw(...r){let e=[];for(let i=0;i<r.length;i++)e[i]=r[i];let t="",n=!1,s;for(let i=e.length-1;i>=-1&&!n;i--){let o;i>=0?o=e[i]:(s===void 0&&(s=Ag()),o=s),o.length!==0&&(t=`${o}/${t}`,n=o.charCodeAt(0)===_i)}return t=Ew(t,!n),n?`/${t}`:t.length>0?t:"."}var _i=47,lh=46;function Ew(r,e){let t="",n=-1,s=0,i,o=!1;for(let a=0;a<=r.length;++a){if(a<r.length)i=r.charCodeAt(a);else{if(i===_i)break;i=_i}if(i===_i){if(!(n===a-1||s===1))if(n!==a-1&&s===2){if(t.length<2||!o||t.charCodeAt(t.length-1)!==lh||t.charCodeAt(t.length-2)!==lh){if(t.length>2){let c=t.length-1,l=c;for(;l>=0&&t.charCodeAt(l)!==_i;--l);if(l!==c){t=l===-1?"":t.slice(0,l),n=a,s=0,o=!1;continue}}else if(t.length===2||t.length===1){t="",n=a,s=0,o=!1;continue}}e&&(t.length>0?t+="/..":t="..",o=!0)}else{let c=r.slice(n+1,a);t.length>0?t+=`/${c}`:t=c,o=!1}n=a,s=0}else i===lh&&s!==-1?++s:s=-1}return t}var Rw=r=>typeof r=="boolean",yi=r=>typeof r=="function",ln=r=>r!==null&&typeof r=="object",uh=r=>ln(r)&&r.constructor==={}.constructor;var Sg=r=>Boolean(r)&&typeof r[Symbol.iterator]=="function",Eg=r=>r&&typeof r[Symbol.asyncIterator]=="function";var rt=r=>typeof Response<"u"&&r instanceof Response||r&&r.arrayBuffer&&r.text&&r.json;var nt=r=>typeof Blob<"u"&&r instanceof Blob,Rg=r=>r&&typeof r=="object"&&r.isBuffer;var Iw=r=>typeof ReadableStream<"u"&&r instanceof ReadableStream||ln(r)&&yi(r.tee)&&yi(r.cancel)&&yi(r.getReader);var Pw=r=>ln(r)&&yi(r.read)&&yi(r.pipe)&&Rw(r.readable),Za=r=>Iw(r)||Pw(r);var Ga=class extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response};var Cw=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,Mw=/^([-\w.]+\/[-\w.+]+)/;function fh(r,e){return r.toLowerCase()===e.toLowerCase()}function Ig(r){let e=Mw.exec(r);return e?e[1]:r}function hh(r){let e=Cw.exec(r);return e?e[1]:""}var Pg=/\?.*/;function Cg(r){let e=r.match(Pg);return e&&e[0]}function ns(r){return r.replace(Pg,"")}function Mg(r){if(r.length<50)return r;let e=r.slice(r.length-15);return`${r.substr(0,32)}...${e}`}function un(r){return rt(r)?r.url:nt(r)?r.name||"":typeof r=="string"?r:""}function xi(r){if(rt(r)){let e=r,t=e.headers.get("content-type")||"",n=ns(e.url);return Ig(t)||hh(n)}return nt(r)?r.type||"":typeof r=="string"?hh(r):""}function Og(r){return rt(r)?r.headers["content-length"]||-1:nt(r)?r.size:typeof r=="string"?r.length:r instanceof ArrayBuffer||ArrayBuffer.isView(r)?r.byteLength:-1}async function Qa(r){if(rt(r))return r;let e={},t=Og(r);t>=0&&(e["content-length"]=String(t));let n=un(r),s=xi(r);s&&(e["content-type"]=s);let i=await kw(r);i&&(e["x-first-bytes"]=i),typeof r=="string"&&(r=new TextEncoder().encode(r));let o=new Response(r,{headers:e});return Object.defineProperty(o,"url",{value:n}),o}async function kg(r){if(!r.ok)throw await Ow(r)}async function Ow(r){let e=Mg(r.url),t=`Failed to fetch resource (${r.status}) ${r.statusText}: ${e}`;t=t.length>100?`${t.slice(0,100)}...`:t;let n={reason:r.statusText,url:r.url,response:r};try{let s=r.headers.get("Content-Type");n.reason=!r.bodyUsed&&s?.includes("application/json")?await r.json():await r.text()}catch{}return new Ga(t,n)}async function kw(r){if(typeof r=="string")return`data:,${r.slice(0,5)}`;if(r instanceof Blob){let t=r.slice(0,5);return await new Promise(n=>{let s=new FileReader;s.onload=i=>n(i?.target?.result),s.readAsDataURL(t)})}if(r instanceof ArrayBuffer){let t=r.slice(0,5);return`data:base64,${Nw(t)}`}return null}function Nw(r){let e="",t=new Uint8Array(r);for(let n=0;n<t.byteLength;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function Dw(r){return!Fw(r)&&!Bw(r)}function Fw(r){return r.startsWith("http:")||r.startsWith("https:")}function Bw(r){return r.startsWith("data:")}async function ss(r,e){if(typeof r=="string"){let t=ch(r);return Dw(t)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(t,e):await fetch(t,e)}return await Qa(r)}Cs();var dh=new Ie({id:"loaders.gl"}),Ja=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},ec=class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var ph={fetch:null,mimeType:void 0,nothrow:!1,log:new ec,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:on,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},Ng={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function mh(){globalThis.loaders=globalThis.loaders||{};let{loaders:r}=globalThis;return r._state||(r._state={}),r._state}function gh(){let r=mh();return r.globalOptions=r.globalOptions||{...ph},r.globalOptions}function Bg(r,e,t,n){return t=t||[],t=Array.isArray(t)?t:[t],Lw(r,t),Vw(e,r,n)}function Lw(r,e){Dg(r,null,ph,Ng,e);for(let t of e){let n=r&&r[t.id]||{},s=t.options&&t.options[t.id]||{},i=t.deprecatedOptions&&t.deprecatedOptions[t.id]||{};Dg(n,t.id,s,i,e)}}function Dg(r,e,t,n,s){let i=e||"Top level",o=e?`${e}.`:"";for(let a in r){let c=!e&&ln(r[a]),l=a==="baseUri"&&!e,u=a==="workerUrl"&&e;if(!(a in t)&&!l&&!u){if(a in n)dh.warn(`${i} loader option '${o}${a}' no longer supported, use '${n[a]}'`)();else if(!c){let f=Uw(a,s);dh.warn(`${i} loader option '${o}${a}' not recognized. ${f}`)()}}}}function Uw(r,e){let t=r.toLowerCase(),n="";for(let s of e)for(let i in s.options){if(r===i)return`Did you mean '${s.id}.${i}'?`;let o=i.toLowerCase();(t.startsWith(o)||o.startsWith(t))&&(n=n||`Did you mean '${s.id}.${i}'?`)}return n}function Vw(r,e,t){let s={...r.options||{}};return zw(s,t),s.log===null&&(s.log=new Ja),Fg(s,gh()),Fg(s,e),s}function Fg(r,e){for(let t in e)if(t in e){let n=e[t];uh(n)&&uh(r[t])?r[t]={...r[t],...e[t]}:r[t]=e[t]}}function zw(r,e){e&&!("baseUri"in r)&&(r.baseUri=e)}function bi(r){return r?(Array.isArray(r)&&(r=r[0]),Array.isArray(r?.extensions)):!1}function Ti(r){wr(r,"null loader"),wr(bi(r),"invalid loader");let e;return Array.isArray(r)&&(e=r[1],r=r[0],r={...r,options:{...r.options,...e}}),(r?.parseTextSync||r?.parseText)&&(r.text=!0),r.text||(r.binary=!0),r}var Lg=()=>{let r=mh();return r.loaderRegistry=r.loaderRegistry||[],r.loaderRegistry};function wi(r){let e=Lg();r=Array.isArray(r)?r:[r];for(let t of r){let n=Ti(t);e.find(s=>n===s)||e.unshift(n)}}function Ug(){return Lg()}var Ww=/\.([^.]+)$/;async function Wg(r,e=[],t,n){if(!$g(r))return null;let s=Vg(r,e,{...t,nothrow:!0},n);if(s)return s;if(nt(r)&&(r=await r.slice(0,10).arrayBuffer(),s=Vg(r,e,t,n)),!s&&!t?.nothrow)throw new Error(jg(r));return s}function Vg(r,e=[],t,n){if(!$g(r))return null;if(e&&!Array.isArray(e))return Ti(e);let s=[];e&&(s=s.concat(e)),t?.ignoreRegisteredLoaders||s.push(...Ug()),jw(s);let i=$w(r,s,t,n);if(!i&&!t?.nothrow)throw new Error(jg(r));return i}function $w(r,e,t,n){let s=un(r),i=xi(r),o=ns(s)||n?.url,a=null,c="";return t?.mimeType&&(a=_h(e,t?.mimeType),c=`match forced by supplied MIME type ${t?.mimeType}`),a=a||Hw(e,o),c=c||(a?`matched url ${o}`:""),a=a||_h(e,i),c=c||(a?`matched MIME type ${i}`:""),a=a||Yw(e,r),c=c||(a?`matched initial data ${Hg(r)}`:""),t?.fallbackMimeType&&(a=a||_h(e,t?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${i}`:"")),c&&Kf.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function $g(r){return!(r instanceof Response&&r.status===204)}function jg(r){let e=un(r),t=xi(r),n="No valid loader found (";n+=e?`${cn.filename(e)}, `:"no url provided, ",n+=`MIME type: ${t?`"${t}"`:"not provided"}, `;let s=r?Hg(r):"";return n+=s?` first bytes: "${s}"`:"first bytes: not available",n+=")",n}function jw(r){for(let e of r)Ti(e)}function Hw(r,e){let t=e&&Ww.exec(e),n=t&&t[1];return n?Xw(r,n):null}function Xw(r,e){e=e.toLowerCase();for(let t of r)for(let n of t.extensions)if(n.toLowerCase()===e)return t;return null}function _h(r,e){for(let t of r)if(t.mimeTypes?.some(n=>fh(e,n))||fh(e,`application/x.${t.id}`))return t;return null}function Yw(r,e){if(!e)return null;for(let t of r)if(typeof e=="string"){if(qw(e,t))return t}else if(ArrayBuffer.isView(e)){if(zg(e.buffer,e.byteOffset,t))return t}else if(e instanceof ArrayBuffer&&zg(e,0,t))return t;return null}function qw(r,e){return e.testText?e.testText(r):(Array.isArray(e.tests)?e.tests:[e.tests]).some(n=>r.startsWith(n))}function zg(r,e,t){return(Array.isArray(t.tests)?t.tests:[t.tests]).some(s=>Kw(r,e,t,s))}function Kw(r,e,t,n){if(n instanceof ArrayBuffer)return ih(n,r,n.byteLength);switch(typeof n){case"function":return n(r);case"string":let s=yh(r,e,n.length);return n===s;default:return!1}}function Hg(r,e=5){return typeof r=="string"?r.slice(0,e):ArrayBuffer.isView(r)?yh(r.buffer,r.byteOffset,e):r instanceof ArrayBuffer?yh(r,0,e):""}function yh(r,e,t){if(r.byteLength<e+t)return"";let n=new DataView(r),s="";for(let i=0;i<t;i++)s+=String.fromCharCode(n.getUint8(e+i));return s}function*Xg(r,e){let t=e?.chunkSize||262144,n=0,s=new TextEncoder;for(;n<r.length;){let i=Math.min(r.length-n,t),o=r.slice(n,n+i);n+=i,yield s.encode(o)}}function*Yg(r,e={}){let{chunkSize:t=262144}=e,n=0;for(;n<r.byteLength;){let s=Math.min(r.byteLength-n,t),i=new ArrayBuffer(s),o=new Uint8Array(r,n,s);new Uint8Array(i).set(o),n+=s,yield i}}async function*qg(r,e){let t=e?.chunkSize||1048576,n=0;for(;n<r.size;){let s=n+t,i=await r.slice(n,s).arrayBuffer();n=s,yield i}}function xh(r,e){return on?Zw(r,e):Gw(r,e)}async function*Zw(r,e){let t=r.getReader(),n;try{for(;;){let s=n||t.read();e?._streamReadAhead&&(n=t.read());let{done:i,value:o}=await s;if(i)return;yield Ka(o)}}catch{t.releaseLock()}}async function*Gw(r,e){for await(let t of r)yield Ka(t)}function Kg(r,e){if(typeof r=="string")return Xg(r,e);if(r instanceof ArrayBuffer)return Yg(r,e);if(nt(r))return qg(r,e);if(Za(r))return xh(r,e);if(rt(r))return xh(r.body,e);throw new Error("makeIterator")}var Zg="Cannot convert supplied data type";function Qw(r,e,t){if(e.text&&typeof r=="string")return r;if(Rg(r)&&(r=r.buffer),r instanceof ArrayBuffer){let n=r;return e.text&&!e.binary?new TextDecoder("utf8").decode(n):n}if(ArrayBuffer.isView(r)){if(e.text&&!e.binary)return new TextDecoder("utf8").decode(r);let n=r.buffer,s=r.byteLength||r.length;return(r.byteOffset!==0||s!==n.byteLength)&&(n=n.slice(r.byteOffset,r.byteOffset+s)),n}throw new Error(Zg)}async function Gg(r,e,t){let n=r instanceof ArrayBuffer||ArrayBuffer.isView(r);if(typeof r=="string"||n)return Qw(r,e,t);if(nt(r)&&(r=await Qa(r)),rt(r)){let s=r;return await kg(s),e.binary?await s.arrayBuffer():await s.text()}if(Za(r)&&(r=Kg(r,t)),Sg(r)||Eg(r))return ah(r);throw new Error(Zg)}function tc(r,e){let t=gh(),n=r||t;return typeof n.fetch=="function"?n.fetch:ln(n.fetch)?s=>ss(s,n.fetch):e?.fetch?e?.fetch:ss}function Qg(r,e,t){if(t)return t;let n={fetch:tc(e,r),...r};if(n.url){let s=ns(n.url);n.baseUrl=s,n.queryString=Cg(n.url),n.filename=cn.filename(s),n.baseUrl=cn.dirname(s)}return Array.isArray(n.loaders)||(n.loaders=null),n}function Jg(r,e){if(r&&!Array.isArray(r))return r;let t;if(r&&(t=Array.isArray(r)?r:[r]),e&&e.loaders){let n=Array.isArray(e.loaders)?e.loaders:[e.loaders];t=t?[...t,...n]:n}return t&&t.length?t:void 0}async function Sr(r,e,t,n){e&&!Array.isArray(e)&&!bi(e)&&(n=void 0,t=e,e=void 0),r=await r,t=t||{};let s=un(r),o=Jg(e,n),a=await Wg(r,o,t);return a?(t=Bg(t,a,o,s),n=Qg({url:s,_parse:Sr,loaders:o},t,n||null),await Jw(a,r,t,n)):null}async function Jw(r,e,t,n){if(rh(r),t=Zf(r.options,t),rt(e)){let i=e,{ok:o,redirected:a,status:c,statusText:l,type:u,url:f}=i,h=Object.fromEntries(i.headers.entries());n.response={headers:h,ok:o,redirected:a,status:c,statusText:l,type:u,url:f}}e=await Gg(e,r,t);let s=r;if(s.parseTextSync&&typeof e=="string")return s.parseTextSync(e,t,n);if(nh(r,t))return await sh(r,e,t,n,Sr);if(s.parseText&&typeof e=="string")return await s.parseText(e,t,n);if(s.parse)return await s.parse(e,t,n);throw ke(!s.parseSync),new Error(`${r.id} loader - no parser found and worker is disabled`)}async function Er(r,e,t,n){let s,i;!Array.isArray(e)&&!bi(e)?(s=[],i=e,n=void 0):(s=e,i=t);let o=tc(i),a=r;return typeof r=="string"&&(a=await o(r)),nt(r)&&(a=await o(r)),Array.isArray(s)?await Sr(a,s,i):await Sr(a,s,i)}var e_="4.3.3";var e2=globalThis.loaders?.parseImageNode,Th=typeof Image<"u",wh=typeof ImageBitmap<"u",t2=Boolean(e2),vh=on?!0:t2;function t_(r){switch(r){case"auto":return wh||Th||vh;case"imagebitmap":return wh;case"image":return Th;case"data":return vh;default:throw new Error(`@loaders.gl/images: image ${r} not supported in this environment`)}}function r_(){if(wh)return"imagebitmap";if(Th)return"image";if(vh)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function r2(r){let e=n2(r);if(!e)throw new Error("Not an image");return e}function n_(r){switch(r2(r)){case"data":return r;case"image":case"imagebitmap":let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)throw new Error("getImageData");return e.width=r.width,e.height=r.height,t.drawImage(r,0,0),t.getImageData(0,0,r.width,r.height);default:throw new Error("getImageData")}}function n2(r){return typeof ImageBitmap<"u"&&r instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&r instanceof Image?"image":r&&typeof r=="object"&&r.data&&r.width&&r.height?"data":null}var s2=/^data:image\/svg\+xml/,i2=/\.svg((\?|#).*)?$/;function rc(r){return r&&(s2.test(r)||i2.test(r))}function s_(r,e){if(rc(e)){let n=new TextDecoder().decode(r);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(n=unescape(encodeURIComponent(n)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(n)}`}return Ah(r,e)}function Ah(r,e){if(rc(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(r)])}async function nc(r,e,t){let n=s_(r,t),s=self.URL||self.webkitURL,i=typeof n!="string"&&s.createObjectURL(n);try{return await o2(i||n,e)}finally{i&&s.revokeObjectURL(i)}}async function o2(r,e){let t=new Image;return t.src=r,e.image&&e.image.decode&&t.decode?(await t.decode(),t):await new Promise((n,s)=>{try{t.onload=()=>n(t),t.onerror=i=>{let o=i instanceof Error?i.message:"error";s(new Error(o))}}catch(i){s(i)}})}var a2={},i_=!0;async function o_(r,e,t){let n;rc(t)?n=await nc(r,e,t):n=Ah(r,t);let s=e&&e.imagebitmap;return await c2(n,s)}async function c2(r,e=null){if((l2(e)||!i_)&&(e=null),e)try{return await createImageBitmap(r,e)}catch(t){console.warn(t),i_=!1}return await createImageBitmap(r)}function l2(r){for(let e in r||a2)return!1;return!0}function a_(r){return!d2(r,"ftyp",4)||!(r[8]&96)?null:u2(r)}function u2(r){switch(f2(r,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function f2(r,e,t){return String.fromCharCode(...r.slice(e,t))}function h2(r){return[...r].map(e=>e.charCodeAt(0))}function d2(r,e,t=0){let n=h2(e);for(let s=0;s<n.length;++s)if(n[s]!==r[s+t])return!1;return!0}var kt=!1,vi=!0;function sc(r){let e=Ai(r);return m2(e)||y2(e)||g2(e)||_2(e)||p2(e)}function p2(r){let e=new Uint8Array(r instanceof DataView?r.buffer:r),t=a_(e);return t?{mimeType:t.mimeType,width:0,height:0}:null}function m2(r){let e=Ai(r);return e.byteLength>=24&&e.getUint32(0,kt)===2303741511?{mimeType:"image/png",width:e.getUint32(16,kt),height:e.getUint32(20,kt)}:null}function g2(r){let e=Ai(r);return e.byteLength>=10&&e.getUint32(0,kt)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,vi),height:e.getUint16(8,vi)}:null}function _2(r){let e=Ai(r);return e.byteLength>=14&&e.getUint16(0,kt)===16973&&e.getUint32(2,vi)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,vi),height:e.getUint32(22,vi)}:null}function y2(r){let e=Ai(r);if(!(e.byteLength>=3&&e.getUint16(0,kt)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:s}=x2(),i=2;for(;i+9<e.byteLength;){let o=e.getUint16(i,kt);if(s.has(o))return{mimeType:"image/jpeg",height:e.getUint16(i+5,kt),width:e.getUint16(i+7,kt)};if(!n.has(o))return null;i+=2,i+=e.getUint16(i,kt)}return null}function x2(){let r=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)r.add(t);return{tableMarkers:r,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function Ai(r){if(r instanceof DataView)return r;if(ArrayBuffer.isView(r))return new DataView(r.buffer);if(r instanceof ArrayBuffer)return new DataView(r);throw new Error("toDataView")}async function c_(r,e){let{mimeType:t}=sc(r)||{},n=globalThis.loaders?.parseImageNode;return wr(n),await n(r,t)}async function l_(r,e,t){e=e||{};let s=(e.image||{}).type||"auto",{url:i}=t||{},o=b2(s),a;switch(o){case"imagebitmap":a=await o_(r,e,i);break;case"image":a=await nc(r,e,i);break;case"data":a=await c_(r,e);break;default:wr(!1)}return s==="data"&&(a=n_(a)),a}function b2(r){switch(r){case"auto":case"data":return r_();default:return t_(r),r}}var T2=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],w2=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],v2={image:{type:"auto",decode:!0}},Sh={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:e_,mimeTypes:w2,extensions:T2,parse:l_,tests:[r=>Boolean(sc(new DataView(r)))],options:v2};Cs();var A2=new Ie({id:"deck"}),$=A2;var Eh={};function ic(r){Eh=r}function he(r,e,t,n){$.level>0&&Eh[r]&&Eh[r].call(null,e,t,n)}function S2(r){let e=r[0],t=r[r.length-1];return e==="{"&&t==="}"||e==="["&&t==="]"}var u_={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:S2,parseTextSync:JSON.parse};function E2(){let r="9.2.10",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==r)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${r}`);return e||($.log(1,`deck.gl ${r}`)(),globalThis.deck={...globalThis.deck,VERSION:r,version:r,log:$,_registerLoggers:ic},wi([u_,[Sh,{imagebitmap:{premultiplyAlpha:"none"}}]])),r}var oc=E2();var f_=`uniform layerUniforms {
862
862
  uniform float opacity;
863
863
  } layer;
864
- `,xh={name:"layer",vs:e_,fs:e_,getUniforms:r=>({opacity:Math.pow(r.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var _2=`
864
+ `,Rh={name:"layer",vs:f_,fs:f_,getUniforms:r=>({opacity:Math.pow(r.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var R2=`
865
865
 
866
866
  struct ColorUniforms {
867
867
  opacity: f32,
@@ -876,7 +876,7 @@ var<private> color: ColorUniforms = ColorUniforms(1.0);
876
876
  fn deckgl_premultiplied_alpha(fragColor: vec4<f32>) -> vec4<f32> {
877
877
  return vec4(fragColor.rgb * fragColor.a, fragColor.a);
878
878
  };
879
- `,bh={name:"color",dependencies:[],source:_2,getUniforms:r=>({}),uniformTypes:{opacity:"f32"}};var y2=`const SMOOTH_EDGE_RADIUS: f32 = 0.5;
879
+ `,Ih={name:"color",dependencies:[],source:R2,getUniforms:r=>({}),uniformTypes:{opacity:"f32"}};var I2=`const SMOOTH_EDGE_RADIUS: f32 = 0.5;
880
880
 
881
881
  struct VertexGeometry {
882
882
  position: vec4<f32>,
@@ -905,7 +905,7 @@ var<private> fragmentGeometry: FragmentGeometry;
905
905
  fn smoothedge(edge: f32, x: f32) -> f32 {
906
906
  return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
907
907
  }
908
- `,t_="#define SMOOTH_EDGE_RADIUS 0.5",x2=`${t_}
908
+ `,h_="#define SMOOTH_EDGE_RADIUS 0.5",P2=`${h_}
909
909
 
910
910
  struct VertexGeometry {
911
911
  vec4 position;
@@ -922,7 +922,7 @@ struct VertexGeometry {
922
922
  vec2(0.0),
923
923
  vec3(0.0)
924
924
  );
925
- `,b2=`${t_}
925
+ `,C2=`${h_}
926
926
 
927
927
  struct FragmentGeometry {
928
928
  vec2 uv;
@@ -931,9 +931,9 @@ struct FragmentGeometry {
931
931
  float smoothedge(float edge, float x) {
932
932
  return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
933
933
  }
934
- `,rc={name:"geometry",source:y2,vs:x2,fs:b2};var ne;(function(r){r[r.Start=1]="Start",r[r.Move=2]="Move",r[r.End=4]="End",r[r.Cancel=8]="Cancel"})(ne||(ne={}));var ae;(function(r){r[r.None=0]="None",r[r.Left=1]="Left",r[r.Right=2]="Right",r[r.Up=4]="Up",r[r.Down=8]="Down",r[r.Horizontal=3]="Horizontal",r[r.Vertical=12]="Vertical",r[r.All=15]="All"})(ae||(ae={}));var V;(function(r){r[r.Possible=1]="Possible",r[r.Began=2]="Began",r[r.Changed=4]="Changed",r[r.Ended=8]="Ended",r[r.Recognized=8]="Recognized",r[r.Cancelled=16]="Cancelled",r[r.Failed=32]="Failed"})(V||(V={}));var r_="compute",Th="auto",vi="manipulation",un="none",Ai="pan-x",Si="pan-y";function wh(r){if(r.includes(un))return un;let e=r.includes(Ai),t=r.includes(Si);return e&&t?un:e||t?e?Ai:Si:r.includes(vi)?vi:Th}var Ei=class{constructor(e,t){this.actions="",this.manager=e,this.set(t)}set(e){e===r_&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(let t of this.manager.recognizers)t.options.enable&&(e=e.concat(t.getTouchAction()));return wh(e.join(" "))}};function rs(r){return r.trim().split(/\s+/g)}function nc(r,e,t){if(r)for(let n of rs(e))r.addEventListener(n,t,!1)}function sc(r,e,t){if(r)for(let n of rs(e))r.removeEventListener(n,t,!1)}function vh(r){return(r.ownerDocument||r).defaultView}function Ah(r,e){let t=r;for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function ic(r){let e=r.length;if(e===1)return{x:Math.round(r[0].clientX),y:Math.round(r[0].clientY)};let t=0,n=0,s=0;for(;s<e;)t+=r[s].clientX,n+=r[s].clientY,s++;return{x:Math.round(t/e),y:Math.round(n/e)}}function Sh(r){let e=[],t=0;for(;t<r.pointers.length;)e[t]={clientX:Math.round(r.pointers[t].clientX),clientY:Math.round(r.pointers[t].clientY)},t++;return{timeStamp:Date.now(),pointers:e,center:ic(e),deltaX:r.deltaX,deltaY:r.deltaY}}function oc(r,e){let t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function Eh(r,e){let t=e.clientX-r.clientX,n=e.clientY-r.clientY;return Math.sqrt(t*t+n*n)}function n_(r,e){let t=e.x-r.x,n=e.y-r.y;return Math.atan2(n,t)*180/Math.PI}function Rh(r,e){let t=e.clientX-r.clientX,n=e.clientY-r.clientY;return Math.atan2(n,t)*180/Math.PI}function ac(r,e){return r===e?ae.None:Math.abs(r)>=Math.abs(e)?r<0?ae.Left:ae.Right:e<0?ae.Up:ae.Down}function s_(r,e){let t=e.center,n=r.offsetDelta,s=r.prevDelta,i=r.prevInput;return(e.eventType===ne.Start||i?.eventType===ne.End)&&(s=r.prevDelta={x:i?.deltaX||0,y:i?.deltaY||0},n=r.offsetDelta={x:t.x,y:t.y}),{deltaX:s.x+(t.x-n.x),deltaY:s.y+(t.y-n.y)}}function cc(r,e,t){return{x:e/r||0,y:t/r||0}}function i_(r,e){return Eh(e[0],e[1])/Eh(r[0],r[1])}function o_(r,e){return Rh(e[1],e[0])-Rh(r[1],r[0])}function a_(r,e){let t=r.lastInterval||e,n=e.timeStamp-t.timeStamp,s,i,o,a;if(e.eventType!==ne.Cancel&&(n>25||t.velocity===void 0)){let c=e.deltaX-t.deltaX,l=e.deltaY-t.deltaY,u=cc(n,c,l);i=u.x,o=u.y,s=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,a=ac(c,l),r.lastInterval=e}else s=t.velocity,i=t.velocityX,o=t.velocityY,a=t.direction;e.velocity=s,e.velocityX=i,e.velocityY=o,e.direction=a}function c_(r,e){let{session:t}=r,{pointers:n}=e,{length:s}=n;t.firstInput||(t.firstInput=Sh(e)),s>1&&!t.firstMultiple?t.firstMultiple=Sh(e):s===1&&(t.firstMultiple=!1);let{firstInput:i,firstMultiple:o}=t,a=o?o.center:i.center,c=e.center=ic(n);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-i.timeStamp,e.angle=n_(a,c),e.distance=oc(a,c);let{deltaX:l,deltaY:u}=s_(t,e);e.deltaX=l,e.deltaY=u,e.offsetDirection=ac(e.deltaX,e.deltaY);let f=cc(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=f.x,e.overallVelocityY=f.y,e.overallVelocity=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,e.scale=o?i_(o.pointers,n):1,e.rotation=o?o_(o.pointers,n):0,e.maxPointers=t.prevInput?e.pointers.length>t.prevInput.maxPointers?e.pointers.length:t.prevInput.maxPointers:e.pointers.length;let h=r.element;return Ah(e.srcEvent.target,h)&&(h=e.srcEvent.target),e.target=h,a_(t,e),e}function l_(r,e,t){let n=t.pointers.length,s=t.changedPointers.length,i=e&ne.Start&&n-s===0,o=e&(ne.End|ne.Cancel)&&n-s===0;t.isFirst=Boolean(i),t.isFinal=Boolean(o),i&&(r.session={}),t.eventType=e;let a=c_(r,t);r.emit("hammer.input",a),r.recognize(a),r.session.prevInput=a}var Ri=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=t=>{this.manager.options.enable&&this.handler(t)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,t){l_(this.manager,e,t)}init(){nc(this.element,this.evEl,this.domHandler),nc(this.target,this.evTarget,this.domHandler),nc(vh(this.element),this.evWin,this.domHandler)}destroy(){sc(this.element,this.evEl,this.domHandler),sc(this.target,this.evTarget,this.domHandler),sc(vh(this.element),this.evWin,this.domHandler)}};var w2={pointerdown:ne.Start,pointermove:ne.Move,pointerup:ne.End,pointercancel:ne.Cancel,pointerout:ne.Cancel},v2="pointerdown",A2="pointermove pointerup pointercancel",Ii=class extends Ri{constructor(e){super(e),this.evEl=v2,this.evWin=A2,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:t}=this,n=!1,s=w2[e.type],i=e.pointerType,o=i==="touch",a=t.findIndex(c=>c.pointerId===e.pointerId);s&ne.Start&&(e.buttons||o)?a<0&&(t.push(e),a=t.length-1):s&(ne.End|ne.Cancel)&&(n=!0),!(a<0)&&(t[a]=e,this.callback(s,{pointers:t,changedPointers:[e],eventType:s,pointerType:i,srcEvent:e}),n&&t.splice(a,1))}};var S2=["","webkit","Moz","MS","ms","o"];function u_(r,e){let t=e[0].toUpperCase()+e.slice(1);for(let n of S2){let s=n?n+t:e;if(s in r)return s}}var E2=1,f_=2,h_={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},Pi=class{constructor(e,t){this.options={...h_,...t,cssProps:{...h_.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new Ii(this),this.touchAction=new Ei(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?f_:E2}recognize(e){let{session:t}=this;if(t.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let n,{recognizers:s}=this,{curRecognizer:i}=t;(!i||i&&i.state&V.Recognized)&&(i=t.curRecognizer=null);let o=0;for(;o<s.length;)n=s[o],t.stopped!==f_&&(!i||n===i||n.canRecognizeWith(i))?n.recognize(e):n.reset(),!i&&n.state&(V.Began|V.Changed|V.Ended)&&(i=t.curRecognizer=n),o++}get(e){let{recognizers:t}=this;for(let n=0;n<t.length;n++)if(t[n].options.event===e)return t[n];return null}add(e){if(Array.isArray(e)){for(let n of e)this.add(n);return this}let t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(let n of e)this.remove(n);return this}let t=typeof e=="string"?this.get(e):e;if(t){let{recognizers:n}=this,s=n.indexOf(t);s!==-1&&(n.splice(s,1),this.touchAction.update())}return this}on(e,t){if(!e||!t)return;let{handlers:n}=this;for(let s of rs(e))n[s]=n[s]||[],n[s].push(t)}off(e,t){if(!e)return;let{handlers:n}=this;for(let s of rs(e))t?n[s]&&n[s].splice(n[s].indexOf(t),1):delete n[s]}emit(e,t){let n=this.handlers[e]&&this.handlers[e].slice();if(!n||!n.length)return;let s=t;s.type=e,s.preventDefault=function(){t.srcEvent.preventDefault()};let i=0;for(;i<n.length;)n[i](s),i++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){let{element:t}=this;if(t){for(let[n,s]of Object.entries(this.options.cssProps)){let i=u_(t.style,n);e?(this.oldCssProps[i]=t.style[i],t.style[i]=s):t.style[i]=this.oldCssProps[i]||""}e||(this.oldCssProps={})}}};var R2=1;function d_(){return R2++}function Ih(r){return r&V.Cancelled?"cancel":r&V.Ended?"end":r&V.Changed?"move":r&V.Began?"start":""}var er=class{constructor(e){this.options=e,this.id=d_(),this.state=V.Possible,this.simultaneous={},this.requireFail=[]}set(e){return Object.assign(this.options,e),this.manager.touchAction.update(),this}recognizeWith(e){if(Array.isArray(e)){for(let s of e)this.recognizeWith(s);return this}let t;if(typeof e=="string"){if(t=this.manager.get(e),!t)throw new Error(`Cannot find recognizer ${e}`)}else t=e;let{simultaneous:n}=this;return n[t.id]||(n[t.id]=t,t.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(let n of e)this.dropRecognizeWith(n);return this}let t;return typeof e=="string"?t=this.manager.get(e):t=e,t&&delete this.simultaneous[t.id],this}requireFailure(e){if(Array.isArray(e)){for(let s of e)this.requireFailure(s);return this}let t;if(typeof e=="string"){if(t=this.manager.get(e),!t)throw new Error(`Cannot find recognizer ${e}`)}else t=e;let{requireFail:n}=this;return n.indexOf(t)===-1&&(n.push(t),t.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(let n of e)this.dropRequireFailure(n);return this}let t;if(typeof e=="string"?t=this.manager.get(e):t=e,t){let n=this.requireFail.indexOf(t);n>-1&&this.requireFail.splice(n,1)}return this}hasRequireFailures(){return Boolean(this.requireFail.find(e=>e.options.enable))}canRecognizeWith(e){return Boolean(this.simultaneous[e.id])}emit(e){if(!e)return;let{state:t}=this;t<V.Ended&&this.manager.emit(this.options.event+Ih(t),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),t>=V.Ended&&this.manager.emit(this.options.event+Ih(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=V.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&(V.Failed|V.Possible)))return!1;e++}return!0}recognize(e){let t={...e};if(!this.options.enable){this.reset(),this.state=V.Failed;return}this.state&(V.Recognized|V.Cancelled|V.Failed)&&(this.state=V.Possible),this.state=this.process(t),this.state&(V.Began|V.Changed|V.Ended|V.Cancelled)&&this.tryEmit(t)}getEventNames(){return[this.options.event]}reset(){}};var tr=class extends er{attrTest(e){let t=this.options.pointers;return t===0||e.pointers.length===t}process(e){let{state:t}=this,{eventType:n}=e,s=t&(V.Began|V.Changed),i=this.attrTest(e);return s&&(n&ne.Cancel||!i)?t|V.Cancelled:s||i?n&ne.End?t|V.Ended:t&V.Began?t|V.Changed:V.Began:V.Failed}};var fn=class extends er{constructor(e={}){super({enable:!0,event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10,...e}),this.pTime=null,this.pCenter=null,this._timer=null,this._input=null,this.count=0}getTouchAction(){return[vi]}process(e){let{options:t}=this,n=e.pointers.length===t.pointers,s=e.distance<t.threshold,i=e.deltaTime<t.time;if(this.reset(),e.eventType&ne.Start&&this.count===0)return this.failTimeout();if(s&&i&&n){if(e.eventType!==ne.End)return this.failTimeout();let o=this.pTime?e.timeStamp-this.pTime<t.interval:!0,a=!this.pCenter||oc(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!a||!o?this.count=1:this.count+=1,this._input=e,this.count%t.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=V.Recognized,this.tryEmit(this._input)},t.interval),V.Began):V.Recognized}return V.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=V.Failed},this.options.interval),V.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===V.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}};var I2=["","start","move","end","cancel","up","down","left","right"],Ir=class extends tr{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:ae.All,...e}),this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,t=[];return e&ae.Horizontal&&t.push(Si),e&ae.Vertical&&t.push(Ai),t}getEventNames(){return I2.map(e=>this.options.event+e)}directionTest(e){let{options:t}=this,n=!0,{distance:s}=e,{direction:i}=e,o=e.deltaX,a=e.deltaY;return i&t.direction||(t.direction&ae.Horizontal?(i=o===0?ae.None:o<0?ae.Left:ae.Right,n=o!==this.pX,s=Math.abs(e.deltaX)):(i=a===0?ae.None:a<0?ae.Up:ae.Down,n=a!==this.pY,s=Math.abs(e.deltaY))),e.direction=i,n&&s>t.threshold&&Boolean(i&t.direction)}attrTest(e){return super.attrTest(e)&&(Boolean(this.state&V.Began)||!(this.state&V.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let t=ae[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}};var P2=["","start","move","end","cancel","in","out"],ns=class extends tr{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,...e})}getTouchAction(){return[un]}getEventNames(){return P2.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||Boolean(this.state&V.Began))}emit(e){if(e.scale!==1){let t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}super.emit(e)}};var Ft=class{constructor(e,t,n){this.element=e,this.callback=t,this.options=n}};var p_=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",d6=typeof window<"u"?window:global;var k2=p_.indexOf("firefox")!==-1,m_=4.000244140625,N2=40,D2=.25,lc=class extends Ft{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=s=>{if(!this.options.enable)return;let i=s.deltaY;globalThis.WheelEvent&&(k2&&s.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(i/=globalThis.devicePixelRatio),s.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(i*=N2)),i!==0&&i%m_===0&&(i=Math.floor(i/m_)),s.shiftKey&&i&&(i=i*D2),this.callback({type:"wheel",center:{x:s.clientX,y:s.clientY},delta:-i,srcEvent:s,pointerType:"mouse",target:s.target})},e.addEventListener("wheel",this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener("wheel",this.handleEvent)}enableEventType(e,t){e==="wheel"&&(this.options.enable=t)}};var g_=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],uc=class extends Ft{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=i=>{this.handleOverEvent(i),this.handleOutEvent(i),this.handleEnterEvent(i),this.handleLeaveEvent(i),this.handleMoveEvent(i)},this.pressed=!1;let{enable:s}=this.options;this.enableMoveEvent=s,this.enableLeaveEvent=s,this.enableEnterEvent=s,this.enableOutEvent=s,this.enableOverEvent=s,g_.forEach(i=>e.addEventListener(i,this.handleEvent))}destroy(){g_.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){switch(e){case"pointermove":this.enableMoveEvent=t;break;case"pointerover":this.enableOverEvent=t;break;case"pointerout":this.enableOutEvent=t;break;case"pointerenter":this.enableEnterEvent=t;break;case"pointerleave":this.enableLeaveEvent=t;break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}};var __=["keydown","keyup"],fc=class extends Ft{constructor(e,t,n){super(e,t,{enable:!0,tabIndex:0,...n}),this.handleEvent=s=>{let i=s.target||s.srcElement;i.tagName==="INPUT"&&i.type==="text"||i.tagName==="TEXTAREA"||(this.enableDownEvent&&s.type==="keydown"&&this.callback({type:"keydown",srcEvent:s,key:s.key,target:s.target}),this.enableUpEvent&&s.type==="keyup"&&this.callback({type:"keyup",srcEvent:s,key:s.key,target:s.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,e.tabIndex=this.options.tabIndex,e.style.outline="none",__.forEach(s=>e.addEventListener(s,this.handleEvent))}destroy(){__.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e==="keydown"&&(this.enableDownEvent=t),e==="keyup"&&(this.enableUpEvent=t)}};var hc=class extends Ft{constructor(e,t,n){super(e,t,n),this.handleEvent=s=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:s.clientX,y:s.clientY},srcEvent:s,pointerType:"mouse",target:s.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,t){e==="contextmenu"&&(this.options.enable=t)}};var F2={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},B2=0,L2=1,U2=2,V2=1,z2=2,W2=4;function y_(r){let e=F2[r.srcEvent.type];if(!e)return null;let{buttons:t,button:n}=r.srcEvent,s=!1,i=!1,o=!1;return e===2?(s=Boolean(t&V2),i=Boolean(t&W2),o=Boolean(t&z2)):(s=n===B2,i=n===L2,o=n===U2),{leftButton:s,middleButton:i,rightButton:o}}function x_(r,e){let t=r.center;if(!t)return null;let n=e.getBoundingClientRect(),s=n.width/e.offsetWidth||1,i=n.height/e.offsetHeight||1,o={x:(t.x-n.left-e.clientLeft)/s,y:(t.y-n.top-e.clientTop)/i};return{center:t,offsetCenter:o}}var $2={srcElement:"root",priority:0},dc=class{constructor(e,t){this.handleEvent=n=>{if(this.isEmpty())return;let s=this._normalizeEvent(n),i=n.srcEvent.target;for(;i&&i!==s.rootElement;){if(this._emit(s,i),s.handled)return;i=i.parentNode}this._emit(s,"root")},this.eventManager=e,this.recognizerName=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,n,s=!1,i=!1){let{handlers:o,handlersByElement:a}=this,c={...$2,...n},l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let u={type:e,handler:t,srcElement:c.srcElement,priority:c.priority};s&&(u.once=!0),i&&(u.passive=!0),o.push(u),this._active=this._active||!u.passive;let f=l.length-1;for(;f>=0&&!(l[f].priority>=u.priority);)f--;l.splice(f+1,0,u)}remove(e,t){let{handlers:n,handlersByElement:s}=this;for(let i=n.length-1;i>=0;i--){let o=n[i];if(o.type===e&&o.handler===t){n.splice(i,1);let a=s.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&s.delete(o.srcElement)}}this._active=n.some(i=>!i.passive)}_emit(e,t){let n=this.handlersByElement.get(t);if(n){let s=!1,i=()=>{e.handled=!0},o=()=>{e.handled=!0,s=!0},a=[];for(let c=0;c<n.length;c++){let{type:l,handler:u,once:f}=n[c];if(u({...e,type:l,stopPropagation:i,stopImmediatePropagation:o}),f&&a.push(n[c]),s)break}for(let c=0;c<a.length;c++){let{type:l,handler:u}=a[c];this.remove(l,u)}}}_normalizeEvent(e){let t=this.eventManager.getElement();return{...e,...y_(e),...x_(e,t),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}};function j2(r){if("recognizer"in r)return r;let e,t=Array.isArray(r)?[...r]:[r];if(typeof t[0]=="function"){let n=t.shift(),s=t.shift()||{};e=new n(s)}else e=t.shift();return{recognizer:e,recognizeWith:typeof t[0]=="string"?[t[0]]:t[0],requireFailure:typeof t[1]=="string"?[t[1]]:t[1]}}var Ci=class{constructor(e=null,t={}){if(this._onBasicInput=n=>{this.manager.emit(n.srcEvent.type,n)},this._onOtherEvent=n=>{this.manager.emit(n.type,n)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...t},this.events=new Map,this.element=e,!!e){this.manager=new Pi(e,this.options);for(let n of this.options.recognizers){let{recognizer:s,recognizeWith:i,requireFailure:o}=j2(n);this.manager.add(s),i&&s.recognizeWith(i),o&&s.requireFailure(o)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new lc(e,this._onOtherEvent,{enable:!1}),this.moveInput=new uc(e,this._onOtherEvent,{enable:!1}),this.keyInput=new fc(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new hc(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy())}on(e,t,n){this._addEventHandler(e,t,n,!1)}once(e,t,n){this._addEventHandler(e,t,n,!0)}watch(e,t,n){this._addEventHandler(e,t,n,!1,!0)}off(e,t){this._removeEventHandler(e,t)}_toggleRecognizer(e,t){let{manager:n}=this;if(!n)return;let s=n.get(e);s&&(s.set({enable:t}),n.touchAction.update()),this.wheelInput?.enableEventType(e,t),this.moveInput?.enableEventType(e,t),this.keyInput?.enableEventType(e,t),this.contextmenuInput?.enableEventType(e,t)}_addEventHandler(e,t,n,s,i){if(typeof e!="string"){n=t;for(let[l,u]of Object.entries(e))this._addEventHandler(l,u,n,s,i);return}let{manager:o,events:a}=this;if(!o)return;let c=a.get(e);if(!c){let l=this._getRecognizerName(e)||e;c=new dc(this,l),a.set(e,c),o&&o.on(e,c.handleEvent)}c.add(e,t,n,s,i),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,t){if(typeof e!="string"){for(let[i,o]of Object.entries(e))this._removeEventHandler(i,o);return}let{events:n}=this,s=n.get(e);if(s&&(s.remove(e,t),s.isEmpty())){let{recognizerName:i}=s,o=!1;for(let a of n.values())if(a.recognizerName===i&&!a.isEmpty()){o=!0;break}o||this._toggleRecognizer(i,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(t=>t.getEventNames().includes(e))?.options.event}};var Y={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(Y,"IDENTITY",{get:()=>($.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});var Te={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Pr={common:0,meters:1,pixels:2},Mi={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},Ph={multipan:[Ir,{threshold:10,direction:ae.Vertical,pointers:2}],pinch:[ns,{},null,["multipan"]],pan:[Ir,{threshold:1},["pinch"],["multipan"]],dblclick:[fn,{event:"dblclick",taps:2}],click:[fn,{event:"click"},null,["dblclick"]]},b_={DRAW:"draw",MASK:"mask",TERRAIN:"terrain"};function H2(r,e){if(r===e)return!0;if(Array.isArray(r)){let t=r.length;if(!e||e.length!==t)return!1;for(let n=0;n<t;n++)if(r[n]!==e[n])return!1;return!0}return!1}function ot(r){let e={},t;return n=>{for(let s in n)if(!H2(n[s],e[s])){t=r(n),e=n;break}return t}}var T_=[0,0,0,0],X2=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],w_=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Y2=[0,0,0],v_=[0,0,0],q2=ot(Z2);function Ch(r,e,t=v_){t.length<3&&(t=[t[0],t[1],0]);let n=t,s,i=!0;switch(e===Y.LNGLAT_OFFSETS||e===Y.METER_OFFSETS?s=t:s=r.isGeospatial?[Math.fround(r.longitude),Math.fround(r.latitude),0]:null,r.projectionMode){case Te.WEB_MERCATOR:(e===Y.LNGLAT||e===Y.CARTESIAN)&&(s=[0,0,0],i=!1);break;case Te.WEB_MERCATOR_AUTO_OFFSET:e===Y.LNGLAT?n=s:e===Y.CARTESIAN&&(n=[Math.fround(r.center[0]),Math.fround(r.center[1]),0],s=r.unprojectPosition(n),n[0]-=t[0],n[1]-=t[1],n[2]-=t[2]);break;case Te.IDENTITY:n=r.position.map(Math.fround),n[2]=n[2]||0;break;case Te.GLOBE:i=!1,s=null;break;default:i=!1}return{geospatialOrigin:s,shaderCoordinateOrigin:n,offsetMode:i}}function K2(r,e,t){let{viewMatrixUncentered:n,projectionMatrix:s}=r,{viewMatrix:i,viewProjectionMatrix:o}=r,a=T_,c=T_,l=r.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:f,offsetMode:h}=Ch(r,e,t);return h&&(c=r.projectPosition(u||f),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=ze.transformMat4([],c,o),i=n||i,o=ye.multiply([],s,i),o=ye.multiply([],o,X2)),{viewMatrix:i,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:f,geospatialOrigin:u}}function pc({viewport:r,devicePixelRatio:e=1,modelMatrix:t=null,coordinateSystem:n=Y.DEFAULT,coordinateOrigin:s=v_,autoWrapLongitude:i=!1}){n===Y.DEFAULT&&(n=r.isGeospatial?Y.LNGLAT:Y.CARTESIAN);let o=q2({viewport:r,devicePixelRatio:e,coordinateSystem:n,coordinateOrigin:s});return o.wrapLongitude=i,o.modelMatrix=t||w_,o}function Z2({viewport:r,devicePixelRatio:e,coordinateSystem:t,coordinateOrigin:n}){let{projectionCenter:s,viewProjectionMatrix:i,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=K2(r,t,n),u=r.getDistanceScales(),f=[r.width*e,r.height*e],h=ze.transformMat4([],[0,0,-r.focalDistance,1],r.projectionMatrix)[3]||1,d={coordinateSystem:t,projectionMode:r.projectionMode,coordinateOrigin:c,commonOrigin:o.slice(0,3),center:s,pseudoMeters:Boolean(r._pseudoMeters),viewportSize:f,devicePixelRatio:e,focalDistance:h,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:Y2,scale:r.scale,wrapLongitude:!1,viewProjectionMatrix:i,modelMatrix:w_,cameraPosition:a};if(l){let m=r.getDistanceScales(l);switch(t){case Y.METER_OFFSETS:d.commonUnitsPerWorldUnit=m.unitsPerMeter,d.commonUnitsPerWorldUnit2=m.unitsPerMeter2;break;case Y.LNGLAT:case Y.LNGLAT_OFFSETS:r._pseudoMeters||(d.commonUnitsPerMeter=m.unitsPerMeter),d.commonUnitsPerWorldUnit=m.unitsPerDegree,d.commonUnitsPerWorldUnit2=m.unitsPerDegree2;break;case Y.CARTESIAN:d.commonUnitsPerWorldUnit=[1,1,m.unitsPerMeter[2]],d.commonUnitsPerWorldUnit2=[0,0,m.unitsPerMeter2[2]];break;default:break}}return d}var G2=Object.keys(Y).map(r=>`const COORDINATE_SYSTEM_${r}: i32 = ${Y[r]};`).join(""),Q2=Object.keys(Te).map(r=>`const PROJECTION_MODE_${r}: i32 = ${Te[r]};`).join(""),J2=Object.keys(Pr).map(r=>`const UNIT_${r.toUpperCase()}: i32 = ${Pr[r]};`).join(""),ev=`${G2}
935
- ${Q2}
936
- ${J2}
934
+ `,ac={name:"geometry",source:I2,vs:P2,fs:C2};var ne;(function(r){r[r.Start=1]="Start",r[r.Move=2]="Move",r[r.End=4]="End",r[r.Cancel=8]="Cancel"})(ne||(ne={}));var ae;(function(r){r[r.None=0]="None",r[r.Left=1]="Left",r[r.Right=2]="Right",r[r.Up=4]="Up",r[r.Down=8]="Down",r[r.Horizontal=3]="Horizontal",r[r.Vertical=12]="Vertical",r[r.All=15]="All"})(ae||(ae={}));var V;(function(r){r[r.Possible=1]="Possible",r[r.Began=2]="Began",r[r.Changed=4]="Changed",r[r.Ended=8]="Ended",r[r.Recognized=8]="Recognized",r[r.Cancelled=16]="Cancelled",r[r.Failed=32]="Failed"})(V||(V={}));var d_="compute",Ph="auto",Si="manipulation",fn="none",Ei="pan-x",Ri="pan-y";function Ch(r){if(r.includes(fn))return fn;let e=r.includes(Ei),t=r.includes(Ri);return e&&t?fn:e||t?e?Ei:Ri:r.includes(Si)?Si:Ph}var Ii=class{constructor(e,t){this.actions="",this.manager=e,this.set(t)}set(e){e===d_&&(e=this.compute()),this.manager.element&&(this.manager.element.style.touchAction=e,this.actions=e)}update(){this.set(this.manager.options.touchAction)}compute(){let e=[];for(let t of this.manager.recognizers)t.options.enable&&(e=e.concat(t.getTouchAction()));return Ch(e.join(" "))}};function is(r){return r.trim().split(/\s+/g)}function cc(r,e,t){if(r)for(let n of is(e))r.addEventListener(n,t,!1)}function lc(r,e,t){if(r)for(let n of is(e))r.removeEventListener(n,t,!1)}function Mh(r){return(r.ownerDocument||r).defaultView}function Oh(r,e){let t=r;for(;t;){if(t===e)return!0;t=t.parentNode}return!1}function uc(r){let e=r.length;if(e===1)return{x:Math.round(r[0].clientX),y:Math.round(r[0].clientY)};let t=0,n=0,s=0;for(;s<e;)t+=r[s].clientX,n+=r[s].clientY,s++;return{x:Math.round(t/e),y:Math.round(n/e)}}function kh(r){let e=[],t=0;for(;t<r.pointers.length;)e[t]={clientX:Math.round(r.pointers[t].clientX),clientY:Math.round(r.pointers[t].clientY)},t++;return{timeStamp:Date.now(),pointers:e,center:uc(e),deltaX:r.deltaX,deltaY:r.deltaY}}function fc(r,e){let t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function Nh(r,e){let t=e.clientX-r.clientX,n=e.clientY-r.clientY;return Math.sqrt(t*t+n*n)}function p_(r,e){let t=e.x-r.x,n=e.y-r.y;return Math.atan2(n,t)*180/Math.PI}function Dh(r,e){let t=e.clientX-r.clientX,n=e.clientY-r.clientY;return Math.atan2(n,t)*180/Math.PI}function hc(r,e){return r===e?ae.None:Math.abs(r)>=Math.abs(e)?r<0?ae.Left:ae.Right:e<0?ae.Up:ae.Down}function m_(r,e){let t=e.center,n=r.offsetDelta,s=r.prevDelta,i=r.prevInput;return(e.eventType===ne.Start||i?.eventType===ne.End)&&(s=r.prevDelta={x:i?.deltaX||0,y:i?.deltaY||0},n=r.offsetDelta={x:t.x,y:t.y}),{deltaX:s.x+(t.x-n.x),deltaY:s.y+(t.y-n.y)}}function dc(r,e,t){return{x:e/r||0,y:t/r||0}}function g_(r,e){return Nh(e[0],e[1])/Nh(r[0],r[1])}function __(r,e){return Dh(e[1],e[0])-Dh(r[1],r[0])}function y_(r,e){let t=r.lastInterval||e,n=e.timeStamp-t.timeStamp,s,i,o,a;if(e.eventType!==ne.Cancel&&(n>25||t.velocity===void 0)){let c=e.deltaX-t.deltaX,l=e.deltaY-t.deltaY,u=dc(n,c,l);i=u.x,o=u.y,s=Math.abs(u.x)>Math.abs(u.y)?u.x:u.y,a=hc(c,l),r.lastInterval=e}else s=t.velocity,i=t.velocityX,o=t.velocityY,a=t.direction;e.velocity=s,e.velocityX=i,e.velocityY=o,e.direction=a}function x_(r,e){let{session:t}=r,{pointers:n}=e,{length:s}=n;t.firstInput||(t.firstInput=kh(e)),s>1&&!t.firstMultiple?t.firstMultiple=kh(e):s===1&&(t.firstMultiple=!1);let{firstInput:i,firstMultiple:o}=t,a=o?o.center:i.center,c=e.center=uc(n);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-i.timeStamp,e.angle=p_(a,c),e.distance=fc(a,c);let{deltaX:l,deltaY:u}=m_(t,e);e.deltaX=l,e.deltaY=u,e.offsetDirection=hc(e.deltaX,e.deltaY);let f=dc(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=f.x,e.overallVelocityY=f.y,e.overallVelocity=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,e.scale=o?g_(o.pointers,n):1,e.rotation=o?__(o.pointers,n):0,e.maxPointers=t.prevInput?e.pointers.length>t.prevInput.maxPointers?e.pointers.length:t.prevInput.maxPointers:e.pointers.length;let h=r.element;return Oh(e.srcEvent.target,h)&&(h=e.srcEvent.target),e.target=h,y_(t,e),e}function b_(r,e,t){let n=t.pointers.length,s=t.changedPointers.length,i=e&ne.Start&&n-s===0,o=e&(ne.End|ne.Cancel)&&n-s===0;t.isFirst=Boolean(i),t.isFinal=Boolean(o),i&&(r.session={}),t.eventType=e;let a=x_(r,t);r.emit("hammer.input",a),r.recognize(a),r.session.prevInput=a}var Pi=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=t=>{this.manager.options.enable&&this.handler(t)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,t){b_(this.manager,e,t)}init(){cc(this.element,this.evEl,this.domHandler),cc(this.target,this.evTarget,this.domHandler),cc(Mh(this.element),this.evWin,this.domHandler)}destroy(){lc(this.element,this.evEl,this.domHandler),lc(this.target,this.evTarget,this.domHandler),lc(Mh(this.element),this.evWin,this.domHandler)}};var O2={pointerdown:ne.Start,pointermove:ne.Move,pointerup:ne.End,pointercancel:ne.Cancel,pointerout:ne.Cancel},k2="pointerdown",N2="pointermove pointerup pointercancel",Ci=class extends Pi{constructor(e){super(e),this.evEl=k2,this.evWin=N2,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:t}=this,n=!1,s=O2[e.type],i=e.pointerType,o=i==="touch",a=t.findIndex(c=>c.pointerId===e.pointerId);s&ne.Start&&(e.buttons||o)?a<0&&(t.push(e),a=t.length-1):s&(ne.End|ne.Cancel)&&(n=!0),!(a<0)&&(t[a]=e,this.callback(s,{pointers:t,changedPointers:[e],eventType:s,pointerType:i,srcEvent:e}),n&&t.splice(a,1))}};var D2=["","webkit","Moz","MS","ms","o"];function T_(r,e){let t=e[0].toUpperCase()+e.slice(1);for(let n of D2){let s=n?n+t:e;if(s in r)return s}}var F2=1,w_=2,v_={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},Mi=class{constructor(e,t){this.options={...v_,...t,cssProps:{...v_.cssProps,...t.cssProps},inputTarget:t.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new Ci(this),this.touchAction=new Ii(this,this.options.touchAction),this.toggleCssProps(!0)}set(e){return Object.assign(this.options,e),e.touchAction&&this.touchAction.update(),e.inputTarget&&(this.input.destroy(),this.input.target=e.inputTarget,this.input.init()),this}stop(e){this.session.stopped=e?w_:F2}recognize(e){let{session:t}=this;if(t.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let n,{recognizers:s}=this,{curRecognizer:i}=t;(!i||i&&i.state&V.Recognized)&&(i=t.curRecognizer=null);let o=0;for(;o<s.length;)n=s[o],t.stopped!==w_&&(!i||n===i||n.canRecognizeWith(i))?n.recognize(e):n.reset(),!i&&n.state&(V.Began|V.Changed|V.Ended)&&(i=t.curRecognizer=n),o++}get(e){let{recognizers:t}=this;for(let n=0;n<t.length;n++)if(t[n].options.event===e)return t[n];return null}add(e){if(Array.isArray(e)){for(let n of e)this.add(n);return this}let t=this.get(e.options.event);return t&&this.remove(t),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(let n of e)this.remove(n);return this}let t=typeof e=="string"?this.get(e):e;if(t){let{recognizers:n}=this,s=n.indexOf(t);s!==-1&&(n.splice(s,1),this.touchAction.update())}return this}on(e,t){if(!e||!t)return;let{handlers:n}=this;for(let s of is(e))n[s]=n[s]||[],n[s].push(t)}off(e,t){if(!e)return;let{handlers:n}=this;for(let s of is(e))t?n[s]&&n[s].splice(n[s].indexOf(t),1):delete n[s]}emit(e,t){let n=this.handlers[e]&&this.handlers[e].slice();if(!n||!n.length)return;let s=t;s.type=e,s.preventDefault=function(){t.srcEvent.preventDefault()};let i=0;for(;i<n.length;)n[i](s),i++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){let{element:t}=this;if(t){for(let[n,s]of Object.entries(this.options.cssProps)){let i=T_(t.style,n);e?(this.oldCssProps[i]=t.style[i],t.style[i]=s):t.style[i]=this.oldCssProps[i]||""}e||(this.oldCssProps={})}}};var B2=1;function A_(){return B2++}function Fh(r){return r&V.Cancelled?"cancel":r&V.Ended?"end":r&V.Changed?"move":r&V.Began?"start":""}var Jt=class{constructor(e){this.options=e,this.id=A_(),this.state=V.Possible,this.simultaneous={},this.requireFail=[]}set(e){return Object.assign(this.options,e),this.manager.touchAction.update(),this}recognizeWith(e){if(Array.isArray(e)){for(let s of e)this.recognizeWith(s);return this}let t;if(typeof e=="string"){if(t=this.manager.get(e),!t)throw new Error(`Cannot find recognizer ${e}`)}else t=e;let{simultaneous:n}=this;return n[t.id]||(n[t.id]=t,t.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(let n of e)this.dropRecognizeWith(n);return this}let t;return typeof e=="string"?t=this.manager.get(e):t=e,t&&delete this.simultaneous[t.id],this}requireFailure(e){if(Array.isArray(e)){for(let s of e)this.requireFailure(s);return this}let t;if(typeof e=="string"){if(t=this.manager.get(e),!t)throw new Error(`Cannot find recognizer ${e}`)}else t=e;let{requireFail:n}=this;return n.indexOf(t)===-1&&(n.push(t),t.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(let n of e)this.dropRequireFailure(n);return this}let t;if(typeof e=="string"?t=this.manager.get(e):t=e,t){let n=this.requireFail.indexOf(t);n>-1&&this.requireFail.splice(n,1)}return this}hasRequireFailures(){return Boolean(this.requireFail.find(e=>e.options.enable))}canRecognizeWith(e){return Boolean(this.simultaneous[e.id])}emit(e){if(!e)return;let{state:t}=this;t<V.Ended&&this.manager.emit(this.options.event+Fh(t),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),t>=V.Ended&&this.manager.emit(this.options.event+Fh(t),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=V.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&(V.Failed|V.Possible)))return!1;e++}return!0}recognize(e){let t={...e};if(!this.options.enable){this.reset(),this.state=V.Failed;return}this.state&(V.Recognized|V.Cancelled|V.Failed)&&(this.state=V.Possible),this.state=this.process(t),this.state&(V.Began|V.Changed|V.Ended|V.Cancelled)&&this.tryEmit(t)}getEventNames(){return[this.options.event]}reset(){}};var er=class extends Jt{attrTest(e){let t=this.options.pointers;return t===0||e.pointers.length===t}process(e){let{state:t}=this,{eventType:n}=e,s=t&(V.Began|V.Changed),i=this.attrTest(e);return s&&(n&ne.Cancel||!i)?t|V.Cancelled:s||i?n&ne.End?t|V.Ended:t&V.Began?t|V.Changed:V.Began:V.Failed}};var hn=class extends Jt{constructor(e={}){super({enable:!0,event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10,...e}),this.pTime=null,this.pCenter=null,this._timer=null,this._input=null,this.count=0}getTouchAction(){return[Si]}process(e){let{options:t}=this,n=e.pointers.length===t.pointers,s=e.distance<t.threshold,i=e.deltaTime<t.time;if(this.reset(),e.eventType&ne.Start&&this.count===0)return this.failTimeout();if(s&&i&&n){if(e.eventType!==ne.End)return this.failTimeout();let o=this.pTime?e.timeStamp-this.pTime<t.interval:!0,a=!this.pCenter||fc(this.pCenter,e.center)<t.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!a||!o?this.count=1:this.count+=1,this._input=e,this.count%t.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=V.Recognized,this.tryEmit(this._input)},t.interval),V.Began):V.Recognized}return V.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=V.Failed},this.options.interval),V.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===V.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}};var L2=["","start","move","end","cancel","up","down","left","right"],Rr=class extends er{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:ae.All,...e}),this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,t=[];return e&ae.Horizontal&&t.push(Ri),e&ae.Vertical&&t.push(Ei),t}getEventNames(){return L2.map(e=>this.options.event+e)}directionTest(e){let{options:t}=this,n=!0,{distance:s}=e,{direction:i}=e,o=e.deltaX,a=e.deltaY;return i&t.direction||(t.direction&ae.Horizontal?(i=o===0?ae.None:o<0?ae.Left:ae.Right,n=o!==this.pX,s=Math.abs(e.deltaX)):(i=a===0?ae.None:a<0?ae.Up:ae.Down,n=a!==this.pY,s=Math.abs(e.deltaY))),e.direction=i,n&&s>t.threshold&&Boolean(i&t.direction)}attrTest(e){return super.attrTest(e)&&(Boolean(this.state&V.Began)||!(this.state&V.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let t=ae[e.direction].toLowerCase();t&&(e.additionalEvent=this.options.event+t),super.emit(e)}};var U2=["","start","move","end","cancel","in","out"],os=class extends er{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,...e})}getTouchAction(){return[fn]}getEventNames(){return U2.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||Boolean(this.state&V.Began))}emit(e){if(e.scale!==1){let t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}super.emit(e)}};var Nt=class{constructor(e,t,n){this.element=e,this.callback=t,this.options=n}};var S_=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",L6=typeof window<"u"?window:global;var $2=S_.indexOf("firefox")!==-1,E_=4.000244140625,j2=40,H2=.25,pc=class extends Nt{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=s=>{if(!this.options.enable)return;let i=s.deltaY;globalThis.WheelEvent&&($2&&s.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(i/=globalThis.devicePixelRatio),s.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(i*=j2)),i!==0&&i%E_===0&&(i=Math.floor(i/E_)),s.shiftKey&&i&&(i=i*H2),this.callback({type:"wheel",center:{x:s.clientX,y:s.clientY},delta:-i,srcEvent:s,pointerType:"mouse",target:s.target})},e.addEventListener("wheel",this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener("wheel",this.handleEvent)}enableEventType(e,t){e==="wheel"&&(this.options.enable=t)}};var R_=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],mc=class extends Nt{constructor(e,t,n){super(e,t,{enable:!0,...n}),this.handleEvent=i=>{this.handleOverEvent(i),this.handleOutEvent(i),this.handleEnterEvent(i),this.handleLeaveEvent(i),this.handleMoveEvent(i)},this.pressed=!1;let{enable:s}=this.options;this.enableMoveEvent=s,this.enableLeaveEvent=s,this.enableEnterEvent=s,this.enableOutEvent=s,this.enableOverEvent=s,R_.forEach(i=>e.addEventListener(i,this.handleEvent))}destroy(){R_.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){switch(e){case"pointermove":this.enableMoveEvent=t;break;case"pointerover":this.enableOverEvent=t;break;case"pointerout":this.enableOutEvent=t;break;case"pointerenter":this.enableEnterEvent=t;break;case"pointerleave":this.enableLeaveEvent=t;break;default:}}handleOverEvent(e){this.enableOverEvent&&e.type==="mouseover"&&this._emit("pointerover",e)}handleOutEvent(e){this.enableOutEvent&&e.type==="mouseout"&&this._emit("pointerout",e)}handleEnterEvent(e){this.enableEnterEvent&&e.type==="mouseenter"&&this._emit("pointerenter",e)}handleLeaveEvent(e){this.enableLeaveEvent&&e.type==="mouseleave"&&this._emit("pointerleave",e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":e.buttons===0&&(this.pressed=!1),this.pressed||this._emit("pointermove",e);break;case"mouseup":this.pressed=!1;break;default:}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}};var I_=["keydown","keyup"],gc=class extends Nt{constructor(e,t,n){super(e,t,{enable:!0,tabIndex:0,...n}),this.handleEvent=s=>{let i=s.target||s.srcElement;i.tagName==="INPUT"&&i.type==="text"||i.tagName==="TEXTAREA"||(this.enableDownEvent&&s.type==="keydown"&&this.callback({type:"keydown",srcEvent:s,key:s.key,target:s.target}),this.enableUpEvent&&s.type==="keyup"&&this.callback({type:"keyup",srcEvent:s,key:s.key,target:s.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,e.tabIndex=this.options.tabIndex,e.style.outline="none",I_.forEach(s=>e.addEventListener(s,this.handleEvent))}destroy(){I_.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e==="keydown"&&(this.enableDownEvent=t),e==="keyup"&&(this.enableUpEvent=t)}};var _c=class extends Nt{constructor(e,t,n){super(e,t,n),this.handleEvent=s=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:s.clientX,y:s.clientY},srcEvent:s,pointerType:"mouse",target:s.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,t){e==="contextmenu"&&(this.options.enable=t)}};var X2={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},Y2=0,q2=1,K2=2,Z2=1,G2=2,Q2=4;function P_(r){let e=X2[r.srcEvent.type];if(!e)return null;let{buttons:t,button:n}=r.srcEvent,s=!1,i=!1,o=!1;return e===2?(s=Boolean(t&Z2),i=Boolean(t&Q2),o=Boolean(t&G2)):(s=n===Y2,i=n===q2,o=n===K2),{leftButton:s,middleButton:i,rightButton:o}}function C_(r,e){let t=r.center;if(!t)return null;let n=e.getBoundingClientRect(),s=n.width/e.offsetWidth||1,i=n.height/e.offsetHeight||1,o={x:(t.x-n.left-e.clientLeft)/s,y:(t.y-n.top-e.clientTop)/i};return{center:t,offsetCenter:o}}var J2={srcElement:"root",priority:0},yc=class{constructor(e,t){this.handleEvent=n=>{if(this.isEmpty())return;let s=this._normalizeEvent(n),i=n.srcEvent.target;for(;i&&i!==s.rootElement;){if(this._emit(s,i),s.handled)return;i=i.parentNode}this._emit(s,"root")},this.eventManager=e,this.recognizerName=t,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,n,s=!1,i=!1){let{handlers:o,handlersByElement:a}=this,c={...J2,...n},l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let u={type:e,handler:t,srcElement:c.srcElement,priority:c.priority};s&&(u.once=!0),i&&(u.passive=!0),o.push(u),this._active=this._active||!u.passive;let f=l.length-1;for(;f>=0&&!(l[f].priority>=u.priority);)f--;l.splice(f+1,0,u)}remove(e,t){let{handlers:n,handlersByElement:s}=this;for(let i=n.length-1;i>=0;i--){let o=n[i];if(o.type===e&&o.handler===t){n.splice(i,1);let a=s.get(o.srcElement);a.splice(a.indexOf(o),1),a.length===0&&s.delete(o.srcElement)}}this._active=n.some(i=>!i.passive)}_emit(e,t){let n=this.handlersByElement.get(t);if(n){let s=!1,i=()=>{e.handled=!0},o=()=>{e.handled=!0,s=!0},a=[];for(let c=0;c<n.length;c++){let{type:l,handler:u,once:f}=n[c];if(u({...e,type:l,stopPropagation:i,stopImmediatePropagation:o}),f&&a.push(n[c]),s)break}for(let c=0;c<a.length;c++){let{type:l,handler:u}=a[c];this.remove(l,u)}}}_normalizeEvent(e){let t=this.eventManager.getElement();return{...e,...P_(e),...C_(e,t),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}};function ev(r){if("recognizer"in r)return r;let e,t=Array.isArray(r)?[...r]:[r];if(typeof t[0]=="function"){let n=t.shift(),s=t.shift()||{};e=new n(s)}else e=t.shift();return{recognizer:e,recognizeWith:typeof t[0]=="string"?[t[0]]:t[0],requireFailure:typeof t[1]=="string"?[t[1]]:t[1]}}var Oi=class{constructor(e=null,t={}){if(this._onBasicInput=n=>{this.manager.emit(n.srcEvent.type,n)},this._onOtherEvent=n=>{this.manager.emit(n.type,n)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...t},this.events=new Map,this.element=e,!!e){this.manager=new Mi(e,this.options);for(let n of this.options.recognizers){let{recognizer:s,recognizeWith:i,requireFailure:o}=ev(n);this.manager.add(s),i&&s.recognizeWith(i),o&&s.requireFailure(o)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new pc(e,this._onOtherEvent,{enable:!1}),this.moveInput=new mc(e,this._onOtherEvent,{enable:!1}),this.keyInput=new gc(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new _c(e,this._onOtherEvent,{enable:!1}),this.on(this.options.events)}}getElement(){return this.element}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy())}on(e,t,n){this._addEventHandler(e,t,n,!1)}once(e,t,n){this._addEventHandler(e,t,n,!0)}watch(e,t,n){this._addEventHandler(e,t,n,!1,!0)}off(e,t){this._removeEventHandler(e,t)}_toggleRecognizer(e,t){let{manager:n}=this;if(!n)return;let s=n.get(e);s&&(s.set({enable:t}),n.touchAction.update()),this.wheelInput?.enableEventType(e,t),this.moveInput?.enableEventType(e,t),this.keyInput?.enableEventType(e,t),this.contextmenuInput?.enableEventType(e,t)}_addEventHandler(e,t,n,s,i){if(typeof e!="string"){n=t;for(let[l,u]of Object.entries(e))this._addEventHandler(l,u,n,s,i);return}let{manager:o,events:a}=this;if(!o)return;let c=a.get(e);if(!c){let l=this._getRecognizerName(e)||e;c=new yc(this,l),a.set(e,c),o&&o.on(e,c.handleEvent)}c.add(e,t,n,s,i),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,t){if(typeof e!="string"){for(let[i,o]of Object.entries(e))this._removeEventHandler(i,o);return}let{events:n}=this,s=n.get(e);if(s&&(s.remove(e,t),s.isEmpty())){let{recognizerName:i}=s,o=!1;for(let a of n.values())if(a.recognizerName===i&&!a.isEmpty()){o=!0;break}o||this._toggleRecognizer(i,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(t=>t.getEventNames().includes(e))?.options.event}};var Y={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(Y,"IDENTITY",{get:()=>($.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});var Te={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Ir={common:0,meters:1,pixels:2},ki={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},Bh={multipan:[Rr,{threshold:10,direction:ae.Vertical,pointers:2}],pinch:[os,{},null,["multipan"]],pan:[Rr,{threshold:1},["pinch"],["multipan"]],dblclick:[hn,{event:"dblclick",taps:2}],click:[hn,{event:"click"},null,["dblclick"]]},M_={DRAW:"draw",MASK:"mask",TERRAIN:"terrain"};function tv(r,e){if(r===e)return!0;if(Array.isArray(r)){let t=r.length;if(!e||e.length!==t)return!1;for(let n=0;n<t;n++)if(r[n]!==e[n])return!1;return!0}return!1}function st(r){let e={},t;return n=>{for(let s in n)if(!tv(n[s],e[s])){t=r(n),e=n;break}return t}}var O_=[0,0,0,0],rv=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],k_=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],nv=[0,0,0],N_=[0,0,0],sv=st(ov);function Lh(r,e,t=N_){t.length<3&&(t=[t[0],t[1],0]);let n=t,s,i=!0;switch(e===Y.LNGLAT_OFFSETS||e===Y.METER_OFFSETS?s=t:s=r.isGeospatial?[Math.fround(r.longitude),Math.fround(r.latitude),0]:null,r.projectionMode){case Te.WEB_MERCATOR:(e===Y.LNGLAT||e===Y.CARTESIAN)&&(s=[0,0,0],i=!1);break;case Te.WEB_MERCATOR_AUTO_OFFSET:e===Y.LNGLAT?n=s:e===Y.CARTESIAN&&(n=[Math.fround(r.center[0]),Math.fround(r.center[1]),0],s=r.unprojectPosition(n),n[0]-=t[0],n[1]-=t[1],n[2]-=t[2]);break;case Te.IDENTITY:n=r.position.map(Math.fround),n[2]=n[2]||0;break;case Te.GLOBE:i=!1,s=null;break;default:i=!1}return{geospatialOrigin:s,shaderCoordinateOrigin:n,offsetMode:i}}function iv(r,e,t){let{viewMatrixUncentered:n,projectionMatrix:s}=r,{viewMatrix:i,viewProjectionMatrix:o}=r,a=O_,c=O_,l=r.cameraPosition,{geospatialOrigin:u,shaderCoordinateOrigin:f,offsetMode:h}=Lh(r,e,t);return h&&(c=r.projectPosition(u||f),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=Ve.transformMat4([],c,o),i=n||i,o=ye.multiply([],s,i),o=ye.multiply([],o,rv)),{viewMatrix:i,viewProjectionMatrix:o,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:f,geospatialOrigin:u}}function xc({viewport:r,devicePixelRatio:e=1,modelMatrix:t=null,coordinateSystem:n=Y.DEFAULT,coordinateOrigin:s=N_,autoWrapLongitude:i=!1}){n===Y.DEFAULT&&(n=r.isGeospatial?Y.LNGLAT:Y.CARTESIAN);let o=sv({viewport:r,devicePixelRatio:e,coordinateSystem:n,coordinateOrigin:s});return o.wrapLongitude=i,o.modelMatrix=t||k_,o}function ov({viewport:r,devicePixelRatio:e,coordinateSystem:t,coordinateOrigin:n}){let{projectionCenter:s,viewProjectionMatrix:i,originCommon:o,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=iv(r,t,n),u=r.getDistanceScales(),f=[r.width*e,r.height*e],h=Ve.transformMat4([],[0,0,-r.focalDistance,1],r.projectionMatrix)[3]||1,d={coordinateSystem:t,projectionMode:r.projectionMode,coordinateOrigin:c,commonOrigin:o.slice(0,3),center:s,pseudoMeters:Boolean(r._pseudoMeters),viewportSize:f,devicePixelRatio:e,focalDistance:h,commonUnitsPerMeter:u.unitsPerMeter,commonUnitsPerWorldUnit:u.unitsPerMeter,commonUnitsPerWorldUnit2:nv,scale:r.scale,wrapLongitude:!1,viewProjectionMatrix:i,modelMatrix:k_,cameraPosition:a};if(l){let m=r.getDistanceScales(l);switch(t){case Y.METER_OFFSETS:d.commonUnitsPerWorldUnit=m.unitsPerMeter,d.commonUnitsPerWorldUnit2=m.unitsPerMeter2;break;case Y.LNGLAT:case Y.LNGLAT_OFFSETS:r._pseudoMeters||(d.commonUnitsPerMeter=m.unitsPerMeter),d.commonUnitsPerWorldUnit=m.unitsPerDegree,d.commonUnitsPerWorldUnit2=m.unitsPerDegree2;break;case Y.CARTESIAN:d.commonUnitsPerWorldUnit=[1,1,m.unitsPerMeter[2]],d.commonUnitsPerWorldUnit2=[0,0,m.unitsPerMeter2[2]];break;default:break}}return d}var av=Object.keys(Y).map(r=>`const COORDINATE_SYSTEM_${r}: i32 = ${Y[r]};`).join(""),cv=Object.keys(Te).map(r=>`const PROJECTION_MODE_${r}: i32 = ${Te[r]};`).join(""),lv=Object.keys(Ir).map(r=>`const UNIT_${r.toUpperCase()}: i32 = ${Ir[r]};`).join(""),uv=`${av}
935
+ ${cv}
936
+ ${lv}
937
937
 
938
938
  const TILE_SIZE: f32 = 512.0;
939
939
  const PI: f32 = 3.1415926536;
@@ -987,7 +987,7 @@ struct Geometry {
987
987
 
988
988
  // @group(0) @binding(1)
989
989
  var<private> geometry: Geometry;
990
- `,A_=`${ev}
990
+ `,D_=`${uv}
991
991
 
992
992
  // -----------------------------------------------------------------------------
993
993
  // Functions
@@ -1214,9 +1214,9 @@ fn project_pixel_size_float(pixels: f32) -> f32 {
1214
1214
  fn project_pixel_size_vec2(pixels: vec2<f32>) -> vec2<f32> {
1215
1215
  return pixels / project.scale;
1216
1216
  }
1217
- `;var tv=Object.keys(Y).map(r=>`const int COORDINATE_SYSTEM_${r} = ${Y[r]};`).join(""),rv=Object.keys(Te).map(r=>`const int PROJECTION_MODE_${r} = ${Te[r]};`).join(""),nv=Object.keys(Pr).map(r=>`const int UNIT_${r.toUpperCase()} = ${Pr[r]};`).join(""),S_=`${tv}
1218
- ${rv}
1219
- ${nv}
1217
+ `;var fv=Object.keys(Y).map(r=>`const int COORDINATE_SYSTEM_${r} = ${Y[r]};`).join(""),hv=Object.keys(Te).map(r=>`const int PROJECTION_MODE_${r} = ${Te[r]};`).join(""),dv=Object.keys(Ir).map(r=>`const int UNIT_${r.toUpperCase()} = ${Ir[r]};`).join(""),F_=`${fv}
1218
+ ${hv}
1219
+ ${dv}
1220
1220
  uniform projectUniforms {
1221
1221
  bool wrapLongitude;
1222
1222
  int coordinateSystem;
@@ -1405,7 +1405,7 @@ return pixels / project.scale;
1405
1405
  vec2 project_pixel_size(vec2 pixels) {
1406
1406
  return pixels / project.scale;
1407
1407
  }
1408
- `;var sv={};function iv(r=sv){return"viewport"in r?pc(r):{}}var Cr={name:"project",dependencies:[If,rc],source:A_,vs:S_,getUniforms:iv,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3<f32>",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3<f32>",commonUnitsPerWorldUnit2:"vec3<f32>",center:"vec4<f32>",modelMatrix:"mat4x4<f32>",viewProjectionMatrix:"mat4x4<f32>",viewportSize:"vec2<f32>",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3<f32>",coordinateOrigin:"vec3<f32>",commonOrigin:"vec3<f32>",pseudoMeters:"f32"}};var ov=`// Define a structure to hold both the clip-space position and the common position.
1408
+ `;var pv={};function mv(r=pv){return"viewport"in r?xc(r):{}}var Pr={name:"project",dependencies:[Ff,ac],source:D_,vs:F_,getUniforms:mv,uniformTypes:{wrapLongitude:"f32",coordinateSystem:"i32",commonUnitsPerMeter:"vec3<f32>",projectionMode:"i32",scale:"f32",commonUnitsPerWorldUnit:"vec3<f32>",commonUnitsPerWorldUnit2:"vec3<f32>",center:"vec4<f32>",modelMatrix:"mat4x4<f32>",viewProjectionMatrix:"mat4x4<f32>",viewportSize:"vec2<f32>",devicePixelRatio:"f32",focalDistance:"f32",cameraPosition:"vec3<f32>",coordinateOrigin:"vec3<f32>",commonOrigin:"vec3<f32>",pseudoMeters:"f32"}};var gv=`// Define a structure to hold both the clip-space position and the common position.
1409
1409
  struct ProjectResult {
1410
1410
  clipPosition: vec4<f32>,
1411
1411
  commonPosition: vec4<f32>,
@@ -1448,7 +1448,7 @@ fn project_position_to_clipspace(
1448
1448
  ) -> vec4<f32> {
1449
1449
  return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition;
1450
1450
  }
1451
- `,av=`vec4 project_position_to_clipspace(
1451
+ `,_v=`vec4 project_position_to_clipspace(
1452
1452
  vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition
1453
1453
  ) {
1454
1454
  vec3 projectedPosition = project_position(position, position64Low);
@@ -1468,7 +1468,7 @@ vec4 project_position_to_clipspace(
1468
1468
  vec4 commonPosition;
1469
1469
  return project_position_to_clipspace(position, position64Low, offset, commonPosition);
1470
1470
  }
1471
- `,Mh={name:"project32",dependencies:[Cr],source:ov,vs:av};function Oh(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Mr(r,e){let t=ze.transformMat4([],e,r);return ze.scale(t,t,1/t[3]),t}function kh(r,e){let t=r%e;return t<0?e+t:t}function E_(r,e,t){return t*e+(1-t)*r}function Oi(r,e,t){return r<e?e:r>t?t:r}function cv(r){return Math.log(r)*Math.LOG2E}var ss=Math.log2||cv;function gt(r,e){if(!r)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var _t=Math.PI,R_=_t/4,at=_t/180,Nh=180/_t,is=512,mc=4003e4,We=85.051129,I_=1.5;function ki(r){return Math.pow(2,r)}function gc(r){return ss(r)}function yt(r){let[e,t]=r;gt(Number.isFinite(e)),gt(Number.isFinite(t)&&t>=-90&&t<=90,"invalid latitude");let n=e*at,s=t*at,i=is*(n+_t)/(2*_t),o=is*(_t+Math.log(Math.tan(R_+s*.5)))/(2*_t);return[i,o]}function $e(r){let[e,t]=r,n=e/is*(2*_t)-_t,s=2*(Math.atan(Math.exp(t/is*(2*_t)-_t))-R_);return[n*Nh,s*Nh]}function Ni(r){let{latitude:e}=r;gt(Number.isFinite(e));let t=Math.cos(e*at);return gc(mc*t)-9}function Di(r){let e=Math.cos(r*at);return is/mc/e}function os(r){let{latitude:e,longitude:t,highPrecision:n=!1}=r;gt(Number.isFinite(e)&&Number.isFinite(t));let s=is,i=Math.cos(e*at),o=s/360,a=o/i,c=s/mc/i,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(n){let u=at*Math.tan(e*at)/i,f=o*u/2,h=s/mc*u,d=h/a*c;l.unitsPerDegree2=[0,f,h],l.unitsPerMeter2=[d,0,d]}return l}function Fi(r,e){let[t,n,s]=r,[i,o,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=os({longitude:t,latitude:n,highPrecision:!0}),u=yt(r);u[0]+=i*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);let f=$e(u),h=(s||0)+(a||0);return Number.isFinite(s)||Number.isFinite(a)?[f[0],f[1],h]:f}function _c(r){let{height:e,pitch:t,bearing:n,altitude:s,scale:i,center:o}=r,a=Oh();ye.translate(a,a,[0,0,-s]),ye.rotateX(a,a,-t*at),ye.rotateZ(a,a,n*at);let c=i/e;return ye.scale(a,a,[c,c,c]),o&&ye.translate(a,a,Oe.negate([],o)),a}function Dh(r){let{width:e,height:t,altitude:n,pitch:s=0,offset:i,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=r,{fovy:u=rr(I_)}=r;n!==void 0&&(u=rr(n));let f=u*at,h=s*at,d=nr(u),m=d;o&&(m+=o[2]*a/Math.cos(h)/t);let y=f*(.5+(i?i[1]:0)/t),_=Math.sin(y)*m/Math.sin(Oi(Math.PI/2-h-y,.01,Math.PI-.01)),x=Math.sin(h)*_+m,E=m*10,b=Math.min(x*l,E);return{fov:f,aspect:e/t,focalDistance:d,near:c,far:b}}function rr(r){return 2*Math.atan(.5/r)*Nh}function nr(r){return .5/Math.tan(.5*r*at)}function as(r,e){let[t,n,s=0]=r;return gt(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(s)),Mr(e,[t,n,s,1])}function ct(r,e,t=0){let[n,s,i]=r;if(gt(Number.isFinite(n)&&Number.isFinite(s),"invalid pixel coordinate"),Number.isFinite(i))return Mr(e,[n,s,i,1]);let o=Mr(e,[n,s,0,1]),a=Mr(e,[n,s,1,1]),c=o[2],l=a[2],u=c===l?0:((t||0)-c)/(l-c);return _e.lerp([],o,a,u)}function yc(r){let{width:e,height:t,bounds:n,minExtent:s=0,maxZoom:i=24,offset:o=[0,0]}=r,[[a,c],[l,u]]=n,f=lv(r.padding),h=yt([a,Oi(u,-We,We)]),d=yt([l,Oi(c,-We,We)]),m=[Math.max(Math.abs(d[0]-h[0]),s),Math.max(Math.abs(d[1]-h[1]),s)],y=[e-f.left-f.right-Math.abs(o[0])*2,t-f.top-f.bottom-Math.abs(o[1])*2];gt(y[0]>0&&y[1]>0);let _=y[0]/m[0],x=y[1]/m[1],E=(f.right-f.left)/2/_,b=(f.top-f.bottom)/2/x,S=[(d[0]+h[0])/2+E,(d[1]+h[1])/2+b],C=$e(S),P=Math.min(i,ss(Math.abs(Math.min(_,x))));return gt(Number.isFinite(P)),{longitude:C[0],latitude:C[1],zoom:P}}function lv(r=0){return typeof r=="number"?{top:r,bottom:r,left:r,right:r}:(gt(Number.isFinite(r.top)&&Number.isFinite(r.bottom)&&Number.isFinite(r.left)&&Number.isFinite(r.right)),r)}var P_=Math.PI/180;function xc(r,e=0){let{width:t,height:n,unproject:s}=r,i={targetZ:e},o=s([0,n],i),a=s([t,n],i),c,l,u=r.fovy?.5*r.fovy*P_:Math.atan(.5/r.altitude),f=(90-r.pitch)*P_;return u>f-.01?(c=C_(r,0,e),l=C_(r,t,e)):(c=s([0,0],i),l=s([t,0],i)),[o,a,l,c]}function C_(r,e,t){let{pixelUnprojectionMatrix:n}=r,s=Mr(n,[e,0,1,1]),i=Mr(n,[e,r.height,1,1]),a=(t*r.distanceScales.unitsPerMeter[2]-s[2])/(i[2]-s[2]),c=_e.lerp([],s,i,a),l=$e(c);return l.push(t),l}var M_=512;function Fh(r){let{width:e,height:t,pitch:n=0}=r,{longitude:s,latitude:i,zoom:o,bearing:a=0}=r;(s<-180||s>180)&&(s=kh(s+180,360)-180),(a<-180||a>180)&&(a=kh(a+180,360)-180);let c=ss(t/M_);if(o<=c)o=c,i=0;else{let l=t/2/Math.pow(2,o),u=$e([0,l])[1];if(i<u)i=u;else{let f=$e([0,M_-l])[1];i>f&&(i=f)}}return{width:e,height:t,longitude:s,latitude:i,zoom:o,pitch:n,bearing:a}}var O_=.01,fv=["longitude","latitude","zoom"],k_={curve:1.414,speed:1.2};function Bh(r,e,t,n){let{startZoom:s,startCenterXY:i,uDelta:o,w0:a,u1:c,S:l,rho:u,rho2:f,r0:h}=N_(r,e,n);if(c<O_){let S={};for(let C of fv){let P=r[C],B=e[C];S[C]=E_(P,B,t)}return S}let d=t*l,m=Math.cosh(h)/Math.cosh(h+u*d),y=a*((Math.cosh(h)*Math.tanh(h+u*d)-Math.sinh(h))/f)/c,_=1/m,x=s+gc(_),E=_e.scale([],o,y);_e.add(E,E,i);let b=$e(E);return{longitude:b[0],latitude:b[1],zoom:x}}function Lh(r,e,t){let n={...k_,...t},{screenSpeed:s,speed:i,maxDuration:o}=n,{S:a,rho:c}=N_(r,e,n),l=1e3*a,u;return Number.isFinite(s)?u=l/(s/c):u=l/i,Number.isFinite(o)&&u>o?0:u}function N_(r,e,t){t=Object.assign({},k_,t);let n=t.curve,s=r.zoom,i=[r.longitude,r.latitude],o=ki(s),a=e.zoom,c=[e.longitude,e.latitude],l=ki(a-s),u=yt(i),f=yt(c),h=_e.sub([],f,u),d=Math.max(r.width,r.height),m=d/l,y=_e.length(h)*o,_=Math.max(y,O_),x=n*n,E=(m*m-d*d+x*x*_*_)/(2*d*x*_),b=(m*m-d*d-x*x*_*_)/(2*m*x*_),S=Math.log(Math.sqrt(E*E+1)-E),C=Math.log(Math.sqrt(b*b+1)-b),P=(C-S)/n;return{startZoom:s,startCenterXY:u,uDelta:h,w0:d,u1:y,S:P,rho:n,rho2:x,r0:S,r1:C}}var D_=`
1471
+ `,Uh={name:"project32",dependencies:[Pr],source:gv,vs:_v};function Vh(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Cr(r,e){let t=Ve.transformMat4([],e,r);return Ve.scale(t,t,1/t[3]),t}function zh(r,e){let t=r%e;return t<0?e+t:t}function B_(r,e,t){return t*e+(1-t)*r}function Ni(r,e,t){return r<e?e:r>t?t:r}function yv(r){return Math.log(r)*Math.LOG2E}var as=Math.log2||yv;function pt(r,e){if(!r)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var mt=Math.PI,L_=mt/4,it=mt/180,Wh=180/mt,cs=512,bc=4003e4,ze=85.051129,U_=1.5;function Di(r){return Math.pow(2,r)}function Tc(r){return as(r)}function gt(r){let[e,t]=r;pt(Number.isFinite(e)),pt(Number.isFinite(t)&&t>=-90&&t<=90,"invalid latitude");let n=e*it,s=t*it,i=cs*(n+mt)/(2*mt),o=cs*(mt+Math.log(Math.tan(L_+s*.5)))/(2*mt);return[i,o]}function We(r){let[e,t]=r,n=e/cs*(2*mt)-mt,s=2*(Math.atan(Math.exp(t/cs*(2*mt)-mt))-L_);return[n*Wh,s*Wh]}function Fi(r){let{latitude:e}=r;pt(Number.isFinite(e));let t=Math.cos(e*it);return Tc(bc*t)-9}function Bi(r){let e=Math.cos(r*it);return cs/bc/e}function ls(r){let{latitude:e,longitude:t,highPrecision:n=!1}=r;pt(Number.isFinite(e)&&Number.isFinite(t));let s=cs,i=Math.cos(e*it),o=s/360,a=o/i,c=s/bc/i,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(n){let u=it*Math.tan(e*it)/i,f=o*u/2,h=s/bc*u,d=h/a*c;l.unitsPerDegree2=[0,f,h],l.unitsPerMeter2=[d,0,d]}return l}function Li(r,e){let[t,n,s]=r,[i,o,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=ls({longitude:t,latitude:n,highPrecision:!0}),u=gt(r);u[0]+=i*(c[0]+l[0]*o),u[1]+=o*(c[1]+l[1]*o);let f=We(u),h=(s||0)+(a||0);return Number.isFinite(s)||Number.isFinite(a)?[f[0],f[1],h]:f}function wc(r){let{height:e,pitch:t,bearing:n,altitude:s,scale:i,center:o}=r,a=Vh();ye.translate(a,a,[0,0,-s]),ye.rotateX(a,a,-t*it),ye.rotateZ(a,a,n*it);let c=i/e;return ye.scale(a,a,[c,c,c]),o&&ye.translate(a,a,Oe.negate([],o)),a}function $h(r){let{width:e,height:t,altitude:n,pitch:s=0,offset:i,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=r,{fovy:u=tr(U_)}=r;n!==void 0&&(u=tr(n));let f=u*it,h=s*it,d=rr(u),m=d;o&&(m+=o[2]*a/Math.cos(h)/t);let y=f*(.5+(i?i[1]:0)/t),_=Math.sin(y)*m/Math.sin(Ni(Math.PI/2-h-y,.01,Math.PI-.01)),x=Math.sin(h)*_+m,E=m*10,b=Math.min(x*l,E);return{fov:f,aspect:e/t,focalDistance:d,near:c,far:b}}function tr(r){return 2*Math.atan(.5/r)*Wh}function rr(r){return .5/Math.tan(.5*r*it)}function us(r,e){let[t,n,s=0]=r;return pt(Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(s)),Cr(e,[t,n,s,1])}function ot(r,e,t=0){let[n,s,i]=r;if(pt(Number.isFinite(n)&&Number.isFinite(s),"invalid pixel coordinate"),Number.isFinite(i))return Cr(e,[n,s,i,1]);let o=Cr(e,[n,s,0,1]),a=Cr(e,[n,s,1,1]),c=o[2],l=a[2],u=c===l?0:((t||0)-c)/(l-c);return _e.lerp([],o,a,u)}function vc(r){let{width:e,height:t,bounds:n,minExtent:s=0,maxZoom:i=24,offset:o=[0,0]}=r,[[a,c],[l,u]]=n,f=xv(r.padding),h=gt([a,Ni(u,-ze,ze)]),d=gt([l,Ni(c,-ze,ze)]),m=[Math.max(Math.abs(d[0]-h[0]),s),Math.max(Math.abs(d[1]-h[1]),s)],y=[e-f.left-f.right-Math.abs(o[0])*2,t-f.top-f.bottom-Math.abs(o[1])*2];pt(y[0]>0&&y[1]>0);let _=y[0]/m[0],x=y[1]/m[1],E=(f.right-f.left)/2/_,b=(f.top-f.bottom)/2/x,S=[(d[0]+h[0])/2+E,(d[1]+h[1])/2+b],C=We(S),P=Math.min(i,as(Math.abs(Math.min(_,x))));return pt(Number.isFinite(P)),{longitude:C[0],latitude:C[1],zoom:P}}function xv(r=0){return typeof r=="number"?{top:r,bottom:r,left:r,right:r}:(pt(Number.isFinite(r.top)&&Number.isFinite(r.bottom)&&Number.isFinite(r.left)&&Number.isFinite(r.right)),r)}var V_=Math.PI/180;function Ac(r,e=0){let{width:t,height:n,unproject:s}=r,i={targetZ:e},o=s([0,n],i),a=s([t,n],i),c,l,u=r.fovy?.5*r.fovy*V_:Math.atan(.5/r.altitude),f=(90-r.pitch)*V_;return u>f-.01?(c=z_(r,0,e),l=z_(r,t,e)):(c=s([0,0],i),l=s([t,0],i)),[o,a,l,c]}function z_(r,e,t){let{pixelUnprojectionMatrix:n}=r,s=Cr(n,[e,0,1,1]),i=Cr(n,[e,r.height,1,1]),a=(t*r.distanceScales.unitsPerMeter[2]-s[2])/(i[2]-s[2]),c=_e.lerp([],s,i,a),l=We(c);return l.push(t),l}var W_=512;function jh(r){let{width:e,height:t,pitch:n=0}=r,{longitude:s,latitude:i,zoom:o,bearing:a=0}=r;(s<-180||s>180)&&(s=zh(s+180,360)-180),(a<-180||a>180)&&(a=zh(a+180,360)-180);let c=as(t/W_);if(o<=c)o=c,i=0;else{let l=t/2/Math.pow(2,o),u=We([0,l])[1];if(i<u)i=u;else{let f=We([0,W_-l])[1];i>f&&(i=f)}}return{width:e,height:t,longitude:s,latitude:i,zoom:o,pitch:n,bearing:a}}var $_=.01,Tv=["longitude","latitude","zoom"],j_={curve:1.414,speed:1.2};function Hh(r,e,t,n){let{startZoom:s,startCenterXY:i,uDelta:o,w0:a,u1:c,S:l,rho:u,rho2:f,r0:h}=H_(r,e,n);if(c<$_){let S={};for(let C of Tv){let P=r[C],B=e[C];S[C]=B_(P,B,t)}return S}let d=t*l,m=Math.cosh(h)/Math.cosh(h+u*d),y=a*((Math.cosh(h)*Math.tanh(h+u*d)-Math.sinh(h))/f)/c,_=1/m,x=s+Tc(_),E=_e.scale([],o,y);_e.add(E,E,i);let b=We(E);return{longitude:b[0],latitude:b[1],zoom:x}}function Xh(r,e,t){let n={...j_,...t},{screenSpeed:s,speed:i,maxDuration:o}=n,{S:a,rho:c}=H_(r,e,n),l=1e3*a,u;return Number.isFinite(s)?u=l/(s/c):u=l/i,Number.isFinite(o)&&u>o?0:u}function H_(r,e,t){t=Object.assign({},j_,t);let n=t.curve,s=r.zoom,i=[r.longitude,r.latitude],o=Di(s),a=e.zoom,c=[e.longitude,e.latitude],l=Di(a-s),u=gt(i),f=gt(c),h=_e.sub([],f,u),d=Math.max(r.width,r.height),m=d/l,y=_e.length(h)*o,_=Math.max(y,$_),x=n*n,E=(m*m-d*d+x*x*_*_)/(2*d*x*_),b=(m*m-d*d-x*x*_*_)/(2*m*x*_),S=Math.log(Math.sqrt(E*E+1)-E),C=Math.log(Math.sqrt(b*b+1)-b),P=(C-S)/n;return{startZoom:s,startCenterXY:u,uDelta:h,w0:d,u1:y,S:P,rho:n,rho2:x,r0:S,r1:C}}var X_=`
1472
1472
  uniform shadowUniforms {
1473
1473
  bool drawShadowMap;
1474
1474
  bool useShadowMap;
@@ -1480,7 +1480,7 @@ uniform shadowUniforms {
1480
1480
  vec4 projectCenter0;
1481
1481
  vec4 projectCenter1;
1482
1482
  } shadow;
1483
- `,dv=`
1483
+ `,vv=`
1484
1484
  const int max_lights = 2;
1485
1485
 
1486
1486
  out vec3 shadow_vPosition[max_lights];
@@ -1506,10 +1506,10 @@ vec4 shadow_setVertexPosition(vec4 position_commonspace) {
1506
1506
  }
1507
1507
  return gl_Position;
1508
1508
  }
1509
- `,pv=`
1510
- ${D_}
1511
- ${dv}
1512
- `,mv=`
1509
+ `,Av=`
1510
+ ${X_}
1511
+ ${vv}
1512
+ `,Sv=`
1513
1513
  const int max_lights = 2;
1514
1514
  uniform sampler2D shadow_uShadowMap0;
1515
1515
  uniform sampler2D shadow_uShadowMap1;
@@ -1549,14 +1549,14 @@ vec4 shadow_filterShadowColor(vec4 color) {
1549
1549
  }
1550
1550
  return color;
1551
1551
  }
1552
- `,gv=`
1553
- ${D_}
1554
- ${mv}
1555
- `,_v=ot(wv),yv=ot(vv),xv=[0,0,0,1],bv=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function Tv(r,e){let[t,n,s]=r,i=ct([t,n,s],e);return Number.isFinite(s)?i:[i[0],i[1],0]}function wv({viewport:r,center:e}){return new Q(r.viewProjectionMatrix).invert().transform(e)}function vv({viewport:r,shadowMatrices:e}){let t=[],n=r.pixelUnprojectionMatrix,s=r.isGeospatial?void 0:1,i=[[0,0,s],[r.width,0,s],[0,r.height,s],[r.width,r.height,s],[0,0,-1],[r.width,0,-1],[0,r.height,-1],[r.width,r.height,-1]].map(o=>Tv(o,n));for(let o of e){let a=o.clone().translate(new G(r.center).negate()),c=i.map(u=>a.transform(u)),l=new Q().ortho({left:Math.min(...c.map(u=>u[0])),right:Math.max(...c.map(u=>u[0])),bottom:Math.min(...c.map(u=>u[1])),top:Math.max(...c.map(u=>u[1])),near:Math.min(...c.map(u=>-u[2])),far:Math.max(...c.map(u=>-u[2]))});t.push(l.multiplyRight(o))}return t}function Av(r){let{shadowEnabled:e=!0,project:t}=r;if(!e||!t||!r.shadowMatrices||!r.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:r.dummyShadowMap,shadow_uShadowMap1:r.dummyShadowMap};let n=Cr.getUniforms(t),s=_v({viewport:t.viewport,center:n.center}),i=[],o=yv({shadowMatrices:r.shadowMatrices,viewport:t.viewport}).slice();for(let c=0;c<r.shadowMatrices.length;c++){let l=o[c],u=l.clone().translate(new G(t.viewport.center).negate());n.coordinateSystem===Y.LNGLAT&&n.projectionMode===Te.WEB_MERCATOR?(o[c]=u,i[c]=s):(o[c]=l.clone().multiplyRight(bv),i[c]=u.transform(s))}let a={drawShadowMap:Boolean(r.drawToShadowMap),useShadowMap:r.shadowMaps?r.shadowMaps.length>0:!1,color:r.shadowColor||xv,lightId:r.shadowLightId||0,lightCount:r.shadowMatrices.length,shadow_uShadowMap0:r.dummyShadowMap,shadow_uShadowMap1:r.dummyShadowMap};for(let c=0;c<o.length;c++)a[`viewProjectionMatrix${c}`]=o[c],a[`projectCenter${c}`]=i[c];for(let c=0;c<2;c++)a[`shadow_uShadowMap${c}`]=r.shadowMaps&&r.shadowMaps[c]||r.dummyShadowMap;return a}var cs={name:"shadow",dependencies:[Cr],vs:pv,fs:gv,inject:{"vs:DECKGL_FILTER_GL_POSITION":`
1552
+ `,Ev=`
1553
+ ${X_}
1554
+ ${Sv}
1555
+ `,Rv=st(Ov),Iv=st(kv),Pv=[0,0,0,1],Cv=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function Mv(r,e){let[t,n,s]=r,i=ot([t,n,s],e);return Number.isFinite(s)?i:[i[0],i[1],0]}function Ov({viewport:r,center:e}){return new Q(r.viewProjectionMatrix).invert().transform(e)}function kv({viewport:r,shadowMatrices:e}){let t=[],n=r.pixelUnprojectionMatrix,s=r.isGeospatial?void 0:1,i=[[0,0,s],[r.width,0,s],[0,r.height,s],[r.width,r.height,s],[0,0,-1],[r.width,0,-1],[0,r.height,-1],[r.width,r.height,-1]].map(o=>Mv(o,n));for(let o of e){let a=o.clone().translate(new G(r.center).negate()),c=i.map(u=>a.transform(u)),l=new Q().ortho({left:Math.min(...c.map(u=>u[0])),right:Math.max(...c.map(u=>u[0])),bottom:Math.min(...c.map(u=>u[1])),top:Math.max(...c.map(u=>u[1])),near:Math.min(...c.map(u=>-u[2])),far:Math.max(...c.map(u=>-u[2]))});t.push(l.multiplyRight(o))}return t}function Nv(r){let{shadowEnabled:e=!0,project:t}=r;if(!e||!t||!r.shadowMatrices||!r.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:r.dummyShadowMap,shadow_uShadowMap1:r.dummyShadowMap};let n=Pr.getUniforms(t),s=Rv({viewport:t.viewport,center:n.center}),i=[],o=Iv({shadowMatrices:r.shadowMatrices,viewport:t.viewport}).slice();for(let c=0;c<r.shadowMatrices.length;c++){let l=o[c],u=l.clone().translate(new G(t.viewport.center).negate());n.coordinateSystem===Y.LNGLAT&&n.projectionMode===Te.WEB_MERCATOR?(o[c]=u,i[c]=s):(o[c]=l.clone().multiplyRight(Cv),i[c]=u.transform(s))}let a={drawShadowMap:Boolean(r.drawToShadowMap),useShadowMap:r.shadowMaps?r.shadowMaps.length>0:!1,color:r.shadowColor||Pv,lightId:r.shadowLightId||0,lightCount:r.shadowMatrices.length,shadow_uShadowMap0:r.dummyShadowMap,shadow_uShadowMap1:r.dummyShadowMap};for(let c=0;c<o.length;c++)a[`viewProjectionMatrix${c}`]=o[c],a[`projectCenter${c}`]=i[c];for(let c=0;c<2;c++)a[`shadow_uShadowMap${c}`]=r.shadowMaps&&r.shadowMaps[c]||r.dummyShadowMap;return a}var fs={name:"shadow",dependencies:[Pr],vs:Av,fs:Ev,inject:{"vs:DECKGL_FILTER_GL_POSITION":`
1556
1556
  position = shadow_setVertexPosition(geometry.position);
1557
1557
  `,"fs:DECKGL_FILTER_COLOR":`
1558
1558
  color = shadow_filterShadowColor(color);
1559
- `},getUniforms:Av,uniformTypes:{drawShadowMap:"f32",useShadowMap:"f32",color:"vec4<f32>",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4<f32>",viewProjectionMatrix1:"mat4x4<f32>",projectCenter0:"vec4<f32>",projectCenter1:"vec4<f32>"}};var Uh={...Fa,defaultUniforms:{...Fa.defaultUniforms,useFloatColors:!1},inject:{"vs:DECKGL_FILTER_GL_POSITION":`
1559
+ `},getUniforms:Nv,uniformTypes:{drawShadowMap:"f32",useShadowMap:"f32",color:"vec4<f32>",lightId:"i32",lightCount:"f32",viewProjectionMatrix0:"mat4x4<f32>",viewProjectionMatrix1:"mat4x4<f32>",projectCenter0:"vec4<f32>",projectCenter1:"vec4<f32>"}};var Yh={...za,defaultUniforms:{...za.defaultUniforms,useFloatColors:!1},inject:{"vs:DECKGL_FILTER_GL_POSITION":`
1560
1560
  // for picking depth values
1561
1561
  picking_setPickingAttribute(position.z / position.w);
1562
1562
  `,"vs:DECKGL_FILTER_COLOR":`
@@ -1567,10 +1567,10 @@ ${mv}
1567
1567
 
1568
1568
  // use picking color if rendering to picking FBO.
1569
1569
  color = picking_filterPickingColor(color);
1570
- `}}};var Sv=[rc],Ev=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"],Rv=[];function bc(r){let e=yr.getDefaultShaderAssembler();for(let n of Sv)e.addDefaultModule(n);e._hookFunctions.length=0;let t=r==="glsl"?Ev:Rv;for(let n of t)e.addShaderHook(n);return e}var Iv=[255,255,255],Pv=1,Cv=0,ls=class{constructor(e={}){this.type="ambient";let{color:t=Iv}=e,{intensity:n=Pv}=e;this.id=e.id||`ambient-${Cv++}`,this.color=t,this.intensity=n}};var Mv=[255,255,255],Ov=1,kv=[0,0,-1],Nv=0,sr=class{constructor(e={}){this.type="directional";let{color:t=Mv}=e,{intensity:n=Ov}=e,{direction:s=kv}=e,{_shadow:i=!1}=e;this.id=e.id||`directional-${Nv++}`,this.color=t,this.intensity=n,this.type="directional",this.direction=new G(s).normalize().toArray(),this.shadow=i}getProjectedLight(e){return this}};var hn=class{constructor(e,t={id:"pass"}){let{id:n}=t;this.id=n,this.device=e,this.props={...t}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var xt=class extends hn{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){let[t,n]=this.device.canvasContext.getDrawingBufferSize(),s=e.clearCanvas??!0,i=e.clearColor??(s?[0,0,0,0]:!1),o=s?1:!1,a=s?0:!1,c=e.colorMask??15,l={viewport:[0,0,t,n]};e.colorMask&&(l.colorMask=c),e.scissorRect&&(l.scissorRect=e.scissorRect);let u=this.device.beginRenderPass({framebuffer:e.target,parameters:l,clearColor:i,clearDepth:o,clearStencil:a});try{return this._drawLayers(u,e)}finally{u.end(),this.device.submit()}}_drawLayers(e,t){let{target:n,shaderModuleProps:s,viewports:i,views:o,onViewportActive:a,clearStack:c=!0}=t;t.pass=t.pass||"unknown",c&&(this._lastRenderIndex=-1);let l=[];for(let u of i){let f=o&&o[u.id];a?.(u);let h=this._getDrawLayerParams(u,t),d=u.subViewports||[u];for(let m of d){let y=this._drawLayersInViewport(e,{target:n,shaderModuleProps:s,viewport:m,view:f,pass:t.pass,layers:t.layers},h);l.push(y)}}return l}_getDrawLayerParams(e,{layers:t,pass:n,isPicking:s=!1,layerFilter:i,cullRect:o,effects:a,shaderModuleProps:c},l=!1){let u=[],f=B_(this._lastRenderIndex+1),h={layer:t[0],viewport:e,isPicking:s,renderPass:n,cullRect:o},d={};for(let m=0;m<t.length;m++){let y=t[m],_=this._shouldDrawLayer(y,h,i,d),x={shouldDrawLayer:_};_&&!l&&(x.shouldDrawLayer=!0,x.layerRenderIndex=f(y,_),x.shaderModuleProps=this._getShaderModuleProps(y,a,n,c),x.layerParameters={...y.context.deck?.props.parameters,...this.getLayerParameters(y,m,e)}),u[m]=x}return u}_drawLayersInViewport(e,{layers:t,shaderModuleProps:n,pass:s,target:i,viewport:o,view:a},c){let l=Dv(this.device,{shaderModuleProps:n,target:i,viewport:o});if(a){let{clear:f,clearColor:h,clearDepth:d,clearStencil:m}=a.props;if(f){let y=[0,0,0,0],_=1,x=0;Array.isArray(h)?y=[...h.slice(0,3),h[3]||255].map(b=>b/255):h===!1&&(y=!1),d!==void 0&&(_=d),m!==void 0&&(x=m),this.device.beginRenderPass({framebuffer:i,parameters:{viewport:l,scissorRect:l},clearColor:y,clearDepth:_,clearStencil:x}).end()}}let u={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let f=0;f<t.length;f++){let h=t[f],d=c[f],{shouldDrawLayer:m}=d;if(m&&h.props.pickable&&u.pickableCount++,h.isComposite&&u.compositeCount++,h.isDrawable&&d.shouldDrawLayer){let{layerRenderIndex:y,shaderModuleProps:_,layerParameters:x}=d;u.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,y),_.project&&(_.project.viewport=o),h.context.renderPass=e;try{h._drawLayer({renderPass:e,shaderModuleProps:_,uniforms:{layerIndex:y},parameters:x})}catch(E){h.raiseError(E,`drawing ${h} to ${s}`)}}}return u}shouldDrawLayer(e){return!0}getShaderModuleProps(e,t,n){return null}getLayerParameters(e,t,n){return e.props.parameters}_shouldDrawLayer(e,t,n,s){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;t.layer=e;let o=e.parent;for(;o;){if(!o.props.visible||!o.filterSubLayer(t))return!1;t.layer=o,o=o.parent}if(n){let a=t.layer.id;if(a in s||(s[a]=n(t)),!s[a])return!1}return e.activateViewport(t.viewport),!0}_getShaderModuleProps(e,t,n,s){let i=this.device.canvasContext.cssToDeviceRatio(),o=e.internalState?.propsInTransition||e.props,a={layer:o,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:i,modelMatrix:o.modelMatrix,coordinateSystem:o.coordinateSystem,coordinateOrigin:o.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(t)for(let c of t)F_(a,c.getShaderModuleProps?.(e,a));return F_(a,this.getShaderModuleProps(e,t,a),s)}};function B_(r=0,e={}){let t={},n=(s,i)=>{let o=s.props._offset,a=s.id,c=s.parent&&s.parent.id,l;if(c&&!(c in e)&&n(s.parent,!1),c in t){let u=t[c]=t[c]||B_(e[c],e);l=u(s,i),t[a]=u}else Number.isFinite(o)?(l=o+(e[c]||0),t[a]=null):l=r;return i&&l>=r&&(r=l+1),e[a]=l,l};return n}function Dv(r,{shaderModuleProps:e,target:t,viewport:n}){let s=e?.project?.devicePixelRatio??r.canvasContext.cssToDeviceRatio(),[,i]=r.canvasContext.getDrawingBufferSize(),o=t?t.height:i,a=n;return[a.x*s,o-(a.y+a.height)*s,a.width*s,a.height*s]}function F_(r,...e){for(let t of e)if(t)for(let n in t)r[n]?Object.assign(r[n],t[n]):r[n]=t[n];return r}var Bi=class extends xt{constructor(e,t){super(e,t);let n=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),s=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[n],depthStencilAttachment:s})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let t=this.fbo,n=this.device.canvasContext.cssToDeviceRatio(),s=e.viewports[0],i=s.width*n,o=s.height*n,a=[1,1,1,1];(i!==t.width||o!==t.height)&&t.resize({width:i,height:o}),super.render({...e,clearColor:a,target:t,pass:"shadow"})}getLayerParameters(e,t,n){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,t,n){return{shadow:{project:n.project,drawToShadowMap:!0}}}};var Fv={color:[255,255,255],intensity:1},L_=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],Bv=[0,0,0,200/255],Or=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=Bv,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:t,deck:n}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),n._addDefaultShaderModule(cs),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let t in e){let n=e[t];switch(n.type){case"ambient":this.ambientLight=n;break;case"directional":this.directionalLights.push(n);break;case"point":this.pointLights.push(n);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(t=>t.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:n,onViewportActive:s,views:i}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;o<this.shadowPasses.length;o++)this.shadowPasses[o].render({layers:e,layerFilter:t,viewports:n,onViewportActive:s,views:i,shaderModuleProps:{shadow:{shadowLightId:o,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,t){let n=this.shadow?{project:t.project,shadowMaps:this.shadowPasses.map(o=>o.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},s={enabled:!0,ambientLight:this.ambientLight,directionalLights:this.directionalLights.map(o=>o.getProjectedLight({layer:e})),pointLights:this.pointLights.map(o=>o.getProjectedLight({layer:e}))},i=e.props.material;return{shadow:n,lighting:s,phongMaterial:i,gouraudMaterial:i}}cleanup(e){for(let t of this.shadowPasses)t.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(cs))}_calculateMatrices(){let e=[];for(let t of this.directionalLights){let n=new Q().lookAt({eye:new G(t.direction).negate()});e.push(n)}return e}_createShadowPasses(e){for(let t=0;t<this.directionalLights.length;t++){let n=new Bi(e);this.shadowPasses[t]=n}}_applyDefaultLights(){let{ambientLight:e,pointLights:t,directionalLights:n}=this;!e&&t.length===0&&n.length===0&&(this.ambientLight=new ls(Fv),this.directionalLights.push(new sr(L_[0]),new sr(L_[1])))}};var Vh=class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,t,{size:n=1,type:s,padding:i=0,copy:o=!1,initialize:a=!1,maxCount:c}){let l=s||e&&e.constructor||Float32Array,u=t*n+i;if(ArrayBuffer.isView(e)){if(u<=e.length)return e;if(u*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new l(e.buffer,0,u)}let f=1/0;c&&(f=c*n+i);let h=this._allocate(l,u,a,f);return e&&o?h.set(e):a||h.fill(0,0,4),this._release(e),h}release(e){this._release(e)}_allocate(e,t,n,s){let i=Math.max(Math.ceil(t*this.opts.overAlloc),1);i>s&&(i=s);let o=this._pool,a=e.BYTES_PER_ELEMENT*i,c=o.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(o.splice(c,1)[0],0,i);return n&&l.fill(0),l}return new e(i)}_release(e){if(!ArrayBuffer.isView(e))return;let t=this._pool,{buffer:n}=e,{byteLength:s}=n,i=t.findIndex(o=>o.byteLength>=s);i<0?t.push(n):(i>0||t.length<this.opts.poolSize)&&t.splice(i,0,n),t.length>this.opts.poolSize&&t.shift()}},bt=new Vh;function fs(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function dn(r,e){let t=r%e;return t<0?e+t:t}function V_(r){return[r[12],r[13],r[14]]}function z_(r){return{left:us(r[3]+r[0],r[7]+r[4],r[11]+r[8],r[15]+r[12]),right:us(r[3]-r[0],r[7]-r[4],r[11]-r[8],r[15]-r[12]),bottom:us(r[3]+r[1],r[7]+r[5],r[11]+r[9],r[15]+r[13]),top:us(r[3]-r[1],r[7]-r[5],r[11]-r[9],r[15]-r[13]),near:us(r[3]+r[2],r[7]+r[6],r[11]+r[10],r[15]+r[14]),far:us(r[3]-r[2],r[7]-r[6],r[11]-r[10],r[15]-r[14])}}var U_=new G;function us(r,e,t,n){U_.set(r,e,t);let s=U_.len();return{distance:n/s,normal:new G(-r/s,-e/s,-t/s)}}function zh(r){return r-Math.fround(r)}var Li;function Tc(r,e){let{size:t=1,startIndex:n=0}=e,s=e.endIndex!==void 0?e.endIndex:r.length,i=(s-n)/t;Li=bt.allocate(Li,i,{type:Float32Array,size:t*2});let o=n,a=0;for(;o<s;){for(let c=0;c<t;c++){let l=r[o++];Li[a+c]=l,Li[a+c+t]=zh(l)}a+=t*2}return Li.subarray(0,i*t*2)}function W_(r){let e=null,t=!1;for(let n of r)n&&(e?(t||(e=[[e[0][0],e[0][1]],[e[1][0],e[1][1]]],t=!0),e[0][0]=Math.min(e[0][0],n[0][0]),e[0][1]=Math.min(e[0][1],n[0][1]),e[1][0]=Math.max(e[1][0],n[1][0]),e[1][1]=Math.max(e[1][1],n[1][1])):e=n);return e}var Lv=Math.PI/180,Uv=fs(),$_=[0,0,0],Vv={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function zv({width:r,height:e,orthographic:t,fovyRadians:n,focalDistance:s,padding:i,near:o,far:a}){let c=r/e,l=t?new Q().orthographic({fovy:n,aspect:c,focalDistance:s,near:o,far:a}):new Q().perspective({fovy:n,aspect:c,near:o,far:a});if(i){let{left:u=0,right:f=0,top:h=0,bottom:d=0}=i,m=ee((u+r-f)/2,0,r)-r/2,y=ee((h+e-d)/2,0,e)-e/2;l[8]-=m*2/r,l[9]+=y*2/e}return l}var hs=class{constructor(e={}){this._frustumPlanes={},this.id=e.id||this.constructor.displayName||"viewport",this.x=e.x||0,this.y=e.y||0,this.width=e.width||1,this.height=e.height||1,this.zoom=e.zoom||0,this.padding=e.padding,this.distanceScales=e.distanceScales||Vv,this.focalDistance=e.focalDistance||1,this.position=e.position||$_,this.modelMatrix=e.modelMatrix||null;let{longitude:t,latitude:n}=e;this.isGeospatial=Number.isFinite(n)&&Number.isFinite(t),this._initProps(e),this._initMatrices(e),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?Te.WEB_MERCATOR:Te.WEB_MERCATOR_AUTO_OFFSET:Te.IDENTITY}equals(e){return e instanceof hs?this===e?!0:e.width===this.width&&e.height===this.height&&e.scale===this.scale&&Xe(e.projectionMatrix,this.projectionMatrix)&&Xe(e.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:t=!0}={}){let n=this.projectPosition(e),s=as(n,this.pixelProjectionMatrix),[i,o]=s,a=t?o:this.height-o;return e.length===2?[i,a]:[i,a,s[2]]}unproject(e,{topLeft:t=!0,targetZ:n}={}){let[s,i,o]=e,a=t?i:this.height-i,c=n&&n*this.distanceScales.unitsPerMeter[2],l=ct([s,a,o],this.pixelUnprojectionMatrix,c),[u,f,h]=this.unprojectPosition(l);return Number.isFinite(o)?[u,f,h]:Number.isFinite(n)?[u,f,n]:[u,f]}projectPosition(e){let[t,n]=this.projectFlat(e),s=(e[2]||0)*this.distanceScales.unitsPerMeter[2];return[t,n,s]}unprojectPosition(e){let[t,n]=this.unprojectFlat(e),s=(e[2]||0)*this.distanceScales.metersPerUnit[2];return[t,n,s]}projectFlat(e){if(this.isGeospatial){let t=yt(e);return t[1]=ee(t[1],-318,830),t}return e}unprojectFlat(e){return this.isGeospatial?$e(e):e}getBounds(e={}){let t={targetZ:e.z||0},n=this.unproject([0,0],t),s=this.unproject([this.width,0],t),i=this.unproject([0,this.height],t),o=this.unproject([this.width,this.height],t);return[Math.min(n[0],s[0],i[0],o[0]),Math.min(n[1],s[1],i[1],o[1]),Math.max(n[0],s[0],i[0],o[0]),Math.max(n[1],s[1],i[1],o[1])]}getDistanceScales(e){return e&&this.isGeospatial?os({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:t,width:n=1,height:s=1}){return e<this.x+this.width&&this.x<e+n&&t<this.y+this.height&&this.y<t+s}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,z_(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(e,t,n){return null}_initProps(e){let t=e.longitude,n=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=Ni({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||os({latitude:n,longitude:t}));let s=Math.pow(2,this.zoom);this.scale=s;let{position:i,modelMatrix:o}=e,a=$_;if(i&&(a=o?new Q(o).transformAsVector(i,[]):i),this.isGeospatial){let c=this.projectPosition([t,n,0]);this.center=new G(a).scale(this.distanceScales.unitsPerMeter).add(c)}else this.center=this.projectPosition(a)}_initMatrices(e){let{viewMatrix:t=Uv,projectionMatrix:n=null,orthographic:s=!1,fovyRadians:i,fovy:o=75,near:a=.1,far:c=1e3,padding:l=null,focalDistance:u=1}=e;this.viewMatrixUncentered=t,this.viewMatrix=new Q().multiplyRight(t).translate(new G(this.center).negate()),this.projectionMatrix=n||zv({width:this.width,height:this.height,orthographic:s,fovyRadians:i||o*Lv,focalDistance:u,padding:l,near:a,far:c});let f=fs();ye.multiply(f,f,this.projectionMatrix),ye.multiply(f,f,this.viewMatrix),this.viewProjectionMatrix=f,this.viewMatrixInverse=ye.invert([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=V_(this.viewMatrixInverse);let h=fs(),d=fs();ye.scale(h,h,[this.width/2,-this.height/2,1]),ye.translate(h,h,[1,-1,0]),ye.multiply(d,h,this.viewProjectionMatrix),this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=ye.invert(fs(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||$.warn("Pixel project matrix not invertible")()}};hs.displayName="Viewport";var je=hs;var pn=class extends je{constructor(e={}){let{latitude:t=0,longitude:n=0,zoom:s=0,pitch:i=0,bearing:o=0,nearZMultiplier:a=.1,farZMultiplier:c=1.01,nearZ:l,farZ:u,orthographic:f=!1,projectionMatrix:h,repeat:d=!1,worldOffset:m=0,position:y,padding:_,legacyMeterSizes:x=!1}=e,{width:E,height:b,altitude:S=1.5}=e,C=Math.pow(2,s);E=E||1,b=b||1;let P,B=null;if(h)S=h[5]/2,P=rr(S);else{e.fovy?(P=e.fovy,S=nr(P)):P=rr(S);let k;if(_){let{top:F=0,bottom:U=0}=_;k=[0,ee((F+b-U)/2,0,b)-b/2]}B=Dh({width:E,height:b,scale:C,center:y&&[0,0,y[2]*Di(t)],offset:k,pitch:i,fovy:P,nearZMultiplier:a,farZMultiplier:c}),Number.isFinite(l)&&(B.near=l),Number.isFinite(u)&&(B.far=u)}let N=_c({height:b,pitch:i,bearing:o,scale:C,altitude:S});m&&(N=new Q().translate([512*m,0,0]).multiplyLeft(N)),super({...e,width:E,height:b,viewMatrix:N,longitude:n,latitude:t,zoom:s,...B,fovy:P,focalDistance:S}),this.latitude=t,this.longitude=n,this.zoom=s,this.pitch=i,this.bearing=o,this.altitude=S,this.fovy=P,this.orthographic=f,this._subViewports=d?[]:null,this._pseudoMeters=x,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let e=this.getBounds(),t=Math.floor((e[0]+180)/360),n=Math.ceil((e[2]-180)/360);for(let s=t;s<=n;s++){let i=s?new pn({...this,worldOffset:s}):this;this._subViewports.push(i)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);let[t,n]=this.projectFlat(e),s=(e[2]||0)*Di(e[1]);return[t,n,s]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);let[t,n]=this.unprojectFlat(e),s=(e[2]||0)/Di(n);return[t,n,s]}addMetersToLngLat(e,t){return Fi(e,t)}panByPosition(e,t,n){let s=ct(t,this.pixelUnprojectionMatrix),i=this.projectFlat(e),o=_e.add([],i,_e.negate([],s)),a=_e.add([],this.center,o),[c,l]=this.unprojectFlat(a);return{longitude:c,latitude:l}}getBounds(e={}){let t=xc(this,e.z||0);return[Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),Math.min(t[0][1],t[1][1],t[2][1],t[3][1]),Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),Math.max(t[0][1],t[1][1],t[2][1],t[3][1])]}fitBounds(e,t={}){let{width:n,height:s}=this,{longitude:i,latitude:o,zoom:a}=yc({width:n,height:s,bounds:e,...t});return new pn({width:n,height:s,longitude:i,latitude:o,zoom:a})}};pn.displayName="WebMercatorViewport";var kr=pn;var j_=[0,0,0];function Wh(r,e,t=!1){let n=e.projectPosition(r);if(t&&e instanceof kr){let[s,i,o=0]=r,a=e.getDistanceScales([s,i]);n[2]=o*a.unitsPerMeter[2]}return n}function Wv(r){let{viewport:e,modelMatrix:t,coordinateOrigin:n}=r,{coordinateSystem:s,fromCoordinateSystem:i,fromCoordinateOrigin:o}=r;return s===Y.DEFAULT&&(s=e.isGeospatial?Y.LNGLAT:Y.CARTESIAN),i===void 0&&(i=s),o===void 0&&(o=n),{viewport:e,coordinateSystem:s,coordinateOrigin:n,modelMatrix:t,fromCoordinateSystem:i,fromCoordinateOrigin:o}}function $h(r,{viewport:e,modelMatrix:t,coordinateSystem:n,coordinateOrigin:s,offsetMode:i}){let[o,a,c=0]=r;switch(t&&([o,a,c]=ze.transformMat4([],[o,a,c,1],t)),n){case Y.LNGLAT:return Wh([o,a,c],e,i);case Y.LNGLAT_OFFSETS:return Wh([o+s[0],a+s[1],c+(s[2]||0)],e,i);case Y.METER_OFFSETS:return Wh(Fi(s,[o,a,c]),e,i);case Y.CARTESIAN:default:return e.isGeospatial?[o+s[0],a+s[1],c+s[2]]:e.projectPosition([o,a,c])}}function wc(r,e){let{viewport:t,coordinateSystem:n,coordinateOrigin:s,modelMatrix:i,fromCoordinateSystem:o,fromCoordinateOrigin:a}=Wv(e),{autoOffset:c=!0}=e,{geospatialOrigin:l=j_,shaderCoordinateOrigin:u=j_,offsetMode:f=!1}=c?Ch(t,n,s):{},h=$h(r,{viewport:t,modelMatrix:i,coordinateSystem:o,coordinateOrigin:a,offsetMode:f});if(f){let d=t.projectPosition(l||u);Oe.sub(h,h,d)}return h}var $v=[255,255,255],jv=1,Hv=[1,0,0],Xv=[0,0,1],Yv=0,ds=class{constructor(e={}){this.type="point";let{color:t=$v}=e,{intensity:n=jv}=e,{position:s=Xv}=e;this.id=e.id||`point-${Yv++}`,this.color=t,this.intensity=n,this.type="point",this.position=s,this.attenuation=qv(e),this.projectedLight={...this}}getProjectedLight({layer:e}){let{projectedLight:t}=this,n=e.context.viewport,{coordinateSystem:s,coordinateOrigin:i}=e.props,o=wc(this.position,{viewport:n,coordinateSystem:s,coordinateOrigin:i,fromCoordinateSystem:n.isGeospatial?Y.LNGLAT:Y.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return t.color=this.color,t.intensity=this.intensity,t.position=o,t}};function qv(r){return r.attenuation?r.attenuation:Hv}var Ui=class extends ds{getProjectedLight({layer:e}){let{projectedLight:t}=this,n=e.context.viewport,{coordinateSystem:s,coordinateOrigin:i,modelMatrix:o}=e.props,{cameraPosition:a}=pc({viewport:n,modelMatrix:o,coordinateSystem:s,coordinateOrigin:i});return t.color=this.color,t.intensity=this.intensity,t.position=a,t}};var mn=Math.PI/180,Kv=1e3*60*60*24,Zv=2440588,Gv=2451545,vc=mn*23.4397,Qv=357.5291,Jv=.98560028,eA=280.147,tA=360.9856235;function H_(r,e,t){let n=mn*-t,s=mn*e,i=nA(r),o=fA(i),a=cA(i,n)-o.rightAscension;return{azimuth:oA(a,s,o.declination),altitude:aA(a,s,o.declination)}}function Ac(r,e,t){let{azimuth:n,altitude:s}=H_(r,e,t);return[Math.sin(n)*Math.cos(s),Math.cos(n)*Math.cos(s),-Math.sin(s)]}function rA(r){return(typeof r=="number"?r:r.getTime())/Kv-.5+Zv}function nA(r){return rA(r)-Gv}function sA(r,e){let t=r;return Math.atan2(Math.sin(t)*Math.cos(vc)-Math.tan(e)*Math.sin(vc),Math.cos(t))}function iA(r,e){let t=r;return Math.asin(Math.sin(e)*Math.cos(vc)+Math.cos(e)*Math.sin(vc)*Math.sin(t))}function oA(r,e,t){let n=r,s=e,i=t;return Math.atan2(Math.sin(n),Math.cos(n)*Math.sin(s)-Math.tan(i)*Math.cos(s))}function aA(r,e,t){let n=r,s=e,i=t;return Math.asin(Math.sin(s)*Math.sin(i)+Math.cos(s)*Math.cos(i)*Math.cos(n))}function cA(r,e){return mn*(eA+tA*r)-e}function lA(r){return mn*(Qv+Jv*r)}function uA(r){let e=r,t=mn*(1.9148*Math.sin(e)+.02*Math.sin(2*e)+3e-4*Math.sin(3*e)),n=mn*102.9372;return e+t+n+Math.PI}function fA(r){let e=lA(r),t=uA(e);return{declination:iA(t,0),rightAscension:sA(t,0)}}var Vi=class extends sr{constructor(e){super(e),this.timestamp=e.timestamp}getProjectedLight({layer:e}){let{viewport:t}=e.context;if(t.resolution&&t.resolution>0){let[s,i,o]=Ac(this.timestamp,0,0);this.direction=[s,-o,i]}else{let{latitude:s,longitude:i}=t;this.direction=Ac(this.timestamp,s,i)}return this}};var hA=`uniform screenUniforms {
1570
+ `}}};var Dv=[ac],Fv=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"],Bv=[];function Sc(r){let e=_r.getDefaultShaderAssembler();for(let n of Dv)e.addDefaultModule(n);e._hookFunctions.length=0;let t=r==="glsl"?Fv:Bv;for(let n of t)e.addShaderHook(n);return e}var Lv=[255,255,255],Uv=1,Vv=0,hs=class{constructor(e={}){this.type="ambient";let{color:t=Lv}=e,{intensity:n=Uv}=e;this.id=e.id||`ambient-${Vv++}`,this.color=t,this.intensity=n}};var zv=[255,255,255],Wv=1,$v=[0,0,-1],jv=0,nr=class{constructor(e={}){this.type="directional";let{color:t=zv}=e,{intensity:n=Wv}=e,{direction:s=$v}=e,{_shadow:i=!1}=e;this.id=e.id||`directional-${jv++}`,this.color=t,this.intensity=n,this.type="directional",this.direction=new G(s).normalize().toArray(),this.shadow=i}getProjectedLight(e){return this}};var dn=class{constructor(e,t={id:"pass"}){let{id:n}=t;this.id=n,this.device=e,this.props={...t}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var _t=class extends dn{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){let[t,n]=this.device.canvasContext.getDrawingBufferSize(),s=e.clearCanvas??!0,i=e.clearColor??(s?[0,0,0,0]:!1),o=s?1:!1,a=s?0:!1,c=e.colorMask??15,l={viewport:[0,0,t,n]};e.colorMask&&(l.colorMask=c),e.scissorRect&&(l.scissorRect=e.scissorRect);let u=this.device.beginRenderPass({framebuffer:e.target,parameters:l,clearColor:i,clearDepth:o,clearStencil:a});try{return this._drawLayers(u,e)}finally{u.end(),this.device.submit()}}_drawLayers(e,t){let{target:n,shaderModuleProps:s,viewports:i,views:o,onViewportActive:a,clearStack:c=!0}=t;t.pass=t.pass||"unknown",c&&(this._lastRenderIndex=-1);let l=[];for(let u of i){let f=o&&o[u.id];a?.(u);let h=this._getDrawLayerParams(u,t),d=u.subViewports||[u];for(let m of d){let y=this._drawLayersInViewport(e,{target:n,shaderModuleProps:s,viewport:m,view:f,pass:t.pass,layers:t.layers},h);l.push(y)}}return l}_getDrawLayerParams(e,{layers:t,pass:n,isPicking:s=!1,layerFilter:i,cullRect:o,effects:a,shaderModuleProps:c},l=!1){let u=[],f=q_(this._lastRenderIndex+1),h={layer:t[0],viewport:e,isPicking:s,renderPass:n,cullRect:o},d={};for(let m=0;m<t.length;m++){let y=t[m],_=this._shouldDrawLayer(y,h,i,d),x={shouldDrawLayer:_};_&&!l&&(x.shouldDrawLayer=!0,x.layerRenderIndex=f(y,_),x.shaderModuleProps=this._getShaderModuleProps(y,a,n,c),x.layerParameters={...y.context.deck?.props.parameters,...this.getLayerParameters(y,m,e)}),u[m]=x}return u}_drawLayersInViewport(e,{layers:t,shaderModuleProps:n,pass:s,target:i,viewport:o,view:a},c){let l=Hv(this.device,{shaderModuleProps:n,target:i,viewport:o});if(a){let{clear:f,clearColor:h,clearDepth:d,clearStencil:m}=a.props;if(f){let y=[0,0,0,0],_=1,x=0;Array.isArray(h)?y=[...h.slice(0,3),h[3]||255].map(b=>b/255):h===!1&&(y=!1),d!==void 0&&(_=d),m!==void 0&&(x=m),this.device.beginRenderPass({framebuffer:i,parameters:{viewport:l,scissorRect:l},clearColor:y,clearDepth:_,clearStencil:x}).end()}}let u={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let f=0;f<t.length;f++){let h=t[f],d=c[f],{shouldDrawLayer:m}=d;if(m&&h.props.pickable&&u.pickableCount++,h.isComposite&&u.compositeCount++,h.isDrawable&&d.shouldDrawLayer){let{layerRenderIndex:y,shaderModuleProps:_,layerParameters:x}=d;u.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,y),_.project&&(_.project.viewport=o),h.context.renderPass=e;try{h._drawLayer({renderPass:e,shaderModuleProps:_,uniforms:{layerIndex:y},parameters:x})}catch(E){h.raiseError(E,`drawing ${h} to ${s}`)}}}return u}shouldDrawLayer(e){return!0}getShaderModuleProps(e,t,n){return null}getLayerParameters(e,t,n){return e.props.parameters}_shouldDrawLayer(e,t,n,s){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;t.layer=e;let o=e.parent;for(;o;){if(!o.props.visible||!o.filterSubLayer(t))return!1;t.layer=o,o=o.parent}if(n){let a=t.layer.id;if(a in s||(s[a]=n(t)),!s[a])return!1}return e.activateViewport(t.viewport),!0}_getShaderModuleProps(e,t,n,s){let i=this.device.canvasContext.cssToDeviceRatio(),o=e.internalState?.propsInTransition||e.props,a={layer:o,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:i,modelMatrix:o.modelMatrix,coordinateSystem:o.coordinateSystem,coordinateOrigin:o.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(t)for(let c of t)Y_(a,c.getShaderModuleProps?.(e,a));return Y_(a,this.getShaderModuleProps(e,t,a),s)}};function q_(r=0,e={}){let t={},n=(s,i)=>{let o=s.props._offset,a=s.id,c=s.parent&&s.parent.id,l;if(c&&!(c in e)&&n(s.parent,!1),c in t){let u=t[c]=t[c]||q_(e[c],e);l=u(s,i),t[a]=u}else Number.isFinite(o)?(l=o+(e[c]||0),t[a]=null):l=r;return i&&l>=r&&(r=l+1),e[a]=l,l};return n}function Hv(r,{shaderModuleProps:e,target:t,viewport:n}){let s=e?.project?.devicePixelRatio??r.canvasContext.cssToDeviceRatio(),[,i]=r.canvasContext.getDrawingBufferSize(),o=t?t.height:i,a=n;return[a.x*s,o-(a.y+a.height)*s,a.width*s,a.height*s]}function Y_(r,...e){for(let t of e)if(t)for(let n in t)r[n]?Object.assign(r[n],t[n]):r[n]=t[n];return r}var Ui=class extends _t{constructor(e,t){super(e,t);let n=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),s=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[n],depthStencilAttachment:s})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let t=this.fbo,n=this.device.canvasContext.cssToDeviceRatio(),s=e.viewports[0],i=s.width*n,o=s.height*n,a=[1,1,1,1];(i!==t.width||o!==t.height)&&t.resize({width:i,height:o}),super.render({...e,clearColor:a,target:t,pass:"shadow"})}getLayerParameters(e,t,n){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,t,n){return{shadow:{project:n.project,drawToShadowMap:!0}}}};var Xv={color:[255,255,255],intensity:1},K_=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],Yv=[0,0,0,200/255],Mr=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=Yv,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:t,deck:n}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),n._addDefaultShaderModule(fs),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let t in e){let n=e[t];switch(n.type){case"ambient":this.ambientLight=n;break;case"directional":this.directionalLights.push(n);break;case"point":this.pointLights.push(n);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(t=>t.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:n,onViewportActive:s,views:i}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;o<this.shadowPasses.length;o++)this.shadowPasses[o].render({layers:e,layerFilter:t,viewports:n,onViewportActive:s,views:i,shaderModuleProps:{shadow:{shadowLightId:o,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,t){let n=this.shadow?{project:t.project,shadowMaps:this.shadowPasses.map(o=>o.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},s={enabled:!0,ambientLight:this.ambientLight,directionalLights:this.directionalLights.map(o=>o.getProjectedLight({layer:e})),pointLights:this.pointLights.map(o=>o.getProjectedLight({layer:e}))},i=e.props.material;return{shadow:n,lighting:s,phongMaterial:i,gouraudMaterial:i}}cleanup(e){for(let t of this.shadowPasses)t.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(fs))}_calculateMatrices(){let e=[];for(let t of this.directionalLights){let n=new Q().lookAt({eye:new G(t.direction).negate()});e.push(n)}return e}_createShadowPasses(e){for(let t=0;t<this.directionalLights.length;t++){let n=new Ui(e);this.shadowPasses[t]=n}}_applyDefaultLights(){let{ambientLight:e,pointLights:t,directionalLights:n}=this;!e&&t.length===0&&n.length===0&&(this.ambientLight=new hs(Xv),this.directionalLights.push(new nr(K_[0]),new nr(K_[1])))}};var qh=class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,t,{size:n=1,type:s,padding:i=0,copy:o=!1,initialize:a=!1,maxCount:c}){let l=s||e&&e.constructor||Float32Array,u=t*n+i;if(ArrayBuffer.isView(e)){if(u<=e.length)return e;if(u*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new l(e.buffer,0,u)}let f=1/0;c&&(f=c*n+i);let h=this._allocate(l,u,a,f);return e&&o?h.set(e):a||h.fill(0,0,4),this._release(e),h}release(e){this._release(e)}_allocate(e,t,n,s){let i=Math.max(Math.ceil(t*this.opts.overAlloc),1);i>s&&(i=s);let o=this._pool,a=e.BYTES_PER_ELEMENT*i,c=o.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(o.splice(c,1)[0],0,i);return n&&l.fill(0),l}return new e(i)}_release(e){if(!ArrayBuffer.isView(e))return;let t=this._pool,{buffer:n}=e,{byteLength:s}=n,i=t.findIndex(o=>o.byteLength>=s);i<0?t.push(n):(i>0||t.length<this.opts.poolSize)&&t.splice(i,0,n),t.length>this.opts.poolSize&&t.shift()}},yt=new qh;function ps(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function pn(r,e){let t=r%e;return t<0?e+t:t}function G_(r){return[r[12],r[13],r[14]]}function Q_(r){return{left:ds(r[3]+r[0],r[7]+r[4],r[11]+r[8],r[15]+r[12]),right:ds(r[3]-r[0],r[7]-r[4],r[11]-r[8],r[15]-r[12]),bottom:ds(r[3]+r[1],r[7]+r[5],r[11]+r[9],r[15]+r[13]),top:ds(r[3]-r[1],r[7]-r[5],r[11]-r[9],r[15]-r[13]),near:ds(r[3]+r[2],r[7]+r[6],r[11]+r[10],r[15]+r[14]),far:ds(r[3]-r[2],r[7]-r[6],r[11]-r[10],r[15]-r[14])}}var Z_=new G;function ds(r,e,t,n){Z_.set(r,e,t);let s=Z_.len();return{distance:n/s,normal:new G(-r/s,-e/s,-t/s)}}function Kh(r){return r-Math.fround(r)}var Vi;function Ec(r,e){let{size:t=1,startIndex:n=0}=e,s=e.endIndex!==void 0?e.endIndex:r.length,i=(s-n)/t;Vi=yt.allocate(Vi,i,{type:Float32Array,size:t*2});let o=n,a=0;for(;o<s;){for(let c=0;c<t;c++){let l=r[o++];Vi[a+c]=l,Vi[a+c+t]=Kh(l)}a+=t*2}return Vi.subarray(0,i*t*2)}function J_(r){let e=null,t=!1;for(let n of r)n&&(e?(t||(e=[[e[0][0],e[0][1]],[e[1][0],e[1][1]]],t=!0),e[0][0]=Math.min(e[0][0],n[0][0]),e[0][1]=Math.min(e[0][1],n[0][1]),e[1][0]=Math.max(e[1][0],n[1][0]),e[1][1]=Math.max(e[1][1],n[1][1])):e=n);return e}var qv=Math.PI/180,Kv=ps(),ey=[0,0,0],Zv={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function Gv({width:r,height:e,orthographic:t,fovyRadians:n,focalDistance:s,padding:i,near:o,far:a}){let c=r/e,l=t?new Q().orthographic({fovy:n,aspect:c,focalDistance:s,near:o,far:a}):new Q().perspective({fovy:n,aspect:c,near:o,far:a});if(i){let{left:u=0,right:f=0,top:h=0,bottom:d=0}=i,m=ee((u+r-f)/2,0,r)-r/2,y=ee((h+e-d)/2,0,e)-e/2;l[8]-=m*2/r,l[9]+=y*2/e}return l}var ms=class{constructor(e={}){this._frustumPlanes={},this.id=e.id||this.constructor.displayName||"viewport",this.x=e.x||0,this.y=e.y||0,this.width=e.width||1,this.height=e.height||1,this.zoom=e.zoom||0,this.padding=e.padding,this.distanceScales=e.distanceScales||Zv,this.focalDistance=e.focalDistance||1,this.position=e.position||ey,this.modelMatrix=e.modelMatrix||null;let{longitude:t,latitude:n}=e;this.isGeospatial=Number.isFinite(n)&&Number.isFinite(t),this._initProps(e),this._initMatrices(e),this.equals=this.equals.bind(this),this.project=this.project.bind(this),this.unproject=this.unproject.bind(this),this.projectPosition=this.projectPosition.bind(this),this.unprojectPosition=this.unprojectPosition.bind(this),this.projectFlat=this.projectFlat.bind(this),this.unprojectFlat=this.unprojectFlat.bind(this)}get subViewports(){return null}get metersPerPixel(){return this.distanceScales.metersPerUnit[2]/this.scale}get projectionMode(){return this.isGeospatial?this.zoom<12?Te.WEB_MERCATOR:Te.WEB_MERCATOR_AUTO_OFFSET:Te.IDENTITY}equals(e){return e instanceof ms?this===e?!0:e.width===this.width&&e.height===this.height&&e.scale===this.scale&&He(e.projectionMatrix,this.projectionMatrix)&&He(e.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:t=!0}={}){let n=this.projectPosition(e),s=us(n,this.pixelProjectionMatrix),[i,o]=s,a=t?o:this.height-o;return e.length===2?[i,a]:[i,a,s[2]]}unproject(e,{topLeft:t=!0,targetZ:n}={}){let[s,i,o]=e,a=t?i:this.height-i,c=n&&n*this.distanceScales.unitsPerMeter[2],l=ot([s,a,o],this.pixelUnprojectionMatrix,c),[u,f,h]=this.unprojectPosition(l);return Number.isFinite(o)?[u,f,h]:Number.isFinite(n)?[u,f,n]:[u,f]}projectPosition(e){let[t,n]=this.projectFlat(e),s=(e[2]||0)*this.distanceScales.unitsPerMeter[2];return[t,n,s]}unprojectPosition(e){let[t,n]=this.unprojectFlat(e),s=(e[2]||0)*this.distanceScales.metersPerUnit[2];return[t,n,s]}projectFlat(e){if(this.isGeospatial){let t=gt(e);return t[1]=ee(t[1],-318,830),t}return e}unprojectFlat(e){return this.isGeospatial?We(e):e}getBounds(e={}){let t={targetZ:e.z||0},n=this.unproject([0,0],t),s=this.unproject([this.width,0],t),i=this.unproject([0,this.height],t),o=this.unproject([this.width,this.height],t);return[Math.min(n[0],s[0],i[0],o[0]),Math.min(n[1],s[1],i[1],o[1]),Math.max(n[0],s[0],i[0],o[0]),Math.max(n[1],s[1],i[1],o[1])]}getDistanceScales(e){return e&&this.isGeospatial?ls({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:t,width:n=1,height:s=1}){return e<this.x+this.width&&this.x<e+n&&t<this.y+this.height&&this.y<t+s}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,Q_(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(e,t,n){return null}_initProps(e){let t=e.longitude,n=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=Fi({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||ls({latitude:n,longitude:t}));let s=Math.pow(2,this.zoom);this.scale=s;let{position:i,modelMatrix:o}=e,a=ey;if(i&&(a=o?new Q(o).transformAsVector(i,[]):i),this.isGeospatial){let c=this.projectPosition([t,n,0]);this.center=new G(a).scale(this.distanceScales.unitsPerMeter).add(c)}else this.center=this.projectPosition(a)}_initMatrices(e){let{viewMatrix:t=Kv,projectionMatrix:n=null,orthographic:s=!1,fovyRadians:i,fovy:o=75,near:a=.1,far:c=1e3,padding:l=null,focalDistance:u=1}=e;this.viewMatrixUncentered=t,this.viewMatrix=new Q().multiplyRight(t).translate(new G(this.center).negate()),this.projectionMatrix=n||Gv({width:this.width,height:this.height,orthographic:s,fovyRadians:i||o*qv,focalDistance:u,padding:l,near:a,far:c});let f=ps();ye.multiply(f,f,this.projectionMatrix),ye.multiply(f,f,this.viewMatrix),this.viewProjectionMatrix=f,this.viewMatrixInverse=ye.invert([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=G_(this.viewMatrixInverse);let h=ps(),d=ps();ye.scale(h,h,[this.width/2,-this.height/2,1]),ye.translate(h,h,[1,-1,0]),ye.multiply(d,h,this.viewProjectionMatrix),this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=ye.invert(ps(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||$.warn("Pixel project matrix not invertible")()}};ms.displayName="Viewport";var $e=ms;var mn=class extends $e{constructor(e={}){let{latitude:t=0,longitude:n=0,zoom:s=0,pitch:i=0,bearing:o=0,nearZMultiplier:a=.1,farZMultiplier:c=1.01,nearZ:l,farZ:u,orthographic:f=!1,projectionMatrix:h,repeat:d=!1,worldOffset:m=0,position:y,padding:_,legacyMeterSizes:x=!1}=e,{width:E,height:b,altitude:S=1.5}=e,C=Math.pow(2,s);E=E||1,b=b||1;let P,B=null;if(h)S=h[5]/2,P=tr(S);else{e.fovy?(P=e.fovy,S=rr(P)):P=tr(S);let k;if(_){let{top:F=0,bottom:U=0}=_;k=[0,ee((F+b-U)/2,0,b)-b/2]}B=$h({width:E,height:b,scale:C,center:y&&[0,0,y[2]*Bi(t)],offset:k,pitch:i,fovy:P,nearZMultiplier:a,farZMultiplier:c}),Number.isFinite(l)&&(B.near=l),Number.isFinite(u)&&(B.far=u)}let N=wc({height:b,pitch:i,bearing:o,scale:C,altitude:S});m&&(N=new Q().translate([512*m,0,0]).multiplyLeft(N)),super({...e,width:E,height:b,viewMatrix:N,longitude:n,latitude:t,zoom:s,...B,fovy:P,focalDistance:S}),this.latitude=t,this.longitude=n,this.zoom=s,this.pitch=i,this.bearing=o,this.altitude=S,this.fovy=P,this.orthographic=f,this._subViewports=d?[]:null,this._pseudoMeters=x,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let e=this.getBounds(),t=Math.floor((e[0]+180)/360),n=Math.ceil((e[2]-180)/360);for(let s=t;s<=n;s++){let i=s?new mn({...this,worldOffset:s}):this;this._subViewports.push(i)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);let[t,n]=this.projectFlat(e),s=(e[2]||0)*Bi(e[1]);return[t,n,s]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);let[t,n]=this.unprojectFlat(e),s=(e[2]||0)/Bi(n);return[t,n,s]}addMetersToLngLat(e,t){return Li(e,t)}panByPosition(e,t,n){let s=ot(t,this.pixelUnprojectionMatrix),i=this.projectFlat(e),o=_e.add([],i,_e.negate([],s)),a=_e.add([],this.center,o),[c,l]=this.unprojectFlat(a);return{longitude:c,latitude:l}}getBounds(e={}){let t=Ac(this,e.z||0);return[Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),Math.min(t[0][1],t[1][1],t[2][1],t[3][1]),Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),Math.max(t[0][1],t[1][1],t[2][1],t[3][1])]}fitBounds(e,t={}){let{width:n,height:s}=this,{longitude:i,latitude:o,zoom:a}=vc({width:n,height:s,bounds:e,...t});return new mn({width:n,height:s,longitude:i,latitude:o,zoom:a})}};mn.displayName="WebMercatorViewport";var Or=mn;var ty=[0,0,0];function Zh(r,e,t=!1){let n=e.projectPosition(r);if(t&&e instanceof Or){let[s,i,o=0]=r,a=e.getDistanceScales([s,i]);n[2]=o*a.unitsPerMeter[2]}return n}function Qv(r){let{viewport:e,modelMatrix:t,coordinateOrigin:n}=r,{coordinateSystem:s,fromCoordinateSystem:i,fromCoordinateOrigin:o}=r;return s===Y.DEFAULT&&(s=e.isGeospatial?Y.LNGLAT:Y.CARTESIAN),i===void 0&&(i=s),o===void 0&&(o=n),{viewport:e,coordinateSystem:s,coordinateOrigin:n,modelMatrix:t,fromCoordinateSystem:i,fromCoordinateOrigin:o}}function Gh(r,{viewport:e,modelMatrix:t,coordinateSystem:n,coordinateOrigin:s,offsetMode:i}){let[o,a,c=0]=r;switch(t&&([o,a,c]=Ve.transformMat4([],[o,a,c,1],t)),n){case Y.LNGLAT:return Zh([o,a,c],e,i);case Y.LNGLAT_OFFSETS:return Zh([o+s[0],a+s[1],c+(s[2]||0)],e,i);case Y.METER_OFFSETS:return Zh(Li(s,[o,a,c]),e,i);case Y.CARTESIAN:default:return e.isGeospatial?[o+s[0],a+s[1],c+s[2]]:e.projectPosition([o,a,c])}}function Rc(r,e){let{viewport:t,coordinateSystem:n,coordinateOrigin:s,modelMatrix:i,fromCoordinateSystem:o,fromCoordinateOrigin:a}=Qv(e),{autoOffset:c=!0}=e,{geospatialOrigin:l=ty,shaderCoordinateOrigin:u=ty,offsetMode:f=!1}=c?Lh(t,n,s):{},h=Gh(r,{viewport:t,modelMatrix:i,coordinateSystem:o,coordinateOrigin:a,offsetMode:f});if(f){let d=t.projectPosition(l||u);Oe.sub(h,h,d)}return h}var Jv=[255,255,255],eA=1,tA=[1,0,0],rA=[0,0,1],nA=0,gs=class{constructor(e={}){this.type="point";let{color:t=Jv}=e,{intensity:n=eA}=e,{position:s=rA}=e;this.id=e.id||`point-${nA++}`,this.color=t,this.intensity=n,this.type="point",this.position=s,this.attenuation=sA(e),this.projectedLight={...this}}getProjectedLight({layer:e}){let{projectedLight:t}=this,n=e.context.viewport,{coordinateSystem:s,coordinateOrigin:i}=e.props,o=Rc(this.position,{viewport:n,coordinateSystem:s,coordinateOrigin:i,fromCoordinateSystem:n.isGeospatial?Y.LNGLAT:Y.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return t.color=this.color,t.intensity=this.intensity,t.position=o,t}};function sA(r){return r.attenuation?r.attenuation:tA}var zi=class extends gs{getProjectedLight({layer:e}){let{projectedLight:t}=this,n=e.context.viewport,{coordinateSystem:s,coordinateOrigin:i,modelMatrix:o}=e.props,{cameraPosition:a}=xc({viewport:n,modelMatrix:o,coordinateSystem:s,coordinateOrigin:i});return t.color=this.color,t.intensity=this.intensity,t.position=a,t}};var gn=Math.PI/180,iA=1e3*60*60*24,oA=2440588,aA=2451545,Ic=gn*23.4397,cA=357.5291,lA=.98560028,uA=280.147,fA=360.9856235;function ry(r,e,t){let n=gn*-t,s=gn*e,i=dA(r),o=TA(i),a=yA(i,n)-o.rightAscension;return{azimuth:gA(a,s,o.declination),altitude:_A(a,s,o.declination)}}function Pc(r,e,t){let{azimuth:n,altitude:s}=ry(r,e,t);return[Math.sin(n)*Math.cos(s),Math.cos(n)*Math.cos(s),-Math.sin(s)]}function hA(r){return(typeof r=="number"?r:r.getTime())/iA-.5+oA}function dA(r){return hA(r)-aA}function pA(r,e){let t=r;return Math.atan2(Math.sin(t)*Math.cos(Ic)-Math.tan(e)*Math.sin(Ic),Math.cos(t))}function mA(r,e){let t=r;return Math.asin(Math.sin(e)*Math.cos(Ic)+Math.cos(e)*Math.sin(Ic)*Math.sin(t))}function gA(r,e,t){let n=r,s=e,i=t;return Math.atan2(Math.sin(n),Math.cos(n)*Math.sin(s)-Math.tan(i)*Math.cos(s))}function _A(r,e,t){let n=r,s=e,i=t;return Math.asin(Math.sin(s)*Math.sin(i)+Math.cos(s)*Math.cos(i)*Math.cos(n))}function yA(r,e){return gn*(uA+fA*r)-e}function xA(r){return gn*(cA+lA*r)}function bA(r){let e=r,t=gn*(1.9148*Math.sin(e)+.02*Math.sin(2*e)+3e-4*Math.sin(3*e)),n=gn*102.9372;return e+t+n+Math.PI}function TA(r){let e=xA(r),t=bA(e);return{declination:mA(t,0),rightAscension:pA(t,0)}}var Wi=class extends nr{constructor(e){super(e),this.timestamp=e.timestamp}getProjectedLight({layer:e}){let{viewport:t}=e.context;if(t.resolution&&t.resolution>0){let[s,i,o]=Pc(this.timestamp,0,0);this.direction=[s,-o,i]}else{let{latitude:s,longitude:i}=t;this.direction=Pc(this.timestamp,s,i)}return this}};var wA=`uniform screenUniforms {
1571
1571
  vec2 texSize;
1572
1572
  } screen;
1573
- `,X_={name:"screen",fs:hA,uniformTypes:{texSize:"vec2<f32>"}};var zi=class extends hn{constructor(e,t){super(e,t);let{module:n,fs:s,id:i}=t,o={depthWriteEnabled:!1,depthCompare:"always",depthBias:0,blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one-minus-src-alpha",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",blendColorOperation:"add",blendAlphaOperation:"add"};this.model=new li(e,{id:i,fs:s,modules:[n,X_],parameters:o})}render(e){this._renderPass(this.device,e)}delete(){this.model.destroy(),this.model=null}_renderPass(e,t){let{clearCanvas:n,inputBuffer:s,outputBuffer:i}=t,o=[s.width,s.height],a={texSrc:s.colorAttachments[0],texSize:o};this.model.shaderInputs.setProps({screen:a,...t.moduleProps});let c=this.device.beginRenderPass({framebuffer:i,parameters:{viewport:[0,0,...o]},clearColor:n?[0,0,0,0]:!1,clearDepth:1,clearStencil:!1});this.model.draw(c),c.end()}};var Wi=class{constructor(e,t){this.id=`${e.name}-pass`,this.props=t,Qo(e),this.module=e}setup({device:e}){this.passes=dA(e,this.module,this.id)}setProps(e){this.props=e}preRender(){}postRender(e){let t=this.passes,{target:n}=e,s=e.inputBuffer,i=e.swapBuffer;for(let o=0;o<t.length;o++){let a=o===t.length-1,c=n!==void 0&&a;c&&(i=n);let l=!c||Boolean(e.clearCanvas),u={},f=this.module.passes[o].uniforms;u[this.module.name]={...this.props,...f},t[o].render({clearCanvas:l,inputBuffer:s,outputBuffer:i,moduleProps:u});let h=i;i=s,s=h}return s}cleanup(){if(this.passes){for(let e of this.passes)e.delete();this.passes=void 0}}};function dA(r,e,t){return e.passes.map((n,s)=>{let i=gA(e,n),o=`${t}-${s}`;return new zi(r,{id:o,module:e,fs:i})})}var Y_=`#version 300 es
1573
+ `,ny={name:"screen",fs:wA,uniformTypes:{texSize:"vec2<f32>"}};var $i=class extends dn{constructor(e,t){super(e,t);let{module:n,fs:s,id:i}=t,o={depthWriteEnabled:!1,depthCompare:"always",depthBias:0,blend:!0,blendColorSrcFactor:"one",blendColorDstFactor:"one-minus-src-alpha",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",blendColorOperation:"add",blendAlphaOperation:"add"};this.model=new fi(e,{id:i,fs:s,modules:[n,ny],parameters:o})}render(e){this._renderPass(this.device,e)}delete(){this.model.destroy(),this.model=null}_renderPass(e,t){let{clearCanvas:n,inputBuffer:s,outputBuffer:i}=t,o=[s.width,s.height],a={texSrc:s.colorAttachments[0],texSize:o};this.model.shaderInputs.setProps({screen:a,...t.moduleProps});let c=this.device.beginRenderPass({framebuffer:i,parameters:{viewport:[0,0,...o]},clearColor:n?[0,0,0,0]:!1,clearDepth:1,clearStencil:!1});this.model.draw(c),c.end()}};var ji=class{constructor(e,t){this.id=`${e.name}-pass`,this.props=t,na(e),this.module=e}setup({device:e}){this.passes=vA(e,this.module,this.id)}setProps(e){this.props=e}preRender(){}postRender(e){let t=this.passes,{target:n}=e,s=e.inputBuffer,i=e.swapBuffer;for(let o=0;o<t.length;o++){let a=o===t.length-1,c=n!==void 0&&a;c&&(i=n);let l=!c||Boolean(e.clearCanvas),u={},f=this.module.passes[o].uniforms;u[this.module.name]={...this.props,...f},t[o].render({clearCanvas:l,inputBuffer:s,outputBuffer:i,moduleProps:u});let h=i;i=s,s=h}return s}cleanup(){if(this.passes){for(let e of this.passes)e.delete();this.passes=void 0}}};function vA(r,e,t){return e.passes.map((n,s)=>{let i=EA(e,n),o=`${t}-${s}`;return new $i(r,{id:o,module:e,fs:i})})}var sy=`#version 300 es
1574
1574
  uniform sampler2D texSrc;
1575
1575
 
1576
1576
  in vec2 position;
@@ -1578,19 +1578,19 @@ in vec2 coordinate;
1578
1578
  in vec2 uv;
1579
1579
 
1580
1580
  out vec4 fragColor;
1581
- `,pA=r=>`${Y_}
1581
+ `,AA=r=>`${sy}
1582
1582
  void main() {
1583
1583
  fragColor = texture(texSrc, coordinate);
1584
1584
  fragColor = ${r}(fragColor, screen.texSize, coordinate);
1585
1585
  }
1586
- `,mA=r=>`${Y_}
1586
+ `,SA=r=>`${sy}
1587
1587
  void main() {
1588
1588
  fragColor = ${r}(texSrc, screen.texSize, coordinate);
1589
1589
  }
1590
- `;function gA(r,e){if(e.filter){let t=typeof e.filter=="string"?e.filter:`${r.name}_filterColor_ext`;return pA(t)}if(e.sampler){let t=typeof e.sampler=="string"?e.sampler:`${r.name}_sampleColor`;return mA(t)}return""}var _A={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant",blendAlphaDstFactor:"zero"},ir=class extends xt{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:t,views:n,viewports:s,onViewportActive:i,pickingFBO:o,deviceRect:{x:a,y:c,width:l,height:u},cullRect:f,effects:h,pass:d="picking",pickZ:m,shaderModuleProps:y}){this.pickZ=m;let _=this._resetColorEncoder(m),x=[a,c,l,u],E=super.render({target:o,layers:e,layerFilter:t,views:n,viewports:s,onViewportActive:i,cullRect:f,effects:h?.filter(S=>S.useInPicking),pass:d,isPicking:!0,shaderModuleProps:y,clearColor:[0,0,0,0],colorMask:15,scissorRect:x});return this._colorEncoderState=null,{decodePickingColor:_&&xA.bind(null,_),stats:E}}shouldDrawLayer(e){let{pickable:t,operation:n}=e.props;return t&&n.includes("draw")||n.includes("terrain")||n.includes("mask")}getShaderModuleProps(e,t,n){return{picking:{isActive:1,isAttribute:this.pickZ},lighting:{enabled:!1}}}getLayerParameters(e,t,n){let s={...e.props.parameters},{pickable:i,operation:o}=e.props;return this._colorEncoderState?i&&o.includes("draw")?(Object.assign(s,_A),s.blend=!0,s.blendColor=yA(this._colorEncoderState,e,n)):o.includes("terrain")&&(s.blend=!1):s.blend=!1,s}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function yA(r,e,t){let{byLayer:n,byAlpha:s}=r,i,o=n.get(e);return o?(o.viewports.push(t),i=o.a):(i=n.size+1,i<=255?(o={a:i,layer:e,viewports:[t]},n.set(e,o),s[i]=o):($.warn("Too many pickable layers, only picking the first 255")(),i=0)),[0,0,0,i/255]}function xA(r,e){let t=r.byAlpha[e[3]];return t&&{pickedLayer:t.layer,pickedViewports:t.viewports,pickedObjectIndex:t.layer.decodePickingColor(e)}}var Nr={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},ps=Symbol.for("component"),lt=Symbol.for("propTypes"),Sc=Symbol.for("deprecatedProps"),or=Symbol.for("asyncPropDefaults"),Bt=Symbol.for("asyncPropOriginal"),Tt=Symbol.for("asyncPropResolved");function Dr(r,e=()=>!0){return Array.isArray(r)?q_(r,e,[]):e(r)?[r]:[]}function q_(r,e,t){let n=-1;for(;++n<r.length;){let s=r[n];Array.isArray(s)?q_(s,e,t):e(s)&&t.push(s)}return t}function Ec({target:r,source:e,start:t=0,count:n=1}){let s=e.length,i=n*s,o=0;for(let a=t;o<s;o++)r[a++]=e[o];for(;o<i;)o<i-o?(r.copyWithin(t+o,t,t+o),o*=2):(r.copyWithin(t+o,t,t+i-o),o=i);return r}Rs();var $i=class{constructor(e,t,n){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=n,this.setData(t)}subscribe(e){this._subscribers.add(e)}unsubscribe(e){this._subscribers.delete(e)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;let n=++this._loadCount,s=e;typeof e=="string"&&(s=Rr(e)),s instanceof Promise?(this.isLoaded=!1,this._loader=s.then(i=>{this._loadCount===n&&(this.isLoaded=!0,this._error=void 0,this._content=i)}).catch(i=>{this._loadCount===n&&(this.isLoaded=!0,this._error=i||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let i of this._subscribers)i.onChange(this.getData())}};var ji=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:t,forceUpdate:n=!1,persistent:s=!0}){let i=this._resources[e];i?i.setData(t,n):(i=new $i(e,t,this._context),this._resources[e]=i),i.persistent=s}remove(e){let t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let t=this._consumers[e];if(t){for(let n in t){let s=t[n],i=this._resources[s.resourceId];i&&i.unsubscribe(s)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:n,requestId:s="default"}){let{_resources:i,protocol:o}=this;e.startsWith(o)&&(e=e.replace(o,""),i[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=i[e];if(this._track(n,s,a,t),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,t,n,s){let i=this._consumers,o=i[e]=i[e]||{},a=o[t],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),n&&(a?(a.onChange=s,a.resourceId=n.id):a={onChange:s,resourceId:n.id},o[t]=a,n.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let t=this._resources[e];!t.persistent&&!t.inUse()&&(t.delete(),delete this._resources[e])}}};var bA="layerManager.setLayers",TA="layerManager.activateViewport",gn=class{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{he(TA,this,a),a&&(this.context.viewport=a)};let{deck:n,stats:s,viewport:i,timeline:o}=t||{};this.layers=[],this.resourceManager=new ji({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:n,shaderAssembler:bc(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[xh],renderPass:void 0,stats:s||new Ze({id:"deck.gl"}),viewport:i||new je({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new qr,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let n of this.layers){let s=n.getNeedsRedraw(e);t=t||s}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(n=>t.id.indexOf(n)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,t){he(bA,this,t,e),this._lastRenderedLayers=e;let n=Dr(e,Boolean);for(let s of n)s.context=this.context;this._updateLayers(this.layers,n)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:t}=this.context;t.find(n=>n.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:t}=this.context,n=t.findIndex(s=>s.name===e.name);n>=0&&(t.splice(n,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,n){n.raiseError(t,`${e} of ${n}`)}_updateLayers(e,t){let n={};for(let o of e)n[o.id]?$.warn(`Multiple old layers with same id ${o.id}`)():n[o.id]=o;if(this._defaultShaderModulesChanged){for(let o of e)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let s=[];this._updateSublayersRecursively(t,n,s),this._finalizeOldLayers(n);let i=!1;for(let o of s)if(o.hasUniformTransition()){i=`Uniform transition in ${o}`;break}this._needsUpdate=i,this.layers=s}_updateSublayersRecursively(e,t,n){for(let s of e){s.context=this.context;let i=t[s.id];i===null&&$.warn(`Multiple new layers with same id ${s.id}`)(),t[s.id]=null;let o=null;try{this._debug&&i!==s&&s.validateProps(),i?(this._transferLayerState(i,s),this._updateLayer(s)):this._initializeLayer(s),n.push(s),o=s.isComposite?s.getSubLayers():null}catch(a){this._handleError("matching",a,s)}o&&this._updateSublayersRecursively(o,t,n)}}_finalizeOldLayers(e){for(let t in e){let n=e[t];n&&this._finalizeLayer(n)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=Nr.INITIALIZED}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=Nr.MATCHED,t!==e&&(e.lifecycle=Nr.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Nr.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=Nr.FINALIZED}catch(t){this._handleError("finalization",t,e)}}};function le(r,e,t){if(r===e)return!0;if(!t||!r||!e)return!1;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(let n=0;n<r.length;n++)if(!le(r[n],e[n],t-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof r=="object"&&typeof e=="object"){let n=Object.keys(r),s=Object.keys(e);if(n.length!==s.length)return!1;for(let i of n)if(!e.hasOwnProperty(i)||!le(r[i],e[i],t-1))return!1;return!0}return!1}var Hi=class{constructor(e){this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=e.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw="First render",this._needsUpdate="Initialize",this._eventManager=e.eventManager,this._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},Object.seal(this),this.setProps(e)}finalize(){for(let e in this.controllers){let t=this.controllers[e];t&&t.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(let e in this.controllers){let t=this.controllers[e];t&&t.updateTransition()}}getViewports(e){return e?this._viewports.filter(t=>t.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){let t=typeof e=="string"?this.getView(e):e,n=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(n):n}getViewport(e){return this._viewportMap[e]}unproject(e,t){let n=this.getViewports(),s={x:e[0],y:e[1]};for(let i=n.length-1;i>=0;--i){let o=n[i];if(o.containsPixel(s)){let a=e.slice();return a[0]-=o.x,a[1]-=o.y,o.unproject(a,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Dr(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!le(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):$.warn("missing `viewState` or `initialViewState`")()}_createController(e,t){let n=t.type;return new n({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:i=>this.getView(e.id)?.makeViewport({viewState:i,width:this.width,height:this.height})})}_updateController(e,t,n,s){let i=e.controller;if(i&&n){let o={...t,...i,id:e.id,x:n.x,y:n.y,width:n.width,height:n.height};return(!s||s.constructor!==i.type)&&(s=this._createController(e,o)),s&&s.setProps(o),s}return null}_rebuildViewports(){let{views:e}=this,t=this.controllers;this._viewports=[],this.controllers={};let n=!1;for(let s=e.length;s--;){let i=e[s],o=this.getViewState(i),a=i.makeViewport({viewState:o,width:this.width,height:this.height}),c=t[i.id],l=Boolean(i.controller);l&&!c&&(n=!0),(n||!l)&&c&&(c.finalize(),c=null),this.controllers[i.id]=this._updateController(i,o,a,c),a&&this._viewports.unshift(a)}for(let s in t){let i=t[s];i&&!this.controllers[s]&&i.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length?!0:e.some((n,s)=>!e[s].equals(t[s]))}};var wA=/^(?:\d+\.?\d*|\.\d+)$/;function ar(r){switch(typeof r){case"number":if(!Number.isFinite(r))throw new Error(`Could not parse position string ${r}`);return{type:"literal",value:r};case"string":try{let e=vA(r);return new Hh(e).parseExpression()}catch(e){let t=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${r}: ${t}`)}default:throw new Error(`Could not parse position string ${r}`)}}function jh(r,e){switch(r.type){case"literal":return r.value;case"percentage":return Math.round(r.value*e);case"binary":let t=jh(r.left,e),n=jh(r.right,e);return r.operator==="+"?t+n:t-n;default:throw new Error("Unknown layout expression type")}}function cr(r,e){return jh(r,e)}function vA(r){let e=[],t=0;for(;t<r.length;){let n=r[t];if(/\s/.test(n)){t++;continue}if(n==="+"||n==="-"||n==="("||n===")"||n==="%"){e.push({type:"symbol",value:n}),t++;continue}if(K_(n)||n==="."){let s=t,i=n===".";for(t++;t<r.length;){let a=r[t];if(K_(a)){t++;continue}if(a==="."&&!i){i=!0,t++;continue}break}let o=r.slice(s,t);if(!wA.test(o))throw new Error("Invalid number token");e.push({type:"number",value:parseFloat(o)});continue}if(Z_(n)){let s=t;for(;t<r.length&&Z_(r[t]);)t++;let i=r.slice(s,t).toLowerCase();e.push({type:"word",value:i});continue}throw new Error("Invalid token in position string")}return e}var Hh=class{constructor(e){this.index=0,this.tokens=e}parseExpression(){let e=this.parseBinaryExpression();if(this.index<this.tokens.length)throw new Error("Unexpected token at end of expression");return e}parseBinaryExpression(){let e=this.parseFactor(),t=this.peek();for(;AA(t);){this.index++;let n=this.parseFactor();e={type:"binary",operator:t.value,left:e,right:n},t=this.peek()}return e}parseFactor(){let e=this.peek();if(!e)throw new Error("Unexpected end of expression");if(e.type==="symbol"&&e.value==="+")return this.index++,this.parseFactor();if(e.type==="symbol"&&e.value==="-"){this.index++;let t=this.parseFactor();return{type:"binary",operator:"-",left:{type:"literal",value:0},right:t}}if(e.type==="symbol"&&e.value==="("){this.index++;let t=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return t}if(e.type==="word"&&e.value==="calc"){if(this.index++,!this.consumeSymbol("("))throw new Error("Missing opening parenthesis after calc");let t=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return t}if(e.type==="number"){this.index++;let t=e.value,n=this.peek();return n&&n.type==="symbol"&&n.value==="%"?(this.index++,{type:"percentage",value:t/100}):n&&n.type==="word"&&n.value==="px"?(this.index++,{type:"literal",value:t}):{type:"literal",value:t}}throw new Error("Unexpected token in expression")}consumeSymbol(e){let t=this.peek();return t&&t.type==="symbol"&&t.value===e?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}};function K_(r){return r>="0"&&r<="9"}function Z_(r){return r>="a"&&r<="z"||r>="A"&&r<="Z"}function AA(r){return Boolean(r&&r.type==="symbol"&&(r.value==="+"||r.value==="-"))}var Ne=class{constructor(e){let{id:t,x:n=0,y:s=0,width:i="100%",height:o="100%",padding:a=null}=e;this.id=t||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=ar(n),this._y=ar(s),this._width=ar(i),this._height=ar(o),this._padding=a&&{left:ar(a.left||0),right:ar(a.right||0),top:ar(a.top||0),bottom:ar(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.constructor===e.constructor&&le(this.props,e.props,2)}clone(e){let t=this.constructor;return new t({...this.props,...e})}makeViewport({width:e,height:t,viewState:n}){n=this.filterViewState(n);let s=this.getDimensions({width:e,height:t});if(!s.height||!s.width)return null;let i=this.getViewportType(n);return new i({...n,...this.props,...s})}getViewStateId(){let{viewState:e}=this.props;return typeof e=="string"?e:e?.id||this.id}filterViewState(e){if(this.props.viewState&&typeof this.props.viewState=="object"){if(!this.props.viewState.id)return this.props.viewState;let t={...e};for(let n in this.props.viewState)n!=="id"&&(t[n]=this.props.viewState[n]);return t}return e}getDimensions({width:e,height:t}){let n={x:cr(this._x,e),y:cr(this._y,t),width:cr(this._width,e),height:cr(this._height,t)};return this._padding&&(n.padding={left:cr(this._padding.left,e),top:cr(this._padding.top,t),right:cr(this._padding.right,e),bottom:cr(this._padding.bottom,t)}),n}get controller(){let e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e=="function"?{type:e}:{type:this.ControllerType,...e}:null}};var wt=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(this._handle===null){let{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}};var G_=()=>{},Xi={BREAK:1,SNAP_TO_END:2,IGNORE:3},SA=r=>r,EA=Xi.BREAK,Yi=class{constructor(e){this._onTransitionUpdate=t=>{let{time:n,settings:{interpolator:s,startProps:i,endProps:o,duration:a,easing:c}}=t,l=c(n/a),u=s.interpolateProps(i,o,l);this.propsInTransition=this.getControllerState({...this.props,...u}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new wt(e.timeline),this.onViewStateChange=e.onViewStateChange||G_,this.onStateChange=e.onStateChange||G_}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1,n=this.props;if(this.props=e,!n||this._shouldIgnoreViewportChange(n,e))return!1;if(this._isTransitionEnabled(e)){let s=n;if(this.transition.inProgress){let{interruption:i,endProps:o}=this.transition.settings;s={...n,...i===Xi.SNAP_TO_END?o:this.propsInTransition||n}}this._triggerTransition(s,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:t,transitionInterpolator:n}=e;return(t>0||t==="auto")&&Boolean(n)}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,t){return this.transition.inProgress?this.transition.settings.interruption===Xi.IGNORE||this._isUpdateDueToCurrentTransition(t):this._isTransitionEnabled(t)?t.transitionInterpolator.arePropsEqual(e,t):!0}_triggerTransition(e,t){let n=this.getControllerState(e),s=this.getControllerState(t).shortestPathFrom(n),i=t.transitionInterpolator,o=i.getDuration?i.getDuration(e,t):t.transitionDuration;if(o===0)return;let a=i.initializeProps(e,s);this.propsInTransition={};let c={duration:o,easing:t.transitionEasing||SA,interpolator:i,interruption:t.transitionInterruption||EA,startProps:a.start,endProps:a.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}};function ie(r,e){if(!r)throw new Error(e||"deck.gl: assertion failed.")}var lr=class{constructor(e){let{compare:t,extract:n,required:s}=e;this._propsToCompare=t,this._propsToExtract=n||t,this._requiredProps=s}arePropsEqual(e,t){for(let n of this._propsToCompare)if(!(n in e)||!(n in t)||!Xe(e[n],t[n]))return!1;return!0}initializeProps(e,t){let n={},s={};for(let i of this._propsToExtract)(i in e||i in t)&&(n[i]=e[i],s[i]=t[i]);return this._checkRequiredProps(n),this._checkRequiredProps(s),{start:n,end:s}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{let n=e[t];ie(Number.isFinite(n)||Array.isArray(n),`${t} is required for transition`)})}};var Rc=Math.PI/180,Q_=180/Math.PI,Ic=6370972,ms=256;function RA(){let r=ms/Ic,e=Math.PI/180*ms;return{unitsPerMeter:[r,r,r],unitsPerMeter2:[0,0,0],metersPerUnit:[1/r,1/r,1/r],unitsPerDegree:[e,e,r],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/e,1/e,1/r]}}var Pc=class extends je{constructor(e={}){let{longitude:t=0,zoom:n=0,nearZMultiplier:s=.5,farZMultiplier:i=1,resolution:o=10}=e,{latitude:a=0,height:c,altitude:l=1.5,fovy:u}=e;a=Math.max(Math.min(a,We),-We),c=c||1,u?l=nr(u):u=rr(l);let f=Math.pow(2,n-_n(a)),h=e.nearZ??s,d=e.farZ??(l+ms*2*f/c)*i,m=new Q().lookAt({eye:[0,-l,0],up:[0,0,1]});m.rotateX(a*Rc),m.rotateZ(-t*Rc),m.scale(f/c),super({...e,height:c,viewMatrix:m,longitude:t,latitude:a,zoom:n,distanceScales:RA(),fovy:u,focalDistance:l,near:h,far:d}),this.scale=f,this.latitude=a,this.longitude=t,this.fovy=u,this.resolution=o}get projectionMode(){return Te.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){let t={targetZ:e.z||0},n=this.unproject([0,this.height/2],t),s=this.unproject([this.width/2,0],t),i=this.unproject([this.width,this.height/2],t),o=this.unproject([this.width/2,this.height],t);return i[0]<this.longitude&&(i[0]+=360),n[0]>this.longitude&&(n[0]-=360),[Math.min(n[0],i[0],s[0],o[0]),Math.min(n[1],i[1],s[1],o[1]),Math.max(n[0],i[0],s[0],o[0]),Math.max(n[1],i[1],s[1],o[1])]}unproject(e,{topLeft:t=!0,targetZ:n}={}){let[s,i,o]=e,a=t?i:this.height-i,{pixelUnprojectionMatrix:c}=this,l;if(Number.isFinite(o))l=Xh(c,[s,a,o,1]);else{let d=Xh(c,[s,a,-1,1]),m=Xh(c,[s,a,1,1]),y=((n||0)/Ic+1)*ms,_=Oe.sqrLen(Oe.sub([],d,m)),x=Oe.sqrLen(d),E=Oe.sqrLen(m),S=4*((4*x*E-(_-x-E)**2)/16)/_,C=Math.sqrt(x-S),P=Math.sqrt(Math.max(0,y*y-S)),B=(C-P)/Math.sqrt(_);l=Oe.lerp([],d,m,B)}let[u,f,h]=this.unprojectPosition(l);return Number.isFinite(o)?[u,f,h]:Number.isFinite(n)?[u,f,n]:[u,f]}projectPosition(e){let[t,n,s=0]=e,i=t*Rc,o=n*Rc,a=Math.cos(o),c=(s/Ic+1)*ms;return[Math.sin(i)*a*c,-Math.cos(i)*a*c,Math.sin(o)*c]}unprojectPosition(e){let[t,n,s]=e,i=Oe.len(e),o=Math.asin(s/i),c=Math.atan2(t,-n)*Q_,l=o*Q_,u=(i/ms-1)*Ic;return[c,l,u]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition([e,t,n],s,i){let a=.25/Math.pow(2,this.zoom-_n(this.latitude)),c=e+a*(i[0]-s[0]),l=t-a*(i[1]-s[1]);l=Math.max(Math.min(l,We),-We);let u={longitude:c,latitude:l,zoom:n-_n(t)};return u.zoom+=_n(u.latitude),u}};Pc.displayName="GlobeViewport";var gs=Pc;function _n(r){let e=Math.PI*Math.cos(r*Math.PI/180);return Math.log2(e)}function Xh(r,e){let t=ze.transformMat4([],e,r);return ze.scale(t,t,1/t[3]),t}var IA=["longitude","latitude","zoom","bearing","pitch"],PA=["longitude","latitude","zoom"],Ae=class extends lr{constructor(e={}){let t=Array.isArray(e)?e:e.transitionProps,n=Array.isArray(e)?{}:e;n.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:IA,required:PA},super(n.transitionProps),this.opts=n}initializeProps(e,t){let n=super.initializeProps(e,t),{makeViewport:s,around:i}=this.opts;if(s&&i)if(s(e)instanceof gs)$.warn("around not supported in GlobeView")();else{let a=s(e),c=s(t),l=a.unproject(i);n.start.around=i,Object.assign(n.end,{around:c.project(l),aroundPosition:l,width:t.width,height:t.height})}return n}interpolateProps(e,t,n){let s={};for(let i of this._propsToExtract)s[i]=Jt(e[i]||0,t[i]||0,n);if(t.aroundPosition&&this.opts.makeViewport){let i=this.opts.makeViewport({...t,...s});Object.assign(s,i.panByPosition(t.aroundPosition,Jt(e.around,t.around,n)))}return s}};var ur={transitionDuration:0},CA=300,Cc=r=>1-(1-r)*(1-r),_s={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],KEYBOARD:["keydown"]},yn={},De=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new Yi({...e,getControllerState:t=>new this.ControllerState(t),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let t=this._eventStartBlocked;switch(e.type){case"panstart":return t?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return t?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"multipanstart":return t?!1:this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:t,y:n}=this.props,{offsetCenter:s}=e;return[s.x-t,s.y-n]}isPointInBounds(e,t){let{width:n,height:s}=this.props;if(t&&t.handled)return!1;let i=e[0]>=0&&e[0]<=n&&e[1]>=0&&e[1]<=s;return i&&t&&t.stopPropagation(),i}isFunctionKeyPressed(e){let{srcEvent:t}=e;return Boolean(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:t}=e;this.inertia=Number.isFinite(t)?t:t===!0?CA:0;let{scrollZoom:n=!0,dragPan:s=!0,dragRotate:i=!0,doubleClickZoom:o=!0,touchZoom:a=!0,touchRotate:c=!1,keyboard:l=!0}=e,u=Boolean(this.onViewStateChange);this.toggleEvents(_s.WHEEL,u&&n),this.toggleEvents(_s.PAN,u),this.toggleEvents(_s.PINCH,u&&(a||c)),this.toggleEvents(_s.MULTI_PAN,u&&c),this.toggleEvents(_s.DOUBLE_CLICK,u&&o),this.toggleEvents(_s.KEYBOARD,u&&l),this.scrollZoom=n,this.dragPan=s,this.dragRotate=i,this.doubleClickZoom=o,this.touchZoom=a,this.touchRotate=c,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(n=>{this._events[n]!==t&&(this._events[n]=t,t?this.eventManager.on(n,this.handleEvent):this.eventManager.off(n,this.handleEvent))})}updateViewport(e,t=null,n={}){let s={...e.getViewportProps(),...t},i=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(n),i){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:s,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(n=!n);let s=this.controllerState[n?"panStart":"rotateStart"]({pos:t});return this._panMove=n,this.updateViewport(s,ur,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let t=this.getCenter(e),n=this.controllerState.pan({pos:t});return this.updateViewport(n,ur,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:t}=this;if(this.dragPan&&t&&e.velocity){let n=this.getCenter(e),s=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],i=this.controllerState.pan({pos:s}).panEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:Cc},{isDragging:!1,isPanning:!0})}else{let n=this.controllerState.panEnd();this.updateViewport(n,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let t=this.getCenter(e),n=this.controllerState.rotate({pos:t});return this.updateViewport(n,ur,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){let n=this.getCenter(e),s=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],i=this.controllerState.rotate({pos:s}).rotateEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:Cc},{isDragging:!1,isRotating:!0})}else{let n=this.controllerState.rotateEnd();this.updateViewport(n,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();let{speed:n=.01,smooth:s=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:i}=e,o=2/(1+Math.exp(-Math.abs(i*n)));i<0&&o!==0&&(o=1/o);let a=s?{...this._getTransitionProps({around:t}),transitionDuration:250}:ur,c=this.controllerState.zoom({pos:t,scale:o});return this.updateViewport(c,a,{isZooming:!0,isPanning:!0}),s||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.controllerState.rotateStart({pos:t});return this.updateViewport(n,ur,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate||!this.isDragging())return!1;let t=this.getCenter(e);t[0]-=e.deltaX;let n=this.controllerState.rotate({pos:t});return this.updateViewport(n,ur,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this;if(this.touchRotate&&t&&e.velocityY){let n=this.getCenter(e),s=[n[0],n[1]+=e.velocityY*t/2],i=this.controllerState.rotate({pos:s});this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:Cc},{isDragging:!1,isRotating:!0}),this.blockEvents(t)}else{let n=this.controllerState.rotateEnd();this.updateViewport(n,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.controllerState.zoomStart({pos:t}).rotateStart({pos:t});return yn._startPinchRotation=e.rotation,yn._lastPinchEvent=e,this.updateViewport(n,ur,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){let{scale:n}=e,s=this.getCenter(e);t=t.zoom({pos:s,scale:n})}if(this.touchRotate){let{rotation:n}=e;t=t.rotate({deltaAngleX:yn._startPinchRotation-n})}return this.updateViewport(t,ur,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),yn._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this,{_lastPinchEvent:n}=yn;if(this.touchZoom&&t&&n&&e.scale!==n.scale){let s=this.getCenter(e),i=this.controllerState.rotateEnd(),o=Math.log2(e.scale),a=(o-Math.log2(n.scale))/(e.deltaTime-n.deltaTime),c=Math.pow(2,o+a*t/2);i=i.zoom({pos:s,scale:c}).zoomEnd(),this.updateViewport(i,{...this._getTransitionProps({around:s}),transitionDuration:t,transitionEasing:Cc},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{let s=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(s,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return yn._startPinchRotation=null,yn._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.isFunctionKeyPressed(e),s=this.controllerState.zoom({pos:t,scale:n?.5:2});return this.updateViewport(s,this._getTransitionProps({around:t}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let t=this.isFunctionKeyPressed(e),{zoomSpeed:n,moveSpeed:s,rotateSpeedX:i,rotateSpeedY:o}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(e.srcEvent.code){case"Minus":c=t?a.zoomOut(n).zoomOut(n):a.zoomOut(n),l.isZooming=!0;break;case"Equal":c=t?a.zoomIn(n).zoomIn(n):a.zoomIn(n),l.isZooming=!0;break;case"ArrowLeft":t?(c=a.rotateLeft(i),l.isRotating=!0):(c=a.moveLeft(s),l.isPanning=!0);break;case"ArrowRight":t?(c=a.rotateRight(i),l.isRotating=!0):(c=a.moveRight(s),l.isPanning=!0);break;case"ArrowUp":t?(c=a.rotateUp(o),l.isRotating=!0):(c=a.moveUp(s),l.isPanning=!0);break;case"ArrowDown":t?(c=a.rotateDown(o),l.isRotating=!0):(c=a.moveDown(s),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(e){let{transition:t}=this;return!t||!t.transitionInterpolator?ur:e?{...t,transitionInterpolator:new Ae({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t}};var fr=class{constructor(e,t){this._viewportProps=this.applyConstraints(e),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}};var J_=5,MA=1.2,qi=class extends fr{constructor(e){let{width:t,height:n,latitude:s,longitude:i,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:u=[0,0,0],maxZoom:f=20,minZoom:h=0,maxPitch:d=60,minPitch:m=0,startPanLngLat:y,startZoomLngLat:_,startRotatePos:x,startBearing:E,startPitch:b,startZoom:S,normalize:C=!0}=e;ie(Number.isFinite(i)),ie(Number.isFinite(s)),ie(Number.isFinite(o)),super({width:t,height:n,latitude:s,longitude:i,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:f,minZoom:h,maxPitch:d,minPitch:m,normalize:C,position:u},{startPanLngLat:y,startZoomLngLat:_,startRotatePos:x,startBearing:E,startPitch:b,startZoom:S}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:t}){let n=this.getState().startPanLngLat||this._unproject(t);if(!n)return this;let i=this.makeViewport(this.getViewportProps()).panByPosition(n,e);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:n=0}){let{startRotatePos:s,startBearing:i,startPitch:o}=this.getState();if(!s||i===void 0||o===void 0)return this;let a;return e?a=this._getNewRotation(e,s,o,i):a={bearing:i+t,pitch:o+n},this._getUpdatedState(a)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:n}){let{startZoom:s,startZoomLngLat:i}=this.getState();if(i||(s=this.getViewportProps().zoom,i=this._unproject(t)||this._unproject(e)),!i)return this;let{maxZoom:o,minZoom:a}=this.getViewportProps(),c=s+Math.log2(n);c=ee(c,a,o);let l=this.makeViewport({...this.getViewportProps(),zoom:c});return this._getUpdatedState({zoom:c,...l.panByPosition(i,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let t=e.getViewportProps(),n={...this.getViewportProps()},{bearing:s,longitude:i}=n;return Math.abs(s-t.bearing)>180&&(n.bearing=s<0?s+360:s-360),Math.abs(i-t.longitude)>180&&(n.longitude=i<0?i+360:i-360),n}applyConstraints(e){let{maxZoom:t,minZoom:n,zoom:s}=e;e.zoom=ee(s,n,t);let{maxPitch:i,minPitch:o,pitch:a}=e;e.pitch=ee(a,o,i);let{normalize:c=!0}=e;return c&&Object.assign(e,Fh(e)),e}_zoomFromCenter(e){let{width:t,height:n}=this.getViewportProps();return this.zoom({pos:[t/2,n/2],scale:e})}_panFromCenter(e){let{width:t,height:n}=this.getViewportProps();return this.pan({startPos:[t/2,n/2],pos:[t/2+e[0],n/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_getNewRotation(e,t,n,s){let i=e[0]-t[0],o=e[1]-t[1],a=e[1],c=t[1],{width:l,height:u}=this.getViewportProps(),f=i/l,h=0;o>0?Math.abs(u-c)>J_&&(h=o/(c-u)*MA):o<0&&c>J_&&(h=1-a/c),h=ee(h,-1,1);let{minPitch:d,maxPitch:m}=this.getViewportProps(),y=s+180*f,_=n;return h>0?_=n+h*(m-n):h<0&&(_=n-h*(d-n)),{pitch:_,bearing:y}}},xn=class extends De{constructor(){super(...arguments),this.ControllerState=qi,this.transition={transitionDuration:300,transitionInterpolator:new Ae({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(e){e.position=e.position||[0,0,0];let t=this.props;super.setProps(e),(!t||t.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}};var Mc=class extends Ne{constructor(e={}){super(e)}getViewportType(){return kr}get ControllerType(){return xn}};Mc.displayName="MapView";var Oc=Mc;var OA=new Or;function kA(r,e){let t=r.order??1/0,n=e.order??1/0;return t-n}var Ki=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let t=this._defaultEffects;if(!t.find(n=>n.id===e.id)){let n=t.findIndex(s=>kA(s,e)>0);n<0?t.push(e):t.splice(n,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(le(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){let t={};for(let s of this.effects)t[s.id]=s;let n=[];for(let s of e){let i=t[s.id],o=s;i&&i!==s?i.setProps?(i.setProps(s.props),o=i):i.cleanup(this._context):i||s.setup(this._context),n.push(o),delete t[s.id]}for(let s in t)t[s].cleanup(this._context);this.effects=n,this._resolvedEffects=n.concat(this._defaultEffects),e.some(s=>s instanceof Or)||this._resolvedEffects.push(OA),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var Zi=class extends xt{shouldDrawLayer(e){let{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}};var NA="deckRenderer.renderLayers",bn=class{constructor(e){this.device=e,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Zi(e),this.pickLayersPass=new ir(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;let t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,n={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};n.effects&&this._preRender(n.effects,n);let s=this.lastPostProcessEffect?this.renderBuffers[0]:n.target;this.lastPostProcessEffect&&(n.clearColor=[0,0,0,0],n.clearCanvas=!0);let i=t.render({...n,target:s});n.effects&&(this.lastPostProcessEffect&&(n.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(n.effects,n)),this.renderCount++,he(NA,this,i,e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){let{renderBuffers:e}=this;for(let t of e)t.delete();e.length=0}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(let n of e)t.preRenderStats[n.id]=n.preRender(t),n.postRender&&(this.lastPostProcessEffect=n.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,t=this.device.canvasContext.getDrawingBufferSize(),[n,s]=t;e.length===0&&[0,1].map(i=>{let o=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:n,height:s});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${i}`,colorAttachments:[o]}))});for(let i of e)i.resize(t)}_postRender(e,t){let{renderBuffers:n}=this,s={...t,inputBuffer:n[0],swapBuffer:n[1]};for(let i of e)if(i.postRender){s.target=i.id===this.lastPostProcessEffect?t.target:void 0;let o=i.postRender(s);s.inputBuffer=o,s.swapBuffer=o===n[0]?n[1]:n[0]}}};var DA={pickedColor:null,pickedObjectIndex:-1};function Yh({pickedColors:r,decodePickingColor:e,deviceX:t,deviceY:n,deviceRadius:s,deviceRect:i}){let{x:o,y:a,width:c,height:l}=i,u=s*s,f=-1,h=0;for(let d=0;d<l;d++){let m=d+a-n,y=m*m;if(y>u)h+=4*c;else for(let _=0;_<c;_++){if(r[h+3]-1>=0){let E=_+o-t,b=E*E+y;b<=u&&(u=b,f=h)}h+=4}}if(f>=0){let d=r.slice(f,f+4),m=e(d);if(m){let y=Math.floor(f/4/c),_=f/4-y*c;return{...m,pickedColor:d,pickedX:o+_,pickedY:a+y}}$.error("Picked non-existent layer. Is picking buffer corrupt?")()}return DA}function qh({pickedColors:r,decodePickingColor:e}){let t=new Map;if(r){for(let n=0;n<r.length;n+=4)if(r[n+3]-1>=0){let i=r.slice(n,n+4),o=i.join(",");if(!t.has(o)){let a=e(i);a?t.set(o,{...a,color:i}):$.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(t.values())}function kc({pickInfo:r,viewports:e,pixelRatio:t,x:n,y:s,z:i}){let o=e[0];e.length>1&&(o=FA(r?.pickedViewports||e,{x:n,y:s}));let a;if(o){let c=[n-o.x,s-o.y];i!==void 0&&(c[2]=i),a=o.unproject(c)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:n,y:s,pixel:[n,s],coordinate:a,devicePixel:r&&"pickedX"in r?[r.pickedX,r.pickedY]:void 0,pixelRatio:t}}function Kh(r){let{pickInfo:e,lastPickedInfo:t,mode:n,layers:s}=r,{pickedColor:i,pickedLayer:o,pickedObjectIndex:a}=e,c=o?[o]:[];if(n==="hover"){let f=t.index,h=t.layerId,d=o?o.props.id:null;if(d!==h||a!==f){if(d!==h){let m=s.find(y=>y.props.id===h);m&&c.unshift(m)}t.layerId=d,t.index=a,t.info=null}}let l=kc(r),u=new Map;return u.set(null,l),c.forEach(f=>{let h={...l};f===o&&(h.color=i,h.index=a,h.picked=!0),h=Nc({layer:f,info:h,mode:n});let d=h.layer;f===o&&n==="hover"&&(t.info=h),u.set(d.id,h),n==="hover"&&d.updateAutoHighlight(h)}),u}function Nc({layer:r,info:e,mode:t}){for(;r&&e;){let n=e.layer||null;e.sourceLayer=n,e.layer=r,e=r.getPickingInfo({info:e,mode:t,sourceLayer:n}),r=r.parent}return e}function FA(r,e){for(let t=r.length-1;t>=0;t--){let n=r[t];if(n.containsPixel(e))return n}return r[0]}var Gi=class{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new ir(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:n,viewports:s},i=this.lastPickedInfo.info){let o=i&&i.layer&&i.layer.id,a=i&&i.viewport&&i.viewport.id,c=o?n.find(h=>h.id===o):null,l=a&&s.find(h=>h.id===a)||s[0],u=l&&l.unproject([e-l.x,t-l.y]);return{...i,...{x:e,y:t,viewport:l,coordinate:u,layer:c}}}_resizeBuffer(){if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){let t=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=t}let{canvas:e}=this.device.getDefaultCanvasContext();this.pickingFBO?.resize({width:e.width,height:e.height}),this.depthFBO?.resize({width:e.width,height:e.height})}_getPickable(e){if(this._pickable===!1)return null;let t=e.filter(n=>this.pickLayersPass.shouldDrawLayer(n)&&!n.isComposite);return t.length?t:null}async _pickClosestObjectAsync({layers:e,views:t,viewports:n,x:s,y:i,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:u,effects:f}){let h=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||n.length===0)return{result:[],emptyInfo:kc({viewports:n,x:s,y:i,pixelRatio:h})};this._resizeBuffer();let m=this.device.canvasContext.cssToDevicePixels([s,i],!0),y=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],_=Math.round(o*h),{width:x,height:E}=this.pickingFBO,b=this._getPickingRect({deviceX:y[0],deviceY:y[1],deviceRadius:_,deviceWidth:x,deviceHeight:E}),S={x:s-o,y:i-o,width:o*2+1,height:o*2+1},C,P=[],B=new Set;for(let N=0;N<a;N++){let k;if(b){let U=this._drawAndSample({layers:d,views:t,viewports:n,onViewportActive:u,deviceRect:b,cullRect:S,effects:f,pass:`picking:${c}`});k=Yh({...U,deviceX:y[0],deviceY:y[1],deviceRadius:_,deviceRect:b})}else k={pickedColor:null,pickedObjectIndex:-1};let F;if(k.pickedLayer&&l&&this.depthFBO){let{pickedColors:U}=this._drawAndSample({layers:[k.pickedLayer],views:t,viewports:n,onViewportActive:u,deviceRect:{x:k.pickedX,y:k.pickedY,width:1,height:1},cullRect:S,effects:f,pass:`picking:${c}:z`},!0);U[3]&&(F=U[0])}k.pickedLayer&&N+1<a&&(B.add(k.pickedLayer),k.pickedLayer.disablePickingIndex(k.pickedObjectIndex)),C=Kh({pickInfo:k,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:n,x:s,y:i,z:F,pixelRatio:h});for(let U of C.values())U.layer&&P.push(U);if(!k.pickedColor)break}for(let N of B)N.restorePickingColors();return{result:P,emptyInfo:C.get(null)}}_pickClosestObject({layers:e,views:t,viewports:n,x:s,y:i,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:u,effects:f}){let h=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||n.length===0)return{result:[],emptyInfo:kc({viewports:n,x:s,y:i,pixelRatio:h})};this._resizeBuffer();let m=this.device.canvasContext.cssToDevicePixels([s,i],!0),y=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],_=Math.round(o*h),{width:x,height:E}=this.pickingFBO,b=this._getPickingRect({deviceX:y[0],deviceY:y[1],deviceRadius:_,deviceWidth:x,deviceHeight:E}),S={x:s-o,y:i-o,width:o*2+1,height:o*2+1},C,P=[],B=new Set;for(let N=0;N<a;N++){let k;if(b){let U=this._drawAndSample({layers:d,views:t,viewports:n,onViewportActive:u,deviceRect:b,cullRect:S,effects:f,pass:`picking:${c}`});k=Yh({...U,deviceX:y[0],deviceY:y[1],deviceRadius:_,deviceRect:b})}else k={pickedColor:null,pickedObjectIndex:-1};let F;if(k.pickedLayer&&l&&this.depthFBO){let{pickedColors:U}=this._drawAndSample({layers:[k.pickedLayer],views:t,viewports:n,onViewportActive:u,deviceRect:{x:k.pickedX,y:k.pickedY,width:1,height:1},cullRect:S,effects:f,pass:`picking:${c}:z`},!0);U[3]&&(F=U[0])}k.pickedLayer&&N+1<a&&(B.add(k.pickedLayer),k.pickedLayer.disablePickingIndex(k.pickedObjectIndex)),C=Kh({pickInfo:k,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:n,x:s,y:i,z:F,pixelRatio:h});for(let U of C.values())U.layer&&P.push(U);if(!k.pickedColor)break}for(let N of B)N.restorePickingColors();return{result:P,emptyInfo:C.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:t,viewports:n,x:s,y:i,width:o=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:u,effects:f}){let h=this._getPickable(e);if(!h||n.length===0)return[];this._resizeBuffer();let d=this.device.canvasContext.cssToDeviceRatio(),m=this.device.canvasContext.cssToDevicePixels([s,i],!0),y=m.x,_=m.y+m.height,x=this.device.canvasContext.cssToDevicePixels([s+o,i+a],!0),E=x.x+x.width,b=x.y,S={x:y,y:b,width:E-y,height:_-b},C=this._drawAndSample({layers:h,views:t,viewports:n,onViewportActive:u,deviceRect:S,cullRect:{x:s,y:i,width:o,height:a},effects:f,pass:`picking:${c}`}),P=qh(C),B=new Map,N=[],k=Number.isFinite(l);for(let F=0;F<P.length&&!(k&&N.length>=l);F++){let U=P[F],X={color:U.pickedColor,layer:null,index:U.pickedObjectIndex,picked:!0,x:s,y:i,pixelRatio:d};X=Nc({layer:U.pickedLayer,info:X,mode:c});let J=X.layer.id;B.has(J)||B.set(J,new Set);let q=B.get(J),pe=X.object??X.index;q.has(pe)||(q.add(pe),N.push(X))}return N}_pickVisibleObjects({layers:e,views:t,viewports:n,x:s,y:i,width:o=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:u,effects:f}){let h=this._getPickable(e);if(!h||n.length===0)return[];this._resizeBuffer();let d=this.device.canvasContext.cssToDeviceRatio(),m=this.device.canvasContext.cssToDevicePixels([s,i],!0),y=m.x,_=m.y+m.height,x=this.device.canvasContext.cssToDevicePixels([s+o,i+a],!0),E=x.x+x.width,b=x.y,S={x:y,y:b,width:E-y,height:_-b},C=this._drawAndSample({layers:h,views:t,viewports:n,onViewportActive:u,deviceRect:S,cullRect:{x:s,y:i,width:o,height:a},effects:f,pass:`picking:${c}`}),P=qh(C),B=new Map,N=[],k=Number.isFinite(l);for(let F=0;F<P.length&&!(k&&N.length>=l);F++){let U=P[F],X={color:U.pickedColor,layer:null,index:U.pickedObjectIndex,picked:!0,x:s,y:i,pixelRatio:d};X=Nc({layer:U.pickedLayer,info:X,mode:c});let J=X.layer.id;B.has(J)||B.set(J,new Set);let q=B.get(J),pe=X.object??X.index;q.has(pe)||(q.add(pe),N.push(X))}return N}async _drawAndSampleAsync({layers:e,views:t,viewports:n,onViewportActive:s,deviceRect:i,cullRect:o,effects:a,pass:c},l=!1){let u=l?this.depthFBO:this.pickingFBO,f={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:s,pickingFBO:u,deviceRect:i,cullRect:o,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let E of a)E.useInPicking&&(f.preRenderStats[E.id]=E.preRender(f));let{decodePickingColor:h}=this.pickLayersPass.render(f),{x:d,y:m,width:y,height:_}=i,x=new(l?Float32Array:Uint8Array)(y*_*4);return this.device.readPixelsToArrayWebGL(u,{sourceX:d,sourceY:m,sourceWidth:y,sourceHeight:_,target:x}),{pickedColors:x,decodePickingColor:h}}_drawAndSample({layers:e,views:t,viewports:n,onViewportActive:s,deviceRect:i,cullRect:o,effects:a,pass:c},l=!1){let u=l?this.depthFBO:this.pickingFBO,f={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:s,pickingFBO:u,deviceRect:i,cullRect:o,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let E of a)E.useInPicking&&(f.preRenderStats[E.id]=E.preRender(f));let{decodePickingColor:h}=this.pickLayersPass.render(f),{x:d,y:m,width:y,height:_}=i,x=new(l?Float32Array:Uint8Array)(y*_*4);return this.device.readPixelsToArrayWebGL(u,{sourceX:d,sourceY:m,sourceWidth:y,sourceHeight:_,target:x}),{pickedColors:x,decodePickingColor:h}}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:n,deviceWidth:s,deviceHeight:i}){let o=Math.max(0,e-n),a=Math.max(0,t-n),c=Math.min(s,e+n+1)-o,l=Math.min(i,t+n+1)-a;return c<=0||l<=0?null:{x:o,y:a,width:c,height:l}}};var BA={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},LA="top-left",ey="root",Dc=class{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,t?.classList.add("deck-widget-container"),this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!le(e.widgets,this.widgets,1)){let t=e.widgets.filter(Boolean);this._setWidgets(t)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:t}){let n=e.reduce((s,i)=>(s[i.id]=i,s),{});for(let s of this.getWidgets()){let{viewId:i}=s;if(i){let o=n[i];o&&(s.onViewportChange&&s.onViewportChange(o),s.onRedraw?.({viewports:[o],layers:t}))}else{if(s.onViewportChange)for(let o of e)s.onViewportChange(o);s.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=n,this._updateContainers()}onHover(e,t){for(let n of this.getWidgets()){let{viewId:s}=n;(!s||s===e.viewport?.id)&&n.onHover?.(e,t)}}onEvent(e,t){let n=Mi[t.type];if(n)for(let s of this.getWidgets()){let{viewId:i}=s;(!i||i===e.viewport?.id)&&s[n]?.(e,t)}}_setWidgets(e){let t={};for(let n of this.resolvedWidgets)t[n.id]=n;this.resolvedWidgets.length=0;for(let n of this.defaultWidgets)t[n.id]=null,this.resolvedWidgets.push(n);for(let n of e){let s=t[n.id];s?s.viewId!==n.viewId||s.placement!==n.placement?(this._removeWidget(s),this._addWidget(n)):n!==s&&(s.setProps(n.props),n=s):this._addWidget(n),t[n.id]=null,this.resolvedWidgets.push(n)}for(let n in t){let s=t[n];s&&this._removeWidget(s)}this.widgets=e}_addWidget(e){let{viewId:t=null,placement:n=LA}=e,s=e.props._container??t;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:t}),e.rootElement&&this._getContainer(s,n).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,t){if(e&&typeof e!="string")return e;let n=e||ey,s=this.containers[n];s||(s=document.createElement("div"),s.style.pointerEvents="none",s.style.position="absolute",s.style.overflow="hidden",this.parentElement?.append(s),this.containers[n]=s);let i=s.querySelector(`.${t}`);return i||(i=globalThis.document.createElement("div"),i.className=t,i.style.position="absolute",i.style.zIndex="2",Object.assign(i.style,BA[t]),s.append(i)),i}_updateContainers(){let e=this.deck.width,t=this.deck.height;for(let n in this.containers){let s=this.lastViewports[n]||null,i=n===ey||s,o=this.containers[n];i?(o.style.display="block",o.style.left=`${s?s.x:0}px`,o.style.top=`${s?s.y:0}px`,o.style.width=`${s?s.width:e}px`,o.style.height=`${s?s.height:t}px`):o.style.display="none"}}};function Qi(r,e){e&&Object.entries(e).map(([t,n])=>{t.startsWith("--")?r.style.setProperty(t,n):r.style[t]=n})}function Fc(r,e){e&&Object.keys(e).map(t=>{t.startsWith("--")?r.style.removeProperty(t):r.style[t]=""})}var Fr=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let t=this.props,n=this.rootElement;n&&t.className!==e.className&&(t.className&&n.classList.remove(t.className),e.className&&n.classList.add(e.className)),n&&!le(t.style,e.style,1)&&(Fc(n,t.style),Qi(n,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}onCreateRootElement(){let e=["deck-widget",this.className,this.props.className],t=document.createElement("div");return e.filter(n=>typeof n=="string"&&n.length>0).forEach(n=>t.classList.add(n)),Qi(t,this.props.style),t}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,t){}onClick(e,t){}onDrag(e,t){}onDragStart(e,t){}onDragEnd(e,t){}};Fr.defaultProps={id:"widget",style:{},_container:null,className:""};var UA={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},Ji=class extends Fr{constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement("div");return e.className=this.className,Object.assign(e.style,UA),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:t}=this,n=t&&t.props.getTooltip;if(!n)return;let s=n(e);this.setTooltip(s,e.x,e.y)}setTooltip(e,t,n){let s=this.rootElement;if(s){if(typeof e=="string")s.innerText=e;else if(e)e.text&&(s.innerText=e.text),e.html&&(s.innerHTML=e.html),e.className&&(s.className=e.className);else{this.isVisible=!1,s.style.display="none";return}this.isVisible=!0,s.style.display="block",s.style.transform=`translate(${t}px, ${n}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(s.style,e.style)}}};Ji.defaultProps={...Fr.defaultProps};H();ol();Rs();function Ur(){}var jS=({isDragging:r})=>r?"grabbing":"grab",Ax={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:Ur,onWebGLInitialized:Ur,onResize:Ur,onViewStateChange:Ur,onInteractionStateChange:Ur,onBeforeRender:Ur,onAfterRender:Ur,onLoad:Ur,onError:r=>$.error(r.message,r.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:jS,getTooltip:null,debug:!1,drawPickingColors:!1},ao=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Ze({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._onPointerMove=n=>{let{_pickRequest:s}=this;if(n.type==="pointerleave")s.x=-1,s.y=-1,s.radius=0;else{if(n.leftButton||n.rightButton)return;{let i=n.offsetCenter;if(!i)return;s.x=i.x,s.y=i.y,s.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:s.x,y:s.y}),s.event=n},this._onEvent=n=>{let s=Mi[n.type],i=n.offsetCenter;if(!s||!i||!this.layerManager)return;let o,a=this.layerManager.getLayers(),c=a.some(d=>d.props.pickable==="3d");if(n.type==="click"&&c){let d=this._pick("pickObject","pickObject Time",{x:i.x,y:i.y,radius:this.props.pickingRadius,unproject3D:!0});o=d.result[0]||d.emptyInfo}else o=this.deckPicker.getLastPickedObject({x:i.x,y:i.y,layers:a,viewports:this.getViewports(i)},this._lastPointerDownInfo);let{layer:l}=o,u=l&&(l[s]||l.props[s]),f=this.props[s],h=!1;u&&(h=u.call(l,o,n)),h||(f?.(o,n),this.widgetManager.onEvent(o,n))},this._onPointerDown=n=>{if(this.device?.type==="webgpu")return;let s=n.offsetCenter,i=this._pick("pickObject","pickObject Time",{x:s.x,y:s.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=i.result[0]||i.emptyInfo},this.props={...Ax,...e},e=this.props,e.viewState&&e.initialViewState&&$.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device);let t=this.device;if(!t&&e.gl){e.gl instanceof WebGLRenderingContext&&$.error("WebGL1 context not supported.")();let n=this.props.deviceProps?.onResize;t=oo.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps,onResize:(s,i)=>{let{width:o,height:a}=s.canvas;s.drawingBufferWidth=o,s.drawingBufferHeight=a,this._needsRedraw="Canvas resized",n?.(s,i)}})}t||(t=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(t,e),this.setProps(e),e._typedArrayManagerProps&&bt.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._lastPointerDownInfo=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&$.removed("onLayerHover","onHover")(),"onLayerClick"in e&&$.removed("onLayerClick","onClick")(),e.initialViewState&&!le(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._setCanvasSize(this.props);let t=Object.create(this.props);Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),e.device&&e.device.id!==this.device?.id&&(this.animationLoop?.stop(),this.canvas!==e.device.canvasContext?.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),$.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()),this.animationLoop?.setProps(t),e.useDevicePixels!==void 0&&this.device?.canvasContext?.setProps&&this.device.canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t),this.widgetManager.setProps(t)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let n=this.viewManager.needsRedraw(e),s=this.layerManager.needsRedraw(e),i=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return t=t||n||s||i||o,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return this.viewManager!==null}getViews(){return ie(this.viewManager),this.viewManager.views}getView(e){return ie(this.viewManager),this.viewManager.getView(e)}getViewports(e){return ie(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}pickObject(e){let t=this._pick("pickObject","pickObject Time",e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_addResources(e,t=!1){for(let n in e)this.layerManager.resourceManager.add({resourceId:n,data:e[n],forceUpdate:t})}_removeResources(e){for(let t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_pick(e,t,n){ie(this.deckPicker);let{stats:s}=this;s.get("Pick Count").incrementCount(),s.get(t).timeStart();let i=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n});return s.get(t).timeEnd(),i}_createCanvas(e){let t=e.canvas;return typeof t=="string"&&(t=document.getElementById(t),ie(t)),t||(t=document.createElement("canvas"),t.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(t.width=e.width),e.height&&typeof e.height=="number"&&(t.height=e.height),(e.parent||document.body).appendChild(t)),Object.assign(t.style,e.style),t}_setCanvasSize(e){if(!this.canvas)return;let{width:t,height:n}=e;if(t||t===0){let s=Number.isFinite(t)?`${t}px`:t;this.canvas.style.width=s}if(n||n===0){let s=Number.isFinite(n)?`${n}px`:n;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=s}}_updateCanvasSize(){let{canvas:e}=this;if(!e)return;let t=e.clientWidth??e.width,n=e.clientHeight??e.height;(t!==this.width||n!==this.height)&&(this.width=t,this.height=n,this.viewManager?.setProps({width:t,height:n}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:t,height:n}))}_createAnimationLoop(e,t){let{gl:n,onError:s}=t;return new Vn({device:e,autoResizeDrawingBuffer:!n,autoResizeViewport:!1,onInitialize:i=>this._setDevice(i.device),onRender:this._onRenderFrame.bind(this),onError:s})}_createDevice(e){let t=this.props.deviceProps?.createCanvasContext,n=typeof t=="object"?t:void 0,s={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};s.adapters.includes(oo)||s.adapters.push(oo);let i={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0},o=this.props.deviceProps?.onResize;return mr.createDevice({_reuseDevices:!0,type:"webgl",...s,createCanvasContext:{...i,...n,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0},onResize:(a,c)=>{this._needsRedraw="Canvas resized",o?.(a,c)}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new Oc({id:"default-view"})];return t.length&&this.props.controller&&(t[0].props.controller=this.props.controller),t}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){if(this.device?.type==="webgpu")return;let{_pickRequest:e}=this;if(e.event){let n=(this.layerManager?.getLayers()||[]).some(c=>c.props.pickable==="3d");e.unproject3D=n;let{result:s,emptyInfo:i}=this._pick("pickObject","pickObject Time",e);this.cursorState.isHovering=s.length>0;let o=i,a=!1;for(let c of s)o=c,a=c.layer?.onHover(c,e.event)||a;a||(this.props.onHover?.(o,e.event),this.widgetManager.onHover(o,e.event)),e.event=null}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,!this.animationLoop)return;this.canvas||(this.canvas=this.device.canvasContext?.canvas,!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild)),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let t=new qr;t.play(),this.animationLoop.attachTimeline(t),this.eventManager=new Ci(this.props.parent||this.canvas,{touchAction:this.props.touchAction,recognizers:Object.keys(Ph).map(s=>{let[i,o,a,c]=Ph[s],l=this.props.eventRecognizerOptions?.[s],u={...o,...l,event:s};return{recognizer:new i(u),recognizeWith:a,requestFailure:c}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let s in Mi)this.eventManager.on(s,this._onEvent);this.viewManager=new Hi({timeline:t,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let n=this.viewManager.getViewports()[0];this.layerManager=new gn(this.device,{deck:this,stats:this.stats,viewport:n,timeline:t}),this.effectManager=new Ki({deck:this,device:this.device}),this.deckRenderer=new bn(this.device),this.deckPicker=new Gi(this.device),this.widgetManager=new Dc({deck:this,parentElement:this.canvas?.parentElement}),this.widgetManager.addDefault(new Ji),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,t){let{device:n,gl:s}=this.layerManager.context;this.props.onBeforeRender({device:n,gl:s});let i={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...t};this.deckRenderer?.renderLayers(i),i.pass==="screen"&&this.widgetManager.onRedraw({viewports:i.viewports,layers:i.layers}),this.props.onAfterRender({device:n,gl:s})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),$.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this.device?.type!=="webgpu"&&this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let t=this.animationLoop.stats;e.get("GPU Time").addTime(t.get("GPU Time").lastTiming),e.get("CPU Time").addTime(t.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:t}=this;e.fps=t.get("frameRate").getHz(),e.setPropsTime=t.get("setProps Time").time,e.updateAttributesTime=t.get("Update Attributes").time,e.framesRedrawn=t.get("Redraw Count").count,e.pickTime=t.get("pickObject Time").time+t.get("pickMultipleObjects Time").time+t.get("pickObjects Time").time,e.pickCount=t.get("Pick Count").count,e.gpuTime=t.get("GPU Time").time,e.cpuTime=t.get("CPU Time").time,e.gpuTimePerFrame=t.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=t.get("CPU Time").getAverageTime();let n=mr.stats.get("Memory Usage");e.bufferMemory=n.get("Buffer Memory").count,e.textureMemory=n.get("Texture Memory").count,e.renderbufferMemory=n.get("Renderbuffer Memory").count,e.gpuMemory=n.get("GPU Memory").count}};ao.defaultProps=Ax;ao.VERSION=tc;var ul=ao;H();H();function Sx(r){switch(r){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return jr(r)}}var Ex=$r;function co(r,e,t){let n=t==="webgpu"&&e.type==="uint8"?"unorm8":e.type;return{attribute:r,format:e.size>1?`${n}x${e.size}`:e.type,byteOffset:e.offset||0}}function Vr(r){return r.stride||r.size*r.bytesPerElement}function Rx(r,e){return r.type===e.type&&r.size===e.size&&Vr(r)===Vr(e)&&(r.offset||0)===(e.offset||0)}function yd(r,e){e.offset&&$.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let t=Vr(r),n=e.vertexOffset!==void 0?e.vertexOffset:r.vertexOffset||0,s=e.elementOffset||0,i=n*t+s*r.bytesPerElement+(r.offset||0);return{...e,offset:i,stride:t}}function HS(r,e){let t=yd(r,e);return{high:t,low:{...t,offset:t.offset+r.size*4}}}var lo=class{constructor(e,t,n){this._buffer=null,this.device=e,this.id=t.id||"",this.size=t.size||1;let s=t.logicalType||t.type,i=s==="float64",{defaultValue:o}=t;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;i?a="float32":!s&&t.isIndexed?a="uint32":a=s||"float32";let c=Sx(s||a);this.doublePrecision=i,i&&t.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...t,defaultType:c,defaultValue:o,logicalType:s,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...n,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*Vr(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),bt.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){let n={};if(this.state.constant){let s=this.value;if(t){let i=yd(this.getAccessor(),t),o=i.offset/s.BYTES_PER_ELEMENT,a=i.size||this.size;n[e]=s.subarray(o,o+a)}else n[e]=s}else n[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?n[`${e}64Low`]=n[e]:n[`${e}64Low`]=new Float32Array(this.size)),n}_getBufferLayout(e=this.id,t=null){let n=this.getAccessor(),s=[],i={name:this.id,byteStride:Vr(n),attributes:s};if(this.doublePrecision){let o=HS(n,t||{});s.push(co(e,{...n,...o.high},this.device.type),co(`${e}64Low`,{...n,...o.low},this.device.type))}else if(t){let o=yd(n,t);s.push(co(e,{...n,...o},this.device.type))}else s.push(co(e,n,this.device.type));return i}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let t=Array.from(this.value);e=[t,t]}else{let{value:t,numInstances:n,size:s}=this,i=n*s;if(t&&i&&t.length>=i){let o=new Array(s).fill(1/0),a=new Array(s).fill(-1/0);for(let c=0;c<i;)for(let l=0;l<s;l++){let u=t[c++];u<o[l]&&(o[l]=u),u>a[l]&&(a[l]=u)}e=[o,a]}}return this.state.bounds=e,e}setData(e){let{state:t}=this,n;ArrayBuffer.isView(e)?n={value:e}:e instanceof W?n={buffer:e}:n=e;let s={...this.settings,...n};if(ArrayBuffer.isView(n.value)){if(!n.type)if(this.doublePrecision&&n.value instanceof Float64Array)s.type="float32";else{let o=Ex(n.value);s.type=s.normalized?o.replace("int","norm"):o}s.bytesPerElement=n.value.BYTES_PER_ELEMENT,s.stride=Vr(s)}if(t.bounds=null,n.constant){let i=n.value;if(i=this._normalizeValue(i,[],0),this.settings.normalized&&(i=this.normalizeConstant(i)),!(!t.constant||!this._areValuesEqual(i,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(i)?i:new Float32Array(i)}else if(n.buffer){let i=n.buffer;t.externalBuffer=i,t.constant=!1,this.value=n.value||null}else if(n.value){this._checkExternalBuffer(n);let i=n.value;t.externalBuffer=null,t.constant=!1,this.value=i;let{buffer:o}=this,a=Vr(s),c=(s.vertexOffset||0)*a;if(this.doublePrecision&&i instanceof Float64Array&&(i=Tc(i,s)),this.settings.isIndexed){let u=this.settings.defaultType;i.constructor!==u&&(i=new u(i))}let l=i.byteLength+c+a*2;(!o||o.byteLength<l)&&(o=this._createBuffer(l)),o.write(i,c)}return this.setAccessor(s),!0}updateSubBuffer(e={}){this.state.bounds=null;let t=this.value,{startOffset:n=0,endOffset:s}=e;this.buffer.write(this.doublePrecision&&t instanceof Float64Array?Tc(t,{size:this.size,startIndex:n,endIndex:s}):t.subarray(n,s),n*t.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,t=!1){let{state:n}=this,s=n.allocatedValue,i=bt.allocate(s,e+1,{size:this.size,type:this.settings.defaultType,copy:t});this.value=i;let{byteOffset:o}=this,{buffer:a}=this;return(!a||a.byteLength<i.byteLength+o)&&(a=this._createBuffer(i.byteLength+o),t&&s&&a.write(s instanceof Float64Array?Tc(s,this):s,o)),n.allocatedValue=i,n.constant=!1,n.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){let{value:t}=e;if(!ArrayBuffer.isView(t))throw new Error(`Attribute ${this.id} value is not TypedArray`);let n=this.settings.defaultType,s=!1;if(this.doublePrecision&&(s=t.BYTES_PER_ELEMENT<4),s)throw new Error(`Attribute ${this.id} does not support ${t.constructor.name}`);!(t instanceof n)&&this.settings.normalized&&!("normalized"in e)&&$.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case"snorm8":return new Float32Array(e).map(t=>(t+128)/255*2-1);case"snorm16":return new Float32Array(e).map(t=>(t+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(t=>t/255);case"unorm16":return new Float32Array(e).map(t=>t/65535);default:return e}}_normalizeValue(e,t,n){let{defaultValue:s,size:i}=this.settings;if(Number.isFinite(e))return t[n]=e,t;if(!e){let o=i;for(;--o>=0;)t[n+o]=s[o];return t}switch(i){case 4:t[n+3]=Number.isFinite(e[3])?e[3]:s[3];case 3:t[n+2]=Number.isFinite(e[2])?e[2]:s[2];case 2:t[n+1]=Number.isFinite(e[1])?e[1]:s[1];case 1:t[n+0]=Number.isFinite(e[0])?e[0]:s[0];break;default:let o=i;for(;--o>=0;)t[n+o]=Number.isFinite(e[o])?e[o]:s[o]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;let{size:n}=this;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();let{isIndexed:t,type:n}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(t?W.INDEX:W.VERTEX)|W.COPY_DST,indexType:t?n:void 0,byteLength:e}),this._buffer}};var Ix=[],Px=[];function vs(r,e=0,t=1/0){let n=Ix,s={index:-1,data:r,target:[]};return r?typeof r[Symbol.iterator]=="function"?n=r:r.length>0&&(Px.length=r.length,n=Px):n=Ix,(e>0||Number.isFinite(t))&&(n=(Array.isArray(n)?n:Array.from(n)).slice(e,t),s.index=e-1),{iterable:n,objectInfo:s}}function fl(r){return r&&r[Symbol.asyncIterator]}function hl(r,e){let{size:t,stride:n,offset:s,startIndices:i,nested:o}=e,a=r.BYTES_PER_ELEMENT,c=n?n/a:t,l=s?s/a:0,u=Math.floor((r.length-l)/c);return(f,{index:h,target:d})=>{if(!i){let x=h*c+l;for(let E=0;E<t;E++)d[E]=r[x+E];return d}let m=i[h],y=i[h+1]||u,_;if(o){_=new Array(y-m);for(let x=m;x<y;x++){let E=x*c+l;d=new Array(t);for(let b=0;b<t;b++)d[b]=r[E+b];_[x-m]=d}}else if(c===t)_=r.subarray(m*t+l,y*t+l);else{_=new r.constructor((y-m)*t);let x=0;for(let E=m;E<y;E++){let b=E*c+l;for(let S=0;S<t;S++)_[x++]=r[b+S]}}return _}}var Cx=[],uo=[[0,1/0]];function Mx(r,e){if(r===uo||(e[0]<0&&(e[0]=0),e[0]>=e[1]))return r;let t=[],n=r.length,s=0;for(let i=0;i<n;i++){let o=r[i];o[1]<e[0]?(t.push(o),s=i+1):o[0]>e[1]?t.push(o):e=[Math.min(o[0],e[0]),Math.max(o[1],e[1])]}return t.splice(s,0,e),t}var YS={interpolation:{duration:0,easing:r=>r},spring:{stiffness:.05,damping:.5}};function dl(r,e){if(!r)return null;Number.isFinite(r)&&(r={type:"interpolation",duration:r});let t=r.type||"interpolation";return{...YS[t],...e,...r,type:t}}var hr=class extends lo{constructor(e,t){super(e,t,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:uo}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t;(t=this.state).layoutChanged||(t.layoutChanged=!Rx(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:t}=this.settings,n=this.settings.transition,s=Array.isArray(t)?e[t.find(i=>e[i])]:e[t];return dl(s,n)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){let{startRow:n=0,endRow:s=1/0}=t;this.state.updateRanges=Mx(this.state.updateRanges,[n,s])}else this.state.updateRanges=uo}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=Cx}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:t,settings:n}=this;return n.noAlloc?!1:n.update?(super.allocate(e,t.updateRanges!==uo),!0):!1}updateBuffer({numInstances:e,data:t,props:n,context:s}){if(!this.needsUpdate())return!1;let{state:{updateRanges:i},settings:{update:o,noAlloc:a}}=this,c=!0;if(o){for(let[l,u]of i)o.call(s,this,{data:t,startRow:l,endRow:u,props:n,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(let[l,u]of i){let f=Number.isFinite(l)?this.getVertexOffset(l):0,h=Number.isFinite(u)?this.getVertexOffset(u):a||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:f,endOffset:h})}this._checkAttributeArray()}else c=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),c}setConstantValue(e,t){let n=this.device.type==="webgpu";if(n||t===void 0||typeof t=="function"){if(n&&typeof t!="function"){let o=this._normalizeValue(t,[],0);this._areValuesEqual(o,this.value)||this.setNeedsUpdate("WebGPU constant updated")}return!1}let s=this.settings.transform&&e?this.settings.transform.call(e,t):t;return this.setData({constant:!0,value:s})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0}setExternalBuffer(e){let{state:t}=this;return e?(this.clearNeedsUpdate(),t.lastExternalBuffer===e||(t.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e)),!0):(t.lastExternalBuffer=null,!1)}setBinaryValue(e,t=null){let{state:n,settings:s}=this;if(!e)return n.binaryValue=null,n.binaryAccessor=null,!1;if(s.noAlloc)return!1;if(n.binaryValue===e)return this.clearNeedsUpdate(),!0;if(n.binaryValue=e,this.setNeedsRedraw(),s.transform||t!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});let o=e;ie(ArrayBuffer.isView(o.value),`invalid ${s.accessor}`);let a=Boolean(o.size)&&o.size!==this.size;return n.binaryAccessor=hl(o.value,{size:o.size||this.size,stride:o.stride,offset:o.offset,startIndices:t,nested:a}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){let{startIndices:t}=this;return(t?e<t.length?t[e]:this.numInstances:e)*this.size}getValue(){let e=this.settings.shaderAttributes,t=super.getValue();if(!e)return t;for(let n in e)Object.assign(t,super.getValue(n,e[n]));return t}getBufferLayout(e){this.state.layoutChanged=!1;let t=this.settings.shaderAttributes,n=super._getBufferLayout(),{stepMode:s}=this.settings;if(s==="dynamic"?n.stepMode=e?e.isInstanced?"instance":"vertex":"instance":n.stepMode=s??"vertex",!t)return n;for(let i in t){let o=super._getBufferLayout(i,t[i]);n.attributes.push(...o.attributes)}return n}_autoUpdater(e,{data:t,startRow:n,endRow:s,props:i,numInstances:o}){if(e.constant&&this.context.device.type!=="webgpu")return;let{settings:a,state:c,value:l,size:u,startIndices:f}=e,{accessor:h,transform:d}=a,m=c.binaryAccessor||(typeof h=="function"?h:i[h]);typeof m!="function"&&typeof h=="string"&&(m=()=>i[h]),ie(typeof m=="function",`accessor "${h}" is not a function`);let y=e.getVertexOffset(n),{iterable:_,objectInfo:x}=vs(t,n,s);for(let E of _){x.index++;let b=m(E,x);if(d&&(b=d.call(this,b)),f){let S=(x.index<f.length-1?f[x.index+1]:o)-f[x.index];if(b&&Array.isArray(b[0])){let C=y;for(let P of b)e._normalizeValue(P,l,C),C+=u}else b&&b.length>u?l.set(b,y):(e._normalizeValue(b,x.target,0),Ec({target:l,source:x.target,start:y,count:S}));y+=S*u}else e._normalizeValue(b,l,y),y+=u}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let n=!0;switch(t){case 4:n=n&&Number.isFinite(e[3]);case 3:n=n&&Number.isFinite(e[2]);case 2:n=n&&Number.isFinite(e[1]);case 1:n=n&&Number.isFinite(e[0]);break;default:n=!1}if(!n)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function xd(r){let{source:e,target:t,start:n=0,size:s,getData:i}=r,o=r.end||t.length,a=e.length,c=o-n;if(a>c){t.set(e.subarray(0,c),n);return}if(t.set(e,n),!i)return;let l=a;for(;l<c;){let u=i(l,e);for(let f=0;f<s;f++)t[n+l]=u[f]||0,l++}}function Ox({source:r,target:e,size:t,getData:n,sourceStartIndices:s,targetStartIndices:i}){if(!s||!i)return xd({source:r,target:e,size:t,getData:n}),e;let o=0,a=0,c=n&&((u,f)=>n(u+a,f)),l=Math.min(s.length,i.length);for(let u=1;u<l;u++){let f=s[u]*t,h=i[u]*t;xd({source:r.subarray(o,f),target:e,start:a,end:h,size:t,getData:c}),o=f,a=h}return a<e.length&&xd({source:[],target:e,start:a,size:t,getData:c}),e}function kx(r){let{device:e,settings:t,value:n}=r,s=new hr(e,t);return s.setData({value:n instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:t.normalized}),s}function pl(r){switch(r){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`No defined attribute type for size "${r}"`)}}function ml(r){switch(r){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function gl(r){r.push(r.shift())}function Nx(r,e){let{doublePrecision:t,settings:n,value:s,size:i}=r,o=t&&s instanceof Float64Array?2:1,a=0,{shaderAttributes:c}=r.settings;if(c)for(let l of Object.values(c))a=Math.max(a,l.vertexOffset??0);return(n.noAlloc?s.length:(e+a)*i)*o}function _l({device:r,source:e,target:t}){return(!t||t.byteLength<e.byteLength)&&(t?.destroy(),t=r.createBuffer({byteLength:e.byteLength,usage:e.usage})),t}function yl({device:r,buffer:e,attribute:t,fromLength:n,toLength:s,fromStartIndices:i,getData:o=a=>a}){let a=t.doublePrecision&&t.value instanceof Float64Array?2:1,c=t.size*a,l=t.byteOffset,u=t.settings.bytesPerElement<4?l/t.settings.bytesPerElement*4:l,f=t.startIndices,h=i&&f,d=t.isConstant;if(!h&&e&&n>=s)return e;let m=t.value instanceof Float64Array?Float32Array:t.value.constructor,y=d?t.value:new m(t.getBuffer().readSyncWebGL(l,s*m.BYTES_PER_ELEMENT).buffer);if(t.settings.normalized&&!d){let b=o;o=(S,C)=>t.normalizeConstant(b(S,C))}let _=d?(b,S)=>o(y,S):(b,S)=>o(y.subarray(b+l,b+l+c),S),x=e?new Float32Array(e.readSyncWebGL(u,n*4).buffer):new Float32Array(0),E=new Float32Array(s);return Ox({source:x,target:E,sourceStartIndices:i,targetStartIndices:f,size:c,getData:_}),(!e||e.byteLength<E.byteLength+u)&&(e?.destroy(),e=r.createBuffer({byteLength:E.byteLength+u,usage:35050})),e.write(E,u),e}var As=class{constructor({device:e,attribute:t,timeline:n}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new wt(n),this.attribute=t,this.attributeInTransition=kx(t),this.currentStartIndices=t.startIndices}get inProgress(){return this.transition.inProgress}start(e,t,n=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=Nx(this.attribute,t),this.transition.start({...e,duration:n})}update(){let e=this.transition.update();return e&&this.onUpdate(),e}setBuffer(e){this.attributeInTransition.setData({buffer:e,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(let e of this.buffers)e.destroy();this.buffers.length=0}};var fo=class extends As{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type="interpolation",this.transform=GS(e,t)}start(e,t){let n=this.currentLength,s=this.currentStartIndices;if(super.start(e,t,e.duration),e.duration<=0){this.transition.cancel();return}let{buffers:i,attribute:o}=this;gl(i),i[0]=yl({device:this.device,buffer:i[0],attribute:o,fromLength:n,toLength:this.currentLength,fromStartIndices:s,getData:e.enter}),i[1]=_l({device:this.device,source:i[0],target:i[1]}),this.setBuffer(i[1]);let{transform:a}=this,c=a.model,l=Math.floor(this.currentLength/o.size);Fx(o)&&(l/=2),c.setVertexCount(l),o.isConstant?(c.setAttributes({aFrom:i[0]}),c.setConstantAttributes({aTo:o.value})):c.setAttributes({aFrom:i[0],aTo:o.getBuffer()}),a.transformFeedback.setBuffers({vCurrent:i[1]})}onUpdate(){let{duration:e,easing:t}=this.settings,{time:n}=this.transition,s=n/e;t&&(s=t(s));let{model:i}=this.transform,o={time:s};i.shaderInputs.setProps({interpolation:o}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},qS=`uniform interpolationUniforms {
1590
+ `;function EA(r,e){if(e.filter){let t=typeof e.filter=="string"?e.filter:`${r.name}_filterColor_ext`;return AA(t)}if(e.sampler){let t=typeof e.sampler=="string"?e.sampler:`${r.name}_sampleColor`;return SA(t)}return""}var RA={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant",blendAlphaDstFactor:"zero"},sr=class extends _t{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:t,views:n,viewports:s,onViewportActive:i,pickingFBO:o,deviceRect:{x:a,y:c,width:l,height:u},cullRect:f,effects:h,pass:d="picking",pickZ:m,shaderModuleProps:y}){this.pickZ=m;let _=this._resetColorEncoder(m),x=[a,c,l,u],E=super.render({target:o,layers:e,layerFilter:t,views:n,viewports:s,onViewportActive:i,cullRect:f,effects:h?.filter(S=>S.useInPicking),pass:d,isPicking:!0,shaderModuleProps:y,clearColor:[0,0,0,0],colorMask:15,scissorRect:x});return this._colorEncoderState=null,{decodePickingColor:_&&PA.bind(null,_),stats:E}}shouldDrawLayer(e){let{pickable:t,operation:n}=e.props;return t&&n.includes("draw")||n.includes("terrain")||n.includes("mask")}getShaderModuleProps(e,t,n){return{picking:{isActive:1,isAttribute:this.pickZ},lighting:{enabled:!1}}}getLayerParameters(e,t,n){let s={...e.props.parameters},{pickable:i,operation:o}=e.props;return this._colorEncoderState?i&&o.includes("draw")?(Object.assign(s,RA),s.blend=!0,s.blendColor=IA(this._colorEncoderState,e,n)):o.includes("terrain")&&(s.blend=!1):s.blend=!1,s}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function IA(r,e,t){let{byLayer:n,byAlpha:s}=r,i,o=n.get(e);return o?(o.viewports.push(t),i=o.a):(i=n.size+1,i<=255?(o={a:i,layer:e,viewports:[t]},n.set(e,o),s[i]=o):($.warn("Too many pickable layers, only picking the first 255")(),i=0)),[0,0,0,i/255]}function PA(r,e){let t=r.byAlpha[e[3]];return t&&{pickedLayer:t.layer,pickedViewports:t.viewports,pickedObjectIndex:t.layer.decodePickingColor(e)}}var kr={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},_s=Symbol.for("component"),at=Symbol.for("propTypes"),Cc=Symbol.for("deprecatedProps"),ir=Symbol.for("asyncPropDefaults"),Dt=Symbol.for("asyncPropOriginal"),xt=Symbol.for("asyncPropResolved");function Nr(r,e=()=>!0){return Array.isArray(r)?iy(r,e,[]):e(r)?[r]:[]}function iy(r,e,t){let n=-1;for(;++n<r.length;){let s=r[n];Array.isArray(s)?iy(s,e,t):e(s)&&t.push(s)}return t}function Mc({target:r,source:e,start:t=0,count:n=1}){let s=e.length,i=n*s,o=0;for(let a=t;o<s;o++)r[a++]=e[o];for(;o<i;)o<i-o?(r.copyWithin(t+o,t,t+o),o*=2):(r.copyWithin(t+o,t,t+i-o),o=i);return r}function Hi(){let r;if(typeof window<"u"&&window.performance)r=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();r=e[0]*1e3+e[1]/1e6}else r=Date.now();return r}var _n=class{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=Hi(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Hi()-this._startTime),this._timerPending=!1,this._checkSampling(),this):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)}};var Dr=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(let e of Object.values(this.stats))e.reset();return this}forEach(e){for(let t of Object.values(this.stats))e(t)}getTable(){let e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(t=>this._getOrCreate(t))}_getOrCreate(e){let{name:t,type:n}=e,s=this.stats[t];return s||(e instanceof _n?s=e:s=new _n(t,n),this.stats[t]=s),s}};var Xi=class{constructor(e,t,n){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=n,this.setData(t)}subscribe(e){this._subscribers.add(e)}unsubscribe(e){this._subscribers.delete(e)}inUse(){return this._subscribers.size>0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;let n=++this._loadCount,s=e;typeof e=="string"&&(s=Er(e)),s instanceof Promise?(this.isLoaded=!1,this._loader=s.then(i=>{this._loadCount===n&&(this.isLoaded=!0,this._error=void 0,this._content=i)}).catch(i=>{this._loadCount===n&&(this.isLoaded=!0,this._error=i||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let i of this._subscribers)i.onChange(this.getData())}};var Yi=class{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:t,forceUpdate:n=!1,persistent:s=!0}){let i=this._resources[e];i?i.setData(t,n):(i=new Xi(e,t,this._context),this._resources[e]=i),i.persistent=s}remove(e){let t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let t=this._consumers[e];if(t){for(let n in t){let s=t[n],i=this._resources[s.resourceId];i&&i.unsubscribe(s)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:n,requestId:s="default"}){let{_resources:i,protocol:o}=this;e.startsWith(o)&&(e=e.replace(o,""),i[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=i[e];if(this._track(n,s,a,t),a)return a.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(let e in this._resources)this._resources[e].delete()}_track(e,t,n,s){let i=this._consumers,o=i[e]=i[e]||{},a=o[t],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),n&&(a?(a.onChange=s,a.resourceId=n.id):a={onChange:s,resourceId:n.id},o[t]=a,n.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let t=this._resources[e];!t.persistent&&!t.inUse()&&(t.delete(),delete this._resources[e])}}};var CA="layerManager.setLayers",MA="layerManager.activateViewport",yn=class{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{he(MA,this,a),a&&(this.context.viewport=a)};let{deck:n,stats:s,viewport:i,timeline:o}=t||{};this.layers=[],this.resourceManager=new Yi({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:n,shaderAssembler:Sc(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[Rh],renderPass:void 0,stats:s||new Dr({id:"deck.gl"}),viewport:i||new $e({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new Kr,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(let e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let n of this.layers){let s=n.getNeedsRedraw(e);t=t||s}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(n=>t.id.indexOf(n)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,t){he(CA,this,t,e),this._lastRenderedLayers=e;let n=Nr(e,Boolean);for(let s of n)s.context=this.context;this._updateLayers(this.layers,n)}updateLayers(){let e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){let{defaultShaderModules:t}=this.context;t.find(n=>n.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:t}=this.context,n=t.findIndex(s=>s.name===e.name);n>=0&&(t.splice(n,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,n){n.raiseError(t,`${e} of ${n}`)}_updateLayers(e,t){let n={};for(let o of e)n[o.id]?$.warn(`Multiple old layers with same id ${o.id}`)():n[o.id]=o;if(this._defaultShaderModulesChanged){for(let o of e)o.setNeedsUpdate(),o.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let s=[];this._updateSublayersRecursively(t,n,s),this._finalizeOldLayers(n);let i=!1;for(let o of s)if(o.hasUniformTransition()){i=`Uniform transition in ${o}`;break}this._needsUpdate=i,this.layers=s}_updateSublayersRecursively(e,t,n){for(let s of e){s.context=this.context;let i=t[s.id];i===null&&$.warn(`Multiple new layers with same id ${s.id}`)(),t[s.id]=null;let o=null;try{this._debug&&i!==s&&s.validateProps(),i?(this._transferLayerState(i,s),this._updateLayer(s)):this._initializeLayer(s),n.push(s),o=s.isComposite?s.getSubLayers():null}catch(a){this._handleError("matching",a,s)}o&&this._updateSublayersRecursively(o,t,n)}}_finalizeOldLayers(e){for(let t in e){let n=e[t];n&&this._finalizeLayer(n)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=kr.INITIALIZED}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=kr.MATCHED,t!==e&&(e.lifecycle=kr.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=kr.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=kr.FINALIZED}catch(t){this._handleError("finalization",t,e)}}};function le(r,e,t){if(r===e)return!0;if(!t||!r||!e)return!1;if(Array.isArray(r)){if(!Array.isArray(e)||r.length!==e.length)return!1;for(let n=0;n<r.length;n++)if(!le(r[n],e[n],t-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof r=="object"&&typeof e=="object"){let n=Object.keys(r),s=Object.keys(e);if(n.length!==s.length)return!1;for(let i of n)if(!e.hasOwnProperty(i)||!le(r[i],e[i],t-1))return!1;return!0}return!1}var qi=class{constructor(e){this.views=[],this.width=100,this.height=100,this.viewState={},this.controllers={},this.timeline=e.timeline,this._viewports=[],this._viewportMap={},this._isUpdating=!1,this._needsRedraw="First render",this._needsUpdate="Initialize",this._eventManager=e.eventManager,this._eventCallbacks={onViewStateChange:e.onViewStateChange,onInteractionStateChange:e.onInteractionStateChange},Object.seal(this),this.setProps(e)}finalize(){for(let e in this.controllers){let t=this.controllers[e];t&&t.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(let e in this.controllers){let t=this.controllers[e];t&&t.updateTransition()}}getViewports(e){return e?this._viewports.filter(t=>t.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){let t=typeof e=="string"?this.getView(e):e,n=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(n):n}getViewport(e){return this._viewportMap[e]}unproject(e,t){let n=this.getViewports(),s={x:e[0],y:e[1]};for(let i=n.length-1;i>=0;--i){let o=n[i];if(o.containsPixel(s)){let a=e.slice();return a[0]-=o.x,a[1]-=o.y,o.unproject(a,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){(e!==this.width||t!==this.height)&&(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Nr(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!le(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):$.warn("missing `viewState` or `initialViewState`")()}_createController(e,t){let n=t.type;return new n({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:i=>this.getView(e.id)?.makeViewport({viewState:i,width:this.width,height:this.height})})}_updateController(e,t,n,s){let i=e.controller;if(i&&n){let o={...t,...i,id:e.id,x:n.x,y:n.y,width:n.width,height:n.height};return(!s||s.constructor!==i.type)&&(s=this._createController(e,o)),s&&s.setProps(o),s}return null}_rebuildViewports(){let{views:e}=this,t=this.controllers;this._viewports=[],this.controllers={};let n=!1;for(let s=e.length;s--;){let i=e[s],o=this.getViewState(i),a=i.makeViewport({viewState:o,width:this.width,height:this.height}),c=t[i.id],l=Boolean(i.controller);l&&!c&&(n=!0),(n||!l)&&c&&(c.finalize(),c=null),this.controllers[i.id]=this._updateController(i,o,a,c),a&&this._viewports.unshift(a)}for(let s in t){let i=t[s];i&&!this.controllers[s]&&i.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length?!0:e.some((n,s)=>!e[s].equals(t[s]))}};var OA=/^(?:\d+\.?\d*|\.\d+)$/;function or(r){switch(typeof r){case"number":if(!Number.isFinite(r))throw new Error(`Could not parse position string ${r}`);return{type:"literal",value:r};case"string":try{let e=kA(r);return new Jh(e).parseExpression()}catch(e){let t=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${r}: ${t}`)}default:throw new Error(`Could not parse position string ${r}`)}}function Qh(r,e){switch(r.type){case"literal":return r.value;case"percentage":return Math.round(r.value*e);case"binary":let t=Qh(r.left,e),n=Qh(r.right,e);return r.operator==="+"?t+n:t-n;default:throw new Error("Unknown layout expression type")}}function ar(r,e){return Qh(r,e)}function kA(r){let e=[],t=0;for(;t<r.length;){let n=r[t];if(/\s/.test(n)){t++;continue}if(n==="+"||n==="-"||n==="("||n===")"||n==="%"){e.push({type:"symbol",value:n}),t++;continue}if(oy(n)||n==="."){let s=t,i=n===".";for(t++;t<r.length;){let a=r[t];if(oy(a)){t++;continue}if(a==="."&&!i){i=!0,t++;continue}break}let o=r.slice(s,t);if(!OA.test(o))throw new Error("Invalid number token");e.push({type:"number",value:parseFloat(o)});continue}if(ay(n)){let s=t;for(;t<r.length&&ay(r[t]);)t++;let i=r.slice(s,t).toLowerCase();e.push({type:"word",value:i});continue}throw new Error("Invalid token in position string")}return e}var Jh=class{constructor(e){this.index=0,this.tokens=e}parseExpression(){let e=this.parseBinaryExpression();if(this.index<this.tokens.length)throw new Error("Unexpected token at end of expression");return e}parseBinaryExpression(){let e=this.parseFactor(),t=this.peek();for(;NA(t);){this.index++;let n=this.parseFactor();e={type:"binary",operator:t.value,left:e,right:n},t=this.peek()}return e}parseFactor(){let e=this.peek();if(!e)throw new Error("Unexpected end of expression");if(e.type==="symbol"&&e.value==="+")return this.index++,this.parseFactor();if(e.type==="symbol"&&e.value==="-"){this.index++;let t=this.parseFactor();return{type:"binary",operator:"-",left:{type:"literal",value:0},right:t}}if(e.type==="symbol"&&e.value==="("){this.index++;let t=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return t}if(e.type==="word"&&e.value==="calc"){if(this.index++,!this.consumeSymbol("("))throw new Error("Missing opening parenthesis after calc");let t=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return t}if(e.type==="number"){this.index++;let t=e.value,n=this.peek();return n&&n.type==="symbol"&&n.value==="%"?(this.index++,{type:"percentage",value:t/100}):n&&n.type==="word"&&n.value==="px"?(this.index++,{type:"literal",value:t}):{type:"literal",value:t}}throw new Error("Unexpected token in expression")}consumeSymbol(e){let t=this.peek();return t&&t.type==="symbol"&&t.value===e?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}};function oy(r){return r>="0"&&r<="9"}function ay(r){return r>="a"&&r<="z"||r>="A"&&r<="Z"}function NA(r){return Boolean(r&&r.type==="symbol"&&(r.value==="+"||r.value==="-"))}var Ne=class{constructor(e){let{id:t,x:n=0,y:s=0,width:i="100%",height:o="100%",padding:a=null}=e;this.id=t||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=or(n),this._y=or(s),this._width=or(i),this._height=or(o),this._padding=a&&{left:or(a.left||0),right:or(a.right||0),top:or(a.top||0),bottom:or(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.constructor===e.constructor&&le(this.props,e.props,2)}clone(e){let t=this.constructor;return new t({...this.props,...e})}makeViewport({width:e,height:t,viewState:n}){n=this.filterViewState(n);let s=this.getDimensions({width:e,height:t});if(!s.height||!s.width)return null;let i=this.getViewportType(n);return new i({...n,...this.props,...s})}getViewStateId(){let{viewState:e}=this.props;return typeof e=="string"?e:e?.id||this.id}filterViewState(e){if(this.props.viewState&&typeof this.props.viewState=="object"){if(!this.props.viewState.id)return this.props.viewState;let t={...e};for(let n in this.props.viewState)n!=="id"&&(t[n]=this.props.viewState[n]);return t}return e}getDimensions({width:e,height:t}){let n={x:ar(this._x,e),y:ar(this._y,t),width:ar(this._width,e),height:ar(this._height,t)};return this._padding&&(n.padding={left:ar(this._padding.left,e),top:ar(this._padding.top,t),right:ar(this._padding.right,e),bottom:ar(this._padding.bottom,t)}),n}get controller(){let e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e=="function"?{type:e}:{type:this.ControllerType,...e}:null}};var bt=class{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(this._handle===null){let{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}};var cy=()=>{},Ki={BREAK:1,SNAP_TO_END:2,IGNORE:3},DA=r=>r,FA=Ki.BREAK,Zi=class{constructor(e){this._onTransitionUpdate=t=>{let{time:n,settings:{interpolator:s,startProps:i,endProps:o,duration:a,easing:c}}=t,l=c(n/a),u=s.interpolateProps(i,o,l);this.propsInTransition=this.getControllerState({...this.props,...u}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new bt(e.timeline),this.onViewStateChange=e.onViewStateChange||cy,this.onStateChange=e.onStateChange||cy}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1,n=this.props;if(this.props=e,!n||this._shouldIgnoreViewportChange(n,e))return!1;if(this._isTransitionEnabled(e)){let s=n;if(this.transition.inProgress){let{interruption:i,endProps:o}=this.transition.settings;s={...n,...i===Ki.SNAP_TO_END?o:this.propsInTransition||n}}this._triggerTransition(s,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:t,transitionInterpolator:n}=e;return(t>0||t==="auto")&&Boolean(n)}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,t){return this.transition.inProgress?this.transition.settings.interruption===Ki.IGNORE||this._isUpdateDueToCurrentTransition(t):this._isTransitionEnabled(t)?t.transitionInterpolator.arePropsEqual(e,t):!0}_triggerTransition(e,t){let n=this.getControllerState(e),s=this.getControllerState(t).shortestPathFrom(n),i=t.transitionInterpolator,o=i.getDuration?i.getDuration(e,t):t.transitionDuration;if(o===0)return;let a=i.initializeProps(e,s);this.propsInTransition={};let c={duration:o,easing:t.transitionEasing||DA,interpolator:i,interruption:t.transitionInterruption||FA,startProps:a.start,endProps:a.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}};function ie(r,e){if(!r)throw new Error(e||"deck.gl: assertion failed.")}var cr=class{constructor(e){let{compare:t,extract:n,required:s}=e;this._propsToCompare=t,this._propsToExtract=n||t,this._requiredProps=s}arePropsEqual(e,t){for(let n of this._propsToCompare)if(!(n in e)||!(n in t)||!He(e[n],t[n]))return!1;return!0}initializeProps(e,t){let n={},s={};for(let i of this._propsToExtract)(i in e||i in t)&&(n[i]=e[i],s[i]=t[i]);return this._checkRequiredProps(n),this._checkRequiredProps(s),{start:n,end:s}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{let n=e[t];ie(Number.isFinite(n)||Array.isArray(n),`${t} is required for transition`)})}};var Oc=Math.PI/180,ly=180/Math.PI,kc=6370972,ys=256;function BA(){let r=ys/kc,e=Math.PI/180*ys;return{unitsPerMeter:[r,r,r],unitsPerMeter2:[0,0,0],metersPerUnit:[1/r,1/r,1/r],unitsPerDegree:[e,e,r],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/e,1/e,1/r]}}var Nc=class extends $e{constructor(e={}){let{longitude:t=0,zoom:n=0,nearZMultiplier:s=.5,farZMultiplier:i=1,resolution:o=10}=e,{latitude:a=0,height:c,altitude:l=1.5,fovy:u}=e;a=Math.max(Math.min(a,ze),-ze),c=c||1,u?l=rr(u):u=tr(l);let f=Math.pow(2,n-xn(a)),h=e.nearZ??s,d=e.farZ??(l+ys*2*f/c)*i,m=new Q().lookAt({eye:[0,-l,0],up:[0,0,1]});m.rotateX(a*Oc),m.rotateZ(-t*Oc),m.scale(f/c),super({...e,height:c,viewMatrix:m,longitude:t,latitude:a,zoom:n,distanceScales:BA(),fovy:u,focalDistance:l,near:h,far:d}),this.scale=f,this.latitude=a,this.longitude=t,this.fovy=u,this.resolution=o}get projectionMode(){return Te.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){let t={targetZ:e.z||0},n=this.unproject([0,this.height/2],t),s=this.unproject([this.width/2,0],t),i=this.unproject([this.width,this.height/2],t),o=this.unproject([this.width/2,this.height],t);return i[0]<this.longitude&&(i[0]+=360),n[0]>this.longitude&&(n[0]-=360),[Math.min(n[0],i[0],s[0],o[0]),Math.min(n[1],i[1],s[1],o[1]),Math.max(n[0],i[0],s[0],o[0]),Math.max(n[1],i[1],s[1],o[1])]}unproject(e,{topLeft:t=!0,targetZ:n}={}){let[s,i,o]=e,a=t?i:this.height-i,{pixelUnprojectionMatrix:c}=this,l;if(Number.isFinite(o))l=ed(c,[s,a,o,1]);else{let d=ed(c,[s,a,-1,1]),m=ed(c,[s,a,1,1]),y=((n||0)/kc+1)*ys,_=Oe.sqrLen(Oe.sub([],d,m)),x=Oe.sqrLen(d),E=Oe.sqrLen(m),S=4*((4*x*E-(_-x-E)**2)/16)/_,C=Math.sqrt(x-S),P=Math.sqrt(Math.max(0,y*y-S)),B=(C-P)/Math.sqrt(_);l=Oe.lerp([],d,m,B)}let[u,f,h]=this.unprojectPosition(l);return Number.isFinite(o)?[u,f,h]:Number.isFinite(n)?[u,f,n]:[u,f]}projectPosition(e){let[t,n,s=0]=e,i=t*Oc,o=n*Oc,a=Math.cos(o),c=(s/kc+1)*ys;return[Math.sin(i)*a*c,-Math.cos(i)*a*c,Math.sin(o)*c]}unprojectPosition(e){let[t,n,s]=e,i=Oe.len(e),o=Math.asin(s/i),c=Math.atan2(t,-n)*ly,l=o*ly,u=(i/ys-1)*kc;return[c,l,u]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition([e,t,n],s,i){let a=.25/Math.pow(2,this.zoom-xn(this.latitude)),c=e+a*(i[0]-s[0]),l=t-a*(i[1]-s[1]);l=Math.max(Math.min(l,ze),-ze);let u={longitude:c,latitude:l,zoom:n-xn(t)};return u.zoom+=xn(u.latitude),u}};Nc.displayName="GlobeViewport";var xs=Nc;function xn(r){let e=Math.PI*Math.cos(r*Math.PI/180);return Math.log2(e)}function ed(r,e){let t=Ve.transformMat4([],e,r);return Ve.scale(t,t,1/t[3]),t}var LA=["longitude","latitude","zoom","bearing","pitch"],UA=["longitude","latitude","zoom"],Ae=class extends cr{constructor(e={}){let t=Array.isArray(e)?e:e.transitionProps,n=Array.isArray(e)?{}:e;n.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:LA,required:UA},super(n.transitionProps),this.opts=n}initializeProps(e,t){let n=super.initializeProps(e,t),{makeViewport:s,around:i}=this.opts;if(s&&i)if(s(e)instanceof xs)$.warn("around not supported in GlobeView")();else{let a=s(e),c=s(t),l=a.unproject(i);n.start.around=i,Object.assign(n.end,{around:c.project(l),aroundPosition:l,width:t.width,height:t.height})}return n}interpolateProps(e,t,n){let s={};for(let i of this._propsToExtract)s[i]=Qt(e[i]||0,t[i]||0,n);if(t.aroundPosition&&this.opts.makeViewport){let i=this.opts.makeViewport({...t,...s});Object.assign(s,i.panByPosition(t.aroundPosition,Qt(e.around,t.around,n)))}return s}};var lr={transitionDuration:0},VA=300,Dc=r=>1-(1-r)*(1-r),bs={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],KEYBOARD:["keydown"]},bn={},De=class{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new Zi({...e,getControllerState:t=>new this.ControllerState(t),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(let e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;let t=this._eventStartBlocked;switch(e.type){case"panstart":return t?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return t?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"multipanstart":return t?!1:this._onMultiPanStart(e);case"multipanmove":return this._onMultiPan(e);case"multipanend":return this._onMultiPanEnd(e);case"dblclick":return this._onDoubleClick(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){let{x:t,y:n}=this.props,{offsetCenter:s}=e;return[s.x-t,s.y-n]}isPointInBounds(e,t){let{width:n,height:s}=this.props;if(t&&t.handled)return!1;let i=e[0]>=0&&e[0]<=n&&e[1]>=0&&e[1]<=s;return i&&t&&t.stopPropagation(),i}isFunctionKeyPressed(e){let{srcEvent:t}=e;return Boolean(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:t}=e;this.inertia=Number.isFinite(t)?t:t===!0?VA:0;let{scrollZoom:n=!0,dragPan:s=!0,dragRotate:i=!0,doubleClickZoom:o=!0,touchZoom:a=!0,touchRotate:c=!1,keyboard:l=!0}=e,u=Boolean(this.onViewStateChange);this.toggleEvents(bs.WHEEL,u&&n),this.toggleEvents(bs.PAN,u),this.toggleEvents(bs.PINCH,u&&(a||c)),this.toggleEvents(bs.MULTI_PAN,u&&c),this.toggleEvents(bs.DOUBLE_CLICK,u&&o),this.toggleEvents(bs.KEYBOARD,u&&l),this.scrollZoom=n,this.dragPan=s,this.dragRotate=i,this.doubleClickZoom=o,this.touchZoom=a,this.touchRotate=c,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(n=>{this._events[n]!==t&&(this._events[n]=t,t?this.eventManager.on(n,this.handleEvent):this.eventManager.off(n,this.handleEvent))})}updateViewport(e,t=null,n={}){let s={...e.getViewportProps(),...t},i=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(n),i){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:s,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(n=!n);let s=this.controllerState[n?"panStart":"rotateStart"]({pos:t});return this._panMove=n,this.updateViewport(s,lr,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;let t=this.getCenter(e),n=this.controllerState.pan({pos:t});return this.updateViewport(n,lr,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:t}=this;if(this.dragPan&&t&&e.velocity){let n=this.getCenter(e),s=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],i=this.controllerState.pan({pos:s}).panEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:Dc},{isDragging:!1,isPanning:!0})}else{let n=this.controllerState.panEnd();this.updateViewport(n,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let t=this.getCenter(e),n=this.controllerState.rotate({pos:t});return this.updateViewport(n,lr,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){let n=this.getCenter(e),s=[n[0]+e.velocityX*t/2,n[1]+e.velocityY*t/2],i=this.controllerState.rotate({pos:s}).rotateEnd();this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:Dc},{isDragging:!1,isRotating:!0})}else{let n=this.controllerState.rotateEnd();this.updateViewport(n,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();let{speed:n=.01,smooth:s=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:i}=e,o=2/(1+Math.exp(-Math.abs(i*n)));i<0&&o!==0&&(o=1/o);let a=s?{...this._getTransitionProps({around:t}),transitionDuration:250}:lr,c=this.controllerState.zoom({pos:t,scale:o});return this.updateViewport(c,a,{isZooming:!0,isPanning:!0}),s||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.controllerState.rotateStart({pos:t});return this.updateViewport(n,lr,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate||!this.isDragging())return!1;let t=this.getCenter(e);t[0]-=e.deltaX;let n=this.controllerState.rotate({pos:t});return this.updateViewport(n,lr,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this;if(this.touchRotate&&t&&e.velocityY){let n=this.getCenter(e),s=[n[0],n[1]+=e.velocityY*t/2],i=this.controllerState.rotate({pos:s});this.updateViewport(i,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:Dc},{isDragging:!1,isRotating:!0}),this.blockEvents(t)}else{let n=this.controllerState.rotateEnd();this.updateViewport(n,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.controllerState.zoomStart({pos:t}).rotateStart({pos:t});return bn._startPinchRotation=e.rotation,bn._lastPinchEvent=e,this.updateViewport(n,lr,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){let{scale:n}=e,s=this.getCenter(e);t=t.zoom({pos:s,scale:n})}if(this.touchRotate){let{rotation:n}=e;t=t.rotate({deltaAngleX:bn._startPinchRotation-n})}return this.updateViewport(t,lr,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),bn._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:t}=this,{_lastPinchEvent:n}=bn;if(this.touchZoom&&t&&n&&e.scale!==n.scale){let s=this.getCenter(e),i=this.controllerState.rotateEnd(),o=Math.log2(e.scale),a=(o-Math.log2(n.scale))/(e.deltaTime-n.deltaTime),c=Math.pow(2,o+a*t/2);i=i.zoom({pos:s,scale:c}).zoomEnd(),this.updateViewport(i,{...this._getTransitionProps({around:s}),transitionDuration:t,transitionEasing:Dc},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{let s=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(s,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return bn._startPinchRotation=null,bn._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;let t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let n=this.isFunctionKeyPressed(e),s=this.controllerState.zoom({pos:t,scale:n?.5:2});return this.updateViewport(s,this._getTransitionProps({around:t}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let t=this.isFunctionKeyPressed(e),{zoomSpeed:n,moveSpeed:s,rotateSpeedX:i,rotateSpeedY:o}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(e.srcEvent.code){case"Minus":c=t?a.zoomOut(n).zoomOut(n):a.zoomOut(n),l.isZooming=!0;break;case"Equal":c=t?a.zoomIn(n).zoomIn(n):a.zoomIn(n),l.isZooming=!0;break;case"ArrowLeft":t?(c=a.rotateLeft(i),l.isRotating=!0):(c=a.moveLeft(s),l.isPanning=!0);break;case"ArrowRight":t?(c=a.rotateRight(i),l.isRotating=!0):(c=a.moveRight(s),l.isPanning=!0);break;case"ArrowUp":t?(c=a.rotateUp(o),l.isRotating=!0):(c=a.moveUp(s),l.isPanning=!0);break;case"ArrowDown":t?(c=a.rotateDown(o),l.isRotating=!0):(c=a.moveDown(s),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(e){let{transition:t}=this;return!t||!t.transitionInterpolator?lr:e?{...t,transitionInterpolator:new Ae({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t}};var ur=class{constructor(e,t){this._viewportProps=this.applyConstraints(e),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}};var uy=5,zA=1.2,Gi=class extends ur{constructor(e){let{width:t,height:n,latitude:s,longitude:i,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:u=[0,0,0],maxZoom:f=20,minZoom:h=0,maxPitch:d=60,minPitch:m=0,startPanLngLat:y,startZoomLngLat:_,startRotatePos:x,startBearing:E,startPitch:b,startZoom:S,normalize:C=!0}=e;ie(Number.isFinite(i)),ie(Number.isFinite(s)),ie(Number.isFinite(o)),super({width:t,height:n,latitude:s,longitude:i,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:f,minZoom:h,maxPitch:d,minPitch:m,normalize:C,position:u},{startPanLngLat:y,startZoomLngLat:_,startRotatePos:x,startBearing:E,startPitch:b,startZoom:S}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:t}){let n=this.getState().startPanLngLat||this._unproject(t);if(!n)return this;let i=this.makeViewport(this.getViewportProps()).panByPosition(n,e);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:n=0}){let{startRotatePos:s,startBearing:i,startPitch:o}=this.getState();if(!s||i===void 0||o===void 0)return this;let a;return e?a=this._getNewRotation(e,s,o,i):a={bearing:i+t,pitch:o+n},this._getUpdatedState(a)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:n}){let{startZoom:s,startZoomLngLat:i}=this.getState();if(i||(s=this.getViewportProps().zoom,i=this._unproject(t)||this._unproject(e)),!i)return this;let{maxZoom:o,minZoom:a}=this.getViewportProps(),c=s+Math.log2(n);c=ee(c,a,o);let l=this.makeViewport({...this.getViewportProps(),zoom:c});return this._getUpdatedState({zoom:c,...l.panByPosition(i,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){let t=e.getViewportProps(),n={...this.getViewportProps()},{bearing:s,longitude:i}=n;return Math.abs(s-t.bearing)>180&&(n.bearing=s<0?s+360:s-360),Math.abs(i-t.longitude)>180&&(n.longitude=i<0?i+360:i-360),n}applyConstraints(e){let{maxZoom:t,minZoom:n,zoom:s}=e;e.zoom=ee(s,n,t);let{maxPitch:i,minPitch:o,pitch:a}=e;e.pitch=ee(a,o,i);let{normalize:c=!0}=e;return c&&Object.assign(e,jh(e)),e}_zoomFromCenter(e){let{width:t,height:n}=this.getViewportProps();return this.zoom({pos:[t/2,n/2],scale:e})}_panFromCenter(e){let{width:t,height:n}=this.getViewportProps();return this.pan({startPos:[t/2,n/2],pos:[t/2+e[0],n/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_getNewRotation(e,t,n,s){let i=e[0]-t[0],o=e[1]-t[1],a=e[1],c=t[1],{width:l,height:u}=this.getViewportProps(),f=i/l,h=0;o>0?Math.abs(u-c)>uy&&(h=o/(c-u)*zA):o<0&&c>uy&&(h=1-a/c),h=ee(h,-1,1);let{minPitch:d,maxPitch:m}=this.getViewportProps(),y=s+180*f,_=n;return h>0?_=n+h*(m-n):h<0&&(_=n-h*(d-n)),{pitch:_,bearing:y}}},Tn=class extends De{constructor(){super(...arguments),this.ControllerState=Gi,this.transition={transitionDuration:300,transitionInterpolator:new Ae({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(e){e.position=e.position||[0,0,0];let t=this.props;super.setProps(e),(!t||t.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}};var Fc=class extends Ne{constructor(e={}){super(e)}getViewportType(){return Or}get ControllerType(){return Tn}};Fc.displayName="MapView";var Bc=Fc;var WA=new Mr;function $A(r,e){let t=r.order??1/0,n=e.order??1/0;return t-n}var Qi=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let t=this._defaultEffects;if(!t.find(n=>n.id===e.id)){let n=t.findIndex(s=>$A(s,e)>0);n<0?t.push(e):t.splice(n,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(le(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){let t={};for(let s of this.effects)t[s.id]=s;let n=[];for(let s of e){let i=t[s.id],o=s;i&&i!==s?i.setProps?(i.setProps(s.props),o=i):i.cleanup(this._context):i||s.setup(this._context),n.push(o),delete t[s.id]}for(let s in t)t[s].cleanup(this._context);this.effects=n,this._resolvedEffects=n.concat(this._defaultEffects),e.some(s=>s instanceof Mr)||this._resolvedEffects.push(WA),this._needsRedraw="effects changed"}finalize(){for(let e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}};var Ji=class extends _t{shouldDrawLayer(e){let{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}};var jA="deckRenderer.renderLayers",wn=class{constructor(e){this.device=e,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Ji(e),this.pickLayersPass=new sr(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;let t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,n={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};n.effects&&this._preRender(n.effects,n);let s=this.lastPostProcessEffect?this.renderBuffers[0]:n.target;this.lastPostProcessEffect&&(n.clearColor=[0,0,0,0],n.clearCanvas=!0);let i=t.render({...n,target:s});n.effects&&(this.lastPostProcessEffect&&(n.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(n.effects,n)),this.renderCount++,he(jA,this,i,e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){let{renderBuffers:e}=this;for(let t of e)t.delete();e.length=0}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(let n of e)t.preRenderStats[n.id]=n.preRender(t),n.postRender&&(this.lastPostProcessEffect=n.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,t=this.device.canvasContext.getDrawingBufferSize(),[n,s]=t;e.length===0&&[0,1].map(i=>{let o=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:n,height:s});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${i}`,colorAttachments:[o]}))});for(let i of e)i.resize(t)}_postRender(e,t){let{renderBuffers:n}=this,s={...t,inputBuffer:n[0],swapBuffer:n[1]};for(let i of e)if(i.postRender){s.target=i.id===this.lastPostProcessEffect?t.target:void 0;let o=i.postRender(s);s.inputBuffer=o,s.swapBuffer=o===n[0]?n[1]:n[0]}}};var HA={pickedColor:null,pickedObjectIndex:-1};function td({pickedColors:r,decodePickingColor:e,deviceX:t,deviceY:n,deviceRadius:s,deviceRect:i}){let{x:o,y:a,width:c,height:l}=i,u=s*s,f=-1,h=0;for(let d=0;d<l;d++){let m=d+a-n,y=m*m;if(y>u)h+=4*c;else for(let _=0;_<c;_++){if(r[h+3]-1>=0){let E=_+o-t,b=E*E+y;b<=u&&(u=b,f=h)}h+=4}}if(f>=0){let d=r.slice(f,f+4),m=e(d);if(m){let y=Math.floor(f/4/c),_=f/4-y*c;return{...m,pickedColor:d,pickedX:o+_,pickedY:a+y}}$.error("Picked non-existent layer. Is picking buffer corrupt?")()}return HA}function rd({pickedColors:r,decodePickingColor:e}){let t=new Map;if(r){for(let n=0;n<r.length;n+=4)if(r[n+3]-1>=0){let i=r.slice(n,n+4),o=i.join(",");if(!t.has(o)){let a=e(i);a?t.set(o,{...a,color:i}):$.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(t.values())}function Lc({pickInfo:r,viewports:e,pixelRatio:t,x:n,y:s,z:i}){let o=e[0];e.length>1&&(o=XA(r?.pickedViewports||e,{x:n,y:s}));let a;if(o){let c=[n-o.x,s-o.y];i!==void 0&&(c[2]=i),a=o.unproject(c)}return{color:null,layer:null,viewport:o,index:-1,picked:!1,x:n,y:s,pixel:[n,s],coordinate:a,devicePixel:r&&"pickedX"in r?[r.pickedX,r.pickedY]:void 0,pixelRatio:t}}function nd(r){let{pickInfo:e,lastPickedInfo:t,mode:n,layers:s}=r,{pickedColor:i,pickedLayer:o,pickedObjectIndex:a}=e,c=o?[o]:[];if(n==="hover"){let f=t.index,h=t.layerId,d=o?o.props.id:null;if(d!==h||a!==f){if(d!==h){let m=s.find(y=>y.props.id===h);m&&c.unshift(m)}t.layerId=d,t.index=a,t.info=null}}let l=Lc(r),u=new Map;return u.set(null,l),c.forEach(f=>{let h={...l};f===o&&(h.color=i,h.index=a,h.picked=!0),h=Uc({layer:f,info:h,mode:n});let d=h.layer;f===o&&n==="hover"&&(t.info=h),u.set(d.id,h),n==="hover"&&d.updateAutoHighlight(h)}),u}function Uc({layer:r,info:e,mode:t}){for(;r&&e;){let n=e.layer||null;e.sourceLayer=n,e.layer=r,e=r.getPickingInfo({info:e,mode:t,sourceLayer:n}),r=r.parent}return e}function XA(r,e){for(let t=r.length-1;t>=0;t--){let n=r[t];if(n.containsPixel(e))return n}return r[0]}var eo=class{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new sr(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObjectAsync(e){return this._pickClosestObjectAsync(e)}pickObjectsAsync(e){return this._pickVisibleObjectsAsync(e)}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:n,viewports:s},i=this.lastPickedInfo.info){let o=i&&i.layer&&i.layer.id,a=i&&i.viewport&&i.viewport.id,c=o?n.find(h=>h.id===o):null,l=a&&s.find(h=>h.id===a)||s[0],u=l&&l.unproject([e-l.x,t-l.y]);return{...i,...{x:e,y:t,viewport:l,coordinate:u,layer:c}}}_resizeBuffer(){if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){let t=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=t}let{canvas:e}=this.device.getDefaultCanvasContext();this.pickingFBO?.resize({width:e.width,height:e.height}),this.depthFBO?.resize({width:e.width,height:e.height})}_getPickable(e){if(this._pickable===!1)return null;let t=e.filter(n=>this.pickLayersPass.shouldDrawLayer(n)&&!n.isComposite);return t.length?t:null}async _pickClosestObjectAsync({layers:e,views:t,viewports:n,x:s,y:i,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:u,effects:f}){let h=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||n.length===0)return{result:[],emptyInfo:Lc({viewports:n,x:s,y:i,pixelRatio:h})};this._resizeBuffer();let m=this.device.canvasContext.cssToDevicePixels([s,i],!0),y=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],_=Math.round(o*h),{width:x,height:E}=this.pickingFBO,b=this._getPickingRect({deviceX:y[0],deviceY:y[1],deviceRadius:_,deviceWidth:x,deviceHeight:E}),S={x:s-o,y:i-o,width:o*2+1,height:o*2+1},C,P=[],B=new Set;for(let N=0;N<a;N++){let k;if(b){let U=this._drawAndSample({layers:d,views:t,viewports:n,onViewportActive:u,deviceRect:b,cullRect:S,effects:f,pass:`picking:${c}`});k=td({...U,deviceX:y[0],deviceY:y[1],deviceRadius:_,deviceRect:b})}else k={pickedColor:null,pickedObjectIndex:-1};let F;if(k.pickedLayer&&l&&this.depthFBO){let{pickedColors:U}=this._drawAndSample({layers:[k.pickedLayer],views:t,viewports:n,onViewportActive:u,deviceRect:{x:k.pickedX,y:k.pickedY,width:1,height:1},cullRect:S,effects:f,pass:`picking:${c}:z`},!0);U[3]&&(F=U[0])}k.pickedLayer&&N+1<a&&(B.add(k.pickedLayer),k.pickedLayer.disablePickingIndex(k.pickedObjectIndex)),C=nd({pickInfo:k,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:n,x:s,y:i,z:F,pixelRatio:h});for(let U of C.values())U.layer&&P.push(U);if(!k.pickedColor)break}for(let N of B)N.restorePickingColors();return{result:P,emptyInfo:C.get(null)}}_pickClosestObject({layers:e,views:t,viewports:n,x:s,y:i,radius:o=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:u,effects:f}){let h=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||n.length===0)return{result:[],emptyInfo:Lc({viewports:n,x:s,y:i,pixelRatio:h})};this._resizeBuffer();let m=this.device.canvasContext.cssToDevicePixels([s,i],!0),y=[m.x+Math.floor(m.width/2),m.y+Math.floor(m.height/2)],_=Math.round(o*h),{width:x,height:E}=this.pickingFBO,b=this._getPickingRect({deviceX:y[0],deviceY:y[1],deviceRadius:_,deviceWidth:x,deviceHeight:E}),S={x:s-o,y:i-o,width:o*2+1,height:o*2+1},C,P=[],B=new Set;for(let N=0;N<a;N++){let k;if(b){let U=this._drawAndSample({layers:d,views:t,viewports:n,onViewportActive:u,deviceRect:b,cullRect:S,effects:f,pass:`picking:${c}`});k=td({...U,deviceX:y[0],deviceY:y[1],deviceRadius:_,deviceRect:b})}else k={pickedColor:null,pickedObjectIndex:-1};let F;if(k.pickedLayer&&l&&this.depthFBO){let{pickedColors:U}=this._drawAndSample({layers:[k.pickedLayer],views:t,viewports:n,onViewportActive:u,deviceRect:{x:k.pickedX,y:k.pickedY,width:1,height:1},cullRect:S,effects:f,pass:`picking:${c}:z`},!0);U[3]&&(F=U[0])}k.pickedLayer&&N+1<a&&(B.add(k.pickedLayer),k.pickedLayer.disablePickingIndex(k.pickedObjectIndex)),C=nd({pickInfo:k,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:n,x:s,y:i,z:F,pixelRatio:h});for(let U of C.values())U.layer&&P.push(U);if(!k.pickedColor)break}for(let N of B)N.restorePickingColors();return{result:P,emptyInfo:C.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:t,viewports:n,x:s,y:i,width:o=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:u,effects:f}){let h=this._getPickable(e);if(!h||n.length===0)return[];this._resizeBuffer();let d=this.device.canvasContext.cssToDeviceRatio(),m=this.device.canvasContext.cssToDevicePixels([s,i],!0),y=m.x,_=m.y+m.height,x=this.device.canvasContext.cssToDevicePixels([s+o,i+a],!0),E=x.x+x.width,b=x.y,S={x:y,y:b,width:E-y,height:_-b},C=this._drawAndSample({layers:h,views:t,viewports:n,onViewportActive:u,deviceRect:S,cullRect:{x:s,y:i,width:o,height:a},effects:f,pass:`picking:${c}`}),P=rd(C),B=new Map,N=[],k=Number.isFinite(l);for(let F=0;F<P.length&&!(k&&N.length>=l);F++){let U=P[F],X={color:U.pickedColor,layer:null,index:U.pickedObjectIndex,picked:!0,x:s,y:i,pixelRatio:d};X=Uc({layer:U.pickedLayer,info:X,mode:c});let J=X.layer.id;B.has(J)||B.set(J,new Set);let q=B.get(J),pe=X.object??X.index;q.has(pe)||(q.add(pe),N.push(X))}return N}_pickVisibleObjects({layers:e,views:t,viewports:n,x:s,y:i,width:o=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:u,effects:f}){let h=this._getPickable(e);if(!h||n.length===0)return[];this._resizeBuffer();let d=this.device.canvasContext.cssToDeviceRatio(),m=this.device.canvasContext.cssToDevicePixels([s,i],!0),y=m.x,_=m.y+m.height,x=this.device.canvasContext.cssToDevicePixels([s+o,i+a],!0),E=x.x+x.width,b=x.y,S={x:y,y:b,width:E-y,height:_-b},C=this._drawAndSample({layers:h,views:t,viewports:n,onViewportActive:u,deviceRect:S,cullRect:{x:s,y:i,width:o,height:a},effects:f,pass:`picking:${c}`}),P=rd(C),B=new Map,N=[],k=Number.isFinite(l);for(let F=0;F<P.length&&!(k&&N.length>=l);F++){let U=P[F],X={color:U.pickedColor,layer:null,index:U.pickedObjectIndex,picked:!0,x:s,y:i,pixelRatio:d};X=Uc({layer:U.pickedLayer,info:X,mode:c});let J=X.layer.id;B.has(J)||B.set(J,new Set);let q=B.get(J),pe=X.object??X.index;q.has(pe)||(q.add(pe),N.push(X))}return N}async _drawAndSampleAsync({layers:e,views:t,viewports:n,onViewportActive:s,deviceRect:i,cullRect:o,effects:a,pass:c},l=!1){let u=l?this.depthFBO:this.pickingFBO,f={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:s,pickingFBO:u,deviceRect:i,cullRect:o,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let E of a)E.useInPicking&&(f.preRenderStats[E.id]=E.preRender(f));let{decodePickingColor:h}=this.pickLayersPass.render(f),{x:d,y:m,width:y,height:_}=i,x=new(l?Float32Array:Uint8Array)(y*_*4);return this.device.readPixelsToArrayWebGL(u,{sourceX:d,sourceY:m,sourceWidth:y,sourceHeight:_,target:x}),{pickedColors:x,decodePickingColor:h}}_drawAndSample({layers:e,views:t,viewports:n,onViewportActive:s,deviceRect:i,cullRect:o,effects:a,pass:c},l=!1){let u=l?this.depthFBO:this.pickingFBO,f={layers:e,layerFilter:this.layerFilter,views:t,viewports:n,onViewportActive:s,pickingFBO:u,deviceRect:i,cullRect:o,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let E of a)E.useInPicking&&(f.preRenderStats[E.id]=E.preRender(f));let{decodePickingColor:h}=this.pickLayersPass.render(f),{x:d,y:m,width:y,height:_}=i,x=new(l?Float32Array:Uint8Array)(y*_*4);return this.device.readPixelsToArrayWebGL(u,{sourceX:d,sourceY:m,sourceWidth:y,sourceHeight:_,target:x}),{pickedColors:x,decodePickingColor:h}}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:n,deviceWidth:s,deviceHeight:i}){let o=Math.max(0,e-n),a=Math.max(0,t-n),c=Math.min(s,e+n+1)-o,l=Math.min(i,t+n+1)-a;return c<=0||l<=0?null:{x:o,y:a,width:c,height:l}}};var YA={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},qA="top-left",fy="root",Vc=class{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,t?.classList.add("deck-widget-container"),this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!le(e.widgets,this.widgets,1)){let t=e.widgets.filter(Boolean);this._setWidgets(t)}}finalize(){for(let e of this.getWidgets())this._removeWidget(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(let e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:t}){let n=e.reduce((s,i)=>(s[i.id]=i,s),{});for(let s of this.getWidgets()){let{viewId:i}=s;if(i){let o=n[i];o&&(s.onViewportChange&&s.onViewportChange(o),s.onRedraw?.({viewports:[o],layers:t}))}else{if(s.onViewportChange)for(let o of e)s.onViewportChange(o);s.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=n,this._updateContainers()}onHover(e,t){for(let n of this.getWidgets()){let{viewId:s}=n;(!s||s===e.viewport?.id)&&n.onHover?.(e,t)}}onEvent(e,t){let n=ki[t.type];if(n)for(let s of this.getWidgets()){let{viewId:i}=s;(!i||i===e.viewport?.id)&&s[n]?.(e,t)}}_setWidgets(e){let t={};for(let n of this.resolvedWidgets)t[n.id]=n;this.resolvedWidgets.length=0;for(let n of this.defaultWidgets)t[n.id]=null,this.resolvedWidgets.push(n);for(let n of e){let s=t[n.id];s?s.viewId!==n.viewId||s.placement!==n.placement?(this._removeWidget(s),this._addWidget(n)):n!==s&&(s.setProps(n.props),n=s):this._addWidget(n),t[n.id]=null,this.resolvedWidgets.push(n)}for(let n in t){let s=t[n];s&&this._removeWidget(s)}this.widgets=e}_addWidget(e){let{viewId:t=null,placement:n=qA}=e,s=e.props._container??t;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:t}),e.rootElement&&this._getContainer(s,n).append(e.rootElement),e.updateHTML()}_removeWidget(e){e.onRemove?.(),e.rootElement&&e.rootElement.remove(),e.rootElement=void 0,e.deck=void 0,e.widgetManager=void 0}_getContainer(e,t){if(e&&typeof e!="string")return e;let n=e||fy,s=this.containers[n];s||(s=document.createElement("div"),s.style.pointerEvents="none",s.style.position="absolute",s.style.overflow="hidden",this.parentElement?.append(s),this.containers[n]=s);let i=s.querySelector(`.${t}`);return i||(i=globalThis.document.createElement("div"),i.className=t,i.style.position="absolute",i.style.zIndex="2",Object.assign(i.style,YA[t]),s.append(i)),i}_updateContainers(){let e=this.deck.width,t=this.deck.height;for(let n in this.containers){let s=this.lastViewports[n]||null,i=n===fy||s,o=this.containers[n];i?(o.style.display="block",o.style.left=`${s?s.x:0}px`,o.style.top=`${s?s.y:0}px`,o.style.width=`${s?s.width:e}px`,o.style.height=`${s?s.height:t}px`):o.style.display="none"}}};function to(r,e){e&&Object.entries(e).map(([t,n])=>{t.startsWith("--")?r.style.setProperty(t,n):r.style[t]=n})}function zc(r,e){e&&Object.keys(e).map(t=>{t.startsWith("--")?r.style.removeProperty(t):r.style[t]=""})}var Fr=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let t=this.props,n=this.rootElement;n&&t.className!==e.className&&(t.className&&n.classList.remove(t.className),e.className&&n.classList.add(e.className)),n&&!le(t.style,e.style,1)&&(zc(n,t.style),to(n,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}onCreateRootElement(){let e=["deck-widget",this.className,this.props.className],t=document.createElement("div");return e.filter(n=>typeof n=="string"&&n.length>0).forEach(n=>t.classList.add(n)),to(t,this.props.style),t}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,t){}onClick(e,t){}onDrag(e,t){}onDragStart(e,t){}onDragEnd(e,t){}};Fr.defaultProps={id:"widget",style:{},_container:null,className:""};var KA={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},ro=class extends Fr{constructor(e={}){super(e),this.id="default-tooltip",this.placement="fill",this.className="deck-tooltip",this.isVisible=!1,this.setProps(e)}onCreateRootElement(){let e=document.createElement("div");return e.className=this.className,Object.assign(e.style,KA),e}onRenderHTML(e){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&!e.equals(this.lastViewport)&&this.setTooltip(null),this.lastViewport=e}onHover(e){let{deck:t}=this,n=t&&t.props.getTooltip;if(!n)return;let s=n(e);this.setTooltip(s,e.x,e.y)}setTooltip(e,t,n){let s=this.rootElement;if(s){if(typeof e=="string")s.innerText=e;else if(e)e.text&&(s.innerText=e.text),e.html&&(s.innerHTML=e.html),e.className&&(s.className=e.className);else{this.isVisible=!1,s.style.display="none";return}this.isVisible=!0,s.style.display="block",s.style.transform=`translate(${t}px, ${n}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(s.style,e.style)}}};ro.defaultProps={...Fr.defaultProps};H();fl();function Ur(){}var eE=({isDragging:r})=>r?"grabbing":"grab",Dx={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{},gl:null,canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:Ur,onWebGLInitialized:Ur,onResize:Ur,onViewStateChange:Ur,onInteractionStateChange:Ur,onBeforeRender:Ur,onAfterRender:Ur,onLoad:Ur,onError:r=>$.error(r.message,r.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:eE,getTooltip:null,debug:!1,drawPickingColors:!1},uo=class{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Dr({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._onPointerMove=n=>{let{_pickRequest:s}=this;if(n.type==="pointerleave")s.x=-1,s.y=-1,s.radius=0;else{if(n.leftButton||n.rightButton)return;{let i=n.offsetCenter;if(!i)return;s.x=i.x,s.y=i.y,s.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:s.x,y:s.y}),s.event=n},this._onEvent=n=>{let s=ki[n.type],i=n.offsetCenter;if(!s||!i||!this.layerManager)return;let o,a=this.layerManager.getLayers(),c=a.some(d=>d.props.pickable==="3d");if(n.type==="click"&&c){let d=this._pick("pickObject","pickObject Time",{x:i.x,y:i.y,radius:this.props.pickingRadius,unproject3D:!0});o=d.result[0]||d.emptyInfo}else o=this.deckPicker.getLastPickedObject({x:i.x,y:i.y,layers:a,viewports:this.getViewports(i)},this._lastPointerDownInfo);let{layer:l}=o,u=l&&(l[s]||l.props[s]),f=this.props[s],h=!1;u&&(h=u.call(l,o,n)),h||(f?.(o,n),this.widgetManager.onEvent(o,n))},this._onPointerDown=n=>{if(this.device?.type==="webgpu")return;let s=n.offsetCenter,i=this._pick("pickObject","pickObject Time",{x:s.x,y:s.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=i.result[0]||i.emptyInfo},this.props={...Dx,...e},e=this.props,e.viewState&&e.initialViewState&&$.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device&&(this.device=e.device);let t=this.device;if(!t&&e.gl){e.gl instanceof WebGLRenderingContext&&$.error("WebGL1 context not supported.")();let n=this.props.deviceProps?.onResize;t=lo.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps,onResize:(s,i)=>{let{width:o,height:a}=s.canvas;s.drawingBufferWidth=o,s.drawingBufferHeight=a,this._needsRedraw="Canvas resized",n?.(s,i)}})}t||(t=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(t,e),this.setProps(e),e._typedArrayManagerProps&&yt.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._lastPointerDownInfo=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,!this.props.canvas&&!this.props.device&&!this.props.gl&&this.canvas&&(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&$.removed("onLayerHover","onHover")(),"onLayerClick"in e&&$.removed("onLayerClick","onClick")(),e.initialViewState&&!le(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._setCanvasSize(this.props);let t=Object.create(this.props);Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),e.device&&e.device.id!==this.device?.id&&(this.animationLoop?.stop(),this.canvas!==e.device.canvasContext?.canvas&&(this.canvas?.remove(),this.eventManager?.destroy(),this.canvas=null),$.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()),this.animationLoop?.setProps(t),e.useDevicePixels!==void 0&&this.device?.canvasContext?.setProps&&this.device.canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t),this.widgetManager.setProps(t)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let n=this.viewManager.needsRedraw(e),s=this.layerManager.needsRedraw(e),i=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return t=t||n||s||i||o,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return this.viewManager!==null}getViews(){return ie(this.viewManager),this.viewManager.views}getView(e){return ie(this.viewManager),this.viewManager.getView(e)}getViewports(e){return ie(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}pickObject(e){let t=this._pick("pickObject","pickObject Time",e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_addResources(e,t=!1){for(let n in e)this.layerManager.resourceManager.add({resourceId:n,data:e[n],forceUpdate:t})}_removeResources(e){for(let t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_pick(e,t,n){ie(this.deckPicker);let{stats:s}=this;s.get("Pick Count").incrementCount(),s.get(t).timeStart();let i=this.deckPicker[e]({layers:this.layerManager.getLayers(n),views:this.viewManager.getViews(),viewports:this.getViewports(n),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...n});return s.get(t).timeEnd(),i}_createCanvas(e){let t=e.canvas;return typeof t=="string"&&(t=document.getElementById(t),ie(t)),t||(t=document.createElement("canvas"),t.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(t.width=e.width),e.height&&typeof e.height=="number"&&(t.height=e.height),(e.parent||document.body).appendChild(t)),Object.assign(t.style,e.style),t}_setCanvasSize(e){if(!this.canvas)return;let{width:t,height:n}=e;if(t||t===0){let s=Number.isFinite(t)?`${t}px`:t;this.canvas.style.width=s}if(n||n===0){let s=Number.isFinite(n)?`${n}px`:n;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=s}}_updateCanvasSize(){let{canvas:e}=this;if(!e)return;let t=e.clientWidth??e.width,n=e.clientHeight??e.height;(t!==this.width||n!==this.height)&&(this.width=t,this.height=n,this.viewManager?.setProps({width:t,height:n}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:t,height:n}))}_createAnimationLoop(e,t){let{gl:n,onError:s}=t;return new $n({device:e,autoResizeDrawingBuffer:!n,autoResizeViewport:!1,onInitialize:i=>this._setDevice(i.device),onRender:this._onRenderFrame.bind(this),onError:s})}_createDevice(e){let t=this.props.deviceProps?.createCanvasContext,n=typeof t=="object"?t:void 0,s={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};s.adapters.includes(lo)||s.adapters.push(lo);let i={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0},o=this.props.deviceProps?.onResize;return pr.createDevice({_reuseDevices:!0,type:"webgl",...s,createCanvasContext:{...i,...n,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0},onResize:(a,c)=>{this._needsRedraw="Canvas resized",o?.(a,c)}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new Bc({id:"default-view"})];return t.length&&this.props.controller&&(t[0].props.controller=this.props.controller),t}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){if(this.device?.type==="webgpu")return;let{_pickRequest:e}=this;if(e.event){let n=(this.layerManager?.getLayers()||[]).some(c=>c.props.pickable==="3d");e.unproject3D=n;let{result:s,emptyInfo:i}=this._pick("pickObject","pickObject Time",e);this.cursorState.isHovering=s.length>0;let o=i,a=!1;for(let c of s)o=c,a=c.layer?.onHover(c,e.event)||a;a||(this.props.onHover?.(o,e.event),this.widgetManager.onHover(o,e.event)),e.event=null}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,!this.animationLoop)return;this.canvas||(this.canvas=this.device.canvasContext?.canvas,!this.canvas.isConnected&&this.props.parent&&this.props.parent.insertBefore(this.canvas,this.props.parent.firstChild)),this.device.type==="webgl"&&this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device.type==="webgl"&&this.props.onWebGLInitialized(this.device.gl);let t=new Kr;t.play(),this.animationLoop.attachTimeline(t),this.eventManager=new Oi(this.props.parent||this.canvas,{touchAction:this.props.touchAction,recognizers:Object.keys(Bh).map(s=>{let[i,o,a,c]=Bh[s],l=this.props.eventRecognizerOptions?.[s],u={...o,...l,event:s};return{recognizer:new i(u),recognizeWith:a,requestFailure:c}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let s in ki)this.eventManager.on(s,this._onEvent);this.viewManager=new qi({timeline:t,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let n=this.viewManager.getViewports()[0];this.layerManager=new yn(this.device,{deck:this,stats:this.stats,viewport:n,timeline:t}),this.effectManager=new Qi({deck:this,device:this.device}),this.deckRenderer=new wn(this.device),this.deckPicker=new eo(this.device),this.widgetManager=new Vc({deck:this,parentElement:this.canvas?.parentElement}),this.widgetManager.addDefault(new ro),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,t){let{device:n,gl:s}=this.layerManager.context;this.props.onBeforeRender({device:n,gl:s});let i={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...t};this.deckRenderer?.renderLayers(i),i.pass==="screen"&&this.widgetManager.onRedraw({viewports:i.viewports,layers:i.layers}),this.props.onAfterRender({device:n,gl:s})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),$.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this.device?.type!=="webgpu"&&this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){let{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();let t=this.animationLoop.stats;e.get("GPU Time").addTime(t.get("GPU Time").lastTiming),e.get("CPU Time").addTime(t.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:t}=this;e.fps=t.get("frameRate").getHz(),e.setPropsTime=t.get("setProps Time").time,e.updateAttributesTime=t.get("Update Attributes").time,e.framesRedrawn=t.get("Redraw Count").count,e.pickTime=t.get("pickObject Time").time+t.get("pickMultipleObjects Time").time+t.get("pickObjects Time").time,e.pickCount=t.get("Pick Count").count,e.gpuTime=t.get("GPU Time").time,e.cpuTime=t.get("CPU Time").time,e.gpuTimePerFrame=t.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=t.get("CPU Time").getAverageTime();let n=pr.stats.get("Memory Usage");e.bufferMemory=n.get("Buffer Memory").count,e.textureMemory=n.get("Texture Memory").count,e.renderbufferMemory=n.get("Renderbuffer Memory").count,e.gpuMemory=n.get("GPU Memory").count}};uo.defaultProps=Dx;uo.VERSION=oc;var ml=uo;H();H();function Fx(r){switch(r){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Hr(r)}}var Bx=jr;function fo(r,e,t){let n=t==="webgpu"&&e.type==="uint8"?"unorm8":e.type;return{attribute:r,format:e.size>1?`${n}x${e.size}`:e.type,byteOffset:e.offset||0}}function Vr(r){return r.stride||r.size*r.bytesPerElement}function Lx(r,e){return r.type===e.type&&r.size===e.size&&Vr(r)===Vr(e)&&(r.offset||0)===(e.offset||0)}function Ed(r,e){e.offset&&$.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let t=Vr(r),n=e.vertexOffset!==void 0?e.vertexOffset:r.vertexOffset||0,s=e.elementOffset||0,i=n*t+s*r.bytesPerElement+(r.offset||0);return{...e,offset:i,stride:t}}function tE(r,e){let t=Ed(r,e);return{high:t,low:{...t,offset:t.offset+r.size*4}}}var ho=class{constructor(e,t,n){this._buffer=null,this.device=e,this.id=t.id||"",this.size=t.size||1;let s=t.logicalType||t.type,i=s==="float64",{defaultValue:o}=t;o=Number.isFinite(o)?[o]:o||new Array(this.size).fill(0);let a;i?a="float32":!s&&t.isIndexed?a="uint32":a=s||"float32";let c=Fx(s||a);this.doublePrecision=i,i&&t.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...t,defaultType:c,defaultValue:o,logicalType:s,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...n,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){let e=this.getAccessor();return e.vertexOffset?e.vertexOffset*Vr(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),yt.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){let n={};if(this.state.constant){let s=this.value;if(t){let i=Ed(this.getAccessor(),t),o=i.offset/s.BYTES_PER_ELEMENT,a=i.size||this.size;n[e]=s.subarray(o,o+a)}else n[e]=s}else n[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?n[`${e}64Low`]=n[e]:n[`${e}64Low`]=new Float32Array(this.size)),n}_getBufferLayout(e=this.id,t=null){let n=this.getAccessor(),s=[],i={name:this.id,byteStride:Vr(n),attributes:s};if(this.doublePrecision){let o=tE(n,t||{});s.push(fo(e,{...n,...o.high},this.device.type),fo(`${e}64Low`,{...n,...o.low},this.device.type))}else if(t){let o=Ed(n,t);s.push(fo(e,{...n,...o},this.device.type))}else s.push(fo(e,n,this.device.type));return i}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){let t=Array.from(this.value);e=[t,t]}else{let{value:t,numInstances:n,size:s}=this,i=n*s;if(t&&i&&t.length>=i){let o=new Array(s).fill(1/0),a=new Array(s).fill(-1/0);for(let c=0;c<i;)for(let l=0;l<s;l++){let u=t[c++];u<o[l]&&(o[l]=u),u>a[l]&&(a[l]=u)}e=[o,a]}}return this.state.bounds=e,e}setData(e){let{state:t}=this,n;ArrayBuffer.isView(e)?n={value:e}:e instanceof W?n={buffer:e}:n=e;let s={...this.settings,...n};if(ArrayBuffer.isView(n.value)){if(!n.type)if(this.doublePrecision&&n.value instanceof Float64Array)s.type="float32";else{let o=Bx(n.value);s.type=s.normalized?o.replace("int","norm"):o}s.bytesPerElement=n.value.BYTES_PER_ELEMENT,s.stride=Vr(s)}if(t.bounds=null,n.constant){let i=n.value;if(i=this._normalizeValue(i,[],0),this.settings.normalized&&(i=this.normalizeConstant(i)),!(!t.constant||!this._areValuesEqual(i,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(i)?i:new Float32Array(i)}else if(n.buffer){let i=n.buffer;t.externalBuffer=i,t.constant=!1,this.value=n.value||null}else if(n.value){this._checkExternalBuffer(n);let i=n.value;t.externalBuffer=null,t.constant=!1,this.value=i;let{buffer:o}=this,a=Vr(s),c=(s.vertexOffset||0)*a;if(this.doublePrecision&&i instanceof Float64Array&&(i=Ec(i,s)),this.settings.isIndexed){let u=this.settings.defaultType;i.constructor!==u&&(i=new u(i))}let l=i.byteLength+c+a*2;(!o||o.byteLength<l)&&(o=this._createBuffer(l)),o.write(i,c)}return this.setAccessor(s),!0}updateSubBuffer(e={}){this.state.bounds=null;let t=this.value,{startOffset:n=0,endOffset:s}=e;this.buffer.write(this.doublePrecision&&t instanceof Float64Array?Ec(t,{size:this.size,startIndex:n,endIndex:s}):t.subarray(n,s),n*t.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,t=!1){let{state:n}=this,s=n.allocatedValue,i=yt.allocate(s,e+1,{size:this.size,type:this.settings.defaultType,copy:t});this.value=i;let{byteOffset:o}=this,{buffer:a}=this;return(!a||a.byteLength<i.byteLength+o)&&(a=this._createBuffer(i.byteLength+o),t&&s&&a.write(s instanceof Float64Array?Ec(s,this):s,o)),n.allocatedValue=i,n.constant=!1,n.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){let{value:t}=e;if(!ArrayBuffer.isView(t))throw new Error(`Attribute ${this.id} value is not TypedArray`);let n=this.settings.defaultType,s=!1;if(this.doublePrecision&&(s=t.BYTES_PER_ELEMENT<4),s)throw new Error(`Attribute ${this.id} does not support ${t.constructor.name}`);!(t instanceof n)&&this.settings.normalized&&!("normalized"in e)&&$.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case"snorm8":return new Float32Array(e).map(t=>(t+128)/255*2-1);case"snorm16":return new Float32Array(e).map(t=>(t+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(t=>t/255);case"unorm16":return new Float32Array(e).map(t=>t/65535);default:return e}}_normalizeValue(e,t,n){let{defaultValue:s,size:i}=this.settings;if(Number.isFinite(e))return t[n]=e,t;if(!e){let o=i;for(;--o>=0;)t[n+o]=s[o];return t}switch(i){case 4:t[n+3]=Number.isFinite(e[3])?e[3]:s[3];case 3:t[n+2]=Number.isFinite(e[2])?e[2]:s[2];case 2:t[n+1]=Number.isFinite(e[1])?e[1]:s[1];case 1:t[n+0]=Number.isFinite(e[0])?e[0]:s[0];break;default:let o=i;for(;--o>=0;)t[n+o]=Number.isFinite(e[o])?e[o]:s[o]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;let{size:n}=this;for(let s=0;s<n;s++)if(e[s]!==t[s])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();let{isIndexed:t,type:n}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(t?W.INDEX:W.VERTEX)|W.COPY_DST,indexType:t?n:void 0,byteLength:e}),this._buffer}};var Ux=[],Vx=[];function Es(r,e=0,t=1/0){let n=Ux,s={index:-1,data:r,target:[]};return r?typeof r[Symbol.iterator]=="function"?n=r:r.length>0&&(Vx.length=r.length,n=Vx):n=Ux,(e>0||Number.isFinite(t))&&(n=(Array.isArray(n)?n:Array.from(n)).slice(e,t),s.index=e-1),{iterable:n,objectInfo:s}}function gl(r){return r&&r[Symbol.asyncIterator]}function _l(r,e){let{size:t,stride:n,offset:s,startIndices:i,nested:o}=e,a=r.BYTES_PER_ELEMENT,c=n?n/a:t,l=s?s/a:0,u=Math.floor((r.length-l)/c);return(f,{index:h,target:d})=>{if(!i){let x=h*c+l;for(let E=0;E<t;E++)d[E]=r[x+E];return d}let m=i[h],y=i[h+1]||u,_;if(o){_=new Array(y-m);for(let x=m;x<y;x++){let E=x*c+l;d=new Array(t);for(let b=0;b<t;b++)d[b]=r[E+b];_[x-m]=d}}else if(c===t)_=r.subarray(m*t+l,y*t+l);else{_=new r.constructor((y-m)*t);let x=0;for(let E=m;E<y;E++){let b=E*c+l;for(let S=0;S<t;S++)_[x++]=r[b+S]}}return _}}var zx=[],po=[[0,1/0]];function Wx(r,e){if(r===po||(e[0]<0&&(e[0]=0),e[0]>=e[1]))return r;let t=[],n=r.length,s=0;for(let i=0;i<n;i++){let o=r[i];o[1]<e[0]?(t.push(o),s=i+1):o[0]>e[1]?t.push(o):e=[Math.min(o[0],e[0]),Math.max(o[1],e[1])]}return t.splice(s,0,e),t}var nE={interpolation:{duration:0,easing:r=>r},spring:{stiffness:.05,damping:.5}};function yl(r,e){if(!r)return null;Number.isFinite(r)&&(r={type:"interpolation",duration:r});let t=r.type||"interpolation";return{...nE[t],...e,...r,type:t}}var fr=class extends ho{constructor(e,t){super(e,t,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:po}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){let t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t;(t=this.state).layoutChanged||(t.layoutChanged=!Lx(e,this.getAccessor())),super.setAccessor(e)}getUpdateTriggers(){let{accessor:e}=this.settings;return[this.id].concat(typeof e!="function"&&e||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;let{accessor:t}=this.settings,n=this.settings.transition,s=Array.isArray(t)?e[t.find(i=>e[i])]:e[t];return yl(s,n)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){let{startRow:n=0,endRow:s=1/0}=t;this.state.updateRanges=Wx(this.state.updateRanges,[n,s])}else this.state.updateRanges=po}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=zx}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:t,settings:n}=this;return n.noAlloc?!1:n.update?(super.allocate(e,t.updateRanges!==po),!0):!1}updateBuffer({numInstances:e,data:t,props:n,context:s}){if(!this.needsUpdate())return!1;let{state:{updateRanges:i},settings:{update:o,noAlloc:a}}=this,c=!0;if(o){for(let[l,u]of i)o.call(s,this,{data:t,startRow:l,endRow:u,props:n,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(let[l,u]of i){let f=Number.isFinite(l)?this.getVertexOffset(l):0,h=Number.isFinite(u)?this.getVertexOffset(u):a||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:f,endOffset:h})}this._checkAttributeArray()}else c=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),c}setConstantValue(e,t){let n=this.device.type==="webgpu";if(n||t===void 0||typeof t=="function"){if(n&&typeof t!="function"){let o=this._normalizeValue(t,[],0);this._areValuesEqual(o,this.value)||this.setNeedsUpdate("WebGPU constant updated")}return!1}let s=this.settings.transform&&e?this.settings.transform.call(e,t):t;return this.setData({constant:!0,value:s})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0}setExternalBuffer(e){let{state:t}=this;return e?(this.clearNeedsUpdate(),t.lastExternalBuffer===e||(t.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e)),!0):(t.lastExternalBuffer=null,!1)}setBinaryValue(e,t=null){let{state:n,settings:s}=this;if(!e)return n.binaryValue=null,n.binaryAccessor=null,!1;if(s.noAlloc)return!1;if(n.binaryValue===e)return this.clearNeedsUpdate(),!0;if(n.binaryValue=e,this.setNeedsRedraw(),s.transform||t!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});let o=e;ie(ArrayBuffer.isView(o.value),`invalid ${s.accessor}`);let a=Boolean(o.size)&&o.size!==this.size;return n.binaryAccessor=_l(o.value,{size:o.size||this.size,stride:o.stride,offset:o.offset,startIndices:t,nested:a}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){let{startIndices:t}=this;return(t?e<t.length?t[e]:this.numInstances:e)*this.size}getValue(){let e=this.settings.shaderAttributes,t=super.getValue();if(!e)return t;for(let n in e)Object.assign(t,super.getValue(n,e[n]));return t}getBufferLayout(e){this.state.layoutChanged=!1;let t=this.settings.shaderAttributes,n=super._getBufferLayout(),{stepMode:s}=this.settings;if(s==="dynamic"?n.stepMode=e?e.isInstanced?"instance":"vertex":"instance":n.stepMode=s??"vertex",!t)return n;for(let i in t){let o=super._getBufferLayout(i,t[i]);n.attributes.push(...o.attributes)}return n}_autoUpdater(e,{data:t,startRow:n,endRow:s,props:i,numInstances:o}){if(e.constant&&this.context.device.type!=="webgpu")return;let{settings:a,state:c,value:l,size:u,startIndices:f}=e,{accessor:h,transform:d}=a,m=c.binaryAccessor||(typeof h=="function"?h:i[h]);typeof m!="function"&&typeof h=="string"&&(m=()=>i[h]),ie(typeof m=="function",`accessor "${h}" is not a function`);let y=e.getVertexOffset(n),{iterable:_,objectInfo:x}=Es(t,n,s);for(let E of _){x.index++;let b=m(E,x);if(d&&(b=d.call(this,b)),f){let S=(x.index<f.length-1?f[x.index+1]:o)-f[x.index];if(b&&Array.isArray(b[0])){let C=y;for(let P of b)e._normalizeValue(P,l,C),C+=u}else b&&b.length>u?l.set(b,y):(e._normalizeValue(b,x.target,0),Mc({target:l,source:x.target,start:y,count:S}));y+=S*u}else e._normalizeValue(b,l,y),y+=u}}_validateAttributeUpdaters(){let{settings:e}=this;if(!(e.noAlloc||typeof e.update=="function"))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){let{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let n=!0;switch(t){case 4:n=n&&Number.isFinite(e[3]);case 3:n=n&&Number.isFinite(e[2]);case 2:n=n&&Number.isFinite(e[1]);case 1:n=n&&Number.isFinite(e[0]);break;default:n=!1}if(!n)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function Rd(r){let{source:e,target:t,start:n=0,size:s,getData:i}=r,o=r.end||t.length,a=e.length,c=o-n;if(a>c){t.set(e.subarray(0,c),n);return}if(t.set(e,n),!i)return;let l=a;for(;l<c;){let u=i(l,e);for(let f=0;f<s;f++)t[n+l]=u[f]||0,l++}}function $x({source:r,target:e,size:t,getData:n,sourceStartIndices:s,targetStartIndices:i}){if(!s||!i)return Rd({source:r,target:e,size:t,getData:n}),e;let o=0,a=0,c=n&&((u,f)=>n(u+a,f)),l=Math.min(s.length,i.length);for(let u=1;u<l;u++){let f=s[u]*t,h=i[u]*t;Rd({source:r.subarray(o,f),target:e,start:a,end:h,size:t,getData:c}),o=f,a=h}return a<e.length&&Rd({source:[],target:e,start:a,size:t,getData:c}),e}function jx(r){let{device:e,settings:t,value:n}=r,s=new fr(e,t);return s.setData({value:n instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:t.normalized}),s}function xl(r){switch(r){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`No defined attribute type for size "${r}"`)}}function bl(r){switch(r){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function Tl(r){r.push(r.shift())}function Hx(r,e){let{doublePrecision:t,settings:n,value:s,size:i}=r,o=t&&s instanceof Float64Array?2:1,a=0,{shaderAttributes:c}=r.settings;if(c)for(let l of Object.values(c))a=Math.max(a,l.vertexOffset??0);return(n.noAlloc?s.length:(e+a)*i)*o}function wl({device:r,source:e,target:t}){return(!t||t.byteLength<e.byteLength)&&(t?.destroy(),t=r.createBuffer({byteLength:e.byteLength,usage:e.usage})),t}function vl({device:r,buffer:e,attribute:t,fromLength:n,toLength:s,fromStartIndices:i,getData:o=a=>a}){let a=t.doublePrecision&&t.value instanceof Float64Array?2:1,c=t.size*a,l=t.byteOffset,u=t.settings.bytesPerElement<4?l/t.settings.bytesPerElement*4:l,f=t.startIndices,h=i&&f,d=t.isConstant;if(!h&&e&&n>=s)return e;let m=t.value instanceof Float64Array?Float32Array:t.value.constructor,y=d?t.value:new m(t.getBuffer().readSyncWebGL(l,s*m.BYTES_PER_ELEMENT).buffer);if(t.settings.normalized&&!d){let b=o;o=(S,C)=>t.normalizeConstant(b(S,C))}let _=d?(b,S)=>o(y,S):(b,S)=>o(y.subarray(b+l,b+l+c),S),x=e?new Float32Array(e.readSyncWebGL(u,n*4).buffer):new Float32Array(0),E=new Float32Array(s);return $x({source:x,target:E,sourceStartIndices:i,targetStartIndices:f,size:c,getData:_}),(!e||e.byteLength<E.byteLength+u)&&(e?.destroy(),e=r.createBuffer({byteLength:E.byteLength+u,usage:35050})),e.write(E,u),e}var Rs=class{constructor({device:e,attribute:t,timeline:n}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new bt(n),this.attribute=t,this.attributeInTransition=jx(t),this.currentStartIndices=t.startIndices}get inProgress(){return this.transition.inProgress}start(e,t,n=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=Hx(this.attribute,t),this.transition.start({...e,duration:n})}update(){let e=this.transition.update();return e&&this.onUpdate(),e}setBuffer(e){this.attributeInTransition.setData({buffer:e,normalized:this.attribute.settings.normalized,value:this.attributeInTransition.value})}cancel(){this.transition.cancel()}delete(){this.cancel();for(let e of this.buffers)e.destroy();this.buffers.length=0}};var mo=class extends Rs{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type="interpolation",this.transform=aE(e,t)}start(e,t){let n=this.currentLength,s=this.currentStartIndices;if(super.start(e,t,e.duration),e.duration<=0){this.transition.cancel();return}let{buffers:i,attribute:o}=this;Tl(i),i[0]=vl({device:this.device,buffer:i[0],attribute:o,fromLength:n,toLength:this.currentLength,fromStartIndices:s,getData:e.enter}),i[1]=wl({device:this.device,source:i[0],target:i[1]}),this.setBuffer(i[1]);let{transform:a}=this,c=a.model,l=Math.floor(this.currentLength/o.size);Yx(o)&&(l/=2),c.setVertexCount(l),o.isConstant?(c.setAttributes({aFrom:i[0]}),c.setConstantAttributes({aTo:o.value})):c.setAttributes({aFrom:i[0],aTo:o.getBuffer()}),a.transformFeedback.setBuffers({vCurrent:i[1]})}onUpdate(){let{duration:e,easing:t}=this.settings,{time:n}=this.transition,s=n/e;t&&(s=t(s));let{model:i}=this.transform,o={time:s};i.shaderInputs.setProps({interpolation:o}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},sE=`uniform interpolationUniforms {
1591
1591
  float time;
1592
1592
  } interpolation;
1593
- `,Dx={name:"interpolation",vs:qS,uniformTypes:{time:"f32"}},KS=`#version 300 es
1593
+ `,Xx={name:"interpolation",vs:sE,uniformTypes:{time:"f32"}},iE=`#version 300 es
1594
1594
  #define SHADER_NAME interpolation-transition-vertex-shader
1595
1595
 
1596
1596
  in ATTRIBUTE_TYPE aFrom;
@@ -1601,7 +1601,7 @@ void main(void) {
1601
1601
  vCurrent = mix(aFrom, aTo, interpolation.time);
1602
1602
  gl_Position = vec4(0.0);
1603
1603
  }
1604
- `,ZS=`#version 300 es
1604
+ `,oE=`#version 300 es
1605
1605
  #define SHADER_NAME interpolation-transition-vertex-shader
1606
1606
 
1607
1607
  in ATTRIBUTE_TYPE aFrom;
@@ -1624,11 +1624,11 @@ void main(void) {
1624
1624
  }
1625
1625
  gl_Position = vec4(0.0);
1626
1626
  }
1627
- `;function Fx(r){return r.doublePrecision&&r.value instanceof Float64Array}function GS(r,e){let t=e.size,n=pl(t),s=ml(t),i=e.getBufferLayout();return Fx(e)?new pt(r,{vs:ZS,bufferLayout:[{name:"aFrom",byteStride:8*t,attributes:[{attribute:"aFrom",format:s,byteOffset:0},{attribute:"aFrom64Low",format:s,byteOffset:4*t}]},{name:"aTo",byteStride:8*t,attributes:[{attribute:"aTo",format:s,byteOffset:0},{attribute:"aTo64Low",format:s,byteOffset:4*t}]}],modules:[Pf,Dx],defines:{ATTRIBUTE_TYPE:n,ATTRIBUTE_SIZE:t},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new pt(r,{vs:KS,bufferLayout:[{name:"aFrom",format:s},{name:"aTo",format:i.attributes[0].format}],modules:[Dx],defines:{ATTRIBUTE_TYPE:n},varyings:["vCurrent"],disableWarnings:!0})}var ho=class extends As{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type="spring",this.texture=nE(e),this.framebuffer=sE(e,this.texture),this.transform=rE(e,t)}start(e,t){let n=this.currentLength,s=this.currentStartIndices;super.start(e,t);let{buffers:i,attribute:o}=this;for(let c=0;c<2;c++)i[c]=yl({device:this.device,buffer:i[c],attribute:o,fromLength:n,toLength:this.currentLength,fromStartIndices:s,getData:e.enter});i[2]=_l({device:this.device,source:i[0],target:i[2]}),this.setBuffer(i[1]);let{model:a}=this.transform;a.setVertexCount(Math.floor(this.currentLength/o.size)),o.isConstant?a.setConstantAttributes({aTo:o.value}):a.setAttributes({aTo:o.getBuffer()})}onUpdate(){let{buffers:e,transform:t,framebuffer:n,transition:s}=this,i=this.settings;t.model.setAttributes({aPrev:e[0],aCur:e[1]}),t.transformFeedback.setBuffers({vNext:e[2]});let o={stiffness:i.stiffness,damping:i.damping};t.model.shaderInputs.setProps({spring:o}),t.run({framebuffer:n,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),gl(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(n)[0]>0||s.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},QS=`uniform springUniforms {
1627
+ `;function Yx(r){return r.doublePrecision&&r.value instanceof Float64Array}function aE(r,e){let t=e.size,n=xl(t),s=bl(t),i=e.getBufferLayout();return Yx(e)?new ht(r,{vs:oE,bufferLayout:[{name:"aFrom",byteStride:8*t,attributes:[{attribute:"aFrom",format:s,byteOffset:0},{attribute:"aFrom64Low",format:s,byteOffset:4*t}]},{name:"aTo",byteStride:8*t,attributes:[{attribute:"aTo",format:s,byteOffset:0},{attribute:"aTo64Low",format:s,byteOffset:4*t}]}],modules:[Bf,Xx],defines:{ATTRIBUTE_TYPE:n,ATTRIBUTE_SIZE:t},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new ht(r,{vs:iE,bufferLayout:[{name:"aFrom",format:s},{name:"aTo",format:i.attributes[0].format}],modules:[Xx],defines:{ATTRIBUTE_TYPE:n},varyings:["vCurrent"],disableWarnings:!0})}var go=class extends Rs{constructor({device:e,attribute:t,timeline:n}){super({device:e,attribute:t,timeline:n}),this.type="spring",this.texture=dE(e),this.framebuffer=pE(e,this.texture),this.transform=hE(e,t)}start(e,t){let n=this.currentLength,s=this.currentStartIndices;super.start(e,t);let{buffers:i,attribute:o}=this;for(let c=0;c<2;c++)i[c]=vl({device:this.device,buffer:i[c],attribute:o,fromLength:n,toLength:this.currentLength,fromStartIndices:s,getData:e.enter});i[2]=wl({device:this.device,source:i[0],target:i[2]}),this.setBuffer(i[1]);let{model:a}=this.transform;a.setVertexCount(Math.floor(this.currentLength/o.size)),o.isConstant?a.setConstantAttributes({aTo:o.value}):a.setAttributes({aTo:o.getBuffer()})}onUpdate(){let{buffers:e,transform:t,framebuffer:n,transition:s}=this,i=this.settings;t.model.setAttributes({aPrev:e[0],aCur:e[1]}),t.transformFeedback.setBuffers({vNext:e[2]});let o={stiffness:i.stiffness,damping:i.damping};t.model.shaderInputs.setProps({spring:o}),t.run({framebuffer:n,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),Tl(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(n)[0]>0||s.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},cE=`uniform springUniforms {
1628
1628
  float damping;
1629
1629
  float stiffness;
1630
1630
  } spring;
1631
- `,JS={name:"spring",vs:QS,uniformTypes:{damping:"f32",stiffness:"f32"}},eE=`#version 300 es
1631
+ `,lE={name:"spring",vs:cE,uniformTypes:{damping:"f32",stiffness:"f32"}},uE=`#version 300 es
1632
1632
  #define SHADER_NAME spring-transition-vertex-shader
1633
1633
 
1634
1634
  #define EPSILON 0.00001
@@ -1655,7 +1655,7 @@ void main(void) {
1655
1655
  gl_Position = vec4(0, 0, 0, 1);
1656
1656
  gl_PointSize = 100.0;
1657
1657
  }
1658
- `,tE=`#version 300 es
1658
+ `,fE=`#version 300 es
1659
1659
  #define SHADER_NAME spring-transition-is-transitioning-fragment-shader
1660
1660
 
1661
1661
  in float vIsTransitioningFlag;
@@ -1667,6 +1667,6 @@ void main(void) {
1667
1667
  discard;
1668
1668
  }
1669
1669
  fragColor = vec4(1.0);
1670
- }`;function rE(r,e){let t=pl(e.size),n=ml(e.size);return new pt(r,{vs:eE,fs:tE,bufferLayout:[{name:"aPrev",format:n},{name:"aCur",format:n},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[JS],defines:{ATTRIBUTE_TYPE:t},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function nE(r){return r.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function sE(r,e){return r.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var iE={interpolation:fo,spring:ho},po=class{constructor(e,{id:t,timeline:n}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=t,this.device=e,this.timeline=n,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:n}){this.numInstances=n||1;for(let s in e){let i=e[s],o=i.getTransitionSetting(t);o&&this._updateAttribute(s,i,o)}for(let s in this.transitions){let i=e[s];(!i||!i.getTransitionSetting(t))&&this._removeTransition(s)}}hasAttribute(e){let t=this.transitions[e];return t&&t.inProgress}getAttributes(){let e={};for(let t in this.transitions){let n=this.transitions[t];n.inProgress&&(e[t]=n.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let t in this.transitions)this.transitions[t].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,t,n){let s=this.transitions[e],i=!s||s.type!==n.type;if(i){s&&this._removeTransition(e);let o=iE[n.type];o?this.transitions[e]=new o({attribute:t,timeline:this.timeline,device:this.device}):($.error(`unsupported transition type '${n.type}'`)(),i=!1)}(i||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(n,this.numInstances))}};var Bx="attributeManager.invalidate",oE="attributeManager.updateStart",aE="attributeManager.updateEnd",cE="attribute.updateStart",lE="attribute.allocate",uE="attribute.updateEnd",vn=class{constructor(e,{id:t="attribute-manager",stats:n,timeline:s}={}){this.mergeBoundsMemoized=ot(W_),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=n,this.attributeTransitionManager=new po(e,{id:`${t}-transitions`,timeline:s}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let t of e)this.attributes[t]!==void 0&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){let n=this._invalidateTrigger(e,t);he(Bx,this,e,n)}invalidateAll(e){for(let t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);he(Bx,this,"all")}update({data:e,numInstances:t,startIndices:n=null,transitions:s,props:i={},buffers:o={},context:a={}}){let c=!1;he(oE,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let u=this.attributes[l],f=u.settings.accessor;u.startIndices=n,u.numInstances=t,i[l]&&$.removed(`props.${l}`,`data.attributes.${l}`)(),u.setExternalBuffer(o[l])||u.setBinaryValue(typeof f=="string"?o[f]:void 0,e.startIndices)||typeof f=="string"&&!o[f]&&u.setConstantValue(a,i[f])||u.needsUpdate()&&(c=!0,this._updateAttribute({attribute:u,numInstances:t,data:e,props:i,context:a})),this.needsRedraw=this.needsRedraw||u.needsRedraw()}c&&he(aE,this,t),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:s})}updateTransition(){let{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let t=e.map(n=>this.attributes[n]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:t,attributeTransitionManager:n}=this,s={...n.getAttributes()};for(let i in t){let o=t[i];o.needsRedraw(e)&&!n.hasAttribute(i)&&(s[i]=o)}return s}getBufferLayouts(e){return Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}_add(e,t){for(let n in e){let s=e[n],i={...s,id:n,size:s.isIndexed&&1||s.size||1,...t};this.attributes[n]=new hr(this.device,i)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let t in this.attributes)this.attributes[t].getUpdateTriggers().forEach(s=>{e[s]||(e[s]=[]),e[s].push(t)});this.updateTriggers=e}_invalidateTrigger(e,t){let{attributes:n,updateTriggers:s}=this,i=s[e];return i&&i.forEach(o=>{let a=n[o];a&&a.setNeedsUpdate(a.id,t)}),i}_updateAttribute(e){let{attribute:t,numInstances:n}=e;if(he(cE,t),t.constant){t.setConstantValue(e.context,t.value);return}t.allocate(n)&&he(lE,t,n),t.updateBuffer(e)&&(this.needsRedraw=!0,he(uE,t,n))}};H();ol();var mo=class extends wt{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:t,toValue:n,duration:s,easing:i}}=this,o=i(e/s);this._value=Jt(t,n,o)}};var Lx=1e-5;function Ux(r,e,t,n,s){let i=e-r,a=(t-e)*s,c=-i*n;return a+c+i+e}function fE(r,e,t,n,s){if(Array.isArray(t)){let i=[];for(let o=0;o<t.length;o++)i[o]=Ux(r[o],e[o],t[o],n,s);return i}return Ux(r,e,t,n,s)}function Vx(r,e){if(Array.isArray(r)){let t=0;for(let n=0;n<r.length;n++){let s=r[n]-e[n];t+=s*s}return Math.sqrt(t)}return Math.abs(r-e)}var go=class extends wt{get value(){return this._currValue}_onUpdate(){let{fromValue:e,toValue:t,damping:n,stiffness:s}=this.settings,{_prevValue:i=e,_currValue:o=e}=this,a=fE(i,o,t,n,s),c=Vx(a,t),l=Vx(a,o);c<Lx&&l<Lx&&(a=t,this.end()),this._prevValue=o,this._currValue=a}};var hE={interpolation:mo,spring:go},_o=class{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,t,n,s){let{transitions:i}=this;if(i.has(e)){let c=i.get(e),{value:l=c.settings.fromValue}=c;t=l,this.remove(e)}if(s=dl(s),!s)return;let o=hE[s.type];if(!o){$.error(`unsupported transition type '${s.type}'`)();return}let a=new o(this.timeline);a.start({...s,fromValue:t,toValue:n}),i.set(e,a)}remove(e){let{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){let e={};for(let[t,n]of this.transitions)n.update(),e[t]=n.value,n.inProgress||this.remove(t);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function Wx(r){let e=r[lt];for(let t in e){let n=e[t],{validate:s}=n;if(s&&!s(r[t],n))throw new Error(`Invalid prop ${t}: ${r[t]}`)}}function $x(r,e){let t=xl({newProps:r,oldProps:e,propTypes:r[lt],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),n=pE(r,e),s=!1;return n||(s=mE(r,e)),{dataChanged:n,propsChanged:t,updateTriggersChanged:s,extensionsChanged:gE(r,e),transitionsChanged:dE(r,e)}}function dE(r,e){if(!r.transitions)return!1;let t={},n=r[lt],s=!1;for(let i in r.transitions){let o=n[i],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&bd(r[i],e[i],o)&&(t[i]=!0,s=!0)}return s?t:!1}function xl({newProps:r,oldProps:e,ignoreProps:t={},propTypes:n={},triggerName:s="props"}){if(e===r)return!1;if(typeof r!="object"||r===null)return`${s} changed shallowly`;if(typeof e!="object"||e===null)return`${s} changed shallowly`;for(let i of Object.keys(r))if(!(i in t)){if(!(i in e))return`${s}.${i} added`;let o=bd(r[i],e[i],n[i]);if(o)return`${s}.${i} ${o}`}for(let i of Object.keys(e))if(!(i in t)){if(!(i in r))return`${s}.${i} dropped`;if(!Object.hasOwnProperty.call(r,i)){let o=bd(r[i],e[i],n[i]);if(o)return`${s}.${i} ${o}`}}return!1}function bd(r,e,t){let n=t&&t.equal;return n&&!n(r,e,t)||!n&&(n=r&&e&&r.equals,n&&!n.call(r,e))?"changed deeply":!n&&e!==r?"changed shallowly":null}function pE(r,e){if(e===null)return"oldProps is null, initial diff";let t=!1,{dataComparator:n,_dataDiff:s}=r;return n?n(r.data,e.data)||(t="Data comparator detected a change"):r.data!==e.data&&(t="A new data container was supplied"),t&&s&&(t=s(r.data,e.data)||t),t}function mE(r,e){if(e===null)return{all:!0};if("all"in r.updateTriggers&&zx(r,e,"all"))return{all:!0};let t={},n=!1;for(let s in r.updateTriggers)s!=="all"&&zx(r,e,s)&&(t[s]=!0,n=!0);return n?t:!1}function gE(r,e){if(e===null)return!0;let t=e.extensions,{extensions:n}=r;if(n===t)return!1;if(!t||!n||n.length!==t.length)return!0;for(let s=0;s<n.length;s++)if(!n[s].equals(t[s]))return!0;return!1}function zx(r,e,t){let n=r.updateTriggers[t];n=n??{};let s=e.updateTriggers[t];return s=s??{},xl({oldProps:s,newProps:n,triggerName:t})}var _E="count(): argument not an object",yE="count(): argument not a container";function bl(r){if(!bE(r))throw new Error(_E);if(typeof r.count=="function")return r.count();if(Number.isFinite(r.size))return r.size;if(Number.isFinite(r.length))return r.length;if(xE(r))return Object.keys(r).length;throw new Error(yE)}function xE(r){return r!==null&&typeof r=="object"&&r.constructor===Object}function bE(r){return r!==null&&typeof r=="object"}function yo(r,e){if(!e)return r;let t={...r,...e};if("defines"in e&&(t.defines={...r.defines,...e.defines}),"modules"in e&&(t.modules=(r.modules||[]).concat(e.modules),e.modules.some(n=>n.name==="project64"))){let n=t.modules.findIndex(s=>s.name==="project32");n>=0&&t.modules.splice(n,1)}if("inject"in e)if(!r.inject)t.inject=e.inject;else{let n={...r.inject};for(let s in e.inject)n[s]=(n[s]||"")+e.inject[s];t.inject=n}return t}H();var TE={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Td={};function jx(r,e,t,n){if(t instanceof K)return t;t.constructor&&t.constructor.name!=="Object"&&(t={data:t});let s=null;t.compressed&&(s={minFilter:"linear",mipmapFilter:t.data.length>1?"nearest":"linear"});let{width:i,height:o}=t.data,a=e.createTexture({...t,sampler:{...TE,...s,...n},mipLevels:e.getMipLevelCount(i,o)});return a.generateMipmapsWebGL(),Td[a.id]=r,a}function Hx(r,e){!e||!(e instanceof K)||Td[e.id]===r&&(e.delete(),delete Td[e.id])}var wE={boolean:{validate(r,e){return!0},equal(r,e,t){return Boolean(r)===Boolean(e)}},number:{validate(r,e){return Number.isFinite(r)&&(!("max"in e)||r<=e.max)&&(!("min"in e)||r>=e.min)}},color:{validate(r,e){return e.optional&&!r||wd(r)&&(r.length===3||r.length===4)},equal(r,e,t){return le(r,e,1)}},accessor:{validate(r,e){let t=Tl(r);return t==="function"||t===Tl(e.value)},equal(r,e,t){return typeof e=="function"?!0:le(r,e,1)}},array:{validate(r,e){return e.optional&&!r||wd(r)},equal(r,e,t){let{compare:n}=t,s=Number.isInteger(n)?n:n?1:0;return n?le(r,e,s):r===e}},object:{equal(r,e,t){if(t.ignore)return!0;let{compare:n}=t,s=Number.isInteger(n)?n:n?1:0;return n?le(r,e,s):r===e}},function:{validate(r,e){return e.optional&&!r||typeof r=="function"},equal(r,e,t){return!t.compare&&t.ignore!==!1||r===e}},data:{transform:(r,e,t)=>{if(!r)return r;let{dataTransform:n}=t.props;return n?n(r):typeof r.shape=="string"&&r.shape.endsWith("-table")&&Array.isArray(r.data)?r.data:r}},image:{transform:(r,e,t)=>{let n=t.context;return!n||!n.device?null:jx(t.id,n.device,r,{...e.parameters,...t.props.textureParameters})},release:(r,e,t)=>{Hx(t.id,r)}}};function Xx(r){let e={},t={},n={};for(let[s,i]of Object.entries(r)){let o=i?.deprecatedFor;if(o)n[s]=Array.isArray(o)?o:[o];else{let a=vE(s,i);e[s]=a,t[s]=a.value}}return{propTypes:e,defaultProps:t,deprecatedProps:n}}function vE(r,e){switch(Tl(e)){case"object":return xo(r,e);case"array":return xo(r,{type:"array",value:e,compare:!1});case"boolean":return xo(r,{type:"boolean",value:e});case"number":return xo(r,{type:"number",value:e});case"function":return xo(r,{type:"function",value:e,compare:!0});default:return{name:r,type:"unknown",value:e}}}function xo(r,e){return"type"in e?{name:r,...wE[e.type],...e}:"value"in e?{name:r,type:Tl(e.value),...e}:{name:r,type:"object",value:e}}function wd(r){return Array.isArray(r)||ArrayBuffer.isView(r)}function Tl(r){return wd(r)?"array":r===null?"null":typeof r}function Yx(r,e){let t;for(let i=e.length-1;i>=0;i--){let o=e[i];"extensions"in o&&(t=o.extensions)}let n=vd(r.constructor,t),s=Object.create(n);s[ps]=r,s[Bt]={},s[Tt]={};for(let i=0;i<e.length;++i){let o=e[i];for(let a in o)s[a]=o[a]}return Object.freeze(s),s}var AE="_mergedDefaultProps";function vd(r,e){if(!(r instanceof Ss.constructor))return{};let t=AE;if(e)for(let s of e){let i=s.constructor;i&&(t+=`:${i.extensionName||i.name}`)}let n=qx(r,t);return n||(r[t]=SE(r,e||[]))}function SE(r,e){if(!r.prototype)return null;let n=Object.getPrototypeOf(r),s=vd(n),i=qx(r,"defaultProps")||{},o=Xx(i),a=Object.assign(Object.create(null),s,o.defaultProps),c=Object.assign(Object.create(null),s?.[lt],o.propTypes),l=Object.assign(Object.create(null),s?.[Sc],o.deprecatedProps);for(let u of e){let f=vd(u.constructor);f&&(Object.assign(a,f),Object.assign(c,f[lt]),Object.assign(l,f[Sc]))}return EE(a,r),IE(a,c),RE(a,l),a[lt]=c,a[Sc]=l,e.length===0&&!Ad(r,"_propTypes")&&(r._propTypes=c),a}function EE(r,e){let t=CE(e);Object.defineProperties(r,{id:{writable:!0,value:t}})}function RE(r,e){for(let t in e)Object.defineProperty(r,t,{enumerable:!1,set(n){let s=`${this.id}: ${t}`;for(let i of e[t])Ad(this,i)||(this[i]=n);$.deprecated(s,e[t].join("/"))()}})}function IE(r,e){let t={},n={};for(let s in e){let i=e[s],{name:o,value:a}=i;i.async&&(t[o]=a,n[o]=PE(o))}r[or]=t,r[Bt]={},Object.defineProperties(r,n)}function PE(r){return{enumerable:!0,set(e){typeof e=="string"||e instanceof Promise||fl(e)?this[Bt][r]=e:this[Tt][r]=e},get(){if(this[Tt]){if(r in this[Tt])return this[Tt][r]||this[or][r];if(r in this[Bt]){let e=this[ps]&&this[ps].internalState;if(e&&e.hasAsyncProp(r))return e.getAsyncProp(r)||this[or][r]}}return this[or][r]}}}function Ad(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function qx(r,e){return Ad(r,e)&&r[e]}function CE(r){let e=r.componentName;return e||$.warn(`${r.name}.componentName not specified`)(),e||r.name}var ME=0,bo=class{constructor(...e){this.props=Yx(this,e),this.id=this.props.id,this.count=ME++}clone(e){let{props:t}=this,n={};for(let s in t[or])s in t[Tt]?n[s]=t[Tt][s]:s in t[Bt]&&(n[s]=t[Bt][s]);return new this.constructor({...t,...n,...e})}};bo.componentName="Component";bo.defaultProps={};var Ss=bo;var OE=Object.freeze({}),An=class{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||OE}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){let t=this.asyncProps[e];return Boolean(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(let t in this.asyncProps)if(this.isAsyncPropLoading(t))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[ps]||this.component;let t=e[Tt]||{},n=e[Bt]||e,s=e[or]||{};for(let i in t){let o=t[i];this._createAsyncPropData(i,s[i]),this._updateAsyncProp(i,o),t[i]=this.getAsyncProp(i)}for(let i in n){let o=n[i];this._createAsyncPropData(i,s[i]),this._updateAsyncProp(i,o)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){if(this._didAsyncInputValueChange(e,t)){if(typeof t=="string"&&(t=this._fetch(e,t)),t instanceof Promise){this._watchPromise(e,t);return}if(fl(t)){this._resolveAsyncIterable(e,t);return}this._setPropValue(e,t)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){let n=this.asyncProps[e];return t===n.resolvedValue||t===n.lastValue?!1:(n.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();let n=this.asyncProps[e];n&&(t=this._postProcessValue(n,t),n.resolvedValue=t,n.pendingLoadCount++,n.resolvedLoadCount=n.pendingLoadCount)}_setAsyncPropValue(e,t,n){let s=this.asyncProps[e];s&&n>=s.resolvedLoadCount&&t!==void 0&&(this._freezeAsyncOldProps(),s.resolvedValue=t,s.resolvedLoadCount=n,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){let n=this.asyncProps[e];if(n){n.pendingLoadCount++;let s=n.pendingLoadCount;t.then(i=>{this.component&&(i=this._postProcessValue(n,i),this._setAsyncPropValue(e,i,s),this._onResolve(e,i))}).catch(i=>{this._onError(e,i)})}}async _resolveAsyncIterable(e,t){if(e!=="data"){this._setPropValue(e,t);return}let n=this.asyncProps[e];if(!n)return;n.pendingLoadCount++;let s=n.pendingLoadCount,i=[],o=0;for await(let a of t){if(!this.component)return;let{dataTransform:c}=this.component.props;c?i=c(a,i):i=i.concat(a),Object.defineProperty(i,"__diff",{enumerable:!1,value:[{startRow:o,endRow:i.length}]}),o=i.length,this._setAsyncPropValue(e,i,s)}this._onResolve(e,i)}_postProcessValue(e,t){let n=e.type;return n&&this.component&&(n.release&&n.release(e.resolvedValue,n,this.component),n.transform)?n.transform(t,n,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){let s=this.component&&this.component.props[lt];this.asyncProps[e]={type:s&&s[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}};var To=class extends An{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,t){let n=this.layer,s=n?.props.fetch;return s?s(t,{propName:e,layer:n}):super._fetch(e,t)}_onResolve(e,t){let n=this.layer;if(n){let s=n.props.onDataLoad;e==="data"&&s&&s(t,{propName:e,layer:n})}}_onError(e,t){let n=this.layer;n&&n.raiseError(t,`loading ${e} of ${this.layer}`)}};var kE="layer.changeFlag",NE="layer.initialize",DE="layer.update",FE="layer.finalize",BE="layer.matched",Kx=2**24-1,LE=Object.freeze([]),UE=ot(({oldViewport:r,viewport:e})=>r.equals(e)),Et=new Uint8ClampedArray(0),VE={data:{type:"data",value:LE,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:r=>r&&r.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(r,{propName:e,layer:t,loaders:n,loadOptions:s,signal:i})=>{let{resourceManager:o}=t.context;s=s||t.getLoadOptions(),n=n||t.props.loaders,i&&(s={...s,fetch:{...s?.fetch,signal:i}});let a=o.contains(r);return!a&&!s&&(o.add({resourceId:r,data:Rr(r,n),persistent:!1}),a=!0),a?o.subscribe({resourceId:r,onChange:c=>t.internalState?.reloadAsyncProp(e,c),consumerId:t.id,requestId:e}):Rr(r,n,s)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:Y.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:r})=>[0,-r*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},wo=class extends Ss{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Nr.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){ie(this.internalState);let t=this.internalState.viewport||this.context.viewport,n=$h(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[s,i,o]=as(n,t.pixelProjectionMatrix);return e.length===2?[s,i]:[s,i,o]}unproject(e){return ie(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){ie(this.internalState);let n=this.internalState.viewport||this.context.viewport;return wc(e,{viewport:n,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e===Y.DEFAULT||e===Y.LNGLAT||e===Y.CARTESIAN}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){ie(e instanceof Uint8Array);let[t,n,s]=e;return t+n*256+s*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:bl(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=yo(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let t of this.props.extensions)e=yo(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let t=this.getAttributeManager(),{dataChanged:n}=e.changeFlags;if(n&&t)if(Array.isArray(n))for(let s of n)t.invalidateAll(s);else t.invalidateAll();if(t){let{props:s}=e,i=this.internalState.hasPickingBuffer,o=Number.isInteger(s.highlightedObjectIndex)||Boolean(s.pickable)||s.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(i!==o){this.internalState.hasPickingBuffer=o;let{pickingColors:a,instancePickingColors:c}=t.attributes,l=a||c;l&&(o&&l.constant&&(l.constant=!1,t.invalidate(l.id)),!l.value&&!o&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(e){for(let n of this.getModels())n.destroy();let t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let t of this.getModels())t.draw(e.renderPass)}getPickingInfo({info:e,mode:t,sourceLayer:n}){let{index:s}=e;return s>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[s]),e}raiseError(e,t){t&&(e=new Error(`${t}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let t=this.internalState.viewport;this.internalState.viewport=e,(!t||!UE({oldViewport:t,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let t=this.getAttributeManager();t&&(e==="all"?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(let n in e)e[n].layoutChanged()&&(t=!0);for(let n of this.getModels())this._setModelAttributes(n,e,t)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let t=this.props,n=this.getNumInstances(),s=this.getStartIndices();e.update({data:t.data,numInstances:n,startIndices:s,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});let i=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(i)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let t=e.update(),n=Object.create(this.props);for(let s in t)Object.defineProperty(n,s,{value:t[s]});return n}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;let n=Math.floor(Et.length/4);if(this.internalState.usesPickingColorCache=!0,n<t){t>Kx&&$.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),Et=bt.allocate(Et,t,{size:4,copy:!0,maxCount:Math.max(t,Kx)});let s=Math.floor(Et.length/4),i=[0,0,0];for(let o=n;o<s;o++)this.encodePickingColor(o,i),Et[o*4+0]=i[0],Et[o*4+1]=i[1],Et[o*4+2]=i[2],Et[o*4+3]=0}e.value=Et.subarray(0,t*4)}_setModelAttributes(e,t,n=!1){if(!Object.keys(t).length)return;if(n){let a=this.getAttributeManager();e.setBufferLayout(a.getBufferLayouts(e)),t=a.getAttributes()}let s=e.userData?.excludeAttributes||{},i={},o={};for(let a in t){if(s[a])continue;let c=t[a].getValue();for(let l in c){let u=c[l];u instanceof W?t[a].settings.isIndexed?e.setIndexBuffer(u):i[l]=u:u&&(o[l]=u)}}e.setAttributes(i),e.setConstantAttributes(o)}disablePickingIndex(e){let t=this.props.data;if(!("attributes"in t)){this._disablePickingIndex(e);return}let{pickingColors:n,instancePickingColors:s}=this.getAttributeManager().attributes,i=n||s,o=i&&t.attributes&&t.attributes[i.id];if(o&&o.value){let a=o.value,c=this.encodePickingColor(e);for(let l=0;l<t.length;l++){let u=i.getVertexOffset(l);a[u]===c[0]&&a[u+1]===c[1]&&a[u+2]===c[2]&&this._disablePickingIndex(l)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){let{pickingColors:t,instancePickingColors:n}=this.getAttributeManager().attributes,s=t||n;if(!s)return;let i=s.getVertexOffset(e),o=s.getVertexOffset(e+1);s.buffer.write(new Uint8Array(o-i),i)}restorePickingColors(){let{pickingColors:e,instancePickingColors:t}=this.getAttributeManager().attributes,n=e||t;n&&(this.internalState.usesPickingColorCache&&n.value.buffer!==Et.buffer&&(n.value=Et.subarray(0,n.value.length)),n.updateSubBuffer({startOffset:0}))}_initialize(){ie(!this.internalState),ie(Number.isFinite(this.props.coordinateSystem)),he(NE,this);let e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new To({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>($.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new _o(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let t of this.props.extensions)t.initializeState.call(this,this.context,t);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){he(BE,this,this===e);let{state:t,internalState:n}=e;this!==e&&(this.internalState=n,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(he(DE,this,e),!e)return;let t=this.props,n=this.context,s=this.internalState,i=n.viewport,o=this._updateUniformTransition();s.propsInTransition=o,n.viewport=s.viewport||i,this.props=o;try{let a=this._getUpdateParams(),c=this.getModels();if(n.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let u of this.props.extensions)u.updateState.call(this,a,u);this.setNeedsRedraw(),this._updateAttributes();let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{n.viewport=i,this.props=t,this._clearChangeFlags(),s.needsUpdate=!1,s.resetOldProps()}}_finalize(){he(FE,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:t=null,uniforms:n={},parameters:s={}}){this._updateAttributeTransition();let i=this.props,o=this.context;this.props=this.internalState.propsInTransition||i;try{t&&this.setShaderModuleProps(t);let{getPolygonOffset:a}=this.props,c=a&&a(n)||[0,0];o.device instanceof wn&&o.device.setParametersWebGL({polygonOffset:c});for(let l of this.getModels())l.device.type==="webgpu"?l.setParameters({...l.parameters,...s}):l.setParameters(s);if(o.device instanceof wn)o.device.withParametersWebGL(s,()=>{let l={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:s,context:o};for(let u of this.props.extensions)u.draw.call(this,l,u);this.draw(l)});else{let l={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:s,context:o};for(let u of this.props.extensions)u.draw.call(this,l,u);this.draw(l)}}finally{this.props=i}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:t}=this.internalState;for(let s in e)if(e[s]){let i=!1;switch(s){case"dataChanged":let o=e[s],a=t[s];o&&Array.isArray(a)&&(t.dataChanged=Array.isArray(o)?a.concat(o):o,i=!0);default:t[s]||(t[s]=e[s],i=!0)}i&&he(kE,this,s,e)}let n=Boolean(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=n,t.somethingChanged=n||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){let n=$x(e,t);if(n.updateTriggersChanged)for(let s in n.updateTriggersChanged)n.updateTriggersChanged[s]&&this.invalidateAttribute(s);if(n.transitionsChanged)for(let s in n.transitionsChanged)this.internalState.uniformTransitions.add(s,t[s],e[s],e.transitions?.[s]);return this.setChangeFlags(n)}validateProps(){Wx(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:n}=this.props;e.picked&&typeof n=="function"&&(t.highlightColor=n(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new vn(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){let{props:n,oldProps:s}=e,i=this.state.model;i?.isInstanced&&i.setInstanceCount(this.getNumInstances());let{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=n;if(t||s.autoHighlight!==o||s.highlightedObjectIndex!==a||s.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(t||s.autoHighlight!==o||a!==s.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t=t||this.internalState.needsRedraw&&this.id;let n=this.getAttributeManager(),s=n?n.getNeedsRedraw(e):!1;if(t=t||s,t)for(let i of this.props.extensions)i.onNeedsRedraw.call(this,i);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};wo.defaultProps=VE;wo.layerName="Layer";var wl=wo;var zE="compositeLayer.renderLayers",vl=class extends wl{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){let{object:t}=e;return t&&t.__source&&t.__source.parent&&t.__source.parent.id===this.id&&(e.object=t.__source.object,e.index=t.__source.index),e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,t){return t&&t.length}getSubLayerClass(e,t){let{_subLayerProps:n}=this.props;return n&&n[e]&&n[e].type||t}getSubLayerRow(e,t,n){return e.__source={parent:this,object:t,index:n},e}getSubLayerAccessor(e){if(typeof e=="function"){let t={index:-1,data:this.props.data,target:[]};return(n,s)=>n&&n.__source?(t.index=n.__source.index,e(n.__source.object,t)):e(n,s)}return e}getSubLayerProps(e={}){let{opacity:t,pickable:n,visible:s,parameters:i,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:f,wrapLongitude:h,positionFormat:d,modelMatrix:m,extensions:y,fetch:_,operation:x,_subLayerProps:E}=this.props,b={id:"",updateTriggers:{},opacity:t,pickable:n,visible:s,parameters:i,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:f,wrapLongitude:h,positionFormat:d,modelMatrix:m,extensions:y,fetch:_,operation:x},S=E&&e.id&&E[e.id],C=S&&S.updateTriggers,P=e.id||"sublayer";if(S){let B=this.props[lt],N=e.type?e.type._propTypes:{};for(let k in S){let F=N[k]||B[k];F&&F.type==="accessor"&&(S[k]=this.getSubLayerAccessor(S[k]))}}Object.assign(b,e,S),b.id=`${this.props.id}-${P}`,b.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...C};for(let B of y){let N=B.getSubLayerProps.call(this,B);N&&Object.assign(b,N,{updateTriggers:Object.assign(b.updateTriggers,N.updateTriggers)})}return b}_updateAutoHighlight(e){for(let t of this.getSubLayers())t.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,t){let n=this.internalState.subLayers,s=!n||this.needsUpdate();if(s){let i=this.renderLayers();n=Dr(i,Boolean),this.internalState.subLayers=n}he(zE,this,s,n);for(let i of n)i.parent=this}};vl.layerName="CompositeLayer";var Zx=vl;var Sd=Math.PI/180;function WE({height:r,focalDistance:e,orbitAxis:t,rotationX:n,rotationOrbit:s,zoom:i}){let o=t==="Z"?[0,0,1]:[0,1,0],a=t==="Z"?[0,-e,0]:[0,0,e],c=new Q().lookAt({eye:a,up:o});c.rotateX(n*Sd),t==="Z"?c.rotateZ(s*Sd):c.rotateY(s*Sd);let l=Math.pow(2,i)/r;return c.scale(l),c}var Al=class extends je{constructor(e){let{height:t,projectionMatrix:n,fovy:s=50,orbitAxis:i="Z",target:o=[0,0,0],rotationX:a=0,rotationOrbit:c=0,zoom:l=0}=e,u=n?n[5]/2:nr(s);super({...e,longitude:void 0,viewMatrix:WE({height:t||1,focalDistance:u,orbitAxis:i,rotationX:a,rotationOrbit:c,zoom:l}),fovy:s,focalDistance:u,position:o,zoom:l}),this.target=o,this.orbitAxis=i,this.rotationX=a,this.rotationOrbit=c,this.fovy=s,this.projectedCenter=this.project(this.center)}unproject(e,{topLeft:t=!0}={}){let[n,s,i=this.projectedCenter[2]]=e,o=t?s:this.height-s,[a,c,l]=ct([n,o,i],this.pixelUnprojectionMatrix);return[a,c,l]}panByPosition(e,t,n){let s=this.project(e),i=[this.width/2+s[0]-t[0],this.height/2+s[1]-t[1],this.projectedCenter[2]];return{target:this.unproject(i)}}};Al.displayName="OrbitViewport";var Sl=Al;var $E=new Q().lookAt({eye:[0,0,1]});function jE({width:r,height:e,near:t,far:n,padding:s}){let i=-r/2,o=r/2,a=-e/2,c=e/2;if(s){let{left:l=0,right:u=0,top:f=0,bottom:h=0}=s,d=ee((l+r-u)/2,0,r)-r/2,m=ee((f+e-h)/2,0,e)-e/2;i-=d,o-=d,a+=m,c+=m}return new Q().ortho({left:i,right:o,bottom:a,top:c,near:t,far:n})}var El=class extends je{constructor(e){let{width:t,height:n,near:s=.1,far:i=1e3,zoom:o=0,target:a=[0,0,0],padding:c=null,flipY:l=!0}=e,u=e.zoomX??(Array.isArray(o)?o[0]:o),f=e.zoomY??(Array.isArray(o)?o[1]:o),h=Math.min(u,f),d=Math.pow(2,h),m;if(u!==f){let y=Math.pow(2,u),_=Math.pow(2,f);m={unitsPerMeter:[y/d,_/d,1],metersPerUnit:[d/y,d/_,1]}}super({...e,longitude:void 0,position:a,viewMatrix:$E.clone().scale([d,d*(l?-1:1),d]),projectionMatrix:jE({width:t||1,height:n||1,padding:c,near:s,far:i}),zoom:h,distanceScales:m}),this.target=a,this.zoomX=u,this.zoomY=f,this.flipY=l}projectFlat([e,t]){let{unitsPerMeter:n}=this.distanceScales;return[e*n[0],t*n[1]]}unprojectFlat([e,t]){let{metersPerUnit:n}=this.distanceScales;return[e*n[0],t*n[1]]}panByPosition(e,t,n){let s=ct(t,this.pixelUnprojectionMatrix),i=this.projectFlat(e),o=_e.add([],i,_e.negate([],s)),a=_e.add([],this.center,o);return{target:this.unprojectFlat(a)}}};El.displayName="OrthographicViewport";var Rl=El;var Il=class extends je{constructor(e){let{longitude:t,latitude:n,modelMatrix:s,bearing:i=0,pitch:o=0,up:a=[0,0,1]}=e,l=new dt({bearing:i,pitch:o===-90?1e-4:90+o}).toVector3().normalize(),u=s?new Q(s).transformAsVector(l):l,f=Number.isFinite(n)?Ni({latitude:n}):0,h=Math.pow(2,f),d=new Q().lookAt({eye:[0,0,0],center:u,up:a}).scale(h);super({...e,zoom:f,viewMatrix:d}),this.latitude=n,this.longitude=t,this.pitch=o,this.bearing=i,this.up=a}};Il.displayName="FirstPersonViewport";var Pl=Il;var Sn=20,Gx=500,vo=class extends fr{constructor(e){let{width:t,height:n,position:s=[0,0,0],bearing:i=0,pitch:o=0,longitude:a=null,latitude:c=null,maxPitch:l=90,minPitch:u=-90,startRotatePos:f,startBearing:h,startPitch:d,startZoomPosition:m,startPanPos:y,startPanPosition:_}=e;super({width:t,height:n,position:s,bearing:i,pitch:o,longitude:a,latitude:c,maxPitch:l,minPitch:u},{startRotatePos:f,startBearing:h,startPitch:d,startZoomPosition:m,startPanPos:y,startPanPosition:_}),this.makeViewport=e.makeViewport}panStart({pos:e}){let{position:t}=this.getViewportProps();return this._getUpdatedState({startPanPos:e,startPanPosition:t})}pan({pos:e}){if(!e)return this;let{startPanPos:t=[0,0],startPanPosition:n=[0,0]}=this.getState(),{width:s,height:i,bearing:o,pitch:a}=this.getViewportProps(),c=Gx*(e[0]-t[0])/s,l=Gx*(e[1]-t[1])/i,u=new dt({bearing:o,pitch:a}),f=new dt({bearing:o,pitch:-90}),h=u.toVector3().normalize(),d=f.toVector3().cross(h).normalize();return this._getUpdatedState({position:new G(n).add(d.scale(c)).add(h.scale(l))})}panEnd(){return this._getUpdatedState({startPanPos:null,startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:n=0}){let{startRotatePos:s,startBearing:i,startPitch:o}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!s||i===void 0||o===void 0)return this;let l;if(e){let u=(e[0]-s[0])/a,f=(e[1]-s[1])/c;l={bearing:i-u*180,pitch:o-f*90}}else l={bearing:i-t,pitch:o-n};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startBearing:null,startPitch:null})}zoomStart(){return this._getUpdatedState({startZoomPosition:this.getViewportProps().position})}zoom({pos:e,scale:t}){let n=this.getViewportProps(),s=this.getState().startZoomPosition||n.position,i=this.makeViewport(n),{projectionMatrix:o,width:a}=i,l=2*Math.atan(1/o[0])*(e[0]/a-.5),u=this.getDirection(!0);return this._move(u.rotateZ({radians:-l}),Math.log2(t)*Sn,s)}zoomEnd(){return this._getUpdatedState({startZoomPosition:null})}moveLeft(e=Sn){let t=this.getDirection(!0);return this._move(t.rotateZ({radians:Math.PI/2}),e)}moveRight(e=Sn){let t=this.getDirection(!0);return this._move(t.rotateZ({radians:-Math.PI/2}),e)}moveUp(e=Sn){let t=this.getDirection(!0);return this._move(t,e)}moveDown(e=Sn){let t=this.getDirection(!0);return this._move(t.negate(),e)}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}zoomIn(e=Sn){return this._move(new G(0,0,1),e)}zoomOut(e=Sn){return this._move(new G(0,0,-1),e)}shortestPathFrom(e){let t=e.getViewportProps(),n={...this.getViewportProps()},{bearing:s,longitude:i}=n;return Math.abs(s-t.bearing)>180&&(n.bearing=s<0?s+360:s-360),i!==null&&t.longitude!==null&&Math.abs(i-t.longitude)>180&&(n.longitude=i<0?i+360:i-360),n}_move(e,t,n=this.getViewportProps().position){let s=e.scale(t);return this._getUpdatedState({position:new G(n).add(s)})}getDirection(e=!1){return new dt({bearing:this.getViewportProps().bearing,pitch:e?90:90+this.getViewportProps().pitch}).toVector3().normalize()}_getUpdatedState(e){return new vo({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{pitch:t,maxPitch:n,minPitch:s,longitude:i,bearing:o}=e;return e.pitch=ee(t,s,n),i!==null&&(i<-180||i>180)&&(e.longitude=dn(i+180,360)-180),(o<-180||o>180)&&(e.bearing=dn(o+180,360)-180),e}},En=class extends De{constructor(){super(...arguments),this.ControllerState=vo,this.transition={transitionDuration:300,transitionInterpolator:new Ae(["position","pitch","bearing"])}}};var Cl=class extends Ne{constructor(e={}){super(e)}getViewportType(){return Pl}get ControllerType(){return En}};Cl.displayName="FirstPersonView";var Qx=Cl;var Ao=class extends fr{constructor(e){let{width:t,height:n,rotationX:s=0,rotationOrbit:i=0,target:o=[0,0,0],zoom:a=0,minRotationX:c=-90,maxRotationX:l=90,minZoom:u=-1/0,maxZoom:f=1/0,startPanPosition:h,startRotatePos:d,startRotationX:m,startRotationOrbit:y,startZoomPosition:_,startZoom:x}=e;super({width:t,height:n,rotationX:s,rotationOrbit:i,target:o,zoom:a,minRotationX:c,maxRotationX:l,minZoom:u,maxZoom:f},{startPanPosition:h,startRotatePos:d,startRotationX:m,startRotationOrbit:y,startZoomPosition:_,startZoom:x}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:t}){let n=this.getState().startPanPosition||t;if(!n)return this;let i=this.makeViewport(this.getViewportProps()).panByPosition(n,e);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startRotationX:this.getViewportProps().rotationX,startRotationOrbit:this.getViewportProps().rotationOrbit})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:n=0}){let{startRotatePos:s,startRotationX:i,startRotationOrbit:o}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!s||i===void 0||o===void 0)return this;let l;if(e){let u=(e[0]-s[0])/a,f=(e[1]-s[1])/c;(i<-90||i>90)&&(u*=-1),l={rotationX:i+f*180,rotationOrbit:o+u*180}}else l={rotationX:i+n,rotationOrbit:o+t};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotationX:null,startRotationOrbit:null})}shortestPathFrom(e){let t=e.getViewportProps(),n={...this.getViewportProps()},{rotationOrbit:s}=n;return Math.abs(s-t.rotationOrbit)>180&&(n.rotationOrbit=s<0?s+360:s-360),n}zoomStart({pos:e}){return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:n}){let{startZoom:s,startZoomPosition:i}=this.getState();if(i||(s=this.getViewportProps().zoom,i=this._unproject(t)||this._unproject(e)),!i)return this;let o=this._calculateNewZoom({scale:n,startZoom:s}),a=this.makeViewport({...this.getViewportProps(),zoom:o});return this._getUpdatedState({zoom:o,...a.panByPosition(i,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:e})})}zoomOut(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:1/e})})}moveLeft(e=50){return this._panFromCenter([-e,0])}moveRight(e=50){return this._panFromCenter([e,0])}moveUp(e=50){return this._panFromCenter([0,-e])}moveDown(e=50){return this._panFromCenter([0,e])}rotateLeft(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit-e})}rotateRight(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit+e})}rotateUp(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX-e})}rotateDown(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX+e})}_unproject(e){let t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_calculateNewZoom({scale:e,startZoom:t}){let{maxZoom:n,minZoom:s}=this.getViewportProps();t===void 0&&(t=this.getViewportProps().zoom);let i=t+Math.log2(e);return ee(i,s,n)}_panFromCenter(e){let{width:t,height:n,target:s}=this.getViewportProps();return this.pan({startPosition:s,pos:[t/2+e[0],n/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{maxZoom:t,minZoom:n,zoom:s,maxRotationX:i,minRotationX:o,rotationOrbit:a}=e;return e.zoom=Array.isArray(s)?[ee(s[0],n,t),ee(s[1],n,t)]:ee(s,n,t),e.rotationX=ee(e.rotationX,o,i),(a<-180||a>180)&&(e.rotationOrbit=dn(a+180,360)-180),e}},Rn=class extends De{constructor(){super(...arguments),this.ControllerState=Ao,this.transition={transitionDuration:300,transitionInterpolator:new Ae({transitionProps:{compare:["target","zoom","rotationX","rotationOrbit"],required:["target","zoom"]}})}}};var Ml=class extends Ne{constructor(e={}){super(e),this.props.orbitAxis=e.orbitAxis||"Z"}getViewportType(){return Sl}get ControllerType(){return Rn}};Ml.displayName="OrbitView";var Jx=Ml;var Ed=class extends Ao{constructor(e){super(e),this.zoomAxis=e.zoomAxis||"all"}_calculateNewZoom({scale:e,startZoom:t}){let{maxZoom:n,minZoom:s}=this.getViewportProps();t===void 0&&(t=this.getViewportProps().zoom);let i=Math.log2(e);if(Array.isArray(t)){let[o,a]=t;switch(this.zoomAxis){case"X":o=ee(o+i,s,n);break;case"Y":a=ee(a+i,s,n);break;default:let c=Math.min(o+i,a+i);c<s&&(i+=s-c),c=Math.max(o+i,a+i),c>n&&(i+=n-c),o+=i,a+=i}return[o,a]}return ee(t+i,s,n)}},In=class extends De{constructor(){super(...arguments),this.ControllerState=Ed,this.transition={transitionDuration:300,transitionInterpolator:new Ae(["target","zoom"])},this.dragMode="pan"}_onPanRotate(){return!1}};var Ol=class extends Ne{constructor(e={}){super(e)}getViewportType(){return Rl}get ControllerType(){return In}};Ol.displayName="OrthographicView";var eb=Ol;var Rd=class extends qi{constructor(e){let{startPanPos:t,...n}=e;super(n),t!==void 0&&(this._state.startPanPos=t)}panStart({pos:e}){let{latitude:t,longitude:n,zoom:s}=this.getViewportProps();return this._getUpdatedState({startPanLngLat:[n,t],startPanPos:e,startZoom:s})}pan({pos:e,startPos:t}){let n=this.getState(),s=n.startPanLngLat||this._unproject(t);if(!s)return this;let i=n.startZoom??this.getViewportProps().zoom,o=n.startPanPos||t,a=[s[0],s[1],i],l=this.makeViewport(this.getViewportProps()).panByPosition(a,e,o);return this._getUpdatedState(l)}panEnd(){return this._getUpdatedState({startPanLngLat:null,startPanPos:null,startZoom:null})}zoom({scale:e}){let n=(this.getState().startZoom||this.getViewportProps().zoom)+Math.log2(e);return this._getUpdatedState({zoom:n})}applyConstraints(e){let{longitude:t,latitude:n,maxZoom:s,minZoom:i,zoom:o}=e,a=_n(0),c=_n(n)-a;return e.zoom=ee(o,i+c,s+c),(t<-180||t>180)&&(e.longitude=dn(t+180,360)-180),e.latitude=ee(n,-We,We),e}},Pn=class extends De{constructor(){super(...arguments),this.ControllerState=Rd,this.transition={transitionDuration:300,transitionInterpolator:new Ae(["longitude","latitude","zoom"])},this.dragMode="pan"}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}};var kl=class extends Ne{constructor(e={}){super(e)}getViewportType(e){return e.zoom>12?kr:gs}get ControllerType(){return Pn}};kl.displayName="GlobeView";var tb=kl;var So=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&le(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:t}=e.constructor,n={updateTriggers:{}};for(let s in t)if(s in this.props){let i=t[s],o=this.props[s];n[s]=o,i&&i.type==="accessor"&&(n.updateTriggers[s]=this.props.updateTriggers[s],typeof o=="function"&&(n[s]=this.getSubLayerAccessor(o)))}return n}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}};So.defaultProps={};So.extensionName="LayerExtension";var rb=So;var Id={bearing:0,pitch:0,position:[0,0,0]},HE={speed:1.2,curve:1.414},Eo=class extends lr{constructor(e={}){super({compare:["longitude","latitude","zoom","bearing","pitch","position"],extract:["width","height","longitude","latitude","zoom","bearing","pitch","position"],required:["width","height","latitude","longitude","zoom"]}),this.opts={...HE,...e}}interpolateProps(e,t,n){let s=Bh(e,t,n,this.opts);for(let i in Id)s[i]=Jt(e[i]||Id[i],t[i]||Id[i],n);return s}getDuration(e,t){let{transitionDuration:n}=t;return n==="auto"&&(n=Lh(e,t,this.opts)),n}};H();var Ro=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:t={}}=e;this.typedArrayManager=bt,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:t,buffers:n={},getGeometry:s,geometryBuffer:i,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=t,this.getGeometry=s,this.positionSize=i&&i.size||(o==="XY"?2:3),this.buffers=n,this.normalize=c,i&&(ie(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(i),c||(n.vertexPositions=i)),this.geometryBuffer=n.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){let t=e.value||e;return ArrayBuffer.isView(t)?hl(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){let{attributes:n,buffers:s,_attributeDefs:i,typedArrayManager:o}=this;for(let a in i)if(a in s)o.release(n[a]),n[a]=null;else{let c=i[a];c.copy=t,n[a]=o.allocate(n[a],e,c)}}_forEachGeometry(e,t,n){let{data:s,getGeometry:i}=this,{iterable:o,objectInfo:a}=vs(s,t,n);for(let c of o){a.index++;let l=i?i(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:n,instanceCount:s}=this,{data:i,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(t=[0],n=[0]),this.normalize||!o)this._forEachGeometry((f,h)=>{let d=f&&this.normalizeGeometry(f);l[h]=d,n[h+1]=n[h]+(d?this.getGeometrySize(d):0)},a,c),s=n[n.length-1];else if(n=i.startIndices,s=n[i.length]||0,ArrayBuffer.isView(o))s=s||o.length/this.positionSize;else if(o instanceof W){let f=this.positionSize*4;s=s||o.byteLength/f}else if(o.buffer){let f=o.stride||this.positionSize*4;s=s||o.buffer.byteLength/f}else if(o.value){let f=o.value,h=o.stride/f.BYTES_PER_ELEMENT||this.positionSize;s=s||f.length/h}this._allocate(s,Boolean(e)),this.indexStarts=t,this.vertexStarts=n,this.instanceCount=s;let u={};this._forEachGeometry((f,h)=>{let d=l[h]||f;u.vertexStart=n[h],u.indexStart=t[h];let m=h<n.length-1?n[h+1]:s;u.geometrySize=m-n[h],u.geometryIndex=h,this.updateGeometryAttributes(d,u)},a,c),this.vertexCount=t[t.length-1]}};var Nl=class{constructor(e){this.map=null,this.width=0,this.height=0,this.props={...e},this._initialize(this.props)}finalize(){this.map?.remove(),this.map=null}setProps(e){let t=this.props,n={...this.props,...e};if(this.props=n,!this.map)return;this._update(t,n)&&this.redraw()}redraw(){let e=this.map;e.style&&(e._frame&&(e._frame.cancel(),e._frame=null),e._render())}getMap(){return this.map}_initialize(e){let{mapLib:t,container:n}=e;t.accessToken=e.mapboxApiAccessToken||"",this.map=new e.mapLib.Map({container:n,maxZoom:24,...e.mapOptions,...nb(e.viewState),style:e.mapStyle,interactive:!1,trackResize:!1}),Object.defineProperty(n,"offsetWidth",{get:()=>this.width}),Object.defineProperty(n,"clientWidth",{get:()=>this.width}),Object.defineProperty(n,"offsetHeight",{get:()=>this.height}),Object.defineProperty(n,"clientHeight",{get:()=>this.height}),this.map.resize()}_update(e,t){e.mapStyle!==t.mapStyle&&this.map.setStyle(t.mapStyle);let s=e.width!==t.width||e.height!==t.height;s&&(this.width=t.width,this.height=t.height,this.map.resize());let i=e.viewState,o=t.viewState,a=o.latitude!==i.latitude||o.longitude!==i.longitude||o.zoom!==i.zoom||o.pitch!==i.pitch||o.bearing!==i.bearing;return a&&this.map.jumpTo(nb(o)),s||a}};function nb(r){return{center:[r.longitude,r.latitude],zoom:r.zoom,bearing:r.bearing??0,pitch:r.pitch??0}}var sb={position:"absolute",left:0,top:0,width:"100%",height:"100%"};function XE(r){let{container:e=document.body}=r;if(typeof e=="string"&&(e=document.getElementById(e)),!e)throw Error("Deck: container not found");window.getComputedStyle(e).position==="static"&&(e.style.position="relative");let n=document.createElement("div");e.appendChild(n),Object.assign(n.style,sb);let s=document.createElement("canvas");return e.appendChild(s),Object.assign(s.style,sb),{container:e,mapCanvas:n,deckCanvas:s}}var Io=class extends ul{constructor(e){if(typeof document>"u")throw Error("Deck can only be used in the browser");let{mapCanvas:t,deckCanvas:n}=XE(e),s=e.viewState||e.initialViewState,i=Number.isFinite(s&&s.latitude),{map:o=globalThis.mapboxgl||globalThis.maplibregl}=e;super({canvas:n,...e}),o&&o.Map?this._map=i&&new Nl({...e,width:0,height:0,viewState:s,container:t,mapLib:o}):this._map=o}getMapboxMap(){return this._map&&this._map.getMap()}finalize(){this._map&&this._map.finalize(),super.finalize()}setProps(e){"mapStyle"in e&&this._map&&this._map.setProps({mapStyle:e.mapStyle}),super.setProps(e)}_drawLayers(e,t){if(this._map){let n=this.getViewports()[0];n&&this._map.setProps({width:n.width,height:n.height,viewState:n})}super._drawLayers(e,t)}};globalThis.luma=globalThis.luma||{};globalThis.loaders=globalThis.loaders||{};Object.assign(globalThis.luma,Uf);Object.assign(globalThis.loaders,hh);return ub(YE);})();
1670
+ }`;function hE(r,e){let t=xl(e.size),n=bl(e.size);return new ht(r,{vs:uE,fs:fE,bufferLayout:[{name:"aPrev",format:n},{name:"aCur",format:n},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[lE],defines:{ATTRIBUTE_TYPE:t},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function dE(r){return r.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function pE(r,e){return r.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var mE={interpolation:mo,spring:go},_o=class{constructor(e,{id:t,timeline:n}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=t,this.device=e,this.timeline=n,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:n}){this.numInstances=n||1;for(let s in e){let i=e[s],o=i.getTransitionSetting(t);o&&this._updateAttribute(s,i,o)}for(let s in this.transitions){let i=e[s];(!i||!i.getTransitionSetting(t))&&this._removeTransition(s)}}hasAttribute(e){let t=this.transitions[e];return t&&t.inProgress}getAttributes(){let e={};for(let t in this.transitions){let n=this.transitions[t];n.inProgress&&(e[t]=n.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let t in this.transitions)this.transitions[t].update()&&(this.needsRedraw=!0);let e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,t,n){let s=this.transitions[e],i=!s||s.type!==n.type;if(i){s&&this._removeTransition(e);let o=mE[n.type];o?this.transitions[e]=new o({attribute:t,timeline:this.timeline,device:this.device}):($.error(`unsupported transition type '${n.type}'`)(),i=!1)}(i||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(n,this.numInstances))}};var qx="attributeManager.invalidate",gE="attributeManager.updateStart",_E="attributeManager.updateEnd",yE="attribute.updateStart",xE="attribute.allocate",bE="attribute.updateEnd",Sn=class{constructor(e,{id:t="attribute-manager",stats:n,timeline:s}={}){this.mergeBoundsMemoized=st(J_),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=n,this.attributeTransitionManager=new _o(e,{id:`${t}-transitions`,timeline:s}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let t of e)this.attributes[t]!==void 0&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){let n=this._invalidateTrigger(e,t);he(qx,this,e,n)}invalidateAll(e){for(let t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);he(qx,this,"all")}update({data:e,numInstances:t,startIndices:n=null,transitions:s,props:i={},buffers:o={},context:a={}}){let c=!1;he(gE,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let u=this.attributes[l],f=u.settings.accessor;u.startIndices=n,u.numInstances=t,i[l]&&$.removed(`props.${l}`,`data.attributes.${l}`)(),u.setExternalBuffer(o[l])||u.setBinaryValue(typeof f=="string"?o[f]:void 0,e.startIndices)||typeof f=="string"&&!o[f]&&u.setConstantValue(a,i[f])||u.needsUpdate()&&(c=!0,this._updateAttribute({attribute:u,numInstances:t,data:e,props:i,context:a})),this.needsRedraw=this.needsRedraw||u.needsRedraw()}c&&he(_E,this,t),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:s})}updateTransition(){let{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let t=e.map(n=>this.attributes[n]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:t,attributeTransitionManager:n}=this,s={...n.getAttributes()};for(let i in t){let o=t[i];o.needsRedraw(e)&&!n.hasAttribute(i)&&(s[i]=o)}return s}getBufferLayouts(e){return Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}_add(e,t){for(let n in e){let s=e[n],i={...s,id:n,size:s.isIndexed&&1||s.size||1,...t};this.attributes[n]=new fr(this.device,i)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let t in this.attributes)this.attributes[t].getUpdateTriggers().forEach(s=>{e[s]||(e[s]=[]),e[s].push(t)});this.updateTriggers=e}_invalidateTrigger(e,t){let{attributes:n,updateTriggers:s}=this,i=s[e];return i&&i.forEach(o=>{let a=n[o];a&&a.setNeedsUpdate(a.id,t)}),i}_updateAttribute(e){let{attribute:t,numInstances:n}=e;if(he(yE,t),t.constant){t.setConstantValue(e.context,t.value);return}t.allocate(n)&&he(xE,t,n),t.updateBuffer(e)&&(this.needsRedraw=!0,he(bE,t,n))}};H();fl();var yo=class extends bt{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:t,toValue:n,duration:s,easing:i}}=this,o=i(e/s);this._value=Qt(t,n,o)}};var Kx=1e-5;function Zx(r,e,t,n,s){let i=e-r,a=(t-e)*s,c=-i*n;return a+c+i+e}function TE(r,e,t,n,s){if(Array.isArray(t)){let i=[];for(let o=0;o<t.length;o++)i[o]=Zx(r[o],e[o],t[o],n,s);return i}return Zx(r,e,t,n,s)}function Gx(r,e){if(Array.isArray(r)){let t=0;for(let n=0;n<r.length;n++){let s=r[n]-e[n];t+=s*s}return Math.sqrt(t)}return Math.abs(r-e)}var xo=class extends bt{get value(){return this._currValue}_onUpdate(){let{fromValue:e,toValue:t,damping:n,stiffness:s}=this.settings,{_prevValue:i=e,_currValue:o=e}=this,a=TE(i,o,t,n,s),c=Gx(a,t),l=Gx(a,o);c<Kx&&l<Kx&&(a=t,this.end()),this._prevValue=o,this._currValue=a}};var wE={interpolation:yo,spring:xo},bo=class{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,t,n,s){let{transitions:i}=this;if(i.has(e)){let c=i.get(e),{value:l=c.settings.fromValue}=c;t=l,this.remove(e)}if(s=yl(s),!s)return;let o=wE[s.type];if(!o){$.error(`unsupported transition type '${s.type}'`)();return}let a=new o(this.timeline);a.start({...s,fromValue:t,toValue:n}),i.set(e,a)}remove(e){let{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){let e={};for(let[t,n]of this.transitions)n.update(),e[t]=n.value,n.inProgress||this.remove(t);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function Jx(r){let e=r[at];for(let t in e){let n=e[t],{validate:s}=n;if(s&&!s(r[t],n))throw new Error(`Invalid prop ${t}: ${r[t]}`)}}function eb(r,e){let t=Al({newProps:r,oldProps:e,propTypes:r[at],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),n=AE(r,e),s=!1;return n||(s=SE(r,e)),{dataChanged:n,propsChanged:t,updateTriggersChanged:s,extensionsChanged:EE(r,e),transitionsChanged:vE(r,e)}}function vE(r,e){if(!r.transitions)return!1;let t={},n=r[at],s=!1;for(let i in r.transitions){let o=n[i],a=o&&o.type;(a==="number"||a==="color"||a==="array")&&Id(r[i],e[i],o)&&(t[i]=!0,s=!0)}return s?t:!1}function Al({newProps:r,oldProps:e,ignoreProps:t={},propTypes:n={},triggerName:s="props"}){if(e===r)return!1;if(typeof r!="object"||r===null)return`${s} changed shallowly`;if(typeof e!="object"||e===null)return`${s} changed shallowly`;for(let i of Object.keys(r))if(!(i in t)){if(!(i in e))return`${s}.${i} added`;let o=Id(r[i],e[i],n[i]);if(o)return`${s}.${i} ${o}`}for(let i of Object.keys(e))if(!(i in t)){if(!(i in r))return`${s}.${i} dropped`;if(!Object.hasOwnProperty.call(r,i)){let o=Id(r[i],e[i],n[i]);if(o)return`${s}.${i} ${o}`}}return!1}function Id(r,e,t){let n=t&&t.equal;return n&&!n(r,e,t)||!n&&(n=r&&e&&r.equals,n&&!n.call(r,e))?"changed deeply":!n&&e!==r?"changed shallowly":null}function AE(r,e){if(e===null)return"oldProps is null, initial diff";let t=!1,{dataComparator:n,_dataDiff:s}=r;return n?n(r.data,e.data)||(t="Data comparator detected a change"):r.data!==e.data&&(t="A new data container was supplied"),t&&s&&(t=s(r.data,e.data)||t),t}function SE(r,e){if(e===null)return{all:!0};if("all"in r.updateTriggers&&Qx(r,e,"all"))return{all:!0};let t={},n=!1;for(let s in r.updateTriggers)s!=="all"&&Qx(r,e,s)&&(t[s]=!0,n=!0);return n?t:!1}function EE(r,e){if(e===null)return!0;let t=e.extensions,{extensions:n}=r;if(n===t)return!1;if(!t||!n||n.length!==t.length)return!0;for(let s=0;s<n.length;s++)if(!n[s].equals(t[s]))return!0;return!1}function Qx(r,e,t){let n=r.updateTriggers[t];n=n??{};let s=e.updateTriggers[t];return s=s??{},Al({oldProps:s,newProps:n,triggerName:t})}var RE="count(): argument not an object",IE="count(): argument not a container";function Sl(r){if(!CE(r))throw new Error(RE);if(typeof r.count=="function")return r.count();if(Number.isFinite(r.size))return r.size;if(Number.isFinite(r.length))return r.length;if(PE(r))return Object.keys(r).length;throw new Error(IE)}function PE(r){return r!==null&&typeof r=="object"&&r.constructor===Object}function CE(r){return r!==null&&typeof r=="object"}function To(r,e){if(!e)return r;let t={...r,...e};if("defines"in e&&(t.defines={...r.defines,...e.defines}),"modules"in e&&(t.modules=(r.modules||[]).concat(e.modules),e.modules.some(n=>n.name==="project64"))){let n=t.modules.findIndex(s=>s.name==="project32");n>=0&&t.modules.splice(n,1)}if("inject"in e)if(!r.inject)t.inject=e.inject;else{let n={...r.inject};for(let s in e.inject)n[s]=(n[s]||"")+e.inject[s];t.inject=n}return t}H();var ME={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},Pd={};function tb(r,e,t,n){if(t instanceof K)return t;t.constructor&&t.constructor.name!=="Object"&&(t={data:t});let s=null;t.compressed&&(s={minFilter:"linear",mipmapFilter:t.data.length>1?"nearest":"linear"});let{width:i,height:o}=t.data,a=e.createTexture({...t,sampler:{...ME,...s,...n},mipLevels:e.getMipLevelCount(i,o)});return a.generateMipmapsWebGL(),Pd[a.id]=r,a}function rb(r,e){!e||!(e instanceof K)||Pd[e.id]===r&&(e.delete(),delete Pd[e.id])}var OE={boolean:{validate(r,e){return!0},equal(r,e,t){return Boolean(r)===Boolean(e)}},number:{validate(r,e){return Number.isFinite(r)&&(!("max"in e)||r<=e.max)&&(!("min"in e)||r>=e.min)}},color:{validate(r,e){return e.optional&&!r||Cd(r)&&(r.length===3||r.length===4)},equal(r,e,t){return le(r,e,1)}},accessor:{validate(r,e){let t=El(r);return t==="function"||t===El(e.value)},equal(r,e,t){return typeof e=="function"?!0:le(r,e,1)}},array:{validate(r,e){return e.optional&&!r||Cd(r)},equal(r,e,t){let{compare:n}=t,s=Number.isInteger(n)?n:n?1:0;return n?le(r,e,s):r===e}},object:{equal(r,e,t){if(t.ignore)return!0;let{compare:n}=t,s=Number.isInteger(n)?n:n?1:0;return n?le(r,e,s):r===e}},function:{validate(r,e){return e.optional&&!r||typeof r=="function"},equal(r,e,t){return!t.compare&&t.ignore!==!1||r===e}},data:{transform:(r,e,t)=>{if(!r)return r;let{dataTransform:n}=t.props;return n?n(r):typeof r.shape=="string"&&r.shape.endsWith("-table")&&Array.isArray(r.data)?r.data:r}},image:{transform:(r,e,t)=>{let n=t.context;return!n||!n.device?null:tb(t.id,n.device,r,{...e.parameters,...t.props.textureParameters})},release:(r,e,t)=>{rb(t.id,r)}}};function nb(r){let e={},t={},n={};for(let[s,i]of Object.entries(r)){let o=i?.deprecatedFor;if(o)n[s]=Array.isArray(o)?o:[o];else{let a=kE(s,i);e[s]=a,t[s]=a.value}}return{propTypes:e,defaultProps:t,deprecatedProps:n}}function kE(r,e){switch(El(e)){case"object":return wo(r,e);case"array":return wo(r,{type:"array",value:e,compare:!1});case"boolean":return wo(r,{type:"boolean",value:e});case"number":return wo(r,{type:"number",value:e});case"function":return wo(r,{type:"function",value:e,compare:!0});default:return{name:r,type:"unknown",value:e}}}function wo(r,e){return"type"in e?{name:r,...OE[e.type],...e}:"value"in e?{name:r,type:El(e.value),...e}:{name:r,type:"object",value:e}}function Cd(r){return Array.isArray(r)||ArrayBuffer.isView(r)}function El(r){return Cd(r)?"array":r===null?"null":typeof r}function sb(r,e){let t;for(let i=e.length-1;i>=0;i--){let o=e[i];"extensions"in o&&(t=o.extensions)}let n=Md(r.constructor,t),s=Object.create(n);s[_s]=r,s[Dt]={},s[xt]={};for(let i=0;i<e.length;++i){let o=e[i];for(let a in o)s[a]=o[a]}return Object.freeze(s),s}var NE="_mergedDefaultProps";function Md(r,e){if(!(r instanceof Is.constructor))return{};let t=NE;if(e)for(let s of e){let i=s.constructor;i&&(t+=`:${i.extensionName||i.name}`)}let n=ib(r,t);return n||(r[t]=DE(r,e||[]))}function DE(r,e){if(!r.prototype)return null;let n=Object.getPrototypeOf(r),s=Md(n),i=ib(r,"defaultProps")||{},o=nb(i),a=Object.assign(Object.create(null),s,o.defaultProps),c=Object.assign(Object.create(null),s?.[at],o.propTypes),l=Object.assign(Object.create(null),s?.[Cc],o.deprecatedProps);for(let u of e){let f=Md(u.constructor);f&&(Object.assign(a,f),Object.assign(c,f[at]),Object.assign(l,f[Cc]))}return FE(a,r),LE(a,c),BE(a,l),a[at]=c,a[Cc]=l,e.length===0&&!Od(r,"_propTypes")&&(r._propTypes=c),a}function FE(r,e){let t=VE(e);Object.defineProperties(r,{id:{writable:!0,value:t}})}function BE(r,e){for(let t in e)Object.defineProperty(r,t,{enumerable:!1,set(n){let s=`${this.id}: ${t}`;for(let i of e[t])Od(this,i)||(this[i]=n);$.deprecated(s,e[t].join("/"))()}})}function LE(r,e){let t={},n={};for(let s in e){let i=e[s],{name:o,value:a}=i;i.async&&(t[o]=a,n[o]=UE(o))}r[ir]=t,r[Dt]={},Object.defineProperties(r,n)}function UE(r){return{enumerable:!0,set(e){typeof e=="string"||e instanceof Promise||gl(e)?this[Dt][r]=e:this[xt][r]=e},get(){if(this[xt]){if(r in this[xt])return this[xt][r]||this[ir][r];if(r in this[Dt]){let e=this[_s]&&this[_s].internalState;if(e&&e.hasAsyncProp(r))return e.getAsyncProp(r)||this[ir][r]}}return this[ir][r]}}}function Od(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function ib(r,e){return Od(r,e)&&r[e]}function VE(r){let e=r.componentName;return e||$.warn(`${r.name}.componentName not specified`)(),e||r.name}var zE=0,vo=class{constructor(...e){this.props=sb(this,e),this.id=this.props.id,this.count=zE++}clone(e){let{props:t}=this,n={};for(let s in t[ir])s in t[xt]?n[s]=t[xt][s]:s in t[Dt]&&(n[s]=t[Dt][s]);return new this.constructor({...t,...n,...e})}};vo.componentName="Component";vo.defaultProps={};var Is=vo;var WE=Object.freeze({}),En=class{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||WE}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){let t=this.asyncProps[e];return Boolean(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(let t in this.asyncProps)if(this.isAsyncPropLoading(t))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[_s]||this.component;let t=e[xt]||{},n=e[Dt]||e,s=e[ir]||{};for(let i in t){let o=t[i];this._createAsyncPropData(i,s[i]),this._updateAsyncProp(i,o),t[i]=this.getAsyncProp(i)}for(let i in n){let o=n[i];this._createAsyncPropData(i,s[i]),this._updateAsyncProp(i,o)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){if(this._didAsyncInputValueChange(e,t)){if(typeof t=="string"&&(t=this._fetch(e,t)),t instanceof Promise){this._watchPromise(e,t);return}if(gl(t)){this._resolveAsyncIterable(e,t);return}this._setPropValue(e,t)}}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(let e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){let n=this.asyncProps[e];return t===n.resolvedValue||t===n.lastValue?!1:(n.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();let n=this.asyncProps[e];n&&(t=this._postProcessValue(n,t),n.resolvedValue=t,n.pendingLoadCount++,n.resolvedLoadCount=n.pendingLoadCount)}_setAsyncPropValue(e,t,n){let s=this.asyncProps[e];s&&n>=s.resolvedLoadCount&&t!==void 0&&(this._freezeAsyncOldProps(),s.resolvedValue=t,s.resolvedLoadCount=n,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){let n=this.asyncProps[e];if(n){n.pendingLoadCount++;let s=n.pendingLoadCount;t.then(i=>{this.component&&(i=this._postProcessValue(n,i),this._setAsyncPropValue(e,i,s),this._onResolve(e,i))}).catch(i=>{this._onError(e,i)})}}async _resolveAsyncIterable(e,t){if(e!=="data"){this._setPropValue(e,t);return}let n=this.asyncProps[e];if(!n)return;n.pendingLoadCount++;let s=n.pendingLoadCount,i=[],o=0;for await(let a of t){if(!this.component)return;let{dataTransform:c}=this.component.props;c?i=c(a,i):i=i.concat(a),Object.defineProperty(i,"__diff",{enumerable:!1,value:[{startRow:o,endRow:i.length}]}),o=i.length,this._setAsyncPropValue(e,i,s)}this._onResolve(e,i)}_postProcessValue(e,t){let n=e.type;return n&&this.component&&(n.release&&n.release(e.resolvedValue,n,this.component),n.transform)?n.transform(t,n,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){let s=this.component&&this.component.props[at];this.asyncProps[e]={type:s&&s[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}};var Ao=class extends En{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,t){let n=this.layer,s=n?.props.fetch;return s?s(t,{propName:e,layer:n}):super._fetch(e,t)}_onResolve(e,t){let n=this.layer;if(n){let s=n.props.onDataLoad;e==="data"&&s&&s(t,{propName:e,layer:n})}}_onError(e,t){let n=this.layer;n&&n.raiseError(t,`loading ${e} of ${this.layer}`)}};var $E="layer.changeFlag",jE="layer.initialize",HE="layer.update",XE="layer.finalize",YE="layer.matched",ob=2**24-1,qE=Object.freeze([]),KE=st(({oldViewport:r,viewport:e})=>r.equals(e)),At=new Uint8ClampedArray(0),ZE={data:{type:"data",value:qE,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:r=>r&&r.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(r,{propName:e,layer:t,loaders:n,loadOptions:s,signal:i})=>{let{resourceManager:o}=t.context;s=s||t.getLoadOptions(),n=n||t.props.loaders,i&&(s={...s,fetch:{...s?.fetch,signal:i}});let a=o.contains(r);return!a&&!s&&(o.add({resourceId:r,data:Er(r,n),persistent:!1}),a=!0),a?o.subscribe({resourceId:r,onChange:c=>t.internalState?.reloadAsyncProp(e,c),consumerId:t.id,requestId:e}):Er(r,n,s)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:Y.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:r})=>[0,-r*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},So=class extends Is{constructor(){super(...arguments),this.internalState=null,this.lifecycle=kr.NO_STATE,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){ie(this.internalState);let t=this.internalState.viewport||this.context.viewport,n=Gh(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[s,i,o]=us(n,t.pixelProjectionMatrix);return e.length===2?[s,i]:[s,i,o]}unproject(e){return ie(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){ie(this.internalState);let n=this.internalState.viewport||this.context.viewport;return Rc(e,{viewport:n,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}get isDrawable(){return!0}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return this.internalState?!this.internalState.isAsyncPropLoading():!1}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){let e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setShaderModuleProps(...e){for(let t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){let{coordinateSystem:e}=this.props;return e===Y.DEFAULT||e===Y.LNGLAT||e===Y.CARTESIAN}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){ie(e instanceof Uint8Array);let[t,n,s]=e;return t+n*256+s*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:Sl(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=To(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let t of this.props.extensions)e=To(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let t=this.getAttributeManager(),{dataChanged:n}=e.changeFlags;if(n&&t)if(Array.isArray(n))for(let s of n)t.invalidateAll(s);else t.invalidateAll();if(t){let{props:s}=e,i=this.internalState.hasPickingBuffer,o=Number.isInteger(s.highlightedObjectIndex)||Boolean(s.pickable)||s.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(i!==o){this.internalState.hasPickingBuffer=o;let{pickingColors:a,instancePickingColors:c}=t.attributes,l=a||c;l&&(o&&l.constant&&(l.constant=!1,t.invalidate(l.id)),!l.value&&!o&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(e){for(let n of this.getModels())n.destroy();let t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let t of this.getModels())t.draw(e.renderPass)}getPickingInfo({info:e,mode:t,sourceLayer:n}){let{index:s}=e;return s>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[s]),e}raiseError(e,t){t&&(e=new Error(`${t}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return this.internalState?this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()):!1}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;let t=this.internalState.viewport;this.internalState.viewport=e,(!t||!KE({oldViewport:t,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let t=this.getAttributeManager();t&&(e==="all"?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(let n in e)e[n].layoutChanged()&&(t=!0);for(let n of this.getModels())this._setModelAttributes(n,e,t)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let t=this.props,n=this.getNumInstances(),s=this.getStartIndices();e.update({data:t.data,numInstances:n,startIndices:s,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});let i=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(i)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let t=e.update(),n=Object.create(this.props);for(let s in t)Object.defineProperty(n,s,{value:t[s]});return n}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;let n=Math.floor(At.length/4);if(this.internalState.usesPickingColorCache=!0,n<t){t>ob&&$.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),At=yt.allocate(At,t,{size:4,copy:!0,maxCount:Math.max(t,ob)});let s=Math.floor(At.length/4),i=[0,0,0];for(let o=n;o<s;o++)this.encodePickingColor(o,i),At[o*4+0]=i[0],At[o*4+1]=i[1],At[o*4+2]=i[2],At[o*4+3]=0}e.value=At.subarray(0,t*4)}_setModelAttributes(e,t,n=!1){if(!Object.keys(t).length)return;if(n){let a=this.getAttributeManager();e.setBufferLayout(a.getBufferLayouts(e)),t=a.getAttributes()}let s=e.userData?.excludeAttributes||{},i={},o={};for(let a in t){if(s[a])continue;let c=t[a].getValue();for(let l in c){let u=c[l];u instanceof W?t[a].settings.isIndexed?e.setIndexBuffer(u):i[l]=u:u&&(o[l]=u)}}e.setAttributes(i),e.setConstantAttributes(o)}disablePickingIndex(e){let t=this.props.data;if(!("attributes"in t)){this._disablePickingIndex(e);return}let{pickingColors:n,instancePickingColors:s}=this.getAttributeManager().attributes,i=n||s,o=i&&t.attributes&&t.attributes[i.id];if(o&&o.value){let a=o.value,c=this.encodePickingColor(e);for(let l=0;l<t.length;l++){let u=i.getVertexOffset(l);a[u]===c[0]&&a[u+1]===c[1]&&a[u+2]===c[2]&&this._disablePickingIndex(l)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){let{pickingColors:t,instancePickingColors:n}=this.getAttributeManager().attributes,s=t||n;if(!s)return;let i=s.getVertexOffset(e),o=s.getVertexOffset(e+1);s.buffer.write(new Uint8Array(o-i),i)}restorePickingColors(){let{pickingColors:e,instancePickingColors:t}=this.getAttributeManager().attributes,n=e||t;n&&(this.internalState.usesPickingColorCache&&n.value.buffer!==At.buffer&&(n.value=At.subarray(0,n.value.length)),n.updateSubBuffer({startOffset:0}))}_initialize(){ie(!this.internalState),ie(Number.isFinite(this.props.coordinateSystem)),he(jE,this);let e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new Ao({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>($.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new bo(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let t of this.props.extensions)t.initializeState.call(this,this.context,t);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){he(YE,this,this===e);let{state:t,internalState:n}=e;this!==e&&(this.internalState=n,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(he(HE,this,e),!e)return;let t=this.props,n=this.context,s=this.internalState,i=n.viewport,o=this._updateUniformTransition();s.propsInTransition=o,n.viewport=s.viewport||i,this.props=o;try{let a=this._getUpdateParams(),c=this.getModels();if(n.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let u of this.props.extensions)u.updateState.call(this,a,u);this.setNeedsRedraw(),this._updateAttributes();let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{n.viewport=i,this.props=t,this._clearChangeFlags(),s.needsUpdate=!1,s.resetOldProps()}}_finalize(){he(XE,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:t=null,uniforms:n={},parameters:s={}}){this._updateAttributeTransition();let i=this.props,o=this.context;this.props=this.internalState.propsInTransition||i;try{t&&this.setShaderModuleProps(t);let{getPolygonOffset:a}=this.props,c=a&&a(n)||[0,0];o.device instanceof An&&o.device.setParametersWebGL({polygonOffset:c});for(let l of this.getModels())l.device.type==="webgpu"?l.setParameters({...l.parameters,...s}):l.setParameters(s);if(o.device instanceof An)o.device.withParametersWebGL(s,()=>{let l={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:s,context:o};for(let u of this.props.extensions)u.draw.call(this,l,u);this.draw(l)});else{let l={renderPass:e,shaderModuleProps:t,uniforms:n,parameters:s,context:o};for(let u of this.props.extensions)u.draw.call(this,l,u);this.draw(l)}}finally{this.props=i}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:t}=this.internalState;for(let s in e)if(e[s]){let i=!1;switch(s){case"dataChanged":let o=e[s],a=t[s];o&&Array.isArray(a)&&(t.dataChanged=Array.isArray(o)?a.concat(o):o,i=!0);default:t[s]||(t[s]=e[s],i=!0)}i&&he($E,this,s,e)}let n=Boolean(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=n,t.somethingChanged=n||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){let n=eb(e,t);if(n.updateTriggersChanged)for(let s in n.updateTriggersChanged)n.updateTriggersChanged[s]&&this.invalidateAttribute(s);if(n.transitionsChanged)for(let s in n.transitionsChanged)this.internalState.uniformTransitions.add(s,t[s],e[s],e.transitions?.[s]);return this.setChangeFlags(n)}validateProps(){Jx(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:n}=this.props;e.picked&&typeof n=="function"&&(t.highlightColor=n(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new Sn(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){let{props:n,oldProps:s}=e,i=this.state.model;i?.isInstanced&&i.setInstanceCount(this.getNumInstances());let{autoHighlight:o,highlightedObjectIndex:a,highlightColor:c}=n;if(t||s.autoHighlight!==o||s.highlightedObjectIndex!==a||s.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(t||s.autoHighlight!==o||a!==s.highlightedObjectIndex)&&(l.highlightedObjectColor=Number.isFinite(a)&&a>=0?this.encodePickingColor(a):null),this.setShaderModuleProps({picking:l})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t=t||this.internalState.needsRedraw&&this.id;let n=this.getAttributeManager(),s=n?n.getNeedsRedraw(e):!1;if(t=t||s,t)for(let i of this.props.extensions)i.onNeedsRedraw.call(this,i);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};So.defaultProps=ZE;So.layerName="Layer";var Rl=So;var GE="compositeLayer.renderLayers",Il=class extends Rl{get isComposite(){return!0}get isDrawable(){return!1}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){let{object:t}=e;return t&&t.__source&&t.__source.parent&&t.__source.parent.id===this.id&&(e.object=t.__source.object,e.index=t.__source.index),e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,t){return t&&t.length}getSubLayerClass(e,t){let{_subLayerProps:n}=this.props;return n&&n[e]&&n[e].type||t}getSubLayerRow(e,t,n){return e.__source={parent:this,object:t,index:n},e}getSubLayerAccessor(e){if(typeof e=="function"){let t={index:-1,data:this.props.data,target:[]};return(n,s)=>n&&n.__source?(t.index=n.__source.index,e(n.__source.object,t)):e(n,s)}return e}getSubLayerProps(e={}){let{opacity:t,pickable:n,visible:s,parameters:i,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:f,wrapLongitude:h,positionFormat:d,modelMatrix:m,extensions:y,fetch:_,operation:x,_subLayerProps:E}=this.props,b={id:"",updateTriggers:{},opacity:t,pickable:n,visible:s,parameters:i,getPolygonOffset:o,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:u,coordinateOrigin:f,wrapLongitude:h,positionFormat:d,modelMatrix:m,extensions:y,fetch:_,operation:x},S=E&&e.id&&E[e.id],C=S&&S.updateTriggers,P=e.id||"sublayer";if(S){let B=this.props[at],N=e.type?e.type._propTypes:{};for(let k in S){let F=N[k]||B[k];F&&F.type==="accessor"&&(S[k]=this.getSubLayerAccessor(S[k]))}}Object.assign(b,e,S),b.id=`${this.props.id}-${P}`,b.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...C};for(let B of y){let N=B.getSubLayerProps.call(this,B);N&&Object.assign(b,N,{updateTriggers:Object.assign(b.updateTriggers,N.updateTriggers)})}return b}_updateAutoHighlight(e){for(let t of this.getSubLayers())t.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,t){let n=this.internalState.subLayers,s=!n||this.needsUpdate();if(s){let i=this.renderLayers();n=Nr(i,Boolean),this.internalState.subLayers=n}he(GE,this,s,n);for(let i of n)i.parent=this}};Il.layerName="CompositeLayer";var ab=Il;var kd=Math.PI/180;function QE({height:r,focalDistance:e,orbitAxis:t,rotationX:n,rotationOrbit:s,zoom:i}){let o=t==="Z"?[0,0,1]:[0,1,0],a=t==="Z"?[0,-e,0]:[0,0,e],c=new Q().lookAt({eye:a,up:o});c.rotateX(n*kd),t==="Z"?c.rotateZ(s*kd):c.rotateY(s*kd);let l=Math.pow(2,i)/r;return c.scale(l),c}var Pl=class extends $e{constructor(e){let{height:t,projectionMatrix:n,fovy:s=50,orbitAxis:i="Z",target:o=[0,0,0],rotationX:a=0,rotationOrbit:c=0,zoom:l=0}=e,u=n?n[5]/2:rr(s);super({...e,longitude:void 0,viewMatrix:QE({height:t||1,focalDistance:u,orbitAxis:i,rotationX:a,rotationOrbit:c,zoom:l}),fovy:s,focalDistance:u,position:o,zoom:l}),this.target=o,this.orbitAxis=i,this.rotationX=a,this.rotationOrbit=c,this.fovy=s,this.projectedCenter=this.project(this.center)}unproject(e,{topLeft:t=!0}={}){let[n,s,i=this.projectedCenter[2]]=e,o=t?s:this.height-s,[a,c,l]=ot([n,o,i],this.pixelUnprojectionMatrix);return[a,c,l]}panByPosition(e,t,n){let s=this.project(e),i=[this.width/2+s[0]-t[0],this.height/2+s[1]-t[1],this.projectedCenter[2]];return{target:this.unproject(i)}}};Pl.displayName="OrbitViewport";var Cl=Pl;var JE=new Q().lookAt({eye:[0,0,1]});function eR({width:r,height:e,near:t,far:n,padding:s}){let i=-r/2,o=r/2,a=-e/2,c=e/2;if(s){let{left:l=0,right:u=0,top:f=0,bottom:h=0}=s,d=ee((l+r-u)/2,0,r)-r/2,m=ee((f+e-h)/2,0,e)-e/2;i-=d,o-=d,a+=m,c+=m}return new Q().ortho({left:i,right:o,bottom:a,top:c,near:t,far:n})}var Ml=class extends $e{constructor(e){let{width:t,height:n,near:s=.1,far:i=1e3,zoom:o=0,target:a=[0,0,0],padding:c=null,flipY:l=!0}=e,u=e.zoomX??(Array.isArray(o)?o[0]:o),f=e.zoomY??(Array.isArray(o)?o[1]:o),h=Math.min(u,f),d=Math.pow(2,h),m;if(u!==f){let y=Math.pow(2,u),_=Math.pow(2,f);m={unitsPerMeter:[y/d,_/d,1],metersPerUnit:[d/y,d/_,1]}}super({...e,longitude:void 0,position:a,viewMatrix:JE.clone().scale([d,d*(l?-1:1),d]),projectionMatrix:eR({width:t||1,height:n||1,padding:c,near:s,far:i}),zoom:h,distanceScales:m}),this.target=a,this.zoomX=u,this.zoomY=f,this.flipY=l}projectFlat([e,t]){let{unitsPerMeter:n}=this.distanceScales;return[e*n[0],t*n[1]]}unprojectFlat([e,t]){let{metersPerUnit:n}=this.distanceScales;return[e*n[0],t*n[1]]}panByPosition(e,t,n){let s=ot(t,this.pixelUnprojectionMatrix),i=this.projectFlat(e),o=_e.add([],i,_e.negate([],s)),a=_e.add([],this.center,o);return{target:this.unprojectFlat(a)}}};Ml.displayName="OrthographicViewport";var Ol=Ml;var kl=class extends $e{constructor(e){let{longitude:t,latitude:n,modelMatrix:s,bearing:i=0,pitch:o=0,up:a=[0,0,1]}=e,l=new ft({bearing:i,pitch:o===-90?1e-4:90+o}).toVector3().normalize(),u=s?new Q(s).transformAsVector(l):l,f=Number.isFinite(n)?Fi({latitude:n}):0,h=Math.pow(2,f),d=new Q().lookAt({eye:[0,0,0],center:u,up:a}).scale(h);super({...e,zoom:f,viewMatrix:d}),this.latitude=n,this.longitude=t,this.pitch=o,this.bearing=i,this.up=a}};kl.displayName="FirstPersonViewport";var Nl=kl;var Rn=20,cb=500,Eo=class extends ur{constructor(e){let{width:t,height:n,position:s=[0,0,0],bearing:i=0,pitch:o=0,longitude:a=null,latitude:c=null,maxPitch:l=90,minPitch:u=-90,startRotatePos:f,startBearing:h,startPitch:d,startZoomPosition:m,startPanPos:y,startPanPosition:_}=e;super({width:t,height:n,position:s,bearing:i,pitch:o,longitude:a,latitude:c,maxPitch:l,minPitch:u},{startRotatePos:f,startBearing:h,startPitch:d,startZoomPosition:m,startPanPos:y,startPanPosition:_}),this.makeViewport=e.makeViewport}panStart({pos:e}){let{position:t}=this.getViewportProps();return this._getUpdatedState({startPanPos:e,startPanPosition:t})}pan({pos:e}){if(!e)return this;let{startPanPos:t=[0,0],startPanPosition:n=[0,0]}=this.getState(),{width:s,height:i,bearing:o,pitch:a}=this.getViewportProps(),c=cb*(e[0]-t[0])/s,l=cb*(e[1]-t[1])/i,u=new ft({bearing:o,pitch:a}),f=new ft({bearing:o,pitch:-90}),h=u.toVector3().normalize(),d=f.toVector3().cross(h).normalize();return this._getUpdatedState({position:new G(n).add(d.scale(c)).add(h.scale(l))})}panEnd(){return this._getUpdatedState({startPanPos:null,startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:n=0}){let{startRotatePos:s,startBearing:i,startPitch:o}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!s||i===void 0||o===void 0)return this;let l;if(e){let u=(e[0]-s[0])/a,f=(e[1]-s[1])/c;l={bearing:i-u*180,pitch:o-f*90}}else l={bearing:i-t,pitch:o-n};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startBearing:null,startPitch:null})}zoomStart(){return this._getUpdatedState({startZoomPosition:this.getViewportProps().position})}zoom({pos:e,scale:t}){let n=this.getViewportProps(),s=this.getState().startZoomPosition||n.position,i=this.makeViewport(n),{projectionMatrix:o,width:a}=i,l=2*Math.atan(1/o[0])*(e[0]/a-.5),u=this.getDirection(!0);return this._move(u.rotateZ({radians:-l}),Math.log2(t)*Rn,s)}zoomEnd(){return this._getUpdatedState({startZoomPosition:null})}moveLeft(e=Rn){let t=this.getDirection(!0);return this._move(t.rotateZ({radians:Math.PI/2}),e)}moveRight(e=Rn){let t=this.getDirection(!0);return this._move(t.rotateZ({radians:-Math.PI/2}),e)}moveUp(e=Rn){let t=this.getDirection(!0);return this._move(t,e)}moveDown(e=Rn){let t=this.getDirection(!0);return this._move(t.negate(),e)}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}zoomIn(e=Rn){return this._move(new G(0,0,1),e)}zoomOut(e=Rn){return this._move(new G(0,0,-1),e)}shortestPathFrom(e){let t=e.getViewportProps(),n={...this.getViewportProps()},{bearing:s,longitude:i}=n;return Math.abs(s-t.bearing)>180&&(n.bearing=s<0?s+360:s-360),i!==null&&t.longitude!==null&&Math.abs(i-t.longitude)>180&&(n.longitude=i<0?i+360:i-360),n}_move(e,t,n=this.getViewportProps().position){let s=e.scale(t);return this._getUpdatedState({position:new G(n).add(s)})}getDirection(e=!1){return new ft({bearing:this.getViewportProps().bearing,pitch:e?90:90+this.getViewportProps().pitch}).toVector3().normalize()}_getUpdatedState(e){return new Eo({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{pitch:t,maxPitch:n,minPitch:s,longitude:i,bearing:o}=e;return e.pitch=ee(t,s,n),i!==null&&(i<-180||i>180)&&(e.longitude=pn(i+180,360)-180),(o<-180||o>180)&&(e.bearing=pn(o+180,360)-180),e}},In=class extends De{constructor(){super(...arguments),this.ControllerState=Eo,this.transition={transitionDuration:300,transitionInterpolator:new Ae(["position","pitch","bearing"])}}};var Dl=class extends Ne{constructor(e={}){super(e)}getViewportType(){return Nl}get ControllerType(){return In}};Dl.displayName="FirstPersonView";var lb=Dl;var Ro=class extends ur{constructor(e){let{width:t,height:n,rotationX:s=0,rotationOrbit:i=0,target:o=[0,0,0],zoom:a=0,minRotationX:c=-90,maxRotationX:l=90,minZoom:u=-1/0,maxZoom:f=1/0,startPanPosition:h,startRotatePos:d,startRotationX:m,startRotationOrbit:y,startZoomPosition:_,startZoom:x}=e;super({width:t,height:n,rotationX:s,rotationOrbit:i,target:o,zoom:a,minRotationX:c,maxRotationX:l,minZoom:u,maxZoom:f},{startPanPosition:h,startRotatePos:d,startRotationX:m,startRotationOrbit:y,startZoomPosition:_,startZoom:x}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:t}){let n=this.getState().startPanPosition||t;if(!n)return this;let i=this.makeViewport(this.getViewportProps()).panByPosition(n,e);return this._getUpdatedState(i)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startRotationX:this.getViewportProps().rotationX,startRotationOrbit:this.getViewportProps().rotationOrbit})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:n=0}){let{startRotatePos:s,startRotationX:i,startRotationOrbit:o}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!s||i===void 0||o===void 0)return this;let l;if(e){let u=(e[0]-s[0])/a,f=(e[1]-s[1])/c;(i<-90||i>90)&&(u*=-1),l={rotationX:i+f*180,rotationOrbit:o+u*180}}else l={rotationX:i+n,rotationOrbit:o+t};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotationX:null,startRotationOrbit:null})}shortestPathFrom(e){let t=e.getViewportProps(),n={...this.getViewportProps()},{rotationOrbit:s}=n;return Math.abs(s-t.rotationOrbit)>180&&(n.rotationOrbit=s<0?s+360:s-360),n}zoomStart({pos:e}){return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:n}){let{startZoom:s,startZoomPosition:i}=this.getState();if(i||(s=this.getViewportProps().zoom,i=this._unproject(t||e)),!i)return this;let o=this._calculateNewZoom({scale:n,startZoom:s}),a=this.makeViewport({...this.getViewportProps(),zoom:o});return this._getUpdatedState({zoom:o,...a.panByPosition(i,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:e})})}zoomOut(e=2){return this._getUpdatedState({zoom:this._calculateNewZoom({scale:1/e})})}moveLeft(e=50){return this._panFromCenter([-e,0])}moveRight(e=50){return this._panFromCenter([e,0])}moveUp(e=50){return this._panFromCenter([0,-e])}moveDown(e=50){return this._panFromCenter([0,e])}rotateLeft(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit-e})}rotateRight(e=15){return this._getUpdatedState({rotationOrbit:this.getViewportProps().rotationOrbit+e})}rotateUp(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX-e})}rotateDown(e=10){return this._getUpdatedState({rotationX:this.getViewportProps().rotationX+e})}_project(e){return this.makeViewport(this.getViewportProps()).project(e)}_unproject(e){return this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:t}){let{maxZoom:n,minZoom:s}=this.getViewportProps();t===void 0&&(t=this.getViewportProps().zoom);let i=t+Math.log2(e);return ee(i,s,n)}_panFromCenter(e){let{target:t}=this.getViewportProps(),n=this._project(t);return this.pan({startPosition:t,pos:[n[0]+e[0],n[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{maxZoom:t,minZoom:n,zoom:s,maxRotationX:i,minRotationX:o,rotationOrbit:a}=e;return e.zoom=Array.isArray(s)?[ee(s[0],n,t),ee(s[1],n,t)]:ee(s,n,t),e.rotationX=ee(e.rotationX,o,i),(a<-180||a>180)&&(e.rotationOrbit=pn(a+180,360)-180),e}},Pn=class extends De{constructor(){super(...arguments),this.ControllerState=Ro,this.transition={transitionDuration:300,transitionInterpolator:new Ae({transitionProps:{compare:["target","zoom","rotationX","rotationOrbit"],required:["target","zoom"]}})}}};var Fl=class extends Ne{constructor(e={}){super(e),this.props.orbitAxis=e.orbitAxis||"Z"}getViewportType(){return Cl}get ControllerType(){return Pn}};Fl.displayName="OrbitView";var ub=Fl;var Nd=class extends Ro{constructor(e){super(e),this.zoomAxis=e.zoomAxis||"all"}_calculateNewZoom({scale:e,startZoom:t}){let{maxZoom:n,minZoom:s}=this.getViewportProps();t===void 0&&(t=this.getViewportProps().zoom);let i=Math.log2(e);if(Array.isArray(t)){let[o,a]=t;switch(this.zoomAxis){case"X":o=ee(o+i,s,n);break;case"Y":a=ee(a+i,s,n);break;default:let c=Math.min(o+i,a+i);c<s&&(i+=s-c),c=Math.max(o+i,a+i),c>n&&(i+=n-c),o+=i,a+=i}return[o,a]}return ee(t+i,s,n)}},Cn=class extends De{constructor(){super(...arguments),this.ControllerState=Nd,this.transition={transitionDuration:300,transitionInterpolator:new Ae(["target","zoom"])},this.dragMode="pan"}_onPanRotate(){return!1}};var Bl=class extends Ne{constructor(e={}){super(e)}getViewportType(){return Ol}get ControllerType(){return Cn}};Bl.displayName="OrthographicView";var fb=Bl;var Dd=class extends Gi{constructor(e){let{startPanPos:t,...n}=e;super(n),t!==void 0&&(this._state.startPanPos=t)}panStart({pos:e}){let{latitude:t,longitude:n,zoom:s}=this.getViewportProps();return this._getUpdatedState({startPanLngLat:[n,t],startPanPos:e,startZoom:s})}pan({pos:e,startPos:t}){let n=this.getState(),s=n.startPanLngLat||this._unproject(t);if(!s)return this;let i=n.startZoom??this.getViewportProps().zoom,o=n.startPanPos||t,a=[s[0],s[1],i],l=this.makeViewport(this.getViewportProps()).panByPosition(a,e,o);return this._getUpdatedState(l)}panEnd(){return this._getUpdatedState({startPanLngLat:null,startPanPos:null,startZoom:null})}zoom({scale:e}){let n=(this.getState().startZoom||this.getViewportProps().zoom)+Math.log2(e);return this._getUpdatedState({zoom:n})}applyConstraints(e){let{longitude:t,latitude:n,maxZoom:s,minZoom:i,zoom:o}=e,a=xn(0),c=xn(n)-a;return e.zoom=ee(o,i+c,s+c),(t<-180||t>180)&&(e.longitude=pn(t+180,360)-180),e.latitude=ee(n,-ze,ze),e}},Mn=class extends De{constructor(){super(...arguments),this.ControllerState=Dd,this.transition={transitionDuration:300,transitionInterpolator:new Ae(["longitude","latitude","zoom"])},this.dragMode="pan"}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}};var Ll=class extends Ne{constructor(e={}){super(e)}getViewportType(e){return e.zoom>12?Or:xs}get ControllerType(){return Mn}};Ll.displayName="GlobeView";var hb=Ll;var Io=class{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e?!0:this.constructor===e.constructor&&le(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:t}=e.constructor,n={updateTriggers:{}};for(let s in t)if(s in this.props){let i=t[s],o=this.props[s];n[s]=o,i&&i.type==="accessor"&&(n.updateTriggers[s]=this.props.updateTriggers[s],typeof o=="function"&&(n[s]=this.getSubLayerAccessor(o)))}return n}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}};Io.defaultProps={};Io.extensionName="LayerExtension";var db=Io;var Fd={bearing:0,pitch:0,position:[0,0,0]},tR={speed:1.2,curve:1.414},Po=class extends cr{constructor(e={}){super({compare:["longitude","latitude","zoom","bearing","pitch","position"],extract:["width","height","longitude","latitude","zoom","bearing","pitch","position"],required:["width","height","latitude","longitude","zoom"]}),this.opts={...tR,...e}}interpolateProps(e,t,n){let s=Hh(e,t,n,this.opts);for(let i in Fd)s[i]=Qt(e[i]||Fd[i],t[i]||Fd[i],n);return s}getDuration(e,t){let{transitionDuration:n}=t;return n==="auto"&&(n=Xh(e,t,this.opts)),n}};H();var Co=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:t={}}=e;this.typedArrayManager=yt,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:t,buffers:n={},getGeometry:s,geometryBuffer:i,positionFormat:o,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=t,this.getGeometry=s,this.positionSize=i&&i.size||(o==="XY"?2:3),this.buffers=n,this.normalize=c,i&&(ie(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(i),c||(n.vertexPositions=i)),this.geometryBuffer=n.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){let t=e.value||e;return ArrayBuffer.isView(t)?_l(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){let{attributes:n,buffers:s,_attributeDefs:i,typedArrayManager:o}=this;for(let a in i)if(a in s)o.release(n[a]),n[a]=null;else{let c=i[a];c.copy=t,n[a]=o.allocate(n[a],e,c)}}_forEachGeometry(e,t,n){let{data:s,getGeometry:i}=this,{iterable:o,objectInfo:a}=Es(s,t,n);for(let c of o){a.index++;let l=i?i(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:n,instanceCount:s}=this,{data:i,geometryBuffer:o}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(t=[0],n=[0]),this.normalize||!o)this._forEachGeometry((f,h)=>{let d=f&&this.normalizeGeometry(f);l[h]=d,n[h+1]=n[h]+(d?this.getGeometrySize(d):0)},a,c),s=n[n.length-1];else if(n=i.startIndices,s=n[i.length]||0,ArrayBuffer.isView(o))s=s||o.length/this.positionSize;else if(o instanceof W){let f=this.positionSize*4;s=s||o.byteLength/f}else if(o.buffer){let f=o.stride||this.positionSize*4;s=s||o.buffer.byteLength/f}else if(o.value){let f=o.value,h=o.stride/f.BYTES_PER_ELEMENT||this.positionSize;s=s||f.length/h}this._allocate(s,Boolean(e)),this.indexStarts=t,this.vertexStarts=n,this.instanceCount=s;let u={};this._forEachGeometry((f,h)=>{let d=l[h]||f;u.vertexStart=n[h],u.indexStart=t[h];let m=h<n.length-1?n[h+1]:s;u.geometrySize=m-n[h],u.geometryIndex=h,this.updateGeometryAttributes(d,u)},a,c),this.vertexCount=t[t.length-1]}};var Ul=class{constructor(e){this.map=null,this.width=0,this.height=0,this.props={...e},this._initialize(this.props)}finalize(){this.map?.remove(),this.map=null}setProps(e){let t=this.props,n={...this.props,...e};if(this.props=n,!this.map)return;this._update(t,n)&&this.redraw()}redraw(){let e=this.map;e.style&&(e._frame&&(e._frame.cancel(),e._frame=null),e._render())}getMap(){return this.map}_initialize(e){let{mapLib:t,container:n}=e;t.accessToken=e.mapboxApiAccessToken||"",this.map=new e.mapLib.Map({container:n,maxZoom:24,...e.mapOptions,...pb(e.viewState),style:e.mapStyle,interactive:!1,trackResize:!1}),Object.defineProperty(n,"offsetWidth",{get:()=>this.width}),Object.defineProperty(n,"clientWidth",{get:()=>this.width}),Object.defineProperty(n,"offsetHeight",{get:()=>this.height}),Object.defineProperty(n,"clientHeight",{get:()=>this.height}),this.map.resize()}_update(e,t){e.mapStyle!==t.mapStyle&&this.map.setStyle(t.mapStyle);let s=e.width!==t.width||e.height!==t.height;s&&(this.width=t.width,this.height=t.height,this.map.resize());let i=e.viewState,o=t.viewState,a=o.latitude!==i.latitude||o.longitude!==i.longitude||o.zoom!==i.zoom||o.pitch!==i.pitch||o.bearing!==i.bearing;return a&&this.map.jumpTo(pb(o)),s||a}};function pb(r){return{center:[r.longitude,r.latitude],zoom:r.zoom,bearing:r.bearing??0,pitch:r.pitch??0}}var mb={position:"absolute",left:0,top:0,width:"100%",height:"100%"};function rR(r){let{container:e=document.body}=r;if(typeof e=="string"&&(e=document.getElementById(e)),!e)throw Error("Deck: container not found");window.getComputedStyle(e).position==="static"&&(e.style.position="relative");let n=document.createElement("div");e.appendChild(n),Object.assign(n.style,mb);let s=document.createElement("canvas");return e.appendChild(s),Object.assign(s.style,mb),{container:e,mapCanvas:n,deckCanvas:s}}var Mo=class extends ml{constructor(e){if(typeof document>"u")throw Error("Deck can only be used in the browser");let{mapCanvas:t,deckCanvas:n}=rR(e),s=e.viewState||e.initialViewState,i=Number.isFinite(s&&s.latitude),{map:o=globalThis.mapboxgl||globalThis.maplibregl}=e;super({canvas:n,...e}),o&&o.Map?this._map=i&&new Ul({...e,width:0,height:0,viewState:s,container:t,mapLib:o}):this._map=o}getMapboxMap(){return this._map&&this._map.getMap()}finalize(){this._map&&this._map.finalize(),super.finalize()}setProps(e){"mapStyle"in e&&this._map&&this._map.setProps({mapStyle:e.mapStyle}),super.setProps(e)}_drawLayers(e,t){if(this._map){let n=this.getViewports()[0];n&&this._map.setProps({width:n.width,height:n.height,viewState:n})}super._drawLayers(e,t)}};globalThis.luma=globalThis.luma||{};globalThis.loaders=globalThis.loaders||{};Object.assign(globalThis.luma,Yf);Object.assign(globalThis.loaders,bh);return Tb(nR);})();
1671
1671
  return __exports__;
1672
1672
  });