@deck.gl/core 9.3.0-alpha.6 → 9.3.0-beta.1
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/dist.dev.js +125 -56
- package/dist/index.cjs +125 -60
- package/dist/index.cjs.map +3 -3
- package/dist/lib/attribute/attribute.d.ts +2 -0
- package/dist/lib/attribute/attribute.d.ts.map +1 -1
- package/dist/lib/attribute/attribute.js +57 -27
- package/dist/lib/attribute/attribute.js.map +1 -1
- package/dist/lib/constants.d.ts +11 -6
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +8 -9
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/init.js +2 -2
- package/dist/lib/init.js.map +1 -1
- package/dist/lib/layer.d.ts.map +1 -1
- package/dist/lib/layer.js +4 -6
- package/dist/lib/layer.js.map +1 -1
- package/dist/shaderlib/picking/picking.d.ts +1 -2
- package/dist/shaderlib/picking/picking.d.ts.map +1 -1
- package/dist/shaderlib/picking/picking.js +4 -4
- package/dist/shaderlib/picking/picking.js.map +1 -1
- package/dist/shaderlib/project/project-functions.d.ts.map +1 -1
- package/dist/shaderlib/project/project-functions.js +19 -10
- package/dist/shaderlib/project/project-functions.js.map +1 -1
- package/dist/shaderlib/project/project.glsl.d.ts.map +1 -1
- package/dist/shaderlib/project/project.glsl.js +10 -5
- package/dist/shaderlib/project/project.glsl.js.map +1 -1
- package/dist/shaderlib/project/project.wgsl.d.ts.map +1 -1
- package/dist/shaderlib/project/project.wgsl.js +10 -5
- package/dist/shaderlib/project/project.wgsl.js.map +1 -1
- package/dist/shaderlib/project/viewport-uniforms.d.ts +1 -0
- package/dist/shaderlib/project/viewport-uniforms.d.ts.map +1 -1
- package/dist/shaderlib/project/viewport-uniforms.js +28 -17
- package/dist/shaderlib/project/viewport-uniforms.js.map +1 -1
- package/dist/shaderlib/shadow/shadow.d.ts +1 -1
- package/dist/shaderlib/shadow/shadow.d.ts.map +1 -1
- package/dist/shaderlib/shadow/shadow.js +3 -2
- package/dist/shaderlib/shadow/shadow.js.map +1 -1
- package/dist.min.js +84 -84
- package/package.json +2 -2
- package/src/lib/attribute/attribute.ts +70 -27
- package/src/lib/constants.ts +18 -12
- package/src/lib/layer.ts +4 -6
- package/src/shaderlib/picking/picking.ts +4 -4
- package/src/shaderlib/project/project-functions.ts +20 -10
- package/src/shaderlib/project/project.glsl.ts +15 -6
- package/src/shaderlib/project/project.wgsl.ts +15 -6
- package/src/shaderlib/project/viewport-uniforms.ts +30 -21
- package/src/shaderlib/shadow/shadow.ts +6 -2
package/dist.min.js
CHANGED
|
@@ -4,22 +4,22 @@
|
|
|
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 Qn=Object.defineProperty;var O0=Object.getOwnPropertyDescriptor;var N0=Object.getOwnPropertyNames;var D0=Object.prototype.hasOwnProperty;var B0=(t,e,r)=>e in t?Qn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var E=(t,e)=>()=>(t&&(e=t(t=0)),e);var Pt=(t,e)=>{for(var r in e)Qn(t,r,{get:e[r],enumerable:!0})},L0=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of N0(e))!D0.call(t,o)&&o!==r&&Qn(t,o,{get:()=>e[o],enumerable:!(i=O0(e,o))||i.enumerable});return t};var F0=t=>L0(Qn({},"__esModule",{value:!0}),t);var M=(t,e,r)=>(B0(t,typeof e!="symbol"?e+"":e,r),r);function eo(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var rl=E(()=>{});var wr,il=E(()=>{rl();wr=class{constructor(e,r){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=r,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=eo(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(eo()-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 Ne,yd=E(()=>{il();Ne=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}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 r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:i}=e,o=this.stats[r];return o||(e instanceof wr?o=e:o=new wr(r,i),this.stats[r]=o),o}}});var to=E(()=>{yd();il();rl()});function V0(t,e){let r=t.stats,i=!1;for(let c of e)r[c]||(t.get(c),i=!0);let o=Object.keys(r).length,n=bd.get(t);if(!i&&n?.orderedStatNames===e&&n.statCount===o)return;let s={},a=Td.get(e);a||(a=new Set(e),Td.set(e,a));for(let c of e)r[c]&&(s[c]=r[c]);for(let[c,l]of Object.entries(r))a.has(c)||(s[c]=l);for(let c of Object.keys(r))delete r[c];Object.assign(r,s),bd.set(t,{orderedStatNames:e,statCount:o})}var U0,k0,bd,Td,ol,Jn,nl=E(()=>{to();U0="GPU Time and Memory",k0=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","Referenced Buffer Memory","Referenced Texture Memory","Swap Chain Texture"],bd=new WeakMap,Td=new WeakMap,ol=class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new Ne({id:e}));let r=this.stats.get(e);return e===U0&&V0(r,k0),r}},Jn=new ol});var es,z0,ts,W0,xd,sl=E(()=>{es=globalThis,z0=globalThis.document||{},ts=globalThis.process||{},W0=globalThis.console,xd=globalThis.navigator||{}});function rs(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return Boolean(r&&r.indexOf("Electron")>=0)}var al=E(()=>{});function fe(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||rs()}var cl=E(()=>{al()});function ll(t){return!t&&!fe()?"Node":rs(t)?"Electron":(t||xd.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var Ad=E(()=>{cl();al();sl()});var fl,Zt=E(()=>{sl();cl();Ad();fl="4.1.1"});function ti(t,e){if(!t)throw new Error(e||"Assertion failed")}var hl=E(()=>{});function ul(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return ti(Number.isFinite(e)&&e>=0),e}function Sd(t){let{logLevel:e,message:r}=t;t.logLevel=ul(e);let i=t.args?Array.from(t.args):[];for(;i.length&&i.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&i.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let o=typeof t.message;return ti(o==="string"||o==="object"),Object.assign(t,{args:i},t.opts)}var Ed=E(()=>{hl()});var Rr,is,wd=E(()=>{Ed();Rr=()=>{},is=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,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...i){return this._log("log",e,r,i)}info(e,r,...i){return this._log("info",e,r,i)}once(e,r,...i){return this._log("once",e,r,i,{once:!0})}_log(e,r,i,o,n={}){let s=Sd({logLevel:r,message:i,args:this._buildArgs(r,i,o),opts:n});return this._createLogFunction(e,s,n)}_buildArgs(e,r,i){return[e,r,...i]}_createLogFunction(e,r,i){if(!this._shouldLog(r.logLevel))return Rr;let o=this._getOnceTag(i.tag??r.tag??r.message);if((i.once||r.once)&&o!==void 0){if(this._onceCache.has(o))return Rr;this._onceCache.add(o)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=ul(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}});function $0(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var os,Rd=E(()=>{os=class{constructor(e,r,i="sessionStorage"){this.storage=$0(i),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}}});function Pd(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function vd(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var Md=E(()=>{});function Cd(t){return typeof t!="string"?t:(t=t.toUpperCase(),ns[t]||ns.WHITE)}function Id(t,e,r){return!fe&&typeof t=="string"&&(e&&(t=`\x1B[${Cd(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${Cd(r)+H0}m${t}\x1B[49m`)),t}var ns,H0,Od=E(()=>{Zt();(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(ns||(ns={}));H0=10});function Nd(t,e=["constructor"]){let r=Object.getPrototypeOf(t),i=Object.getOwnPropertyNames(r),o=t;for(let n of i){let s=o[n];typeof s=="function"&&(e.find(a=>n===a)||(o[n]=s.bind(t)))}}var Dd=E(()=>{});function ri(){let t;if(fe()&&es.performance)t=es?.performance?.now?.();else if("hrtime"in ts){let e=ts?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Bd=E(()=>{Zt()});function X0(t,e,r){if(typeof e=="string"){let i=r.time?vd(Pd(r.total)):"";e=r.time?`${t}: ${i} ${e}`:`${t}: ${e}`,e=Id(e,r.color,r.background)}return e}function Y0(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}var ii,dl,he,pl=E(()=>{Zt();wd();Rd();Md();Od();Dd();hl();Bd();ii={debug:fe()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},dl={enabled:!0,level:0},he=class extends is{constructor({id:e}={id:""}){super({level:0}),this.VERSION=fl,this._startTs=ri(),this._deltaTs=ri(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new os(`__probe-${this.id}__`,{[this.id]:dl}),this.timeStamp(`${this.id} started`),Nd(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((ri()-this._startTs).toPrecision(10))}getDelta(){return Number((ri()-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,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:ii.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:ii.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...i){return this._log("log",e,r,i,{method:ii.log,time:!0,once:!0})}log(e,r,...i){return this._log("log",e,r,i,{method:ii.debug})}info(e,r,...i){return this._log("info",e,r,i,{method:console.info})}once(e,r,...i){return this._log("once",e,r,i,{method:ii.debug||ii.info,once:!0})}table(e,r,i){return r?this._log("table",e,r,i&&[i]||[],{method:console.table||Rr,tag:Y0(r)}):Rr}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||Rr})}group(e,r,i={collapsed:!1}){let o=(i.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:o})}groupCollapsed(e,r,i={}){return this.group(e,r,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||Rr})}withGroup(e,r,i){this.group(e,r)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let i=r.method;ti(i),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=ri();let o=X0(this.id,r.message,r);return i.bind(console,o,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(dl),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...dl};this._storage.setConfiguration({[this.id]:{...r,...e}})}};he.VERSION=fl});var Ld=E(()=>{globalThis.probe={}});var XM,ro=E(()=>{pl();pl();Ld();XM=new he({id:"@probe.gl/log"})});var x,De=E(()=>{ro();x=new he({id:"luma.gl"})});function nt(t="id"){gl[t]=gl[t]||1;let e=gl[t]++;return`${t}-${e}`}var gl,oi=E(()=>{gl={}});function J0(t,e){let r={...e};for(let i in t)t[i]!==void 0&&(r[i]=t[i]);return r}function Wd(t,e){let r=t.stats,i=!1;for(let c of e)r[c]||(t.get(c),i=!0);let o=Object.keys(r).length,n=Vd.get(t);if(!i&&n?.orderedStatNames===e&&n.statCount===o)return;let s={},a=zd.get(e);a||(a=new Set(e),zd.set(e,a));for(let c of e)r[c]&&(s[c]=r[c]);for(let[c,l]of Object.entries(r))a.has(c)||(s[c]=l);for(let c of Object.keys(r))delete r[c];Object.assign(r,s),Vd.set(t,{orderedStatNames:e,statCount:o})}function jd(t){return t.type==="webgl"?Q0:G0}function io(t){let e=t.userData[K0];return e?.enabled?e:null}function qt(){return globalThis.performance?.now?.()??Date.now()}function eT(t,e){let r=io(t);if(!(!r||!r.activeDefaultFramebufferAcquireDepth))switch(r.transientCanvasResourceCreates=(r.transientCanvasResourceCreates||0)+1,e){case"Texture":r.transientCanvasTextureCreates=(r.transientCanvasTextureCreates||0)+1;break;case"TextureView":r.transientCanvasTextureViewCreates=(r.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":r.transientCanvasSamplerCreates=(r.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":r.transientCanvasFramebufferCreates=(r.transientCanvasFramebufferCreates||0)+1;break;default:break}}function tT(t){let e=Object.getPrototypeOf(t);for(;e;){let r=Object.getPrototypeOf(e);if(!r||r===D.prototype)return rT(e)||t[Symbol.toStringTag]||t.constructor.name;e=r}return t[Symbol.toStringTag]||t.constructor.name}function rT(t){let e=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(t):typeof e?.value=="string"?e.value:null}var K0,Fd,Ud,kd,Z0,q0,G0,Q0,Vd,zd,D,se=E(()=>{oi();K0="cpu-hotspot-profiler",Fd="GPU Resource Counts",Ud="Resource Counts",kd="GPU Time and Memory",Z0=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],q0=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],G0=Z0.flatMap(t=>[`${t} Created`,`${t} Active`]),Q0=q0.flatMap(t=>[`${t} Created`,`${t} Active`]),Vd=new WeakMap,zd=new WeakMap,D=class{toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;constructor(e,r,i){if(!e)throw new Error("no device");this._device=e,this.props=J0(r,i);let o=this.props.id!=="undefined"?this.props.id:nt(this[Symbol.toStringTag]);this.props.id=o,this.id=o,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=io(this._device),r=e?qt():0,i=[this._device.statsManager.getStats(Fd),this._device.statsManager.getStats(Ud)],o=jd(this._device);for(let s of i)Wd(s,o);let n=this.getStatsName();for(let s of i)s.get("Resources Active").decrementCount(),s.get(`${n}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(qt()-r))}trackAllocatedMemory(e,r=this.getStatsName()){let i=io(this._device),o=i?qt():0,n=this._device.statsManager.getStats(kd);this.allocatedBytes>0&&this.allocatedBytesName&&(n.get("GPU Memory").subtractCount(this.allocatedBytes),n.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),n.get("GPU Memory").addCount(e),n.get(`${r} Memory`).addCount(e),i&&(i.statsBookkeepingCalls=(i.statsBookkeepingCalls||0)+1,i.statsBookkeepingTimeMs=(i.statsBookkeepingTimeMs||0)+(qt()-o)),this.allocatedBytes=e,this.allocatedBytesName=r}trackReferencedMemory(e,r=this.getStatsName()){this.trackAllocatedMemory(e,`Referenced ${r}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let r=io(this._device),i=r?qt():0,o=this._device.statsManager.getStats(kd);o.get("GPU Memory").subtractCount(this.allocatedBytes),o.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(qt()-i)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),r=io(this._device),i=r?qt():0,o=[this._device.statsManager.getStats(Fd),this._device.statsManager.getStats(Ud)],n=jd(this._device);for(let s of o)Wd(s,n);for(let s of o)s.get("Resources Created").incrementCount(),s.get("Resources Active").incrementCount(),s.get(`${e}s Created`).incrementCount(),s.get(`${e}s Active`).incrementCount();r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(qt()-i)),eT(this._device,e)}getStatsName(){return tT(this)}};M(D,"defaultProps",{id:"undefined",handle:void 0,userData:void 0})});var oo,I,ss=E(()=>{se();oo=class extends D{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,r){let i={...r};(r.usage||0)&oo.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?i.indexType="uint32":r.data instanceof Uint16Array?i.indexType="uint16":r.data instanceof Uint8Array&&(i.indexType="uint8")),delete i.data,super(e,i,oo.defaultProps),this.usage=i.usage||0,this.indexType=i.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}debugData=new ArrayBuffer(0);_setDebugData(e,r,i){let o=null,n;ArrayBuffer.isView(e)?(o=e,n=e.buffer):n=e;let s=Math.min(e?e.byteLength:i,oo.DEBUG_DATA_MAX_LENGTH);if(n===null)this.debugData=new ArrayBuffer(s);else{let a=Math.min(o?.byteOffset||0,n.byteLength),c=Math.max(0,n.byteLength-a),l=Math.min(s,c);this.debugData=new Uint8Array(n,a,l).slice().buffer}}},I=oo;M(I,"INDEX",16),M(I,"VERTEX",32),M(I,"UNIFORM",64),M(I,"STORAGE",128),M(I,"INDIRECT",256),M(I,"QUERY_RESOLVE",512),M(I,"MAP_READ",1),M(I,"MAP_WRITE",2),M(I,"COPY_SRC",4),M(I,"COPY_DST",8),M(I,"DEBUG_DATA_MAX_LENGTH",32),M(I,"defaultProps",{...D.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0})});var _l,ue,ml,as=E(()=>{_l=class{getDataTypeInfo(e){let[r,i,o]=ml[e],n=e.includes("norm"),s=!n&&!e.startsWith("float"),a=e.startsWith("s");return{signedType:r,primitiveType:i,byteLength:o,normalized:n,integer:s,signed:a}}getNormalizedDataType(e){let r=e;switch(r){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return r}}alignTo(e,r){switch(r){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}getDataType(e){let r=ArrayBuffer.isView(e)?e.constructor:e;if(r===Uint8ClampedArray)return"uint8";let i=Object.values(ml).find(o=>r===o[4]);if(!i)throw new Error(r.name);return i[0]}getTypedArrayConstructor(e){let[,,,,r]=ml[e];return r}},ue=new _l,ml={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]}});var yl,vt,cs=E(()=>{as();yl=class{getVertexFormatInfo(e){let r;e.endsWith("-webgl")&&(e.replace("-webgl",""),r=!0);let[i,o]=e.split("x"),n=i,s=o?parseInt(o):1,a=ue.getDataTypeInfo(n),c={type:n,components:s,byteLength:a.byteLength*s,integer:a.integer,signed:a.signed,normalized:a.normalized};return r&&(c.webglOnly=!0),c}makeVertexFormat(e,r,i){let o=i?ue.getNormalizedDataType(e):e;switch(o){case"unorm8":return r===1?"unorm8":r===3?"unorm8x3-webgl":`${o}x${r}`;case"snorm8":return r===1?"snorm8":r===3?"snorm8x3-webgl":`${o}x${r}`;case"uint8":case"sint8":if(r===1||r===3)throw new Error(`size: ${r}`);return`${o}x${r}`;case"uint16":return r===1?"uint16":r===3?"uint16x3-webgl":`${o}x${r}`;case"sint16":return r===1?"sint16":r===3?"sint16x3-webgl":`${o}x${r}`;case"unorm16":return r===1?"unorm16":r===3?"unorm16x3-webgl":`${o}x${r}`;case"snorm16":return r===1?"snorm16":r===3?"snorm16x3-webgl":`${o}x${r}`;case"float16":if(r===1||r===3)throw new Error(`size: ${r}`);return`${o}x${r}`;default:return r===1?o:`${o}x${r}`}}getVertexFormatFromAttribute(e,r,i){if(!r||r>4)throw new Error(`size ${r}`);let o=r,n=ue.getDataType(e);return this.makeVertexFormat(n,o,i)}getCompatibleVertexFormat(e){let r;switch(e.primitiveType){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return e.components===1?r:`${r}x${e.components}`}},vt=new yl});function El(t){let e=Xd[t];if(!e)throw new Error(`Unsupported texture format ${t}`);return e}function Hd(){return Xd}var ce,X,st,iT,ls,bl,fs,Tl,oT,xl,Gt,Al,Sl,hs,$d,nT,sT,Xd,wl=E(()=>{ce="texture-compression-bc",X="texture-compression-astc",st="texture-compression-etc2",iT="texture-compression-etc1-webgl",ls="texture-compression-pvrtc-webgl",bl="texture-compression-atc-webgl",fs="float32-renderable-webgl",Tl="float16-renderable-webgl",oT="rgb9e5ufloat-renderable-webgl",xl="snorm8-renderable-webgl",Gt="norm16-webgl",Al="norm16-renderable-webgl",Sl="snorm16-renderable-webgl",hs="float32-filterable",$d="float16-filterable-webgl";nT={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:xl},rg8snorm:{render:xl},"rgb8snorm-webgl":{},rgba8snorm:{render:xl},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:Gt,render:Al},rg16unorm:{f:Gt,render:Al},"rgb16unorm-webgl":{f:Gt,render:!1},rgba16unorm:{f:Gt,render:Al},r16snorm:{f:Gt,render:Sl},rg16snorm:{f:Gt,render:Sl},"rgb16snorm-webgl":{f:Gt,render:!1},rgba16snorm:{f:Gt,render:Sl},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:Tl,filter:"float16-filterable-webgl"},rg16float:{render:Tl,filter:$d},rgba16float:{render:Tl,filter:$d},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:fs,filter:hs},rg32float:{render:!1,filter:hs},"rgb32float-webgl":{render:fs,filter:hs},rgba32float:{render:fs,filter:hs},"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:oT},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:fs},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}},sT={"bc1-rgb-unorm-webgl":{f:ce},"bc1-rgb-unorm-srgb-webgl":{f:ce},"bc1-rgba-unorm":{f:ce},"bc1-rgba-unorm-srgb":{f:ce},"bc2-rgba-unorm":{f:ce},"bc2-rgba-unorm-srgb":{f:ce},"bc3-rgba-unorm":{f:ce},"bc3-rgba-unorm-srgb":{f:ce},"bc4-r-unorm":{f:ce},"bc4-r-snorm":{f:ce},"bc5-rg-unorm":{f:ce},"bc5-rg-snorm":{f:ce},"bc6h-rgb-ufloat":{f:ce},"bc6h-rgb-float":{f:ce},"bc7-rgba-unorm":{f:ce},"bc7-rgba-unorm-srgb":{f:ce},"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:X},"astc-4x4-unorm-srgb":{f:X},"astc-5x4-unorm":{f:X},"astc-5x4-unorm-srgb":{f:X},"astc-5x5-unorm":{f:X},"astc-5x5-unorm-srgb":{f:X},"astc-6x5-unorm":{f:X},"astc-6x5-unorm-srgb":{f:X},"astc-6x6-unorm":{f:X},"astc-6x6-unorm-srgb":{f:X},"astc-8x5-unorm":{f:X},"astc-8x5-unorm-srgb":{f:X},"astc-8x6-unorm":{f:X},"astc-8x6-unorm-srgb":{f:X},"astc-8x8-unorm":{f:X},"astc-8x8-unorm-srgb":{f:X},"astc-10x5-unorm":{f:X},"astc-10x5-unorm-srgb":{f:X},"astc-10x6-unorm":{f:X},"astc-10x6-unorm-srgb":{f:X},"astc-10x8-unorm":{f:X},"astc-10x8-unorm-srgb":{f:X},"astc-10x10-unorm":{f:X},"astc-10x10-unorm-srgb":{f:X},"astc-12x10-unorm":{f:X},"astc-12x10-unorm-srgb":{f:X},"astc-12x12-unorm":{f:X},"astc-12x12-unorm-srgb":{f:X},"pvrtc-rgb4unorm-webgl":{f:ls},"pvrtc-rgba4unorm-webgl":{f:ls},"pvrtc-rgb2unorm-webgl":{f:ls},"pvrtc-rgba2unorm-webgl":{f:ls},"etc1-rbg-unorm-webgl":{f:iT},"atc-rgb-unorm-webgl":{f:bl},"atc-rgba-unorm-webgl":{f:bl},"atc-rgbai-unorm-webgl":{f:bl}},Xd={...nT,...sT}});function hT({format:t,width:e,height:r,depth:i,byteAlignment:o}){let n=de.getInfo(t),{bytesPerPixel:s,bytesPerBlock:a=s,blockWidth:c=1,blockHeight:l=1,compressed:f=!1}=n,h=f?Math.ceil(e/c):e,u=f?Math.ceil(r/l):r,d=h*a,p=Math.ceil(d/o)*o,g=u,m=p*g*i;return{bytesPerPixel:s,bytesPerRow:p,rowsPerImage:g,depthOrArrayLayers:i,bytesPerImage:p*g,byteLength:m}}function uT(t){let e=El(t),r={format:t,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},i=Yd(t),o=t.startsWith("depth")||t.startsWith("stencil"),n=i?.signed,s=i?.integer,a=i?.webgl,c=Boolean(i?.compressed);return r.render&&=!o&&!c,r.filter&&=!o&&!n&&!s&&!a,r}function Yd(t){let e=dT(t);if(de.isCompressed(t)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=gT(t);let i=pT(t);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}let r=e.packed?null:aT.exec(t);if(r){let[,i,o,n,s,a]=r,c=`${n}${o}`,l=ue.getDataTypeInfo(c),f=l.byteLength*8,h=i?.length??1,u=[f,h>=2?f:0,h>=3?f:0,h>=4?f:0];e={format:t,attachment:e.attachment,dataType:l.signedType,components:h,channels:i,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:u,bytesPerPixel:l.byteLength*h,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),s==="-srgb"&&(e.srgb=!0)}return t.endsWith("-webgl")&&(e.webgl=!0),t.endsWith("-srgb")&&(e.srgb=!0),e}function dT(t){let e=El(t),r=e.bytesPerPixel||1,i=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:t,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:r,bitsPerChannel:i,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 pT(t){let r=/.*-(\d+)x(\d+)-.*/.exec(t);if(r){let[,i,o]=r;return{blockWidth:Number(i),blockHeight:Number(o)}}return t.startsWith("bc")||t.startsWith("etc1")||t.startsWith("etc2")||t.startsWith("eac")||t.startsWith("atc")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb4")||t.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb2")||t.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function gT(t){return t.startsWith("bc1")||t.startsWith("bc4")||t.startsWith("etc1")||t.startsWith("etc2-rgb8")||t.startsWith("etc2-rgb8a1")||t.startsWith("eac-r11")||t==="atc-rgb-unorm-webgl"?8:t.startsWith("bc2")||t.startsWith("bc3")||t.startsWith("bc5")||t.startsWith("bc6h")||t.startsWith("bc7")||t.startsWith("etc2-rgba8")||t.startsWith("eac-rg11")||t.startsWith("astc")||t==="atc-rgba-unorm-webgl"||t==="atc-rgbai-unorm-webgl"?16:t.startsWith("pvrtc")?8:16}var aT,cT,lT,fT,Rl,de,us=E(()=>{as();wl();aT=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,cT=["rgb","rgba","bgra"],lT=["depth","stencil"],fT=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],Rl=class{isColor(e){return cT.some(r=>e.startsWith(r))}isDepthStencil(e){return lT.some(r=>e.startsWith(r))}isCompressed(e){return fT.some(r=>e.startsWith(r))}getInfo(e){return Yd(e)}getCapabilities(e){return uT(e)}computeMemoryLayout(e){return hT(e)}},de=new Rl});function ni(t){return typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement||typeof VideoFrame<"u"&&t instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas}function no(t){if(typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)return{width:t.width,height:t.height};if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement)return{width:t.naturalWidth,height:t.naturalHeight};if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)return{width:t.videoWidth,height:t.videoHeight};if(typeof VideoFrame<"u"&&t instanceof VideoFrame)return{width:t.displayWidth,height:t.displayHeight};throw new Error("Unknown image type")}var Pl=E(()=>{});function mT(t,e){let r=vl(t),i=e.map(vl).filter(o=>o!==void 0);return[r,...i].filter(o=>o!==void 0)}function vl(t){if(t!==void 0){if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(t instanceof Error)return t.message;if(Array.isArray(t))return t.map(vl);if(typeof t=="object"){if(_T(t)){let e=String(t);if(e!=="[object Object]")return e}return yT(t)?bT(t):t.constructor?.name||"Object"}return String(t)}}function _T(t){return"toString"in t&&typeof t.toString=="function"&&t.toString!==Object.prototype.toString}function yT(t){return"message"in t&&"type"in t}function bT(t){let e=typeof t.type=="string"?t.type:"message",r=typeof t.message=="string"?t.message:"",i=typeof t.lineNum=="number"?t.lineNum:null,o=typeof t.linePos=="number"?t.linePos:null,n=i!==null&&o!==null?` @ ${i}:${o}`:i!==null?` @ ${i}`:"";return`${e}${n}: ${r}`.trim()}function TT(t,e){return t!=null?Boolean(t):e!==void 0?e!=="production":!1}function xT(){return TT(x.get("debug"),AT())}function AT(){let t=globalThis.process;if(t?.env)return t.env.NODE_ENV}var so,ao,Ml,Te,Cl=E(()=>{nl();De();oi();ss();cs();us();Pl();wl();so=class{};ao=class{features;disabledFeatures;constructor(e=[],r){this.features=new Set(e),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}},Ml=class{get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=Jn;_factories={};timestamp=0;_reused=!1;_moduleData={};_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...Ml.defaultProps,...e},this.id=this.props.id||nt(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return vt.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return de.getInfo(e)}getTextureFormatCapabilities(e){let r=this._textureCaps[e];if(!r){let i=this._getDeviceTextureFormatCapabilities(e);r=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=r}return r}getMipLevelCount(e,r,i=1){let o=Math.max(e,r,i);return 1+Math.floor(Math.log2(o))}isExternalImage(e){return ni(e)}getExternalImageSize(e){return no(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 de.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let r of Object.keys(Hd()))this.isTextureFormatCompressed(r)&&this.isTextureFormatSupported(r)&&e.push(r);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,r,...i){if(!this.props.onError(e,r)){let n=mT(r,i);return x.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...n)}return()=>{}}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.`;x.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,r){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,r,i,o,n){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&Boolean(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,r){throw new Error("not implemented")}readPixelsToBufferWebGL(e,r){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,r){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let r=de.getCapabilities(e),i=n=>(typeof n=="string"?this.features.has(n):n)??!0,o=i(r.create);return{format:e,create:o,render:o&&i(r.render),filter:o&&i(r.filter),blend:o&&i(r.blend),store:o&&i(r.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let r={...e};if((e.usage||0)&I.INDEX&&(e.indexType||(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array?r.indexType="uint16":e.data instanceof Uint8Array&&(r.data=new Uint16Array(e.data),r.indexType="uint16")),!r.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return r}},Te=Ml;M(Te,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,r)=>{},onResize:(e,r)=>{let[i,o]=e.getDevicePixelSize();x.log(1,`${e} resized => ${i}x${o}px`)()},onPositionChange:(e,r)=>{let[i,o]=e.getPosition();x.log(1,`${e} repositioned => ${i},${o}`)()},onVisibilityChange:e=>x.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,r)=>x.log(1,`${e} DPR changed ${r.oldRatio} => ${e.devicePixelRatio}`)(),debug:xT(),debugGPUTime:!1,debugShaders:x.get("debug-shaders")||void 0,debugFramebuffers:Boolean(x.get("debug-framebuffers")),debugFactories:Boolean(x.get("debug-factories")),debugWebGL:Boolean(x.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0})});var ST,Kd,ps,ds,Qt,Zd=E(()=>{Cl();nl();De();ST="set luma.log.level=1 (or higher) to trace rendering",Kd="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",ps=class{stats=Jn;log=x;VERSION="9.3.2";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw x.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),x.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");x.error("This version of luma.gl has already been initialized")()}x.log(1,`${this.VERSION} - ${ST}`)(),globalThis.luma=this}async createDevice(e={}){let r={...ps.defaultProps,...e},i=this.selectAdapter(r.type,r.adapters);if(!i)throw new Error(Kd);return r.waitForPageLoad&&await i.pageLoaded,await i.create(r)}async attachDevice(e,r){let i=this._getTypeFromHandle(e,r.adapters),o=i&&this.selectAdapter(i,r.adapters);if(!o)throw new Error(Kd);return await o?.attach?.(e,r)}registerAdapters(e){for(let r of e)this.preregisteredAdapters.set(r.type,r)}getSupportedAdapters(e=[]){let r=this._getAdapterMap(e);return Array.from(r).map(([,i])=>i).filter(i=>i.isSupported?.()).map(i=>i.type)}getBestAvailableAdapterType(e=[]){let r=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(let o of r)if(i.get(o)?.isSupported?.())return o;return null}selectAdapter(e,r=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(r));let o=this._getAdapterMap(r);return i&&o.get(i)||null}enforceWebGL2(e=!0,r=[]){let o=this._getAdapterMap(r).get("webgl");o||x.warn("enforceWebGL2: webgl adapter not found")(),o?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(ps.defaultProps,e)}_getAdapterMap(e=[]){let r=new Map(this.preregisteredAdapters);for(let i of e)r.set(i.type,i);return r}_getTypeFromHandle(e,r=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?x.warn("WebGL1 is not supported",e)():x.warn("Unknown handle type",e)(),null)}},ds=ps;M(ds,"defaultProps",{...Te.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});Qt=new ds});function RT(){return gs||(wT()||typeof window>"u"?gs=Promise.resolve():gs=new Promise(t=>window.addEventListener("load",()=>t()))),gs}var co,ET,wT,gs,qd=E(()=>{Zt();co=class{get pageLoaded(){return RT()}},ET=fe()&&typeof document<"u",wT=()=>ET&&document.readyState==="complete",gs=null});var ms,Gd=E(()=>{ms=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(!(this._started||!this.props.canvas)){this._started=!0,this._intersectionObserver||=new IntersectionObserver(e=>this.props.onIntersection(e)),this._resizeObserver||=new ResizeObserver(e=>this.props.onResize(e)),this._intersectionObserver.observe(this.props.canvas);try{this._resizeObserver.observe(this.props.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}});function Qd(){let t,e;return{promise:new Promise((i,o)=>{t=i,e=o}),resolve:t,reject:e}}var Jd=E(()=>{});function Il(t,e){if(!t){let r=new Error(e??"luma.gl assertion failed.");throw Error.captureStackTrace?.(r,Il),r}}function Pr(t,e){return Il(t,e),t}var Ol=E(()=>{});function PT(t){if(typeof t=="string"){let e=document.getElementById(t);if(!e)throw new Error(`${t} is not an HTML element`);return e}return t||document.body}function vT(t){let e=document.getElementById(t);if(!Mt.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function MT(t){let{width:e,height:r}=t,i=document.createElement("canvas");i.id=nt("lumagl-auto-created-canvas"),i.width=e||1,i.height=r||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(r)?`${r}px`:"100%",t?.visible||(i.style.visibility="hidden");let o=PT(t?.container||null);return o.insertBefore(i,o.firstChild),i}function CT(t,e,r,i,o){let n=t,s=ep(n[0],e,r),a=tp(n[1],e,i,o),c=ep(n[0]+1,e,r),l=c===r-1?c:c-1;c=tp(n[1]+1,e,i,o);let f;return o?(c=c===0?c:c+1,f=a,a=c):f=c===i-1?c:c-1,{x:s,y:a,width:Math.max(l-s+1,1),height:Math.max(f-a+1,1)}}function ep(t,e,r){return Math.min(Math.round(t*e),r-1)}function tp(t,e,r,i){return i?Math.max(0,r-1-Math.round(t*e)):Math.min(Math.round(t*e),r-1)}var lo,Mt,Nl=E(()=>{Zt();Gd();oi();Jd();Ol();lo=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=Qd();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...lo.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,fe()?e.canvas?typeof e.canvas=="string"?this.canvas=vT(e.canvas):this.canvas=e.canvas:this.canvas=MT(e):this.canvas={width:e.width||1,height:e.height||1},lo.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):lo.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new ms({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,onResize:r=>this._handleResize(r),onIntersection:r=>this._handleIntersection(r),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,r){e=Math.floor(e),r=Math.floor(r),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===r)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=r,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,r=!0){let i=this.cssToDeviceRatio(),[o,n]=this.getDrawingBufferSize();return CT(e,i,o,n,r)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,r]=this.getDrawingBufferSize();return e>0&&r>0?e/r:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[r]=this.getCSSSize();return r?e/r:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let r=e.find(o=>o.target===this.canvas);if(!r)return;let i=r.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let r=e.find(l=>l.target===this.canvas);if(!r)return;let i=Pr(r.contentBoxSize?.[0]);this.cssWidth=i.inlineSize,this.cssHeight=i.blockSize;let o=this.getDevicePixelSize(),n=r.devicePixelContentBoxSize?.[0]?.inlineSize||i.inlineSize*devicePixelRatio,s=r.devicePixelContentBoxSize?.[0]?.blockSize||i.blockSize*devicePixelRatio,[a,c]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(n,a)),this.devicePixelHeight=Math.max(1,Math.min(s,c)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:o})}_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._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_resizeDrawingBufferIfNeeded(){this._needsDrawingBufferResize&&(this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight,this._configureDevice()))}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let r=[e.left,e.top];if(this._position??=r,r[0]!==this._position[0]||r[1]!==this._position[1]){let o=this._position;this._position=r,this.device.props.onPositionChange?.(this,{oldPosition:o})}}}},Mt=lo;M(Mt,"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 si,rp=E(()=>{Nl();si=class extends Mt{};M(si,"defaultProps",Mt.defaultProps)});var fo,ip=E(()=>{Nl();fo=class extends Mt{}});var _s,Be,Dl=E(()=>{se();_s=class extends D{get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){r=_s.normalizeProps(e,r),super(e,r,_s.defaultProps)}static normalizeProps(e,r){return r}},Be=_s;M(Be,"defaultProps",{...D.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 IT,Ee,B,Bl=E(()=>{se();Dl();De();us();IT={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Ee=class extends D{dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,r,i){if(r=Ee.normalizeProps(e,r),super(e,r,Ee.defaultProps),this.dimension=this.props.dimension,this.baseDimension=IT[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(r.data)){let o=e.getExternalImageSize(r.data);this.width=o?.width||1,this.height=o?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&x.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=i?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof Be?e:this.device.createSampler(e)}copyImageData(e){let{data:r,depth:i,...o}=e;this.writeData(r,{...o,depthOrArrayLayers:o.depthOrArrayLayers??i})}computeMemoryLayout(e={}){let r=this._normalizeTextureReadOptions(e),{width:i=this.width,height:o=this.height,depthOrArrayLayers:n=this.depth}=r,{format:s,byteAlignment:a}=this;return de.computeMemoryLayout({format:s,width:i,height:o,depth:n,byteAlignment:a})}readBuffer(e,r){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,r){throw new Error("readBuffer not implemented")}writeData(e,r){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,r){let i={...r},{width:o,height:n}=i;return typeof o=="number"&&(i.width=Math.max(1,Math.ceil(o))),typeof n=="number"&&(i.height=Math.max(1,Math.ceil(n))),i}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{data:r,depth:i,...o}=e,n=this._normalizeTextureWriteOptions({...o,depthOrArrayLayers:o.depthOrArrayLayers??i});return{data:r,depth:n.depthOrArrayLayers,...n}}_normalizeCopyExternalImageOptions(e){let r=Ee._omitUndefined(e),i=r.mipLevel??0,o=this._getMipLevelSize(i),n=this.device.getExternalImageSize(e.image),s={...Ee.defaultCopyExternalImageOptions,...o,...n,...r};return s.width=Math.min(s.width,o.width-s.x),s.height=Math.min(s.height,o.height-s.y),s.depth=Math.min(s.depth,o.depthOrArrayLayers-s.z),s}_normalizeTextureReadOptions(e){let r=Ee._omitUndefined(e),i=r.mipLevel??0,o=this._getMipLevelSize(i),n={...Ee.defaultTextureReadOptions,...o,...r};return n.width=Math.min(n.width,o.width-n.x),n.height=Math.min(n.height,o.height-n.y),n.depthOrArrayLayers=Math.min(n.depthOrArrayLayers,o.depthOrArrayLayers-n.z),n}_getSupportedColorReadOptions(e){let r=this._normalizeTextureReadOptions(e),i=de.getInfo(this.format);switch(this._validateColorReadAspect(r),this._validateColorReadFormat(i),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return r;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){let r=Ee._omitUndefined(e),i=r.mipLevel??0,o=this._getMipLevelSize(i),n={...Ee.defaultTextureWriteOptions,...o,...r};n.width=Math.min(n.width,o.width-n.x),n.height=Math.min(n.height,o.height-n.y),n.depthOrArrayLayers=Math.min(n.depthOrArrayLayers,o.depthOrArrayLayers-n.z);let s=de.computeMemoryLayout({format:this.format,width:n.width,height:n.height,depth:n.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=s.bytesPerPixel*n.width;if(n.bytesPerRow=r.bytesPerRow??s.bytesPerRow,n.rowsPerImage=r.rowsPerImage??n.height,n.bytesPerRow<a)throw new Error(`bytesPerRow (${n.bytesPerRow}) must be at least ${a} for ${this.format}`);if(n.rowsPerImage<n.height)throw new Error(`rowsPerImage (${n.rowsPerImage}) must be at least ${n.height} for ${this.format}`);let c=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(c&&n.bytesPerRow%c!==0)throw new Error(`bytesPerRow (${n.bytesPerRow}) must be a multiple of bytesPerPixel (${c}) for ${this.format}`);return n}_getMipLevelSize(e){let r=Math.max(1,this.width>>e),i=this.baseDimension==="1d"?1:Math.max(1,this.height>>e),o=this.dimension==="3d"?Math.max(1,this.depth>>e):this.depth;return{width:r,height:i,depthOrArrayLayers:o}}getAllocatedByteLength(){let e=0;for(let r=0;r<this.mipLevels;r++){let{width:i,height:o,depthOrArrayLayers:n}=this._getMipLevelSize(r);e+=de.computeMemoryLayout({format:this.format,width:i,height:o,depth:n,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))}},B=Ee;M(B,"SAMPLE",4),M(B,"STORAGE",8),M(B,"RENDER",16),M(B,"COPY_SRC",1),M(B,"COPY_DST",2),M(B,"TEXTURE",4),M(B,"RENDER_ATTACHMENT",16),M(B,"defaultProps",{...D.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:Ee.SAMPLE|Ee.RENDER|Ee.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),M(B,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),M(B,"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}),M(B,"defaultTextureReadOptions",{x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}),M(B,"defaultTextureWriteOptions",{byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"})});var Ll,Jt,op=E(()=>{se();Ll=class extends D{get[Symbol.toStringTag](){return"TextureView"}constructor(e,r){super(e,r,Ll.defaultProps)}},Jt=Ll;M(Jt,"defaultProps",{...D.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0})});function np(t,e,r){let i="",o=e.split(/\r?\n/),n=t.slice().sort((s,a)=>s.lineNum-a.lineNum);switch(r?.showSourceCode||"no"){case"all":let s=0;for(let a=1;a<=o.length;a++){let c=o[a-1],l=n[s];for(c&&l&&(i+=sp(c,a,r));n.length>s&&l.lineNum===a;){let f=n[s++];f&&(i+=Fl(f,o,f.lineNum,{...r,inlineSource:!1}))}}for(;n.length>s;){let a=n[s++];a&&(i+=Fl(a,[],0,{...r,inlineSource:!1}))}return i;case"issues":case"no":for(let a of t)i+=Fl(a,o,a.lineNum,{inlineSource:r?.showSourceCode!=="no"});return i}}function Fl(t,e,r,i){if(i?.inlineSource){let n=OT(e,r),s=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^
|
|
7
|
+
"use strict";var __exports__=(()=>{var Jn=Object.defineProperty;var N0=Object.getOwnPropertyDescriptor;var D0=Object.getOwnPropertyNames;var B0=Object.prototype.hasOwnProperty;var F0=(t,e,r)=>e in t?Jn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var E=(t,e)=>()=>(t&&(e=t(t=0)),e);var Rt=(t,e)=>{for(var r in e)Jn(t,r,{get:e[r],enumerable:!0})},L0=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of D0(e))!B0.call(t,o)&&o!==r&&Jn(t,o,{get:()=>e[o],enumerable:!(i=N0(e,o))||i.enumerable});return t};var U0=t=>L0(Jn({},"__esModule",{value:!0}),t);var M=(t,e,r)=>(F0(t,typeof e!="symbol"?e+"":e,r),r);function to(){let t;if(typeof window<"u"&&window.performance)t=window.performance.now();else if(typeof process<"u"&&process.hrtime){let e=process.hrtime();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var ol=E(()=>{});var Er,nl=E(()=>{ol();Er=class{constructor(e,r){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=r,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=to(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(to()-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 Oe,bd=E(()=>{nl();Oe=class{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,r="count"){return this._getOrCreate({name:e,type:r})}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 r of Object.values(this.stats))e(r)}getTable(){let e={};return this.forEach(r=>{e[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(r=>this._getOrCreate(r))}_getOrCreate(e){let{name:r,type:i}=e,o=this.stats[r];return o||(e instanceof Er?o=e:o=new Er(r,i),this.stats[r]=o),o}}});var ro=E(()=>{bd();nl();ol()});function z0(t,e){let r=t.stats,i=!1;for(let c of e)r[c]||(t.get(c),i=!0);let o=Object.keys(r).length,n=Td.get(t);if(!i&&n?.orderedStatNames===e&&n.statCount===o)return;let s={},a=xd.get(e);a||(a=new Set(e),xd.set(e,a));for(let c of e)r[c]&&(s[c]=r[c]);for(let[c,l]of Object.entries(r))a.has(c)||(s[c]=l);for(let c of Object.keys(r))delete r[c];Object.assign(r,s),Td.set(t,{orderedStatNames:e,statCount:o})}var k0,V0,Td,xd,sl,es,al=E(()=>{ro();k0="GPU Time and Memory",V0=["Adapter","GPU","GPU Type","GPU Backend","Frame Rate","CPU Time","GPU Time","GPU Memory","Buffer Memory","Texture Memory","Referenced Buffer Memory","Referenced Texture Memory","Swap Chain Texture"],Td=new WeakMap,xd=new WeakMap,sl=class{stats=new Map;getStats(e){return this.get(e)}get(e){this.stats.has(e)||this.stats.set(e,new Oe({id:e}));let r=this.stats.get(e);return e===k0&&z0(r,V0),r}},es=new sl});var ts,W0,rs,j0,Ad,cl=E(()=>{ts=globalThis,W0=globalThis.document||{},rs=globalThis.process||{},j0=globalThis.console,Ad=globalThis.navigator||{}});function is(t){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let e=typeof navigator<"u"&&navigator.userAgent,r=t||e;return Boolean(r&&r.indexOf("Electron")>=0)}var ll=E(()=>{});function le(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||is()}var fl=E(()=>{ll()});function hl(t){return!t&&!le()?"Node":is(t)?"Electron":(t||Ad.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var Sd=E(()=>{fl();ll();cl()});var ul,Kt=E(()=>{cl();fl();Sd();ul="4.1.1"});function ri(t,e){if(!t)throw new Error(e||"Assertion failed")}var dl=E(()=>{});function pl(t){if(!t)return 0;let e;switch(typeof t){case"number":e=t;break;case"object":e=t.logLevel||t.priority||0;break;default:return 0}return ri(Number.isFinite(e)&&e>=0),e}function Ed(t){let{logLevel:e,message:r}=t;t.logLevel=pl(e);let i=t.args?Array.from(t.args):[];for(;i.length&&i.shift()!==r;);switch(typeof e){case"string":case"function":r!==void 0&&i.unshift(r),t.message=e;break;case"object":Object.assign(t,e);break;default:}typeof t.message=="function"&&(t.message=t.message());let o=typeof t.message;return ri(o==="string"||o==="object"),Object.assign(t,{args:i},t.opts)}var wd=E(()=>{dl()});var wr,os,Rd=E(()=>{wd();wr=()=>{},os=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,...r){return this._log("warn",0,e,r,{once:!0})}error(e,...r){return this._log("error",0,e,r)}log(e,r,...i){return this._log("log",e,r,i)}info(e,r,...i){return this._log("info",e,r,i)}once(e,r,...i){return this._log("once",e,r,i,{once:!0})}_log(e,r,i,o,n={}){let s=Ed({logLevel:r,message:i,args:this._buildArgs(r,i,o),opts:n});return this._createLogFunction(e,s,n)}_buildArgs(e,r,i){return[e,r,...i]}_createLogFunction(e,r,i){if(!this._shouldLog(r.logLevel))return wr;let o=this._getOnceTag(i.tag??r.tag??r.message);if((i.once||r.once)&&o!==void 0){if(this._onceCache.has(o))return wr;this._onceCache.add(o)}return this._emit(e,r)}_shouldLog(e){return this.getLevel()>=pl(e)}_getOnceTag(e){if(e!==void 0)try{return typeof e=="string"?e:String(e)}catch{return}}}});function H0(t){try{let e=window[t],r="__storage_test__";return e.setItem(r,r),e.removeItem(r),e}catch{return null}}var ns,Pd=E(()=>{ns=class{constructor(e,r,i="sessionStorage"){this.storage=H0(i),this.id=e,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let e={};if(this.storage){let r=this.storage.getItem(this.id);e=r?JSON.parse(r):{}}return Object.assign(this.config,e),this}}});function vd(t){let e;return t<10?e=`${t.toFixed(2)}ms`:t<100?e=`${t.toFixed(1)}ms`:t<1e3?e=`${t.toFixed(0)}ms`:e=`${(t/1e3).toFixed(2)}s`,e}function Md(t,e=8){let r=Math.max(e-t.length,0);return`${" ".repeat(r)}${t}`}var Cd=E(()=>{});function Id(t){return typeof t!="string"?t:(t=t.toUpperCase(),ss[t]||ss.WHITE)}function Od(t,e,r){return!le&&typeof t=="string"&&(e&&(t=`\x1B[${Id(e)}m${t}\x1B[39m`),r&&(t=`\x1B[${Id(r)+X0}m${t}\x1B[49m`)),t}var ss,X0,Nd=E(()=>{Kt();(function(t){t[t.BLACK=30]="BLACK",t[t.RED=31]="RED",t[t.GREEN=32]="GREEN",t[t.YELLOW=33]="YELLOW",t[t.BLUE=34]="BLUE",t[t.MAGENTA=35]="MAGENTA",t[t.CYAN=36]="CYAN",t[t.WHITE=37]="WHITE",t[t.BRIGHT_BLACK=90]="BRIGHT_BLACK",t[t.BRIGHT_RED=91]="BRIGHT_RED",t[t.BRIGHT_GREEN=92]="BRIGHT_GREEN",t[t.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",t[t.BRIGHT_BLUE=94]="BRIGHT_BLUE",t[t.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",t[t.BRIGHT_CYAN=96]="BRIGHT_CYAN",t[t.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(ss||(ss={}));X0=10});function Dd(t,e=["constructor"]){let r=Object.getPrototypeOf(t),i=Object.getOwnPropertyNames(r),o=t;for(let n of i){let s=o[n];typeof s=="function"&&(e.find(a=>n===a)||(o[n]=s.bind(t)))}}var Bd=E(()=>{});function ii(){let t;if(le()&&ts.performance)t=ts?.performance?.now?.();else if("hrtime"in rs){let e=rs?.hrtime?.();t=e[0]*1e3+e[1]/1e6}else t=Date.now();return t}var Fd=E(()=>{Kt()});function Y0(t,e,r){if(typeof e=="string"){let i=r.time?Md(vd(r.total)):"";e=r.time?`${t}: ${i} ${e}`:`${t}: ${e}`,e=Od(e,r.color,r.background)}return e}function K0(t){for(let e in t)for(let r in t[e])return r||"untitled";return"empty"}var oi,gl,fe,ml=E(()=>{Kt();Rd();Pd();Cd();Nd();Bd();dl();Fd();oi={debug:le()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},gl={enabled:!0,level:0},fe=class extends os{constructor({id:e}={id:""}){super({level:0}),this.VERSION=ul,this._startTs=ii(),this._deltaTs=ii(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new ns(`__probe-${this.id}__`,{[this.id]:gl}),this.timeStamp(`${this.id} started`),Dd(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((ii()-this._startTs).toPrecision(10))}getDelta(){return Number((ii()-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,r){this._updateConfiguration({[e]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,r){if(!e)throw new Error(r||"Assertion failed")}warn(e,...r){return this._log("warn",0,e,r,{method:oi.warn,once:!0})}error(e,...r){return this._log("error",0,e,r,{method:oi.error})}deprecated(e,r){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(e,r){return this.error(`\`${e}\` has been removed. Use \`${r}\` instead`)}probe(e,r,...i){return this._log("log",e,r,i,{method:oi.log,time:!0,once:!0})}log(e,r,...i){return this._log("log",e,r,i,{method:oi.debug})}info(e,r,...i){return this._log("info",e,r,i,{method:console.info})}once(e,r,...i){return this._log("once",e,r,i,{method:oi.debug||oi.info,once:!0})}table(e,r,i){return r?this._log("table",e,r,i&&[i]||[],{method:console.table||wr,tag:K0(r)}):wr}time(e,r){return this._log("time",e,r,[],{method:console.time?console.time:console.info})}timeEnd(e,r){return this._log("time",e,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(e,r){return this._log("time",e,r,[],{method:console.timeStamp||wr})}group(e,r,i={collapsed:!1}){let o=(i.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",e,r,[],{method:o})}groupCollapsed(e,r,i={}){return this.group(e,r,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._log("groupEnd",e,"",[],{method:console.groupEnd||wr})}withGroup(e,r,i){this.group(e,r)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&super._shouldLog(e)}_emit(e,r){let i=r.method;ri(i),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=ii();let o=Y0(this.id,r.message,r);return i.bind(console,o,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(gl),this._storage.config[this.id]}_updateConfiguration(e){let r=this._storage.config[this.id]||{...gl};this._storage.setConfiguration({[this.id]:{...r,...e}})}};fe.VERSION=ul});var Ld=E(()=>{globalThis.probe={}});var qM,io=E(()=>{ml();ml();Ld();qM=new fe({id:"@probe.gl/log"})});var x,Ne=E(()=>{io();x=new fe({id:"luma.gl"})});function ot(t="id"){_l[t]=_l[t]||1;let e=_l[t]++;return`${t}-${e}`}var _l,ni=E(()=>{_l={}});function eT(t,e){let r={...e};for(let i in t)t[i]!==void 0&&(r[i]=t[i]);return r}function jd(t,e){let r=t.stats,i=!1;for(let c of e)r[c]||(t.get(c),i=!0);let o=Object.keys(r).length,n=zd.get(t);if(!i&&n?.orderedStatNames===e&&n.statCount===o)return;let s={},a=Wd.get(e);a||(a=new Set(e),Wd.set(e,a));for(let c of e)r[c]&&(s[c]=r[c]);for(let[c,l]of Object.entries(r))a.has(c)||(s[c]=l);for(let c of Object.keys(r))delete r[c];Object.assign(r,s),zd.set(t,{orderedStatNames:e,statCount:o})}function $d(t){return t.type==="webgl"?J0:Q0}function oo(t){let e=t.userData[Z0];return e?.enabled?e:null}function Zt(){return globalThis.performance?.now?.()??Date.now()}function tT(t,e){let r=oo(t);if(!(!r||!r.activeDefaultFramebufferAcquireDepth))switch(r.transientCanvasResourceCreates=(r.transientCanvasResourceCreates||0)+1,e){case"Texture":r.transientCanvasTextureCreates=(r.transientCanvasTextureCreates||0)+1;break;case"TextureView":r.transientCanvasTextureViewCreates=(r.transientCanvasTextureViewCreates||0)+1;break;case"Sampler":r.transientCanvasSamplerCreates=(r.transientCanvasSamplerCreates||0)+1;break;case"Framebuffer":r.transientCanvasFramebufferCreates=(r.transientCanvasFramebufferCreates||0)+1;break;default:break}}function rT(t){let e=Object.getPrototypeOf(t);for(;e;){let r=Object.getPrototypeOf(e);if(!r||r===D.prototype)return iT(e)||t[Symbol.toStringTag]||t.constructor.name;e=r}return t[Symbol.toStringTag]||t.constructor.name}function iT(t){let e=Object.getOwnPropertyDescriptor(t,Symbol.toStringTag);return typeof e?.get=="function"?e.get.call(t):typeof e?.value=="string"?e.value:null}var Z0,Ud,kd,Vd,q0,G0,Q0,J0,zd,Wd,D,ne=E(()=>{ni();Z0="cpu-hotspot-profiler",Ud="GPU Resource Counts",kd="Resource Counts",Vd="GPU Time and Memory",q0=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],G0=["Resources","Buffers","Textures","Samplers","TextureViews","Framebuffers","QuerySets","Shaders","RenderPipelines","SharedRenderPipelines","ComputePipelines","PipelineLayouts","VertexArrays","RenderPasss","ComputePasss","CommandEncoders","CommandBuffers"],Q0=q0.flatMap(t=>[`${t} Created`,`${t} Active`]),J0=G0.flatMap(t=>[`${t} Created`,`${t} Active`]),zd=new WeakMap,Wd=new WeakMap,D=class{toString(){return`${this[Symbol.toStringTag]||this.constructor.name}:"${this.id}"`}id;props;userData={};_device;destroyed=!1;allocatedBytes=0;allocatedBytesName=null;_attachedResources=new Set;constructor(e,r,i){if(!e)throw new Error("no device");this._device=e,this.props=eT(r,i);let o=this.props.id!=="undefined"?this.props.id:ot(this[Symbol.toStringTag]);this.props.id=o,this.id=o,this.userData=this.props.userData||{},this.addStats()}destroy(){this.destroyed||this.destroyResource()}delete(){return this.destroy(),this}getProps(){return this.props}attachResource(e){this._attachedResources.add(e)}detachResource(e){this._attachedResources.delete(e)}destroyAttachedResource(e){this._attachedResources.delete(e)&&e.destroy()}destroyAttachedResources(){for(let e of this._attachedResources)e.destroy();this._attachedResources=new Set}destroyResource(){this.destroyed||(this.destroyAttachedResources(),this.removeStats(),this.destroyed=!0)}removeStats(){let e=oo(this._device),r=e?Zt():0,i=[this._device.statsManager.getStats(Ud),this._device.statsManager.getStats(kd)],o=$d(this._device);for(let s of i)jd(s,o);let n=this.getStatsName();for(let s of i)s.get("Resources Active").decrementCount(),s.get(`${n}s Active`).decrementCount();e&&(e.statsBookkeepingCalls=(e.statsBookkeepingCalls||0)+1,e.statsBookkeepingTimeMs=(e.statsBookkeepingTimeMs||0)+(Zt()-r))}trackAllocatedMemory(e,r=this.getStatsName()){let i=oo(this._device),o=i?Zt():0,n=this._device.statsManager.getStats(Vd);this.allocatedBytes>0&&this.allocatedBytesName&&(n.get("GPU Memory").subtractCount(this.allocatedBytes),n.get(`${this.allocatedBytesName} Memory`).subtractCount(this.allocatedBytes)),n.get("GPU Memory").addCount(e),n.get(`${r} Memory`).addCount(e),i&&(i.statsBookkeepingCalls=(i.statsBookkeepingCalls||0)+1,i.statsBookkeepingTimeMs=(i.statsBookkeepingTimeMs||0)+(Zt()-o)),this.allocatedBytes=e,this.allocatedBytesName=r}trackReferencedMemory(e,r=this.getStatsName()){this.trackAllocatedMemory(e,`Referenced ${r}`)}trackDeallocatedMemory(e=this.getStatsName()){if(this.allocatedBytes===0){this.allocatedBytesName=null;return}let r=oo(this._device),i=r?Zt():0,o=this._device.statsManager.getStats(Vd);o.get("GPU Memory").subtractCount(this.allocatedBytes),o.get(`${this.allocatedBytesName||e} Memory`).subtractCount(this.allocatedBytes),r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(Zt()-i)),this.allocatedBytes=0,this.allocatedBytesName=null}trackDeallocatedReferencedMemory(e=this.getStatsName()){this.trackDeallocatedMemory(`Referenced ${e}`)}addStats(){let e=this.getStatsName(),r=oo(this._device),i=r?Zt():0,o=[this._device.statsManager.getStats(Ud),this._device.statsManager.getStats(kd)],n=$d(this._device);for(let s of o)jd(s,n);for(let s of o)s.get("Resources Created").incrementCount(),s.get("Resources Active").incrementCount(),s.get(`${e}s Created`).incrementCount(),s.get(`${e}s Active`).incrementCount();r&&(r.statsBookkeepingCalls=(r.statsBookkeepingCalls||0)+1,r.statsBookkeepingTimeMs=(r.statsBookkeepingTimeMs||0)+(Zt()-i)),tT(this._device,e)}getStatsName(){return rT(this)}};M(D,"defaultProps",{id:"undefined",handle:void 0,userData:void 0})});var no,I,as=E(()=>{ne();no=class extends D{get[Symbol.toStringTag](){return"Buffer"}usage;indexType;updateTimestamp;constructor(e,r){let i={...r};(r.usage||0)&no.INDEX&&!r.indexType&&(r.data instanceof Uint32Array?i.indexType="uint32":r.data instanceof Uint16Array?i.indexType="uint16":r.data instanceof Uint8Array&&(i.indexType="uint8")),delete i.data,super(e,i,no.defaultProps),this.usage=i.usage||0,this.indexType=i.indexType,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createBuffer({...this.props,...e})}debugData=new ArrayBuffer(0);_setDebugData(e,r,i){let o=null,n;ArrayBuffer.isView(e)?(o=e,n=e.buffer):n=e;let s=Math.min(e?e.byteLength:i,no.DEBUG_DATA_MAX_LENGTH);if(n===null)this.debugData=new ArrayBuffer(s);else{let a=Math.min(o?.byteOffset||0,n.byteLength),c=Math.max(0,n.byteLength-a),l=Math.min(s,c);this.debugData=new Uint8Array(n,a,l).slice().buffer}}},I=no;M(I,"INDEX",16),M(I,"VERTEX",32),M(I,"UNIFORM",64),M(I,"STORAGE",128),M(I,"INDIRECT",256),M(I,"QUERY_RESOLVE",512),M(I,"MAP_READ",1),M(I,"MAP_WRITE",2),M(I,"COPY_SRC",4),M(I,"COPY_DST",8),M(I,"DEBUG_DATA_MAX_LENGTH",32),M(I,"defaultProps",{...D.defaultProps,usage:0,byteLength:0,byteOffset:0,data:null,indexType:"uint16",onMapped:void 0})});var bl,he,yl,cs=E(()=>{bl=class{getDataTypeInfo(e){let[r,i,o]=yl[e],n=e.includes("norm"),s=!n&&!e.startsWith("float"),a=e.startsWith("s");return{signedType:r,primitiveType:i,byteLength:o,normalized:n,integer:s,signed:a}}getNormalizedDataType(e){let r=e;switch(r){case"uint8":return"unorm8";case"sint8":return"snorm8";case"uint16":return"unorm16";case"sint16":return"snorm16";default:return r}}alignTo(e,r){switch(r){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}getDataType(e){let r=ArrayBuffer.isView(e)?e.constructor:e;if(r===Uint8ClampedArray)return"uint8";let i=Object.values(yl).find(o=>r===o[4]);if(!i)throw new Error(r.name);return i[0]}getTypedArrayConstructor(e){let[,,,,r]=yl[e];return r}},he=new bl,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]}});var Tl,Pt,ls=E(()=>{cs();Tl=class{getVertexFormatInfo(e){let r;e.endsWith("-webgl")&&(e.replace("-webgl",""),r=!0);let[i,o]=e.split("x"),n=i,s=o?parseInt(o):1,a=he.getDataTypeInfo(n),c={type:n,components:s,byteLength:a.byteLength*s,integer:a.integer,signed:a.signed,normalized:a.normalized};return r&&(c.webglOnly=!0),c}makeVertexFormat(e,r,i){let o=i?he.getNormalizedDataType(e):e;switch(o){case"unorm8":return r===1?"unorm8":r===3?"unorm8x3-webgl":`${o}x${r}`;case"snorm8":return r===1?"snorm8":r===3?"snorm8x3-webgl":`${o}x${r}`;case"uint8":case"sint8":if(r===1||r===3)throw new Error(`size: ${r}`);return`${o}x${r}`;case"uint16":return r===1?"uint16":r===3?"uint16x3-webgl":`${o}x${r}`;case"sint16":return r===1?"sint16":r===3?"sint16x3-webgl":`${o}x${r}`;case"unorm16":return r===1?"unorm16":r===3?"unorm16x3-webgl":`${o}x${r}`;case"snorm16":return r===1?"snorm16":r===3?"snorm16x3-webgl":`${o}x${r}`;case"float16":if(r===1||r===3)throw new Error(`size: ${r}`);return`${o}x${r}`;default:return r===1?o:`${o}x${r}`}}getVertexFormatFromAttribute(e,r,i){if(!r||r>4)throw new Error(`size ${r}`);let o=r,n=he.getDataType(e);return this.makeVertexFormat(n,o,i)}getCompatibleVertexFormat(e){let r;switch(e.primitiveType){case"f32":r="float32";break;case"i32":r="sint32";break;case"u32":r="uint32";break;case"f16":return e.components<=2?"float16x2":"float16x4"}return e.components===1?r:`${r}x${e.components}`}},Pt=new Tl});function Rl(t){let e=Yd[t];if(!e)throw new Error(`Unsupported texture format ${t}`);return e}function Xd(){return Yd}var ae,H,nt,oT,fs,xl,hs,Al,nT,Sl,qt,El,wl,us,Hd,sT,aT,Yd,Pl=E(()=>{ae="texture-compression-bc",H="texture-compression-astc",nt="texture-compression-etc2",oT="texture-compression-etc1-webgl",fs="texture-compression-pvrtc-webgl",xl="texture-compression-atc-webgl",hs="float32-renderable-webgl",Al="float16-renderable-webgl",nT="rgb9e5ufloat-renderable-webgl",Sl="snorm8-renderable-webgl",qt="norm16-webgl",El="norm16-renderable-webgl",wl="snorm16-renderable-webgl",us="float32-filterable",Hd="float16-filterable-webgl";sT={r8unorm:{},rg8unorm:{},"rgb8unorm-webgl":{},rgba8unorm:{},"rgba8unorm-srgb":{},r8snorm:{render:Sl},rg8snorm:{render:Sl},"rgb8snorm-webgl":{},rgba8snorm:{render:Sl},r8uint:{},rg8uint:{},rgba8uint:{},r8sint:{},rg8sint:{},rgba8sint:{},bgra8unorm:{},"bgra8unorm-srgb":{},r16unorm:{f:qt,render:El},rg16unorm:{f:qt,render:El},"rgb16unorm-webgl":{f:qt,render:!1},rgba16unorm:{f:qt,render:El},r16snorm:{f:qt,render:wl},rg16snorm:{f:qt,render:wl},"rgb16snorm-webgl":{f:qt,render:!1},rgba16snorm:{f:qt,render:wl},r16uint:{},rg16uint:{},rgba16uint:{},r16sint:{},rg16sint:{},rgba16sint:{},r16float:{render:Al,filter:"float16-filterable-webgl"},rg16float:{render:Al,filter:Hd},rgba16float:{render:Al,filter:Hd},r32uint:{},rg32uint:{},rgba32uint:{},r32sint:{},rg32sint:{},rgba32sint:{},r32float:{render:hs,filter:us},rg32float:{render:!1,filter:us},"rgb32float-webgl":{render:hs,filter:us},rgba32float:{render:hs,filter:us},"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:nT},rg11b10ufloat:{channels:"rgb",bitsPerChannel:[11,11,10,0],packed:!0,p:1,render:hs},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}},aT={"bc1-rgb-unorm-webgl":{f:ae},"bc1-rgb-unorm-srgb-webgl":{f:ae},"bc1-rgba-unorm":{f:ae},"bc1-rgba-unorm-srgb":{f:ae},"bc2-rgba-unorm":{f:ae},"bc2-rgba-unorm-srgb":{f:ae},"bc3-rgba-unorm":{f:ae},"bc3-rgba-unorm-srgb":{f:ae},"bc4-r-unorm":{f:ae},"bc4-r-snorm":{f:ae},"bc5-rg-unorm":{f:ae},"bc5-rg-snorm":{f:ae},"bc6h-rgb-ufloat":{f:ae},"bc6h-rgb-float":{f:ae},"bc7-rgba-unorm":{f:ae},"bc7-rgba-unorm-srgb":{f:ae},"etc2-rgb8unorm":{f:nt},"etc2-rgb8unorm-srgb":{f:nt},"etc2-rgb8a1unorm":{f:nt},"etc2-rgb8a1unorm-srgb":{f:nt},"etc2-rgba8unorm":{f:nt},"etc2-rgba8unorm-srgb":{f:nt},"eac-r11unorm":{f:nt},"eac-r11snorm":{f:nt},"eac-rg11unorm":{f:nt},"eac-rg11snorm":{f:nt},"astc-4x4-unorm":{f:H},"astc-4x4-unorm-srgb":{f:H},"astc-5x4-unorm":{f:H},"astc-5x4-unorm-srgb":{f:H},"astc-5x5-unorm":{f:H},"astc-5x5-unorm-srgb":{f:H},"astc-6x5-unorm":{f:H},"astc-6x5-unorm-srgb":{f:H},"astc-6x6-unorm":{f:H},"astc-6x6-unorm-srgb":{f:H},"astc-8x5-unorm":{f:H},"astc-8x5-unorm-srgb":{f:H},"astc-8x6-unorm":{f:H},"astc-8x6-unorm-srgb":{f:H},"astc-8x8-unorm":{f:H},"astc-8x8-unorm-srgb":{f:H},"astc-10x5-unorm":{f:H},"astc-10x5-unorm-srgb":{f:H},"astc-10x6-unorm":{f:H},"astc-10x6-unorm-srgb":{f:H},"astc-10x8-unorm":{f:H},"astc-10x8-unorm-srgb":{f:H},"astc-10x10-unorm":{f:H},"astc-10x10-unorm-srgb":{f:H},"astc-12x10-unorm":{f:H},"astc-12x10-unorm-srgb":{f:H},"astc-12x12-unorm":{f:H},"astc-12x12-unorm-srgb":{f:H},"pvrtc-rgb4unorm-webgl":{f:fs},"pvrtc-rgba4unorm-webgl":{f:fs},"pvrtc-rgb2unorm-webgl":{f:fs},"pvrtc-rgba2unorm-webgl":{f:fs},"etc1-rbg-unorm-webgl":{f:oT},"atc-rgb-unorm-webgl":{f:xl},"atc-rgba-unorm-webgl":{f:xl},"atc-rgbai-unorm-webgl":{f:xl}},Yd={...sT,...aT}});function uT({format:t,width:e,height:r,depth:i,byteAlignment:o}){let n=ue.getInfo(t),{bytesPerPixel:s,bytesPerBlock:a=s,blockWidth:c=1,blockHeight:l=1,compressed:f=!1}=n,h=f?Math.ceil(e/c):e,u=f?Math.ceil(r/l):r,d=h*a,p=Math.ceil(d/o)*o,g=u,m=p*g*i;return{bytesPerPixel:s,bytesPerRow:p,rowsPerImage:g,depthOrArrayLayers:i,bytesPerImage:p*g,byteLength:m}}function dT(t){let e=Rl(t),r={format:t,create:e.f??!0,render:e.render??!0,filter:e.filter??!0,blend:e.blend??!0,store:e.store??!0},i=Kd(t),o=t.startsWith("depth")||t.startsWith("stencil"),n=i?.signed,s=i?.integer,a=i?.webgl,c=Boolean(i?.compressed);return r.render&&=!o&&!c,r.filter&&=!o&&!n&&!s&&!a,r}function Kd(t){let e=pT(t);if(ue.isCompressed(t)){e.channels="rgb",e.components=3,e.bytesPerPixel=1,e.srgb=!1,e.compressed=!0,e.bytesPerBlock=mT(t);let i=gT(t);i&&(e.blockWidth=i.blockWidth,e.blockHeight=i.blockHeight)}let r=e.packed?null:cT.exec(t);if(r){let[,i,o,n,s,a]=r,c=`${n}${o}`,l=he.getDataTypeInfo(c),f=l.byteLength*8,h=i?.length??1,u=[f,h>=2?f:0,h>=3?f:0,h>=4?f:0];e={format:t,attachment:e.attachment,dataType:l.signedType,components:h,channels:i,integer:l.integer,signed:l.signed,normalized:l.normalized,bitsPerChannel:u,bytesPerPixel:l.byteLength*h,packed:e.packed,srgb:e.srgb},a==="-webgl"&&(e.webgl=!0),s==="-srgb"&&(e.srgb=!0)}return t.endsWith("-webgl")&&(e.webgl=!0),t.endsWith("-srgb")&&(e.srgb=!0),e}function pT(t){let e=Rl(t),r=e.bytesPerPixel||1,i=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:t,attachment:e.attachment||"color",channels:e.channels||"r",components:e.components||e.channels?.length||1,bytesPerPixel:r,bitsPerChannel:i,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 gT(t){let r=/.*-(\d+)x(\d+)-.*/.exec(t);if(r){let[,i,o]=r;return{blockWidth:Number(i),blockHeight:Number(o)}}return t.startsWith("bc")||t.startsWith("etc1")||t.startsWith("etc2")||t.startsWith("eac")||t.startsWith("atc")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb4")||t.startsWith("pvrtc-rgba4")?{blockWidth:4,blockHeight:4}:t.startsWith("pvrtc-rgb2")||t.startsWith("pvrtc-rgba2")?{blockWidth:8,blockHeight:4}:null}function mT(t){return t.startsWith("bc1")||t.startsWith("bc4")||t.startsWith("etc1")||t.startsWith("etc2-rgb8")||t.startsWith("etc2-rgb8a1")||t.startsWith("eac-r11")||t==="atc-rgb-unorm-webgl"?8:t.startsWith("bc2")||t.startsWith("bc3")||t.startsWith("bc5")||t.startsWith("bc6h")||t.startsWith("bc7")||t.startsWith("etc2-rgba8")||t.startsWith("eac-rg11")||t.startsWith("astc")||t==="atc-rgba-unorm-webgl"||t==="atc-rgbai-unorm-webgl"?16:t.startsWith("pvrtc")?8:16}var cT,lT,fT,hT,vl,ue,ds=E(()=>{cs();Pl();cT=/^(r|rg|rgb|rgba|bgra)([0-9]*)([a-z]*)(-srgb)?(-webgl)?$/,lT=["rgb","rgba","bgra"],fT=["depth","stencil"],hT=["bc1","bc2","bc3","bc4","bc5","bc6","bc7","etc1","etc2","eac","atc","astc","pvrtc"],vl=class{isColor(e){return lT.some(r=>e.startsWith(r))}isDepthStencil(e){return fT.some(r=>e.startsWith(r))}isCompressed(e){return hT.some(r=>e.startsWith(r))}getInfo(e){return Kd(e)}getCapabilities(e){return dT(e)}computeMemoryLayout(e){return uT(e)}},ue=new vl});function si(t){return typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement||typeof VideoFrame<"u"&&t instanceof VideoFrame||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas}function so(t){if(typeof ImageData<"u"&&t instanceof ImageData||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas)return{width:t.width,height:t.height};if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement)return{width:t.naturalWidth,height:t.naturalHeight};if(typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement)return{width:t.videoWidth,height:t.videoHeight};if(typeof VideoFrame<"u"&&t instanceof VideoFrame)return{width:t.displayWidth,height:t.displayHeight};throw new Error("Unknown image type")}var Ml=E(()=>{});function _T(t,e){let r=Cl(t),i=e.map(Cl).filter(o=>o!==void 0);return[r,...i].filter(o=>o!==void 0)}function Cl(t){if(t!==void 0){if(t===null||typeof t=="string"||typeof t=="number"||typeof t=="boolean")return t;if(t instanceof Error)return t.message;if(Array.isArray(t))return t.map(Cl);if(typeof t=="object"){if(yT(t)){let e=String(t);if(e!=="[object Object]")return e}return bT(t)?TT(t):t.constructor?.name||"Object"}return String(t)}}function yT(t){return"toString"in t&&typeof t.toString=="function"&&t.toString!==Object.prototype.toString}function bT(t){return"message"in t&&"type"in t}function TT(t){let e=typeof t.type=="string"?t.type:"message",r=typeof t.message=="string"?t.message:"",i=typeof t.lineNum=="number"?t.lineNum:null,o=typeof t.linePos=="number"?t.linePos:null,n=i!==null&&o!==null?` @ ${i}:${o}`:i!==null?` @ ${i}`:"";return`${e}${n}: ${r}`.trim()}function xT(t,e){return t!=null?Boolean(t):e!==void 0?e!=="production":!1}function AT(){return xT(x.get("debug"),ST())}function ST(){let t=globalThis.process;if(t?.env)return t.env.NODE_ENV}var ao,co,Il,be,Ol=E(()=>{al();Ne();ni();as();ls();ds();Ml();Pl();ao=class{};co=class{features;disabledFeatures;constructor(e=[],r){this.features=new Set(e),this.disabledFeatures=r||{}}*[Symbol.iterator](){yield*this.features}has(e){return!this.disabledFeatures?.[e]&&this.features.has(e)}},Il=class{get[Symbol.toStringTag](){return"Device"}toString(){return`Device(${this.id})`}id;props;userData={};statsManager=es;_factories={};timestamp=0;_reused=!1;_moduleData={};_textureCaps={};_debugGPUTimeQuery=null;constructor(e){this.props={...Il.defaultProps,...e},this.id=this.props.id||ot(this[Symbol.toStringTag].toLowerCase())}getVertexFormatInfo(e){return Pt.getVertexFormatInfo(e)}isVertexFormatSupported(e){return!0}getTextureFormatInfo(e){return ue.getInfo(e)}getTextureFormatCapabilities(e){let r=this._textureCaps[e];if(!r){let i=this._getDeviceTextureFormatCapabilities(e);r=this._getDeviceSpecificTextureFormatCapabilities(i),this._textureCaps[e]=r}return r}getMipLevelCount(e,r,i=1){let o=Math.max(e,r,i);return 1+Math.floor(Math.log2(o))}isExternalImage(e){return si(e)}getExternalImageSize(e){return so(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 ue.isCompressed(e)}getSupportedCompressedTextureFormats(){let e=[];for(let r of Object.keys(Xd()))this.isTextureFormatCompressed(r)&&this.isTextureFormatSupported(r)&&e.push(r);return e}pushDebugGroup(e){this.commandEncoder.pushDebugGroup(e)}popDebugGroup(){this.commandEncoder?.popDebugGroup()}insertDebugMarker(e){this.commandEncoder?.insertDebugMarker(e)}loseDevice(){return!1}incrementTimestamp(){return this.timestamp++}reportError(e,r,...i){if(!this.props.onError(e,r)){let n=_T(r,i);return x.error(this.type==="webgl"?"%cWebGL":"%cWebGPU","color: white; background: red; padding: 2px 6px; border-radius: 3px;",e.message,...n)}return()=>{}}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.`;x.once(0,e)()}}getDefaultCanvasContext(){if(!this.canvasContext)throw new Error("Device has no default CanvasContext. See props.createCanvasContext");return this.canvasContext}createFence(){throw new Error("createFence() not implemented")}beginRenderPass(e){return this.commandEncoder.beginRenderPass(e)}beginComputePass(e){return this.commandEncoder.beginComputePass(e)}generateMipmapsWebGPU(e){throw new Error("not implemented")}_createSharedRenderPipelineWebGL(e){throw new Error("_createSharedRenderPipelineWebGL() not implemented")}_createBindGroupLayoutWebGPU(e,r){throw new Error("_createBindGroupLayoutWebGPU() not implemented")}_createBindGroupWebGPU(e,r,i,o,n){throw new Error("_createBindGroupWebGPU() not implemented")}_supportsDebugGPUTime(){return this.features.has("timestamp-query")&&Boolean(this.props.debug||this.props.debugGPUTime)}_enableDebugGPUTime(e=256){if(!this._supportsDebugGPUTime())return null;if(this._debugGPUTimeQuery)return this._debugGPUTimeQuery;try{this._debugGPUTimeQuery=this.createQuerySet({type:"timestamp",count:e}),this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id,timeProfilingQuerySet:this._debugGPUTimeQuery})}catch{this._debugGPUTimeQuery=null}return this._debugGPUTimeQuery}_disableDebugGPUTime(){this._debugGPUTimeQuery&&(this.commandEncoder.getTimeProfilingQuerySet()===this._debugGPUTimeQuery&&(this.commandEncoder=this.createCommandEncoder({id:this.commandEncoder.props.id})),this._debugGPUTimeQuery.destroy(),this._debugGPUTimeQuery=null)}_isDebugGPUTimeEnabled(){return this._debugGPUTimeQuery!==null}getCanvasContext(){return this.getDefaultCanvasContext()}readPixelsToArrayWebGL(e,r){throw new Error("not implemented")}readPixelsToBufferWebGL(e,r){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,r){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}getModuleData(e){return this._moduleData[e]||={},this._moduleData[e]}static _getCanvasContextProps(e){return e.createCanvasContext===!0?{}:e.createCanvasContext}_getDeviceTextureFormatCapabilities(e){let r=ue.getCapabilities(e),i=n=>(typeof n=="string"?this.features.has(n):n)??!0,o=i(r.create);return{format:e,create:o,render:o&&i(r.render),filter:o&&i(r.filter),blend:o&&i(r.blend),store:o&&i(r.store)}}_normalizeBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});let r={...e};if((e.usage||0)&I.INDEX&&(e.indexType||(e.data instanceof Uint32Array?r.indexType="uint32":e.data instanceof Uint16Array?r.indexType="uint16":e.data instanceof Uint8Array&&(r.data=new Uint16Array(e.data),r.indexType="uint16")),!r.indexType))throw new Error("indices buffer content must be of type uint16 or uint32");return r}},be=Il;M(be,"defaultProps",{id:null,powerPreference:"high-performance",failIfMajorPerformanceCaveat:!1,createCanvasContext:void 0,webgl:{},onError:(e,r)=>{},onResize:(e,r)=>{let[i,o]=e.getDevicePixelSize();x.log(1,`${e} resized => ${i}x${o}px`)()},onPositionChange:(e,r)=>{let[i,o]=e.getPosition();x.log(1,`${e} repositioned => ${i},${o}`)()},onVisibilityChange:e=>x.log(1,`${e} Visibility changed ${e.isVisible}`)(),onDevicePixelRatioChange:(e,r)=>x.log(1,`${e} DPR changed ${r.oldRatio} => ${e.devicePixelRatio}`)(),debug:AT(),debugGPUTime:!1,debugShaders:x.get("debug-shaders")||void 0,debugFramebuffers:Boolean(x.get("debug-framebuffers")),debugFactories:Boolean(x.get("debug-factories")),debugWebGL:Boolean(x.get("debug-webgl")),debugSpectorJS:void 0,debugSpectorJSUrl:void 0,_reuseDevices:!1,_requestMaxLimits:!0,_cacheShaders:!0,_destroyShaders:!1,_cachePipelines:!0,_sharePipelines:!0,_destroyPipelines:!1,_initializeFeatures:!0,_disabledFeatures:{"compilation-status-async-webgl":!0},_handle:void 0})});var ET,Zd,gs,ps,Gt,qd=E(()=>{Ol();al();Ne();ET="set luma.log.level=1 (or higher) to trace rendering",Zd="No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.",gs=class{stats=es;log=x;VERSION="9.3.2";spector;preregisteredAdapters=new Map;constructor(){if(globalThis.luma){if(globalThis.luma.VERSION!==this.VERSION)throw x.error(`Found luma.gl ${globalThis.luma.VERSION} while initialzing ${this.VERSION}`)(),x.error("'yarn why @luma.gl/core' can help identify the source of the conflict")(),new Error("luma.gl - multiple versions detected: see console log");x.error("This version of luma.gl has already been initialized")()}x.log(1,`${this.VERSION} - ${ET}`)(),globalThis.luma=this}async createDevice(e={}){let r={...gs.defaultProps,...e},i=this.selectAdapter(r.type,r.adapters);if(!i)throw new Error(Zd);return r.waitForPageLoad&&await i.pageLoaded,await i.create(r)}async attachDevice(e,r){let i=this._getTypeFromHandle(e,r.adapters),o=i&&this.selectAdapter(i,r.adapters);if(!o)throw new Error(Zd);return await o?.attach?.(e,r)}registerAdapters(e){for(let r of e)this.preregisteredAdapters.set(r.type,r)}getSupportedAdapters(e=[]){let r=this._getAdapterMap(e);return Array.from(r).map(([,i])=>i).filter(i=>i.isSupported?.()).map(i=>i.type)}getBestAvailableAdapterType(e=[]){let r=["webgpu","webgl","null"],i=this._getAdapterMap(e);for(let o of r)if(i.get(o)?.isSupported?.())return o;return null}selectAdapter(e,r=[]){let i=e;e==="best-available"&&(i=this.getBestAvailableAdapterType(r));let o=this._getAdapterMap(r);return i&&o.get(i)||null}enforceWebGL2(e=!0,r=[]){let o=this._getAdapterMap(r).get("webgl");o||x.warn("enforceWebGL2: webgl adapter not found")(),o?.enforceWebGL2?.(e)}setDefaultDeviceProps(e){Object.assign(gs.defaultProps,e)}_getAdapterMap(e=[]){let r=new Map(this.preregisteredAdapters);for(let i of e)r.set(i.type,i);return r}_getTypeFromHandle(e,r=[]){return e instanceof WebGL2RenderingContext?"webgl":typeof GPUDevice<"u"&&e instanceof GPUDevice||e?.queue?"webgpu":e===null?"null":(e instanceof WebGLRenderingContext?x.warn("WebGL1 is not supported",e)():x.warn("Unknown handle type",e)(),null)}},ps=gs;M(ps,"defaultProps",{...be.defaultProps,type:"best-available",adapters:void 0,waitForPageLoad:!0});Gt=new ps});function PT(){return ms||(RT()||typeof window>"u"?ms=Promise.resolve():ms=new Promise(t=>window.addEventListener("load",()=>t()))),ms}var lo,wT,RT,ms,Gd=E(()=>{Kt();lo=class{get pageLoaded(){return PT()}},wT=le()&&typeof document<"u",RT=()=>wT&&document.readyState==="complete",ms=null});var _s,Qd=E(()=>{_s=class{props;_resizeObserver;_intersectionObserver;_observeDevicePixelRatioTimeout=null;_observeDevicePixelRatioMediaQuery=null;_handleDevicePixelRatioChange=()=>this._refreshDevicePixelRatio();_trackPositionInterval=null;_started=!1;get started(){return this._started}constructor(e){this.props=e}start(){if(!(this._started||!this.props.canvas)){this._started=!0,this._intersectionObserver||=new IntersectionObserver(e=>this.props.onIntersection(e)),this._resizeObserver||=new ResizeObserver(e=>this.props.onResize(e)),this._intersectionObserver.observe(this.props.canvas);try{this._resizeObserver.observe(this.props.canvas,{box:"device-pixel-content-box"})}catch{this._resizeObserver.observe(this.props.canvas,{box:"content-box"})}this._observeDevicePixelRatioTimeout=setTimeout(()=>this._refreshDevicePixelRatio(),0),this.props.trackPosition&&this._trackPosition()}}stop(){this._started&&(this._started=!1,this._observeDevicePixelRatioTimeout&&(clearTimeout(this._observeDevicePixelRatioTimeout),this._observeDevicePixelRatioTimeout=null),this._observeDevicePixelRatioMediaQuery&&(this._observeDevicePixelRatioMediaQuery.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=null),this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null),this._resizeObserver?.disconnect(),this._intersectionObserver?.disconnect())}_refreshDevicePixelRatio(){this._started&&(this.props.onDevicePixelRatioChange(),this._observeDevicePixelRatioMediaQuery?.removeEventListener("change",this._handleDevicePixelRatioChange),this._observeDevicePixelRatioMediaQuery=matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),this._observeDevicePixelRatioMediaQuery.addEventListener("change",this._handleDevicePixelRatioChange,{once:!0}))}_trackPosition(e=100){this._trackPositionInterval||(this._trackPositionInterval=setInterval(()=>{this._started?this.props.onPositionChange():this._trackPositionInterval&&(clearInterval(this._trackPositionInterval),this._trackPositionInterval=null)},e))}}});function Jd(){let t,e;return{promise:new Promise((i,o)=>{t=i,e=o}),resolve:t,reject:e}}var ep=E(()=>{});function Nl(t,e){if(!t){let r=new Error(e??"luma.gl assertion failed.");throw Error.captureStackTrace?.(r,Nl),r}}function Rr(t,e){return Nl(t,e),t}var Dl=E(()=>{});function vT(t){if(typeof t=="string"){let e=document.getElementById(t);if(!e)throw new Error(`${t} is not an HTML element`);return e}return t||document.body}function MT(t){let e=document.getElementById(t);if(!vt.isHTMLCanvas(e))throw new Error("Object is not a canvas element");return e}function CT(t){let{width:e,height:r}=t,i=document.createElement("canvas");i.id=ot("lumagl-auto-created-canvas"),i.width=e||1,i.height=r||1,i.style.width=Number.isFinite(e)?`${e}px`:"100%",i.style.height=Number.isFinite(r)?`${r}px`:"100%",t?.visible||(i.style.visibility="hidden");let o=vT(t?.container||null);return o.insertBefore(i,o.firstChild),i}function IT(t,e,r,i,o){let n=t,s=tp(n[0],e,r),a=rp(n[1],e,i,o),c=tp(n[0]+1,e,r),l=c===r-1?c:c-1;c=rp(n[1]+1,e,i,o);let f;return o?(c=c===0?c:c+1,f=a,a=c):f=c===i-1?c:c-1,{x:s,y:a,width:Math.max(l-s+1,1),height:Math.max(f-a+1,1)}}function tp(t,e,r){return Math.min(Math.round(t*e),r-1)}function rp(t,e,r,i){return i?Math.max(0,r-1-Math.round(t*e)):Math.min(Math.round(t*e),r-1)}var fo,vt,Bl=E(()=>{Kt();Qd();ni();ep();Dl();fo=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=Jd();_canvasObserver;_position=[0,0];destroyed=!1;_needsDrawingBufferResize=!0;toString(){return`${this[Symbol.toStringTag]}(${this.id})`}constructor(e){this.props={...fo.defaultProps,...e},e=this.props,this.initialized=this._initializedResolvers.promise,le()?e.canvas?typeof e.canvas=="string"?this.canvas=MT(e.canvas):this.canvas=e.canvas:this.canvas=CT(e):this.canvas={width:e.width||1,height:e.height||1},fo.isHTMLCanvas(this.canvas)?(this.id=e.id||this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):fo.isOffscreenCanvas(this.canvas)?(this.id=e.id||"offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas):(this.id=e.id||"node-canvas-context",this.type="node"),this.cssWidth=this.htmlCanvas?.clientWidth||this.canvas.width,this.cssHeight=this.htmlCanvas?.clientHeight||this.canvas.height,this.devicePixelWidth=this.canvas.width,this.devicePixelHeight=this.canvas.height,this.drawingBufferWidth=this.canvas.width,this.drawingBufferHeight=this.canvas.height,this.devicePixelRatio=globalThis.devicePixelRatio||1,this._position=[0,0],this._canvasObserver=new _s({canvas:this.htmlCanvas,trackPosition:this.props.trackPosition,onResize:r=>this._handleResize(r),onIntersection:r=>this._handleIntersection(r),onDevicePixelRatioChange:()=>this._observeDevicePixelRatio(),onPositionChange:()=>this.updatePosition()})}destroy(){this.destroyed||(this.destroyed=!0,this._stopObservers(),this.device=null)}setProps(e){return"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1,this._updateDrawingBufferSize()),this}getCurrentFramebuffer(e){return this._resizeDrawingBufferIfNeeded(),this._getCurrentFramebuffer(e)}getCSSSize(){return[this.cssWidth,this.cssHeight]}getPosition(){return this._position}getDevicePixelSize(){return[this.devicePixelWidth,this.devicePixelHeight]}getDrawingBufferSize(){return[this.drawingBufferWidth,this.drawingBufferHeight]}getMaxDrawingBufferSize(){let e=this.device.limits.maxTextureDimension2D;return[e,e]}setDrawingBufferSize(e,r){e=Math.floor(e),r=Math.floor(r),!(this.drawingBufferWidth===e&&this.drawingBufferHeight===r)&&(this.drawingBufferWidth=e,this.drawingBufferHeight=r,this._needsDrawingBufferResize=!0)}getDevicePixelRatio(){return typeof window<"u"&&window.devicePixelRatio||1}cssToDevicePixels(e,r=!0){let i=this.cssToDeviceRatio(),[o,n]=this.getDrawingBufferSize();return IT(e,i,o,n,r)}getPixelSize(){return this.getDevicePixelSize()}getAspect(){let[e,r]=this.getDrawingBufferSize();return e>0&&r>0?e/r:1}cssToDeviceRatio(){try{let[e]=this.getDrawingBufferSize(),[r]=this.getCSSSize();return r?e/r:1}catch{return 1}}resize(e){this.setDrawingBufferSize(e.width,e.height)}_setAutoCreatedCanvasId(e){this.htmlCanvas?.id==="lumagl-auto-created-canvas"&&(this.htmlCanvas.id=e)}_startObservers(){this.destroyed||this._canvasObserver.start()}_stopObservers(){this._canvasObserver.stop()}_handleIntersection(e){if(this.destroyed)return;let r=e.find(o=>o.target===this.canvas);if(!r)return;let i=r.isIntersecting;this.isVisible!==i&&(this.isVisible=i,this.device.props.onVisibilityChange(this))}_handleResize(e){if(this.destroyed)return;let r=e.find(l=>l.target===this.canvas);if(!r)return;let i=Rr(r.contentBoxSize?.[0]);this.cssWidth=i.inlineSize,this.cssHeight=i.blockSize;let o=this.getDevicePixelSize(),n=r.devicePixelContentBoxSize?.[0]?.inlineSize||i.inlineSize*devicePixelRatio,s=r.devicePixelContentBoxSize?.[0]?.blockSize||i.blockSize*devicePixelRatio,[a,c]=this.getMaxDrawingBufferSize();this.devicePixelWidth=Math.max(1,Math.min(n,a)),this.devicePixelHeight=Math.max(1,Math.min(s,c)),this._updateDrawingBufferSize(),this.device.props.onResize(this,{oldPixelSize:o})}_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._initializedResolvers.resolve(),this.isInitialized=!0,this.updatePosition()}_resizeDrawingBufferIfNeeded(){this._needsDrawingBufferResize&&(this._needsDrawingBufferResize=!1,(this.drawingBufferWidth!==this.canvas.width||this.drawingBufferHeight!==this.canvas.height)&&(this.canvas.width=this.drawingBufferWidth,this.canvas.height=this.drawingBufferHeight,this._configureDevice()))}_observeDevicePixelRatio(){if(this.destroyed||!this._canvasObserver.started)return;let e=this.devicePixelRatio;this.devicePixelRatio=window.devicePixelRatio,this.updatePosition(),this.device.props.onDevicePixelRatioChange?.(this,{oldRatio:e})}updatePosition(){if(this.destroyed)return;let e=this.htmlCanvas?.getBoundingClientRect();if(e){let r=[e.left,e.top];if(this._position??=r,r[0]!==this._position[0]||r[1]!==this._position[1]){let o=this._position;this._position=r,this.device.props.onPositionChange?.(this,{oldPosition:o})}}}},vt=fo;M(vt,"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 ai,ip=E(()=>{Bl();ai=class extends vt{};M(ai,"defaultProps",vt.defaultProps)});var ho,op=E(()=>{Bl();ho=class extends vt{}});var ys,De,Fl=E(()=>{ne();ys=class extends D{get[Symbol.toStringTag](){return"Sampler"}constructor(e,r){r=ys.normalizeProps(e,r),super(e,r,ys.defaultProps)}static normalizeProps(e,r){return r}},De=ys;M(De,"defaultProps",{...D.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 OT,Se,B,Ll=E(()=>{ne();Fl();Ne();ds();OT={"1d":"1d","2d":"2d","2d-array":"2d",cube:"2d","cube-array":"2d","3d":"3d"},Se=class extends D{dimension;baseDimension;format;width;height;depth;mipLevels;samples;byteAlignment;ready=Promise.resolve(this);isReady=!0;updateTimestamp;get[Symbol.toStringTag](){return"Texture"}toString(){return`Texture(${this.id},${this.format},${this.width}x${this.height})`}constructor(e,r,i){if(r=Se.normalizeProps(e,r),super(e,r,Se.defaultProps),this.dimension=this.props.dimension,this.baseDimension=OT[this.dimension],this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.mipLevels=this.props.mipLevels,this.samples=this.props.samples||1,this.dimension==="cube"&&(this.depth=6),this.props.width===void 0||this.props.height===void 0)if(e.isExternalImage(r.data)){let o=e.getExternalImageSize(r.data);this.width=o?.width||1,this.height=o?.height||1}else this.width=1,this.height=1,(this.props.width===void 0||this.props.height===void 0)&&x.warn(`${this} created with undefined width or height. This is deprecated. Use DynamicTexture instead.`)();this.byteAlignment=i?.byteAlignment||1,this.updateTimestamp=e.incrementTimestamp()}clone(e){return this.device.createTexture({...this.props,...e})}setSampler(e){this.sampler=e instanceof De?e:this.device.createSampler(e)}copyImageData(e){let{data:r,depth:i,...o}=e;this.writeData(r,{...o,depthOrArrayLayers:o.depthOrArrayLayers??i})}computeMemoryLayout(e={}){let r=this._normalizeTextureReadOptions(e),{width:i=this.width,height:o=this.height,depthOrArrayLayers:n=this.depth}=r,{format:s,byteAlignment:a}=this;return ue.computeMemoryLayout({format:s,width:i,height:o,depth:n,byteAlignment:a})}readBuffer(e,r){throw new Error("readBuffer not implemented")}readDataAsync(e){throw new Error("readBuffer not implemented")}writeBuffer(e,r){throw new Error("readBuffer not implemented")}writeData(e,r){throw new Error("readBuffer not implemented")}readDataSyncWebGL(e){throw new Error("readDataSyncWebGL not available")}generateMipmapsWebGL(){throw new Error("generateMipmapsWebGL not available")}static normalizeProps(e,r){let i={...r},{width:o,height:n}=i;return typeof o=="number"&&(i.width=Math.max(1,Math.ceil(o))),typeof n=="number"&&(i.height=Math.max(1,Math.ceil(n))),i}_initializeData(e){this.device.isExternalImage(e)?this.copyExternalImage({image:e,width:this.width,height:this.height,depth:this.depth,mipLevel:0,x:0,y:0,z:0,aspect:"all",colorSpace:"srgb",premultipliedAlpha:!1,flipY:!1}):e&&this.copyImageData({data:e,mipLevel:0,x:0,y:0,z:0,aspect:"all"})}_normalizeCopyImageDataOptions(e){let{data:r,depth:i,...o}=e,n=this._normalizeTextureWriteOptions({...o,depthOrArrayLayers:o.depthOrArrayLayers??i});return{data:r,depth:n.depthOrArrayLayers,...n}}_normalizeCopyExternalImageOptions(e){let r=Se._omitUndefined(e),i=r.mipLevel??0,o=this._getMipLevelSize(i),n=this.device.getExternalImageSize(e.image),s={...Se.defaultCopyExternalImageOptions,...o,...n,...r};return s.width=Math.min(s.width,o.width-s.x),s.height=Math.min(s.height,o.height-s.y),s.depth=Math.min(s.depth,o.depthOrArrayLayers-s.z),s}_normalizeTextureReadOptions(e){let r=Se._omitUndefined(e),i=r.mipLevel??0,o=this._getMipLevelSize(i),n={...Se.defaultTextureReadOptions,...o,...r};return n.width=Math.min(n.width,o.width-n.x),n.height=Math.min(n.height,o.height-n.y),n.depthOrArrayLayers=Math.min(n.depthOrArrayLayers,o.depthOrArrayLayers-n.z),n}_getSupportedColorReadOptions(e){let r=this._normalizeTextureReadOptions(e),i=ue.getInfo(this.format);switch(this._validateColorReadAspect(r),this._validateColorReadFormat(i),this.dimension){case"2d":case"cube":case"cube-array":case"2d-array":case"3d":return r;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}}_validateColorReadAspect(e){if(e.aspect!=="all")throw new Error(`${this} color readback only supports aspect 'all'`)}_validateColorReadFormat(e){if(e.compressed)throw new Error(`${this} color readback does not support compressed formats (${this.format})`);switch(e.attachment){case"color":return;case"depth":throw new Error(`${this} color readback does not support depth formats (${this.format})`);case"stencil":throw new Error(`${this} color readback does not support stencil formats (${this.format})`);case"depth-stencil":throw new Error(`${this} color readback does not support depth-stencil formats (${this.format})`);default:throw new Error(`${this} color readback does not support format ${this.format}`)}}_normalizeTextureWriteOptions(e){let r=Se._omitUndefined(e),i=r.mipLevel??0,o=this._getMipLevelSize(i),n={...Se.defaultTextureWriteOptions,...o,...r};n.width=Math.min(n.width,o.width-n.x),n.height=Math.min(n.height,o.height-n.y),n.depthOrArrayLayers=Math.min(n.depthOrArrayLayers,o.depthOrArrayLayers-n.z);let s=ue.computeMemoryLayout({format:this.format,width:n.width,height:n.height,depth:n.depthOrArrayLayers,byteAlignment:this.byteAlignment}),a=s.bytesPerPixel*n.width;if(n.bytesPerRow=r.bytesPerRow??s.bytesPerRow,n.rowsPerImage=r.rowsPerImage??n.height,n.bytesPerRow<a)throw new Error(`bytesPerRow (${n.bytesPerRow}) must be at least ${a} for ${this.format}`);if(n.rowsPerImage<n.height)throw new Error(`rowsPerImage (${n.rowsPerImage}) must be at least ${n.height} for ${this.format}`);let c=this.device.getTextureFormatInfo(this.format).bytesPerPixel;if(c&&n.bytesPerRow%c!==0)throw new Error(`bytesPerRow (${n.bytesPerRow}) must be a multiple of bytesPerPixel (${c}) for ${this.format}`);return n}_getMipLevelSize(e){let r=Math.max(1,this.width>>e),i=this.baseDimension==="1d"?1:Math.max(1,this.height>>e),o=this.dimension==="3d"?Math.max(1,this.depth>>e):this.depth;return{width:r,height:i,depthOrArrayLayers:o}}getAllocatedByteLength(){let e=0;for(let r=0;r<this.mipLevels;r++){let{width:i,height:o,depthOrArrayLayers:n}=this._getMipLevelSize(r);e+=ue.computeMemoryLayout({format:this.format,width:i,height:o,depth:n,byteAlignment:1}).byteLength}return e*this.samples}static _omitUndefined(e){return Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))}},B=Se;M(B,"SAMPLE",4),M(B,"STORAGE",8),M(B,"RENDER",16),M(B,"COPY_SRC",1),M(B,"COPY_DST",2),M(B,"TEXTURE",4),M(B,"RENDER_ATTACHMENT",16),M(B,"defaultProps",{...D.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",usage:Se.SAMPLE|Se.RENDER|Se.COPY_DST,width:void 0,height:void 0,depth:1,mipLevels:1,samples:void 0,sampler:{},view:void 0}),M(B,"defaultCopyDataOptions",{data:void 0,byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,width:void 0,height:void 0,depthOrArrayLayers:void 0,depth:1,mipLevel:0,x:0,y:0,z:0,aspect:"all"}),M(B,"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}),M(B,"defaultTextureReadOptions",{x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"}),M(B,"defaultTextureWriteOptions",{byteOffset:0,bytesPerRow:void 0,rowsPerImage:void 0,x:0,y:0,z:0,width:void 0,height:void 0,depthOrArrayLayers:1,mipLevel:0,aspect:"all"})});var Ul,Qt,np=E(()=>{ne();Ul=class extends D{get[Symbol.toStringTag](){return"TextureView"}constructor(e,r){super(e,r,Ul.defaultProps)}},Qt=Ul;M(Qt,"defaultProps",{...D.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0})});function sp(t,e,r){let i="",o=e.split(/\r?\n/),n=t.slice().sort((s,a)=>s.lineNum-a.lineNum);switch(r?.showSourceCode||"no"){case"all":let s=0;for(let a=1;a<=o.length;a++){let c=o[a-1],l=n[s];for(c&&l&&(i+=ap(c,a,r));n.length>s&&l.lineNum===a;){let f=n[s++];f&&(i+=kl(f,o,f.lineNum,{...r,inlineSource:!1}))}}for(;n.length>s;){let a=n[s++];a&&(i+=kl(a,[],0,{...r,inlineSource:!1}))}return i;case"issues":case"no":for(let a of t)i+=kl(a,o,a.lineNum,{inlineSource:r?.showSourceCode!=="no"});return i}}function kl(t,e,r,i){if(i?.inlineSource){let n=NT(e,r),s=t.linePos>0?`${" ".repeat(t.linePos+5)}^^^
|
|
9
9
|
`:"";return`
|
|
10
10
|
${n}${s}${t.type.toUpperCase()}: ${t.message}
|
|
11
11
|
|
|
12
|
-
`}let o=t.type==="error"?"red":"orange";return i?.html?`<div class='luma-compiler-log-${t.type}' style="color:${o};"><b> ${t.type.toUpperCase()}: ${t.message}</b></div>`:`${t.type.toUpperCase()}: ${t.message}`}function
|
|
13
|
-
`}`}function
|
|
12
|
+
`}let o=t.type==="error"?"red":"orange";return i?.html?`<div class='luma-compiler-log-${t.type}' style="color:${o};"><b> ${t.type.toUpperCase()}: ${t.message}</b></div>`:`${t.type.toUpperCase()}: ${t.message}`}function NT(t,e,r){let i="";for(let o=e-2;o<=e;o++){let n=t[o-1];n!==void 0&&(i+=ap(n,e,r))}return i}function ap(t,e,r){let i=r?.html?BT(t):t;return`${DT(String(e),4)}: ${i}${r?.html?"<br/>":`
|
|
13
|
+
`}`}function DT(t,e){let r="";for(let i=t.length;i<e;++i)r+=" ";return r+t}function BT(t){return t.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}var cp=E(()=>{});function FT(t){return LT(t.source)||t.id||ot(`unnamed ${t.stage}-shader`)}function LT(t,e="unnamed"){return/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(t)?.[1]??e}var Vl,Jt,zl=E(()=>{ne();ni();cp();Vl=class extends D{get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,r){r={...r,debugShaders:r.debugShaders||e.props.debugShaders||"errors"},super(e,{id:FT(r),...r},Vl.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 r=await this.getCompilationInfo();e==="warnings"&&r?.length===0||this._displayShaderLog(r,this.id)}_displayShaderLog(e,r){if(typeof document>"u"||!document?.createElement)return;let i=r,o=`${this.stage} shader "${i}"`,n=sp(e,this.source,{showSourceCode:"all",html:!0}),s=this.getTranslatedSource(),a=document.createElement("div");a.innerHTML=`<h1>Compilation error in ${o}</h1>
|
|
14
14
|
<div style="display:flex;position:fixed;top:10px;right:20px;gap:2px;">
|
|
15
15
|
<button id="copy">Copy source</button><br/>
|
|
16
16
|
<button id="close">Close</button>
|
|
17
17
|
</div>
|
|
18
|
-
<code><pre>${n}</pre></code>`,s&&(a.innerHTML+=`<br /><h1>Translated Source</h1><br /><br /><code><pre>${s}</pre></code>`),a.style.top="0",a.style.left="0",a.style.background="white",a.style.position="fixed",a.style.zIndex="9999",a.style.maxWidth="100vw",a.style.maxHeight="100vh",a.style.overflowY="auto",document.body.appendChild(a),a.querySelector(".luma-compiler-log-error")?.scrollIntoView(),a.querySelector("button#close").onclick=()=>{a.remove()},a.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}},er=Ul;M(er,"defaultProps",{...D.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0})});var Vl,at,cp=E(()=>{se();Bl();De();Vl=class extends D{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,r={}){super(e,r,Vl.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let r=this.colorAttachments.map(o=>o.texture.clone(e)),i=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:r,depthStencilAttachment:i})}resize(e){let r=!e;if(e){let[i,o]=Array.isArray(e)?e:[e.width,e.height];r=r||o!==this.height||i!==this.width,this.width=i,this.height=o}r&&(x.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((r,i)=>{if(typeof r=="string"){let o=this.createColorTexture(r,i);return this.attachResource(o),o.view}return r instanceof B?r.view:r});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let r=this.createDepthStencilTexture(e);this.attachResource(r),this.depthStencilAttachment=r.view}else e instanceof B?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,r){return this.device.createTexture({id:`${this.id}-color-attachment-${r}`,usage:B.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:B.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,r){if(this.colorAttachments.forEach((i,o)=>{let n=i.texture.clone({width:e,height:r});this.destroyAttachedResource(i),this.colorAttachments[o]=n.view,this.attachResource(n.view)}),this.depthStencilAttachment){let i=this.depthStencilAttachment.texture.clone({width:e,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=i.view,this.attachResource(i)}this.updateAttachments()}},at=Vl;M(at,"defaultProps",{...D.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null})});var zl,we,Wl=E(()=>{se();zl=class extends D{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(e,r){super(e,r,zl.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}},we=zl;M(we,"defaultProps",{...D.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,bindings:void 0,bindGroups:void 0})});var ho,lp=E(()=>{se();ho=class extends D{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,r){super(e,r,{...D.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var jl,ai,fp=E(()=>{se();jl=class extends D{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,r){super(e,r,jl.defaultProps),this.shaderLayout=r.shaderLayout}},ai=jl;M(ai,"defaultProps",{...D.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0})});var $l,ci,hp=E(()=>{fp();Wl();De();oi();$l=class{static getDefaultPipelineFactory(e){let r=e.getModuleData("@luma.gl/core");return r.defaultPipelineFactory||=new $l(e),r.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let r={...we.defaultProps,...e},i=this._renderPipelineCache,o=this._hashRenderPipeline(r),n=i[o]?.resource;if(n)i[o].useCount++,this.device.props.debugFactories&&x.log(3,`${this}: ${i[o].resource} reused, count=${i[o].useCount}, (id=${e.id})`)();else{let s=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(r):void 0;n=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:nt("unnamed-cached"),_sharedRenderPipeline:s}),n.hash=o,i[o]={resource:n,useCount:1},this.device.props.debugFactories&&x.log(3,`${this}: ${n} created, count=${i[o].useCount}`)()}return n}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let r={...ai.defaultProps,...e},i=this._computePipelineCache,o=this._hashComputePipeline(r),n=i[o]?.resource;return n?(i[o].useCount++,this.device.props.debugFactories&&x.log(3,`${this}: ${i[o].resource} reused, count=${i[o].useCount}, (id=${e.id})`)()):(n=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0}),n.hash=o,i[o]={resource:n,useCount:1},this.device.props.debugFactories&&x.log(3,`${this}: ${n} created, count=${i[o].useCount}`)()),n}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let r=this._getCache(e),i=e.hash;r[i].useCount--,r[i].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&x.log(3,`${this}: ${e} released and destroyed`)()):r[i].useCount<0?(x.error(`${this}: ${e} released, useCount < 0, resetting`)(),r[i].useCount=0):this.device.props.debugFactories&&x.log(3,`${this}: ${e} released, count=${r[i].useCount}`)()}createSharedRenderPipeline(e){let r=this._hashSharedRenderPipeline(e),i=this._sharedRenderPipelineCache[r];return i||(i={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[r]=i),i.useCount++,i.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let r=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),i=this._sharedRenderPipelineCache[r];i&&(i.useCount--,i.useCount===0&&(i.resource.destroy(),delete this._sharedRenderPipelineCache[r]))}_destroyPipeline(e){let r=this._getCache(e);return this.device.props._destroyPipelines?(delete r[e.hash],e.destroy(),e instanceof we&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let r;if(e instanceof ai&&(r=this._computePipelineCache),e instanceof we&&(r=this._renderPipelineCache),!r)throw new Error(`${this}`);if(!r[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return r}_hashComputePipeline(e){let{type:r}=this.device,i=this._getHash(e.shader.source),o=this._getHash(JSON.stringify(e.shaderLayout));return`${r}/C/${i}SL${o}`}_hashRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,o=this._getWebGLVaryingHash(e),n=this._getHash(JSON.stringify(e.shaderLayout)),s=this._getHash(JSON.stringify(e.bufferLayout)),{type:a}=this.device;switch(a){case"webgl":let c=this._getHash(JSON.stringify(e.parameters));return`${a}/R/${r}/${i}V${o}T${e.topology}P${c}SL${n}BL${s}`;case"webgpu":default:let l=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),f=this._getHash(JSON.stringify(e.parameters)),h=this._getWebGPUAttachmentHash(e);return`${a}/R/${r}/${i}V${o}T${e.topology}EP${l}P${f}SL${n}BL${s}A${h}`}}_hashSharedRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,o=this._getWebGLVaryingHash(e);return`webgl/S/${r}/${i}V${o}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:r=[],bufferMode:i=null}=e;return this._getHash(JSON.stringify({varyings:r,bufferMode:i}))}_getWebGPUAttachmentHash(e){let r=e.colorAttachmentFormats??[this.device.preferredColorFormat],i=e.parameters?.depthWriteEnabled?e.depthStencilAttachmentFormat||this.device.preferredDepthFormat:null;return this._getHash(JSON.stringify({colorAttachmentFormats:r,depthStencilAttachmentFormat:i}))}},ci=$l;M(ci,"defaultProps",{...we.defaultProps})});var Hl,li,up=E(()=>{kl();De();Hl=class{static getDefaultShaderFactory(e){let r=e.getModuleData("@luma.gl/core");return r.defaultShaderFactory||=new Hl(e),r.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let r=this._hashShader(e),i=this._cache[r];if(i)i.useCount++,this.device.props.debugFactories&&x.log(3,`${this}: Reusing shader ${i.resource.id} count=${i.useCount}`)();else{let o=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[r]=i={resource:o,useCount:1},this.device.props.debugFactories&&x.log(3,`${this}: Created new shader ${o.id}`)()}return i.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let r=this._hashShader(e),i=this._cache[r];if(i)if(i.useCount--,i.useCount===0)this.device.props._destroyShaders&&(delete this._cache[r],i.resource.destroy(),this.device.props.debugFactories&&x.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&x.log(3,`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}},li=Hl;M(li,"defaultProps",{...er.defaultProps})});function dp(t,e,r){let i=t.bindings.find(o=>o.name===e||`${o.name.toLocaleLowerCase()}uniforms`===e.toLocaleLowerCase());return!i&&!r?.ignoreWarnings&&x.warn(`Binding ${e} not set: Not found in shader layout.`)(),i||null}function uo(t,e){if(!e)return{};if(FT(e))return Object.fromEntries(Object.entries(e).map(([o,n])=>[Number(o),{...n}]));let r={};for(let[i,o]of Object.entries(e)){let s=dp(t,i)?.group??0;r[s]||={},r[s][i]=o}return r}function ys(t){let e={};for(let r of Object.values(t))Object.assign(e,r);return e}function FT(t){let e=Object.keys(t);return e.length>0&&e.every(r=>/^\d+$/.test(r))}var pp=E(()=>{De()});var vr,Ct,gp=E(()=>{se();vr=class extends D{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,r){r=vr.normalizeProps(e,r),super(e,r,vr.defaultProps)}static normalizeProps(e,r){return r}},Ct=vr;M(Ct,"defaultClearColor",[0,0,0,1]),M(Ct,"defaultClearDepth",1),M(Ct,"defaultClearStencil",0),M(Ct,"defaultProps",{...D.defaultProps,framebuffer:null,parameters:void 0,clearColor:vr.defaultClearColor,clearColors:void 0,clearDepth:vr.defaultClearDepth,clearStencil:vr.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0})});var Xl,fi,mp=E(()=>{se();Xl=class extends D{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,r){super(e,r,Xl.defaultProps),this._timeProfilingQuerySet=r.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let r=e*2,i=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:r}),o=0n;for(let n=0;n<r;n+=2)o+=i[n+1]-i[n];this._gpuTimeMs=Number(o)/1e6}getTimeProfilingSlotCount(){return this._timeProfilingSlotCount}getTimeProfilingQuerySet(){return this._timeProfilingQuerySet}_applyTimeProfilingToPassProps(e){let r=e||{};if(!this._supportsTimestampQueries()||!this._timeProfilingQuerySet||r.timestampQuerySet!==void 0||r.beginTimestampIndex!==void 0||r.endTimestampIndex!==void 0)return r;let i=this._timeProfilingSlotCount;return i+1>=this._timeProfilingQuerySet.props.count?r:(this._timeProfilingSlotCount+=2,{...r,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:i,endTimestampIndex:i+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}},fi=Xl;M(fi,"defaultProps",{...D.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0})});var Yl,hi,_p=E(()=>{se();Yl=class extends D{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,r){super(e,r,Yl.defaultProps)}},hi=Yl;M(hi,"defaultProps",{...D.defaultProps})});function ui(t){let e=bs(t),r=zT[e];if(!r)throw new Error(`Unsupported variable shader type: ${t}`);return r}function yp(t){let e=bp(t),r=VT[e];if(!r)throw new Error(`Unsupported attribute shader type: ${t}`);let[i,o]=r,n=i==="i32"||i==="u32",s=i!=="u32",a=kT[i]*o;return{primitiveType:i,components:o,byteLength:a,integer:n,signed:s}}function UT(t,e){return e===1?t:`vec${e}<${t}>`}function bp(t){return WT[t]||t}function bs(t){return jT[t]||t}var Kl,Zl,kT,VT,zT,WT,jT,Ts=E(()=>{Kl=class{getVariableShaderTypeInfo(e){return ui(e)}getAttributeShaderTypeInfo(e){return yp(e)}makeShaderAttributeType(e,r){return UT(e,r)}resolveAttributeShaderTypeAlias(e){return bp(e)}resolveVariableShaderTypeAlias(e){return bs(e)}};Zl=new Kl,kT={f32:4,f16:2,i32:4,u32:4},VT={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]},zT={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}},WT={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>"},jT={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>",mat2x2f:"mat2x2<f32>",mat2x3f:"mat2x3<f32>",mat2x4f:"mat2x4<f32>",mat3x2f:"mat3x2<f32>",mat3x3f:"mat3x3<f32>",mat3x4f:"mat3x4<f32>",mat4x2f:"mat4x2<f32>",mat4x3f:"mat4x3<f32>",mat4x4f:"mat4x4<f32>",mat2x2i:"mat2x2<i32>",mat2x3i:"mat2x3<i32>",mat2x4i:"mat2x4<i32>",mat3x2i:"mat3x2<i32>",mat3x3i:"mat3x3<i32>",mat3x4i:"mat3x4<i32>",mat4x2i:"mat4x2<i32>",mat4x3i:"mat4x3<i32>",mat4x4i:"mat4x4<i32>",mat2x2u:"mat2x2<u32>",mat2x3u:"mat2x3<u32>",mat2x4u:"mat2x4<u32>",mat3x2u:"mat3x2<u32>",mat3x3u:"mat3x3<u32>",mat3x4u:"mat3x4<u32>",mat4x2u:"mat4x2<u32>",mat4x3u:"mat4x3<u32>",mat4x4u:"mat4x4<u32>",mat2x2h:"mat2x2<f16>",mat2x3h:"mat2x3<f16>",mat2x4h:"mat2x4<f16>",mat3x2h:"mat3x2<f16>",mat3x3h:"mat3x3<f16>",mat3x4h:"mat3x4<f16>",mat4x2h:"mat4x2<f16>",mat4x3h:"mat4x3<f16>",mat4x4h:"mat4x4<f16>"}});function xs(t,e){let r={};for(let i of t.attributes){let o=$T(t,e,i.name);o&&(r[i.name]=o)}return r}function Tp(t,e,r=16){let i=xs(t,e),o=new Array(r).fill(null);for(let n of Object.values(i))o[n.location]=n;return o}function $T(t,e,r){let i=HT(t,r),o=XT(e,r);if(!i)return null;let n=Zl.getAttributeShaderTypeInfo(i.type),s=vt.getCompatibleVertexFormat(n),a=o?.vertexFormat||s,c=vt.getVertexFormatInfo(a);return{attributeName:o?.attributeName||i.name,bufferName:o?.bufferName||i.name,location:i.location,shaderType:i.type,primitiveType:n.primitiveType,shaderComponents:n.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:n.integer,stepMode:o?.stepMode||i.stepMode||"vertex",byteOffset:o?.byteOffset||0,byteStride:o?.byteStride||0}}function HT(t,e){let r=t.attributes.find(i=>i.name===e);return r||x.warn(`shader layout attribute "${e}" not present in shader`),r||null}function XT(t,e){YT(t);let r=KT(t,e);return r||(r=ZT(t,e),r)?r:(x.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function YT(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&x.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function KT(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function ZT(t,e){for(let r of t){let i=r.byteStride;if(typeof r.byteStride!="number")for(let n of r.attributes||[]){let s=vt.getVertexFormatInfo(n.format);i+=s.byteLength}let o=r.attributes?.find(n=>n.attribute===e);if(o)return{attributeName:o.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:o.format,byteOffset:o.byteOffset,byteStride:i}}return null}var ql=E(()=>{De();Ts();cs()});var Gl,di,xp=E(()=>{ql();se();Gl=class extends D{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,Gl.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=Tp(r.shaderLayout,r.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,r){this.device.reportError(new Error("constant attributes not supported"),this)()}},di=Gl;M(di,"defaultProps",{...D.defaultProps,shaderLayout:void 0,bufferLayout:[]})});var Ql,pi,Ap=E(()=>{se();Ql=class extends D{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,Ql.defaultProps)}},pi=Ql;M(pi,"defaultProps",{...D.defaultProps,layout:void 0,buffers:{}})});var Jl,gi,Sp=E(()=>{se();Jl=class extends D{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,Jl.defaultProps)}},gi=Jl;M(gi,"defaultProps",{...D.defaultProps,type:void 0,count:void 0})});var ef,mi,Ep=E(()=>{se();ef=class extends D{get[Symbol.toStringTag](){return"Fence"}constructor(e,r={}){super(e,r,ef.defaultProps)}},mi=ef;M(mi,"defaultProps",{...D.defaultProps})});function ct(t,e){switch(e){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}function po(t){let[,,,,e]=qT[t];return e}var qT,tf=E(()=>{qT={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 Rp(t,e={}){let r={...t},i=e.layout??"std140",o={},n=0;for(let[s,a]of Object.entries(r))n=rf(o,s,a,n,i);return n=ct(n,tr(r,i)),{layout:i,byteLength:n*4,uniformTypes:r,fields:o}}function go(t,e){let r=bs(t),i=ui(r),o=/^mat(\d)x(\d)<.+>$/.exec(r);if(o){let s=Number(o[1]),a=Number(o[2]),c=wp(a,r,i.type,e),l=QT(c.size,c.alignment,e);return{alignment:c.alignment,size:s*l,components:s*a,columns:s,rows:a,columnStride:l,shaderType:r,type:i.type}}let n=/^vec(\d)<.+>$/.exec(r);return n?wp(Number(n[1]),r,i.type,e):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:r,type:i.type}}function of(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)}function rf(t,e,r,i,o){if(typeof r=="string"){let n=go(r,o),s=ct(i,n.alignment);return t[e]={offset:s,...n},s+n.size}if(Array.isArray(r)){if(Array.isArray(r[0]))throw new Error(`Nested arrays are not supported for ${e}`);let n=r[0],s=r[1],a=vp(n,o),c=ct(i,tr(r,o));for(let l=0;l<s;l++)rf(t,`${e}[${l}]`,n,c+l*a,o);return c+a*s}if(of(r)){let n=tr(r,o),s=ct(i,n);for(let[a,c]of Object.entries(r))s=rf(t,`${e}.${a}`,c,s,o);return ct(s,n)}throw new Error(`Unsupported CompositeShaderType for ${e}`)}function Pp(t,e){if(typeof t=="string")return go(t,e).size;if(Array.isArray(t)){let i=t[0],o=t[1];if(Array.isArray(i))throw new Error("Nested arrays are not supported");return vp(i,e)*o}let r=0;for(let i of Object.values(t)){let o=i;r=ct(r,tr(o,e)),r+=Pp(o,e)}return ct(r,tr(t,e))}function tr(t,e){if(typeof t=="string")return go(t,e).alignment;if(Array.isArray(t)){let i=t[0],o=tr(i,e);return Mp(e)?Math.max(o,4):o}let r=1;for(let i of Object.values(t)){let o=tr(i,e);r=Math.max(r,o)}return JT(e)?Math.max(r,4):r}function wp(t,e,r,i){return{alignment:t===2?2:4,size:t===3?3:t,components:t,columns:1,rows:t,columnStride:t===3?3:t,shaderType:e,type:r}}function vp(t,e){let r=Pp(t,e),i=tr(t,e);return GT(r,i,e)}function GT(t,e,r){return ct(t,Mp(r)?4:e)}function QT(t,e,r){return r==="std140"?4:ct(t,e)}function Mp(t){return t==="std140"||t==="wgsl-uniform"}function JT(t){return t==="std140"||t==="wgsl-uniform"}var nf=E(()=>{tf();Ts()});function sf(t){return(!As||As.byteLength<t)&&(As=new ArrayBuffer(t)),As}function af(t,e){let r=sf(t.BYTES_PER_ELEMENT*e);return new t(r,0,e)}var As,cf=E(()=>{});function ex(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function _i(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":ex(t)}var lf=E(()=>{});function tx(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}function rx(t,e,r){return Array.prototype.slice.call(t,e,r)}var Ss,Cp=E(()=>{cf();lf();De();nf();Ss=class{layout;constructor(e){this.layout=e}has(e){return Boolean(this.layout.fields[e])}get(e){let r=this.layout.fields[e];return r?{offset:r.offset,size:r.size}:void 0}getFlatUniformValues(e){let r={};for(let[i,o]of Object.entries(e)){let n=this.layout.uniformTypes[i];n?this._flattenCompositeValue(r,i,n,o):this.layout.fields[i]&&(r[i]=o)}return r}getData(e){let r=sf(this.layout.byteLength);new Uint8Array(r,0,this.layout.byteLength).fill(0);let i={i32:new Int32Array(r),u32:new Uint32Array(r),f32:new Float32Array(r),f16:new Uint16Array(r)},o=this.getFlatUniformValues(e);for(let[n,s]of Object.entries(o))this._writeLeafValue(i,n,s);return new Uint8Array(r,0,this.layout.byteLength)}_flattenCompositeValue(e,r,i,o){if(o!==void 0){if(typeof i=="string"||this.layout.fields[r]){e[r]=o;return}if(Array.isArray(i)){let n=i[0],s=i[1];if(Array.isArray(n))throw new Error(`Nested arrays are not supported for ${r}`);if(typeof n=="string"&&_i(o)){this._flattenPackedArray(e,r,n,s,o);return}if(!Array.isArray(o)){x.warn(`Unsupported uniform array value for ${r}:`,o)();return}for(let a=0;a<Math.min(o.length,s);a++){let c=o[a];c!==void 0&&this._flattenCompositeValue(e,`${r}[${a}]`,n,c)}return}if(of(i)&&tx(o)){for(let[n,s]of Object.entries(o)){if(s===void 0)continue;let a=`${r}.${n}`;this._flattenCompositeValue(e,a,i[n],s)}return}x.warn(`Unsupported uniform value for ${r}:`,o)()}}_flattenPackedArray(e,r,i,o,n){let s=n,c=go(i,this.layout.layout).components;for(let l=0;l<o;l++){let f=l*c;if(f>=s.length)break;c===1?e[`${r}[${l}]`]=Number(s[f]):e[`${r}[${l}]`]=rx(n,f,f+c)}}_writeLeafValue(e,r,i){let o=this.layout.fields[r];if(!o){x.warn(`Uniform ${r} not found in layout`)();return}let{type:n,components:s,columns:a,rows:c,offset:l,columnStride:f}=o,h=e[n];if(s===1){h[l]=Number(i);return}let u=i;if(a===1){for(let p=0;p<s;p++)h[l+p]=Number(u[p]??0);return}let d=0;for(let p=0;p<a;p++){let g=l+p*f;for(let m=0;m<c;m++)h[g+m]=Number(u[d++]??0)}}}});function Ip(t,e,r=16){if(t===e)return!0;let i=t,o=e;if(!_i(i)||!_i(o)||i.length!==o.length)return!1;let n=Math.min(r,ix);if(i.length>n)return!1;for(let s=0;s<i.length;++s)if(o[s]!==i[s])return!1;return!0}function Op(t){return _i(t)?t.slice():t}var ix,Np=E(()=>{lf();ix=128});var Es,Dp=E(()=>{Np();Es=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let r=e?.shaderLayout.bindings?.find(o=>o.type==="uniform"&&o.name===e?.name);if(!r)throw new Error(e?.name);let i=r;for(let o of i.uniforms||[])this.bindingLayout[o.name]=o}}setUniforms(e){for(let[r,i]of Object.entries(e))this._setUniform(r,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,r){Ip(this.uniforms[e],r)||(this.uniforms[e]=Op(r),this.modifiedUniforms[e]=!0,this.modified=!0)}}});function nx(t){return t.type==="webgpu"?"wgsl-uniform":"std140"}var ox,mo,Bp=E(()=>{ss();De();nf();Dp();Cp();ox=1024,mo=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,r){this.device=e;for(let[i,o]of Object.entries(r)){let n=i,s=Rp(o.uniformTypes??{},{layout:o.layout??nx(e)}),a=new Ss(s);this.shaderBlockLayouts.set(n,s),this.shaderBlockWriters.set(n,a);let c=new Es({name:i});c.setUniforms(a.getFlatUniformValues(o.defaultUniforms||{})),this.uniformBlocks.set(n,c)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[r,i]of Object.entries(e)){let o=r,s=this.shaderBlockWriters.get(o)?.getFlatUniformValues(i||{});this.uniformBlocks.get(o)?.setUniforms(s||{})}this.updateUniformBuffers()}getUniformBufferByteLength(e){let r=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(r,ox)}getUniformBufferData(e){let r=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.shaderBlockWriters.get(e)?.getData(r)||new Uint8Array(0)}createUniformBuffer(e,r){r&&this.setUniforms(r);let i=this.getUniformBufferByteLength(e),o=this.device.createBuffer({usage:I.UNIFORM|I.COPY_DST,byteLength:i}),n=this.getUniformBufferData(e);return o.write(n),o}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){let r=this.getUniformBufferByteLength(e),i=this.device.createBuffer({usage:I.UNIFORM|I.COPY_DST,byteLength:r});this.uniformBuffers.set(e,i)}return this.uniformBuffers.get(e)}updateUniformBuffers(){let e=!1;for(let r of this.uniformBlocks.keys()){let i=this.updateUniformBuffer(r);e||=i}return e&&x.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let r=this.uniformBlocks.get(e),i=this.uniformBuffers.get(e),o=!1;if(i&&r?.needsRedraw){o||=r.needsRedraw;let n=this.getUniformBufferData(e);i=this.uniformBuffers.get(e),i?.write(n);let s=this.uniformBlocks.get(e)?.getAllUniforms();x.log(4,`Writing to uniform buffer ${String(e)}`,n,s)()}return o}}});var F=E(()=>{Zd();qd();Cl();rp();ip();ss();Bl();op();kl();Dl();cp();Wl();lp();hp();up();gp();mp();_p();xp();Ap();Sp();Ep();Bp();as();tf();Ts();cs();us();Pl();De();pp();Ol();cf();ql()});var Ar,wy=E(()=>{(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Ar||(Ar={}))});var Ry=E(()=>{wy()});function Py(t=!0){let e=HTMLCanvasElement.prototype;if(!t&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(r,i){if(r==="webgl"||r==="experimental-webgl"){let o=this.originalGetContext("webgl2",i);return o instanceof HTMLElement&&kP(o),o}return this.originalGetContext(r,i)}}function kP(t){t.getExtension("EXT_color_buffer_float");let e={...BP,WEBGL_disjoint_timer_query:t.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:LP(t),OES_vertex_array_object:FP(t),ANGLE_instanced_arrays:UP(t)},r=t.getExtension;t.getExtension=function(o){let n=r.call(t,o);return n||(o in e?e[o]:null)};let i=t.getSupportedExtensions;t.getSupportedExtensions=function(){return(i.apply(t)||[])?.concat(Object.keys(e))}}var BP,LP,FP,UP,vy=E(()=>{BP={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:{}},LP=t=>({drawBuffersWEBGL(e){return t.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),FP=t=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return t.createVertexArray()},deleteVertexArrayOES(e){return t.deleteVertexArray(e)},isVertexArrayOES(e){return t.isVertexArray(e)},bindVertexArrayOES(e){return t.bindVertexArray(e)}}),UP=t=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return t.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return t.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return t.vertexAttribDivisor(...e)}})});async function Ka(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",t),e&&(i.id=e),new Promise((o,n)=>{i.onload=o,i.onerror=s=>n(new Error(`Unable to load script '${t}': ${s}`)),r.appendChild(i)})}var Iu=E(()=>{});function Xr(t){let e=t.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??=!1,e.extensions||={},t.luma=e,e}var Za=E(()=>{});async function Cy(t){if(!globalThis.SPECTOR)try{await Ka(t.debugSpectorJSUrl||qa.debugSpectorJSUrl)}catch(e){x.warn(String(e))}}function Iy(t){if(t={...qa,...t},!t.debugSpectorJS)return null;if(!Ie&&globalThis.SPECTOR&&!globalThis.luma?.spector){x.probe(VP,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();let{Spector:e}=globalThis.SPECTOR;Ie=new e,globalThis.luma&&(globalThis.luma.spector=Ie)}if(!Ie)return null;if(My||(My=!0,Ie.spyCanvases(),Ie?.onCaptureStarted.add(e=>x.info("Spector capture started:",e)()),Ie?.onCapture.add(e=>{x.info("Spector capture complete:",e)(),Ie?.getResultUI(),Ie?.resultView.display(),Ie?.resultView.addCapture(e)})),t.gl){let e=t.gl,r=Xr(e),i=r.device;Ie?.startCapture(t.gl,500),r.device=i,new Promise(o=>setTimeout(o,2e3)).then(o=>{x.info("Spector capture stopped after 2 seconds")(),Ie?.stopCapture()})}return Ie}var VP,Ie,My,qa,Ou=E(()=>{F();Iu();Za();VP=1,Ie=null,My=!1,qa={debugSpectorJS:x.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0}});function Ny(t){return t.luma=t.luma||{},t.luma}async function Dy(){fe()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await Ka(zP))}function By(t,e={}){return e.debugWebGL||e.traceWebGL?jP(t,e):WP(t)}function WP(t){let e=Ny(t);return e.realContext?e.realContext:t}function jP(t,e){if(!globalThis.WebGLDebugUtils)return x.warn("webgl-debug not loaded")(),t;let r=Ny(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...Ar,...t});let i=globalThis.WebGLDebugUtils.makeDebugContext(t,$P.bind(null,e),HP.bind(null,e));for(let s in Ar)!(s in i)&&typeof Ar[s]=="number"&&(i[s]=Ar[s]);class o{}Object.setPrototypeOf(i,Object.getPrototypeOf(t)),Object.setPrototypeOf(o,i);let n=Object.create(o);return r.realContext=t,r.debugContext=n,n.luma=r,n.debug=!0,n}function Oy(t,e){e=Array.from(e).map(i=>i===void 0?"undefined":i);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function $P(t,e,r,i){i=Array.from(i).map(a=>a===void 0?"undefined":a);let o=globalThis.WebGLDebugUtils.glEnumToString(e),n=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,i),s=`${o} in gl.${r}(${n})`;x.error("%cWebGL","color: white; background: red; padding: 2px 6px; border-radius: 3px;",s)();debugger;throw new Error(s)}function HP(t,e,r){let i="";t.traceWebGL&&x.level>=1&&(i=Oy(e,r),x.info(1,"%cWebGL","color: white; background: blue; padding: 2px 6px; border-radius: 3px;",i)());for(let o of r)if(o===void 0){i=i||Oy(e,r);debugger}}var zP,Nu=E(()=>{F();Ry();Zt();Iu();zP="https://unpkg.com/webgl-debug@2.0.1/index.js"});function Du(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Q(t,e,r){return e[t]!==void 0?e[t]:r[t]}var En,ie,Ly,Oe,Fy,Sn,Uy,ky,Bu,Tt,Lu,Vy,Fu=E(()=>{En={[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},ie=(t,e,r)=>e?t.enable(r):t.disable(r),Ly=(t,e,r)=>t.hint(r,e),Oe=(t,e,r)=>t.pixelStorei(r,e),Fy=(t,e,r)=>{let i=r===36006?36009:36008;return t.bindFramebuffer(i,e)},Sn=(t,e,r)=>{let o={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[r];t.bindBuffer(o,e)};Uy={[3042]:ie,[32773]:(t,e)=>t.blendColor(...e),[32777]:"blendEquation",[34877]:"blendEquation",[32969]:"blendFunc",[32968]:"blendFunc",[32971]:"blendFunc",[32970]:"blendFunc",[3106]:(t,e)=>t.clearColor(...e),[3107]:(t,e)=>t.colorMask(...e),[2884]:ie,[2885]:(t,e)=>t.cullFace(e),[2929]:ie,[2931]:(t,e)=>t.clearDepth(e),[2932]:(t,e)=>t.depthFunc(e),[2928]:(t,e)=>t.depthRange(...e),[2930]:(t,e)=>t.depthMask(e),[3024]:ie,[35723]:Ly,[35725]:(t,e)=>t.useProgram(e),[36007]:(t,e)=>t.bindRenderbuffer(36161,e),[36389]:(t,e)=>t.bindTransformFeedback?.(36386,e),[34229]:(t,e)=>t.bindVertexArray(e),[36006]:Fy,[36010]:Fy,[34964]:Sn,[36662]:Sn,[36663]:Sn,[35053]:Sn,[35055]:Sn,[2886]:(t,e)=>t.frontFace(e),[33170]:Ly,[2849]:(t,e)=>t.lineWidth(e),[32823]:ie,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:ie,[32926]:ie,[32928]:ie,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:ie,[3088]:(t,e)=>t.scissor(...e),[2960]:ie,[2961]:(t,e)=>t.clearStencil(e),[2968]:(t,e)=>t.stencilMaskSeparate(1028,e),[36005]:(t,e)=>t.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]:(t,e)=>t.viewport(...e),[34383]:ie,[10754]:ie,[12288]:ie,[12289]:ie,[12290]:ie,[12291]:ie,[12292]:ie,[12293]:ie,[12294]:ie,[12295]:ie,[3333]:Oe,[3317]:Oe,[37440]:Oe,[37441]:Oe,[37443]:Oe,[3330]:Oe,[3332]:Oe,[3331]:Oe,[3314]:Oe,[32878]:Oe,[3316]:Oe,[3315]:Oe,[32877]:Oe,framebuffer:(t,e)=>{let r=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,r)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{let r=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...r)},blendFunc:(t,e)=>{let r=e?.length===2?[...e,...e]:e;t.blendFuncSeparate(...r)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(e[0],e[1]||!1),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=Du(e)?e:[e,e];let[r,i]=e;t.stencilMaskSeparate(1028,r),t.stencilMaskSeparate(1029,i)},stencilFunc:(t,e)=>{e=Du(e)&&e.length===3?[...e,...e]:e;let[r,i,o,n,s,a]=e;t.stencilFuncSeparate(1028,r,i,o),t.stencilFuncSeparate(1029,n,s,a)},stencilOp:(t,e)=>{e=Du(e)&&e.length===3?[...e,...e]:e;let[r,i,o,n,s,a]=e;t.stencilOpSeparate(1028,r,i,o),t.stencilOpSeparate(1029,n,s,a)},viewport:(t,e)=>t.viewport(...e)};ky={blendEquation:(t,e,r)=>t.blendEquationSeparate(Q(32777,e,r),Q(34877,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(Q(32969,e,r),Q(32968,e,r),Q(32971,e,r),Q(32970,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(Q(32824,e,r),Q(10752,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(Q(32938,e,r),Q(32939,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(1028,Q(2962,e,r),Q(2967,e,r),Q(2963,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(1029,Q(34816,e,r),Q(36003,e,r),Q(36004,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(1028,Q(2964,e,r),Q(2965,e,r),Q(2966,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(1029,Q(34817,e,r),Q(34818,e,r),Q(34819,e,r))},Bu={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,r)=>t({[e]:r}),hint:(t,e,r)=>t({[e]:r}),useProgram:(t,e)=>t({[35725]:e}),bindRenderbuffer:(t,e,r)=>t({[36007]:r}),bindTransformFeedback:(t,e,r)=>t({[36389]:r}),bindVertexArray:(t,e)=>t({[34229]:e}),bindFramebuffer:(t,e,r)=>{switch(e){case 36160:return t({[36006]:r,[36010]:r});case 36009:return t({[36006]:r});case 36008:return t({[36010]:r});default:return null}},bindBuffer:(t,e,r)=>{let i={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[e];return i?t({[i]:r}):{valueChanged:!0}},blendColor:(t,e,r,i,o)=>t({[32773]:new Float32Array([e,r,i,o])}),blendEquation:(t,e)=>t({[32777]:e,[34877]:e}),blendEquationSeparate:(t,e,r)=>t({[32777]:e,[34877]:r}),blendFunc:(t,e,r)=>t({[32969]:e,[32968]:r,[32971]:e,[32970]:r}),blendFuncSeparate:(t,e,r,i,o)=>t({[32969]:e,[32968]:r,[32971]:i,[32970]:o}),clearColor:(t,e,r,i,o)=>t({[3106]:new Float32Array([e,r,i,o])}),clearDepth:(t,e)=>t({[2931]:e}),clearStencil:(t,e)=>t({[2961]:e}),colorMask:(t,e,r,i,o)=>t({[3107]:[e,r,i,o]}),cullFace:(t,e)=>t({[2885]:e}),depthFunc:(t,e)=>t({[2932]:e}),depthRange:(t,e,r)=>t({[2928]:new Float32Array([e,r])}),depthMask:(t,e)=>t({[2930]:e}),frontFace:(t,e)=>t({[2886]:e}),lineWidth:(t,e)=>t({[2849]:e}),polygonOffset:(t,e,r)=>t({[32824]:e,[10752]:r}),sampleCoverage:(t,e,r)=>t({[32938]:e,[32939]:r}),scissor:(t,e,r,i,o)=>t({[3088]:new Int32Array([e,r,i,o])}),stencilMask:(t,e)=>t({[2968]:e,[36005]:e}),stencilMaskSeparate:(t,e,r)=>t({[e===1028?2968:36005]:r}),stencilFunc:(t,e,r,i)=>t({[2962]:e,[2967]:r,[2963]:i,[34816]:e,[36003]:r,[36004]:i}),stencilFuncSeparate:(t,e,r,i,o)=>t({[e===1028?2962:34816]:r,[e===1028?2967:36003]:i,[e===1028?2963:36004]:o}),stencilOp:(t,e,r,i)=>t({[2964]:e,[2965]:r,[2966]:i,[34817]:e,[34818]:r,[34819]:i}),stencilOpSeparate:(t,e,r,i,o)=>t({[e===1028?2964:34817]:r,[e===1028?2965:34818]:i,[e===1028?2966:34819]:o}),viewport:(t,e,r,i,o)=>t({[2978]:[e,r,i,o]})},Tt=(t,e)=>t.isEnabled(e),Lu={[3042]:Tt,[2884]:Tt,[2929]:Tt,[3024]:Tt,[32823]:Tt,[32926]:Tt,[32928]:Tt,[3089]:Tt,[2960]:Tt,[35977]:Tt},Vy=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 Je(t,e){if(XP(e))return;let r={};for(let o in e){let n=Number(o),s=Uy[o];s&&(typeof s=="string"?r[s]=!0:s(t,e[o],n))}let i=t.lumaState?.cache;if(i)for(let o in r){let n=ky[o];n(t,e,i)}}function Ga(t,e=En){if(typeof e=="number"){let o=e,n=Lu[o];return n?n(t,o):t.getParameter(o)}let r=Array.isArray(e)?e:Object.keys(e),i={};for(let o of r){let n=Lu[o];i[o]=n?n(t,Number(o)):t.getParameter(Number(o))}return i}function zy(t){Je(t,En)}function XP(t){for(let e in t)return!1;return!0}var Xi=E(()=>{Fu()});function jy(t,e){if(t===e)return!0;if(Wy(t)&&Wy(e)&&t.length===e.length){for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}return!1}function Wy(t){return Array.isArray(t)||ArrayBuffer.isView(t)}var $y=E(()=>{});function Hy(t,e){let r=t[e].bind(t);t[e]=function(o){if(o===void 0||Vy.has(o))return r(o);let n=et.get(t);return o in n.cache||(n.cache[o]=r(o)),n.enable?n.cache[o]:r(o)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function YP(t,e,r){if(!t[e])return;let i=t[e].bind(t);t[e]=function(...n){let s=et.get(t),{valueChanged:a,oldValue:c}=r(s._updateCache,...n);return a&&i(...n),c},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function KP(t){let e=t.useProgram.bind(t);t.useProgram=function(i){let o=et.get(t);o.program!==i&&(e(i),o.program=i)}}var et,Uu=E(()=>{Xi();$y();Fu();et=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,r){this.gl=e,this.log=r?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];Je(this.gl,e),this.stateStack.pop()}trackState(e,r){if(this.cache=r?.copyState?Ga(e):Object.assign({},En),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,KP(e);for(let i in Bu){let o=Bu[i];YP(e,i,o)}Hy(e,"getParameter"),Hy(e,"isEnabled")}_updateCache(e){let r=!1,i,o=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let n in e){let s=e[n],a=this.cache[n];jy(s,a)||(r=!0,i=a,o&&!(n in o)&&(o[n]=a),this.cache[n]=s)}return{valueChanged:r,oldValue:i}}}});function Xy(t,e,r){let i="",o=c=>{let l=c.statusMessage;l&&(i||=l)};t.addEventListener("webglcontextcreationerror",o,!1);let n=r.failIfMajorPerformanceCaveat!==!0,s={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},a=null;try{a||=t.getContext("webgl2",s),!a&&s.failIfMajorPerformanceCaveat&&(i||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&n&&(s.failIfMajorPerformanceCaveat=!1,a=t.getContext("webgl2",s),c=!0),a||(a=t.getContext("webgl",{}),a&&(a=null,i||="Your browser only supports WebGL1")),!a)throw i||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${i}`);let l=Xr(a);l.softwareRenderer=c;let{onContextLost:f,onContextRestored:h}=e;return t.addEventListener("webglcontextlost",u=>f(u),!1),t.addEventListener("webglcontextrestored",u=>h(u),!1),a}finally{t.removeEventListener("webglcontextcreationerror",o,!1)}}var Yy=E(()=>{Za()});function tt(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}var wn=E(()=>{});function Ky(t,e){let r=t.getParameter(7936),i=t.getParameter(7937);tt(t,"WEBGL_debug_renderer_info",e);let o=e.WEBGL_debug_renderer_info,n=t.getParameter(o?o.UNMASKED_VENDOR_WEBGL:7936),s=t.getParameter(o?o.UNMASKED_RENDERER_WEBGL:7937),a=n||r,c=s||i,l=t.getParameter(7938),f=Zy(a,c),h=ZP(a,c),u=qP(a,c);return{type:"webgl",gpu:f,gpuType:u,gpuBackend:h,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function Zy(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function ZP(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function qP(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(Zy(t,e)){case"apple":return GP(t,e)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function GP(t,e){return/Apple (M\d|A\d|GPU)/i.test(`${t} ${e}`)}var qy=E(()=>{wn()});function Qa(t){switch(t){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(t))}var ku=E(()=>{});function Jy(t){return t in ec}function $u(t,e,r){return eb(t,e,r,new Set)}function eb(t,e,r,i){let o=ec[e];if(!o||i.has(e))return!1;i.add(e);let n=(o.features||[]).every(s=>eb(t,s,r,i));return i.delete(e),n?(o.extensions||[]).every(s=>Boolean(tt(t,s,r))):!1}function tb(t,e,r){let i=e.create,o=tc[e.format];o?.gl===void 0&&(i=!1),o?.x&&(i=i&&Boolean(tt(t,o.x,r))),e.format==="stencil8"&&(i=!1);let n=o?.r===!1?!1:o?.r===void 0||$u(t,o.r,r),s=i&&e.render&&n&&nv(t,e.format,r);return{format:e.format,create:i&&e.create,render:s,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function nv(t,e,r){let i=tc[e],o=i?.gl;if(o===void 0||i?.x&&!tt(t,i.x,r))return!1;let n=t.getParameter(32873),s=t.getParameter(36006),a=t.createTexture(),c=t.createFramebuffer();if(!a||!c)return!1;let l=Number(0),f=Number(t.getError());for(;f!==l;)f=t.getError();let h=!1;try{if(t.bindTexture(3553,a),t.texStorage2D(3553,1,o,1,1),Number(t.getError())!==l)return!1;t.bindFramebuffer(36160,c),t.framebufferTexture2D(36160,36064,3553,a,0),h=Number(t.checkFramebufferStatus(36160))===Number(36053)&&Number(t.getError())===l}finally{t.bindFramebuffer(36160,s),t.deleteFramebuffer(c),t.bindTexture(3553,n),t.deleteTexture(a)}return h}function rc(t){let e=tc[t],r=av(t),i=de.getInfo(t);return i.compressed&&(e.dataFormat=r),{internalFormat:r,format:e?.dataFormat||sv(i.channels,i.integer,i.normalized,r),type:i.dataType?Qa(i.dataType):e?.types?.[0]||5121,compressed:i.compressed||!1}}function rb(t){switch(de.getInfo(t).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${t}`)}}function sv(t,e,r,i){if(i===6408||i===6407)return i;switch(t){case"r":return e&&!r?36244:6403;case"rg":return e&&!r?33320:33319;case"rgb":return e&&!r?36248:6407;case"rgba":return e&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function av(t){let r=tc[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}var Rn,Pn,Yi,Ki,QP,JP,ev,tv,rv,iv,Gy,Qy,Vu,zu,Wu,ju,Ja,ov,ec,tc,Zi=E(()=>{F();wn();ku();Rn="WEBGL_compressed_texture_s3tc",Pn="WEBGL_compressed_texture_s3tc_srgb",Yi="EXT_texture_compression_rgtc",Ki="EXT_texture_compression_bptc",QP="WEBGL_compressed_texture_etc",JP="WEBGL_compressed_texture_astc",ev="WEBGL_compressed_texture_etc1",tv="WEBGL_compressed_texture_pvrtc",rv="WEBGL_compressed_texture_atc",iv="EXT_texture_norm16",Gy="EXT_render_snorm",Qy="EXT_color_buffer_float",Vu="snorm8-renderable-webgl",zu="norm16-renderable-webgl",Wu="snorm16-renderable-webgl",ju="float16-renderable-webgl",Ja="float32-renderable-webgl",ov="rgb9e5ufloat-renderable-webgl",ec={"float32-renderable-webgl":{extensions:[Qy]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[Gy]},"norm16-webgl":{extensions:[iv]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[Gy]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[Rn,Pn,Yi,Ki]},"texture-compression-bc5-webgl":{extensions:[Yi]},"texture-compression-bc7-webgl":{extensions:[Ki]},"texture-compression-etc2":{extensions:[QP]},"texture-compression-astc":{extensions:[JP]},"texture-compression-etc1-webgl":{extensions:[ev]},"texture-compression-pvrtc-webgl":{extensions:[tv]},"texture-compression-atc-webgl":{extensions:[rv]}};tc={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:Vu},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:Vu},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:ju},r16unorm:{gl:33322,rb:!0,r:zu},r16snorm:{gl:36760,r:Wu},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:Vu},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:ju},rg16unorm:{gl:33324,r:zu},rg16snorm:{gl:36761,r:Wu},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:Ja},rgb9e5ufloat:{gl:35901,r:ov},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:Ja},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:ju},rgba16unorm:{gl:32859,rb:!0,r:zu},rgba16snorm:{gl:36763,r:Wu},"rgb32float-webgl":{gl:34837,x:Qy,r:Ja,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:Ja},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:Rn},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Pn},"bc1-rgba-unorm":{gl:33777,x:Rn},"bc1-rgba-unorm-srgb":{gl:35916,x:Pn},"bc2-rgba-unorm":{gl:33778,x:Rn},"bc2-rgba-unorm-srgb":{gl:35918,x:Pn},"bc3-rgba-unorm":{gl:33779,x:Rn},"bc3-rgba-unorm-srgb":{gl:35919,x:Pn},"bc4-r-unorm":{gl:36283,x:Yi},"bc4-r-snorm":{gl:36284,x:Yi},"bc5-rg-unorm":{gl:36285,x:Yi},"bc5-rg-snorm":{gl:36286,x:Yi},"bc6h-rgb-ufloat":{gl:36495,x:Ki},"bc6h-rgb-float":{gl:36494,x:Ki},"bc7-rgba-unorm":{gl:36492,x:Ki},"bc7-rgba-unorm-srgb":{gl:36493,x:Ki},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var ib,ic,ob=E(()=>{F();wn();Zi();ib={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},ic=class extends ao{gl;extensions;testedFeatures=new Set;constructor(e,r,i){super([],i),this.gl=e,this.extensions=r,tt(e,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let e=this.getFeatures();for(let r of e)this.has(r)&&(yield r);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),Jy(e)&&$u(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(r=>r!=="polygon-mode-webgl");for(let r of e)this.has(r)}getFeatures(){return[...Object.keys(ib),...Object.keys(ec)]}getWebGLFeature(e){let r=ib[e];return Boolean(typeof r=="string"?tt(this.gl,r,this.extensions):r)}}});var oc,nb=E(()=>{F();oc=class extends so{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 cv(t){return t<34069?t+34069:t}function lv(t){switch(t){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`${t}`}}var xt,nc=E(()=>{F();Zi();xt=class extends at{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,r){super(e,r);let i=r.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),i||(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 r=0;r<this.colorAttachments.length;++r){let i=this.colorAttachments[r];if(i){let o=36064+r;this._attachTextureView(o,i)}}if(this.depthStencilAttachment){let r=rb(this.depthStencilAttachment.props.format);this._attachTextureView(r,this.depthStencilAttachment)}if(this.device.props.debug){let r=this.gl.checkFramebufferStatus(36160);if(r!==36053)throw new Error(`Framebuffer ${lv(r)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,r){let{gl:i}=this.device,{texture:o}=r,n=r.props.baseMipLevel,s=r.props.baseArrayLayer;switch(i.bindTexture(o.glTarget,o.handle),o.glTarget){case 35866:case 32879:i.framebufferTextureLayer(36160,e,o.handle,n,s);break;case 34067:let a=cv(s);i.framebufferTexture2D(36160,e,a,o.handle,n);break;case 3553:i.framebufferTexture2D(36160,e,3553,o.handle,n);break;default:throw new Error("Illegal texture type")}i.bindTexture(o.glTarget,null)}resizeAttachments(e,r){if(this.handle===null){this.width=e,this.height=r;return}super.resizeAttachments(e,r)}}});var sc,sb=E(()=>{F();nc();sc=class extends si{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,r){super(r),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new xt(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var ac,ab=E(()=>{F();ac=class extends fo{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,r={}){super(r),this.device=e;let i=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${i}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let n=this.canvas.getContext("2d");if(!n)throw new Error(`${i}: Failed to create 2d presentation context`);this.context2d=n,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[r,i]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||r===0||i===0||e.canvas.width===0||e.canvas.height===0)){if(r!==this.drawingBufferWidth||i!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${r}x${i} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let r=this.device.getDefaultCanvasContext();return r.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),r.getCurrentFramebuffer(e)}}});function cb(t="id"){Hu[t]=Hu[t]||1;let e=Hu[t]++;return`${t}-${e}`}var Hu,lb=E(()=>{Hu={}});function fv(t){return t&I.INDEX?34963:t&I.VERTEX?34962:t&I.UNIFORM?35345:34962}function hv(t){return t&I.INDEX||t&I.VERTEX?35044:t&I.UNIFORM?35048:35044}var rt,cc=E(()=>{F();rt=class extends I{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let i=typeof r=="object"?r.handle:void 0;this.handle=i||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=fv(this.props.usage),this.glUsage=hv(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,r=0,i=e.byteLength+r){let o=this.glTarget;this.gl.bindBuffer(o,this.handle),this.gl.bufferData(o,i,this.glUsage),this.gl.bufferSubData(o,r,e),this.gl.bindBuffer(o,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,r,i),this.props.handle?this.trackReferencedMemory(i,"Buffer"):this.trackAllocatedMemory(i)}_initWithByteLength(e){let r=e;e===0&&(r=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,r,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,r=0){let i=ArrayBuffer.isView(e)?e:new Uint8Array(e),o=0,n=void 0,s=36663;this.gl.bindBuffer(s,this.handle),o!==0||n!==void 0?this.gl.bufferSubData(s,r,i,o,n):this.gl.bufferSubData(s,r,i),this.gl.bindBuffer(s,null),this._setDebugData(e,r,e.byteLength)}async mapAndWriteAsync(e,r=0,i=this.byteLength-r){let o=new ArrayBuffer(i);await e(o,"copied"),this.write(o,r)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}async mapAndReadAsync(e,r=0,i){let o=await this.readAsync(r,i);return await e(o.buffer,"copied")}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let i=new Uint8Array(r),o=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,o,r),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,r),i}}});function fb(t){let e=t.split(/\r?\n/),r=[];for(let i of e){if(i.length<=1)continue;let o=i.trim(),n=i.split(":"),s=n[0]?.trim();if(n.length===2){let[d,p]=n;if(!d||!p){r.push({message:o,type:lc(s||"info"),lineNum:0,linePos:0});continue}r.push({message:p.trim(),type:lc(d),lineNum:0,linePos:0});continue}let[a,c,l,...f]=n;if(!a||!c||!l){r.push({message:n.slice(1).join(":").trim()||o,type:lc(s||"info"),lineNum:0,linePos:0});continue}let h=parseInt(l,10);Number.isNaN(h)&&(h=0);let u=parseInt(c,10);Number.isNaN(u)&&(u=0),r.push({message:f.join(":").trim(),type:lc(a),lineNum:h,linePos:u})}return r}function lc(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var hb=E(()=>{});var fc,ub=E(()=>{F();hb();fc=class extends er{device;handle;constructor(e,r){switch(super(e,r),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});let i=this._compile(this.source);i&&typeof i.catch=="function"&&i.catch(()=>{this.compilationStatus="error"})}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?fb(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es
|
|
19
|
-
${e}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,e),r.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}return x.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{x.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async o=>await new Promise(n=>setTimeout(n,o));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}});function pb(t,e,r,i){if(gv(e))return i(t);let o=t;o.pushState();try{return uv(t,e),Je(o.gl,r),i(t)}finally{o.popState()}}function uv(t,e){let r=t,{gl:i}=r;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(Yr("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){let n=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,s=Yr("provokingVertex",e.provokingVertex,{first:36429,last:36430});n?.provokingVertexWEBGL(s)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){let n=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,s=Yr("polygonMode",e.polygonMode,{fill:6914,line:6913});n?.polygonModeWEBGL(1028,s),n?.polygonModeWEBGL(1029,s)}e.polygonOffsetLine&&i.enable(10754)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(pv("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(uc("depthCompare",e.depthCompare))),e.clearDepth!==void 0&&i.clearDepth(e.clearDepth),e.stencilWriteMask){let o=e.stencilWriteMask;i.stencilMaskSeparate(1028,o),i.stencilMaskSeparate(1029,o)}if(e.stencilReadMask&&x.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let o=e.stencilReadMask||4294967295,n=uc("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,n,0,o),i.stencilFuncSeparate(1029,n,0,o)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let o=Xu("stencilPassOperation",e.stencilPassOperation),n=Xu("stencilFailOperation",e.stencilFailOperation),s=Xu("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,n,s,o),i.stencilOpSeparate(1029,n,s,o)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let o=db("blendColorOperation",e.blendColorOperation||"add"),n=db("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(o,n);let s=hc("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=hc("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=hc("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=hc("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(s,a,c,l)}}function uc(t,e){return Yr(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Xu(t,e){return Yr(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function db(t,e){return Yr(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function hc(t,e,r="color"){return Yr(t,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:r==="color"?32769:32771,"one-minus-constant":r==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function dv(t,e){return`Illegal parameter ${e} for ${t}`}function Yr(t,e,r){if(!(e in r))throw new Error(dv(t,e));return r[e]}function pv(t,e){return e}function gv(t){let e=!0;for(let r in t){e=!1;break}return e}var Yu=E(()=>{F();Xi()});function dc(t){let e={};return t.addressModeU&&(e[10242]=Ku(t.addressModeU)),t.addressModeV&&(e[10243]=Ku(t.addressModeV)),t.addressModeW&&(e[32882]=Ku(t.addressModeW)),t.magFilter&&(e[10240]=Zu(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=mv(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[33082]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[33083]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[34892]=34894),t.compare&&(e[34893]=uc("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function Ku(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function Zu(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function mv(t,e="none"){if(!e)return Zu(t);switch(e){case"none":return Zu(t);case"nearest":switch(t){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(t){case"nearest":return 9986;case"linear":return 9987}}}var qu=E(()=>{Yu()});var pc,gb=E(()=>{F();qu();pc=class extends Be{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=dc(r),this.handle=r.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[r,i]of Object.entries(e)){let o=Number(r);switch(o){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,o,i);break;default:this.device.gl.samplerParameteri(this.handle,o,i);break}}}}});function At(t,e,r){if(_v(e))return r(t);let{nocatch:i=!0}=e,o=et.get(t);o.push(),Je(t,e);let n;if(i)n=r(t),o.pop();else try{n=r(t)}finally{o.pop()}return n}function _v(t){for(let e in t)return!1;return!0}var gc=E(()=>{Xi();Uu()});var St,Gu=E(()=>{F();St=class extends Jt{device;gl;handle;texture;constructor(e,r){super(e,{...B.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}});function mc(t){return yv[t]}var yv,Qu=E(()=>{yv={[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 bv(t,e=0){return e?new t.constructor(t.buffer,t.byteOffset+e,(t.byteLength-e)/t.BYTES_PER_ELEMENT):t}function Tv(t,e){if(e%t.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${e} must align to typed array element size ${t.BYTES_PER_ELEMENT}`);return e/t.BYTES_PER_ELEMENT}function xv(t){switch(t){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(t)}function _c(t,e,r){return e==="cube"?34069+r:t}var Et,yc=E(()=>{F();Zi();qu();gc();Gu();Qu();Et=class extends B{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,r){super(e,r,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let i=rc(this.props.format);this.glTarget=xv(this.props.dimension),this.glInternalFormat=i.internalFormat,this.glFormat=i.format,this.glType=i.type,this.compressed=i.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:o,width:n,height:s,depth:a,mipLevels:c,glTarget:l,glInternalFormat:f}=this;if(!this.compressed)switch(o){case"2d":case"cube":this.gl.texStorage2D(l,c,f,n,s);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,f,n,s,a);break;default:throw new Error(o)}this.gl.bindTexture(this.glTarget,null),this._initializeData(r.data),this.props.handle?this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"):this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"),this.setSampler(this.props.sampler),this.view=new St(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Texture"):(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")),this.destroyed=!0)}createView(e){return new St(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);let r=dc(this.sampler.props);this._setSamplerParameters(r)}copyExternalImage(e){let r=this._normalizeCopyExternalImageOptions(e);if(r.sourceX||r.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:i,glType:o}=this,{image:n,depth:s,mipLevel:a,x:c,y:l,z:f,width:h,height:u}=r,d=_c(this.glTarget,this.dimension,f),p=r.flipY?{[37440]:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),At(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(d,a,c,l,h,u,i,o,n);break;case"2d-array":case"3d":this.gl.texSubImage3D(d,a,c,l,f,h,u,s,i,o,n);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},r){if(!r)throw new Error(`${this} readBuffer requires a destination buffer`);let i=this._getSupportedColorReadOptions(e),o=e.byteOffset??0,n=this.computeMemoryLayout(i);if(r.byteLength<o+n.byteLength)throw new Error(`${this} readBuffer target is too small (${r.byteLength} < ${o+n.byteLength})`);let s=r;this.gl.bindBuffer(35051,s.handle);try{this._readColorTextureLayers(i,n,a=>{this.gl.readPixels(i.x,i.y,i.width,i.height,this.glFormat,this.glType,o+a)})}finally{this.gl.bindBuffer(35051,null)}return r}async readDataAsync(e={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,r={}){let i=this._normalizeTextureWriteOptions(r),{width:o,height:n,depthOrArrayLayers:s,mipLevel:a,byteOffset:c,x:l,y:f,z:h}=i,{glFormat:u,glType:d,compressed:p}=this,g=_c(this.glTarget,this.dimension,h);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:m}=this.device.getTextureFormatInfo(this.format),_=m?i.bytesPerRow/m:void 0,b={[3317]:this.byteAlignment,..._!==void 0?{[3314]:_}:{},[32878]:i.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),At(this.gl,b,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(g,a,l,f,o,n,u,d,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(g,a,l,f,h,o,n,s,u,d,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,r={}){let i=this._normalizeTextureWriteOptions(r),o=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:n,height:s,depthOrArrayLayers:a,mipLevel:c,x:l,y:f,z:h,byteOffset:u}=i,{glFormat:d,glType:p,compressed:g}=this,m=_c(this.glTarget,this.dimension,h),_;if(!g){let{bytesPerPixel:w}=this.device.getTextureFormatInfo(this.format);w&&(_=i.bytesPerRow/w)}let b=this.compressed?{}:{[3317]:this.byteAlignment,..._!==void 0?{[3314]:_}:{},[32878]:i.rowsPerImage},y=Tv(o,u),T=g?bv(o,u):o,S=this._getMipLevelSize(c),A=l===0&&f===0&&h===0&&n===S.width&&s===S.height&&a===S.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),At(this.gl,b,()=>{switch(this.dimension){case"2d":case"cube":g?A?this.gl.compressedTexImage2D(m,c,d,n,s,0,T):this.gl.compressedTexSubImage2D(m,c,l,f,n,s,d,T):this.gl.texSubImage2D(m,c,l,f,n,s,d,p,o,y);break;case"2d-array":case"3d":g?A?this.gl.compressedTexImage3D(m,c,d,n,s,a,0,T):this.gl.compressedTexSubImage3D(m,c,l,f,h,n,s,a,d,T):this.gl.texSubImage3D(m,c,l,f,h,n,s,a,d,p,o,y);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,r){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let r=this._getSupportedColorReadOptions(e),i=this.computeMemoryLayout(r),o=mc(this.glType),n=po(o),s=new n(i.byteLength/n.BYTES_PER_ELEMENT);return this._readColorTextureLayers(r,i,a=>{let c=new n(s.buffer,s.byteOffset+a,i.bytesPerImage/n.BYTES_PER_ELEMENT);this.gl.readPixels(r.x,r.y,r.width,r.height,this.glFormat,this.glType,c)}),s.buffer}_readColorTextureLayers(e,r,i){let o=this._getFramebuffer(),n=r.bytesPerRow/r.bytesPerPixel,s={[3333]:this.byteAlignment,...n!==e.width?{[3330]:n}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,o.handle);try{this.gl.readBuffer(36064),At(this.gl,s,()=>{for(let l=0;l<e.depthOrArrayLayers;l++)this._attachReadSubresource(o,e.mipLevel,e.z+l),i(l*r.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,c||null),this.gl.readBuffer(a)}}_attachReadSubresource(e,r,i){let o=`${r}:${i}`;if(this._framebufferAttachmentKey!==o){switch(this.dimension){case"2d":this.gl.framebufferTexture2D(36160,36064,3553,this.handle,r);break;case"cube":this.gl.framebufferTexture2D(36160,36064,_c(this.glTarget,this.dimension,i),this.handle,r);break;case"2d-array":case"3d":this.gl.framebufferTextureLayer(36160,36064,this.handle,r,i);break;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){let n=Number(this.gl.checkFramebufferStatus(36160));if(n!==Number(36053))throw new Error(`${e} incomplete for ${this} readback (${n})`)}this._framebufferAttachmentKey=o}}generateMipmapsWebGL(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(x.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(i){x.warn(`Error generating mipmap for ${this}: ${i.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){x.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,i]of Object.entries(e)){let o=Number(r),n=i;switch(o){case 33082:case 33083:this.gl.texParameterf(this.glTarget,o,n);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,o,n);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,o,n);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,o,n);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,o,n);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:r}=this;return e!==void 0&&(this._textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:r}=this;return e!==void 0&&(this._textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.glTarget,null),e}}});function mb(t,e,r,i){let o=t,n=i;n===!0&&(n=1),n===!1&&(n=0);let s=typeof n=="number"?[n]:n;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,i);case 5126:return t.uniform1fv(e,s);case 35664:return t.uniform2fv(e,s);case 35665:return t.uniform3fv(e,s);case 35666:return t.uniform4fv(e,s);case 5124:return t.uniform1iv(e,s);case 35667:return t.uniform2iv(e,s);case 35668:return t.uniform3iv(e,s);case 35669:return t.uniform4iv(e,s);case 35670:return t.uniform1iv(e,s);case 35671:return t.uniform2iv(e,s);case 35672:return t.uniform3iv(e,s);case 35673:return t.uniform4iv(e,s);case 5125:return o.uniform1uiv(e,s,1);case 36294:return o.uniform2uiv(e,s,2);case 36295:return o.uniform3uiv(e,s,3);case 36296:return o.uniform4uiv(e,s,4);case 35674:return t.uniformMatrix2fv(e,!1,s);case 35675:return t.uniformMatrix3fv(e,!1,s);case 35676:return t.uniformMatrix4fv(e,!1,s);case 35685:return o.uniformMatrix2x3fv(e,!1,s);case 35686:return o.uniformMatrix2x4fv(e,!1,s);case 35687:return o.uniformMatrix3x2fv(e,!1,s);case 35688:return o.uniformMatrix3x4fv(e,!1,s);case 35689:return o.uniformMatrix4x2fv(e,!1,s);case 35690:return o.uniformMatrix4x3fv(e,!1,s)}throw new Error("Illegal uniform")}var _b=E(()=>{});function yb(t){switch(t){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(t)}}function bb(t){switch(t){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(t)}}var Ju=E(()=>{});function Av(t,e){let r={...t,attributes:t.attributes.map(i=>({...i})),bindings:t.bindings.map(i=>({...i}))};for(let i of e?.attributes||[]){let o=r.attributes.find(n=>n.name===i.name);o?(o.type=i.type||o.type,o.stepMode=i.stepMode||o.stepMode):x.warn(`shader layout attribute ${i.name} not present in shader`)}for(let i of e?.bindings||[]){let o=xb(r,i.name);if(!o){x.warn(`shader layout binding ${i.name} not present in shader`);continue}Object.assign(o,i)}return r}function xb(t,e){return t.bindings.find(r=>r.name===e||r.name===`${e}Uniforms`||`${r.name}Uniforms`===e)}function Tb(t,e){return t[e]||t[`${e}Uniforms`]||t[e.replace(/Uniforms$/,"")]}var bc,Ab=E(()=>{F();Yu();_b();cc();nc();yc();Gu();Ju();bc=class extends we{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,r){super(e,r),this.device=e;let i=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(r);this.sharedRenderPipeline=i,this.handle=i.handle,this.vs=i.vs,this.fs=i.fs,this.linkStatus=i.linkStatus,this.introspectedLayout=i.introspectedLayout,this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=r.shaderLayout?Av(this.introspectedLayout,r.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,r){let i=ys(uo(this.shaderLayout,e));for(let[o,n]of Object.entries(i)){let s=xb(this.shaderLayout,o);if(s){switch(n||x.warn(`Unsetting binding "${o}" in render pipeline "${this.id}"`)(),s.type){case"uniform":if(!(n instanceof rt)&&!(n.buffer instanceof rt))throw new Error("buffer value");break;case"texture":if(!(n instanceof St||n instanceof Et||n instanceof xt))throw new Error(`${this} Bad texture binding for ${o}`);break;case"sampler":x.warn(`Ignoring sampler ${o}`)();break;default:throw new Error(s.type)}this.bindings[o]=n}else{let a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");r?.disableWarnings||x.warn(`No binding "${o}" in render pipeline "${this.id}", expected one of ${a}`,n)()}}}draw(e){this._syncLinkStatus();let r=e.bindGroups?ys(e.bindGroups):e.bindings||this.bindings,{renderPass:i,parameters:o=this.props.parameters,topology:n=this.props.topology,vertexArray:s,vertexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:f=0,transformFeedback:h,uniforms:u=this.uniforms}=e,d=yb(n),p=Boolean(s.indexBuffer),g=s.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return x.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable(r))return x.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),s.bindBeforeRender(i),h&&h.begin(this.props.topology),this._applyBindings(r,{disableWarnings:this.props.disableWarnings}),this._applyUniforms(u);let m=i;return pb(this.device,o,m.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(d,a||0,g,f,c||0):p?this.device.gl.drawElements(d,a||0,g,f):l?this.device.gl.drawArraysInstanced(d,f,a||0,c||0):this.device.gl.drawArrays(d,f,a||0),h&&h.end()}),s.unbindAfterRender(i),!0}_areTexturesRenderable(e){let r=!0;for(let i of this.shaderLayout.bindings)Tb(e,i.name)||(x.warn(`Binding ${i.name} not found in ${this.id}`)(),r=!1);return r}_applyBindings(e,r){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:i}=this.device;i.useProgram(this.handle);let o=0,n=0;for(let s of this.shaderLayout.bindings){let a=Tb(e,s.name);if(!a)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":let{name:c}=s,l=i.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);if(i.uniformBlockBinding(this.handle,l,n),a instanceof rt)i.bindBufferBase(35345,n,a.handle);else{let h=a;i.bindBufferRange(35345,n,h.buffer.handle,h.offset||0,h.size||h.buffer.byteLength-(h.offset||0))}n+=1;break;case"texture":if(!(a instanceof St||a instanceof Et||a instanceof xt))throw new Error("texture");let f;if(a instanceof St)f=a.texture;else if(a instanceof Et)f=a;else if(a instanceof xt&&a.colorAttachments[0]instanceof St)x.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),f=a.colorAttachments[0].texture;else throw new Error("No texture");i.activeTexture(33984+o),i.bindTexture(f.glTarget,f.handle),o+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let r of this.shaderLayout.uniforms||[]){let{name:i,location:o,type:n,textureUnit:s}=r,a=e[i]??s;a!==void 0&&mb(this.device.gl,o,n,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});function Sb(t){return Ev[t]}function Tc(t){return Sv[t]}function xc(t){return Boolean(wb[t])}function Eb(t){return wb[t]}var Sv,wb,Ev,Ac=E(()=>{Sv={[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>"},wb={[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"}},Ev={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 Rb(t,e){let r={attributes:[],bindings:[]};r.attributes=wv(t,e);let i=vv(t,e);for(let a of i){let c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));r.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 o=Pv(t,e),n=0;for(let a of o)if(xc(a.type)){let{viewDimension:c,sampleType:l}=Eb(a.type);r.bindings.push({type:"texture",name:a.name,group:0,location:n,viewDimension:c,sampleType:l}),a.textureUnit=n,n+=1}o.length&&(r.uniforms=o);let s=Rv(t,e);return s?.length&&(r.varyings=s),r}function wv(t,e){let r=[],i=t.getProgramParameter(e,35721);for(let o=0;o<i;o++){let n=t.getActiveAttrib(e,o);if(!n)throw new Error("activeInfo");let{name:s,type:a}=n,c=t.getAttribLocation(e,s);if(c>=0){let l=Tc(a),f=/instance/i.test(s)?"instance":"vertex";r.push({name:s,location:c,stepMode:f,type:l})}}return r.sort((o,n)=>o.location-n.location),r}function Rv(t,e){let r=[],i=t.getProgramParameter(e,35971);for(let o=0;o<i;o++){let n=t.getTransformFeedbackVarying(e,o);if(!n)throw new Error("activeInfo");let{name:s,type:a,size:c}=n,l=Tc(a),{type:f,components:h}=ui(l);r.push({location:o,name:s,type:f,size:c*h})}return r.sort((o,n)=>o.location-n.location),r}function Pv(t,e){let r=[],i=t.getProgramParameter(e,35718);for(let o=0;o<i;o++){let n=t.getActiveUniform(e,o);if(!n)throw new Error("activeInfo");let{name:s,size:a,type:c}=n,{name:l,isArray:f}=Mv(s),h=t.getUniformLocation(e,l),u={location:h,name:l,size:a,type:c,isArray:f};if(r.push(u),u.size>1)for(let d=0;d<u.size;d++){let p=`${l}[${d}]`;h=t.getUniformLocation(e,p);let g={...u,name:p,location:h};r.push(g)}}return r}function vv(t,e){let r=(n,s)=>t.getActiveUniformBlockParameter(e,n,s),i=[],o=t.getProgramParameter(e,35382);for(let n=0;n<o;n++){let s={name:t.getActiveUniformBlockName(e,n)||"",location:r(n,35391),byteLength:r(n,35392),vertex:r(n,35396),fragment:r(n,35398),uniformCount:r(n,35394),uniforms:[]},a=r(n,35395)||[],c=t.getActiveUniforms(e,a,35383),l=t.getActiveUniforms(e,a,35384),f=t.getActiveUniforms(e,a,35387),h=t.getActiveUniforms(e,a,35388);for(let p=0;p<s.uniformCount;++p){let g=a[p];if(g!==void 0){let m=t.getActiveUniform(e,g);if(!m)throw new Error("activeInfo");let _=Tc(c[p]);s.uniforms.push({name:m.name,format:_,type:c[p],arrayLength:l[p],byteOffset:f[p],byteStride:h[p]})}}let u=new Set(s.uniforms.map(p=>p.name.split(".")[0]).filter(p=>Boolean(p))),d=s.name.replace(/Uniforms$/,"");if(u.size===1&&!u.has(s.name)&&!u.has(d)){let[p]=u;x.warn(`Uniform block "${s.name}" uses GLSL instance "${p}". luma.gl binds uniform buffers by block name ("${s.name}") and alias ("${d}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}i.push(s)}return i.sort((n,s)=>n.location-s.location),i}function Mv(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);return{name:Pr(r?.[1],`Failed to parse GLSL uniform name ${t}`),length:r?.[2]?1:0,isArray:Boolean(r?.[2])}}var Pb=E(()=>{F();Ac()});var vb,Sc,Mb=E(()=>{F();Pb();Ac();vb=4,Sc=class extends ho{device;handle;vs;fs;introspectedLayout={attributes:[],bindings:[],uniforms:[]};linkStatus="pending";constructor(e,r){super(e,r),this.device=e,this.handle=r.handle||this.device.gl.createProgram(),this.vs=r.vs,this.fs=r.fs,r.varyings&&r.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,r.varyings,r.bufferMode||35981),this._linkShaders(),x.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Rb(this.device.gl,this.handle),x.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),x.time(vb,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),x.timeEnd(vb,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}x.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),x.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}async _reportLinkStatus(e){switch(e){case"success":return;default:let r=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} 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} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let i=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${e}: ${i}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let r=0,i=e.getProgramParameter(this.handle,35718);for(let o=0;o<i;o++){let n=e.getActiveUniform(this.handle,o);if(n&&xc(n.type)){let s=n.name.endsWith("[0]"),a=s?n.name.slice(0,-3):n.name,c=e.getUniformLocation(this.handle,a);c!==null&&(r=this._assignSamplerUniform(c,n,s,r))}}}_assignSamplerUniform(e,r,i,o){let{gl:n}=this.device;if(i&&r.size>1){let s=Int32Array.from({length:r.size},(a,c)=>o+c);return n.uniform1iv(e,s),o+r.size}return n.uniform1i(e,o),o+1}async _waitForLinkComplete(){let e=async o=>await new Promise(n=>setTimeout(n,o));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await e(10)}}}});function Cv(t,e){let r=e.sourceBuffer,i=e.destinationBuffer;t.gl.bindBuffer(36662,r.handle),t.gl.bindBuffer(36663,i.handle),t.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(36662,null),t.gl.bindBuffer(36663,null)}function Iv(t,e){throw new Error("copyBufferToTexture is not supported in WebGL")}function Ov(t,e){let{sourceTexture:r,mipLevel:i=0,aspect:o="all",width:n=e.sourceTexture.width,height:s=e.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:f=0,bytesPerRow:h,rowsPerImage:u}=e;if(r instanceof B){r.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:n,height:s,depthOrArrayLayers:a,mipLevel:i,aspect:o,byteOffset:f},l);return}if(o!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==void 0||h||u)throw new Error("not implemented");let{framebuffer:d,destroyFramebuffer:p}=Cb(r),g;try{let m=l,_=n||d.width,b=s||d.height,y=Pr(d.colorAttachments[0]),T=rc(y.texture.props.format),S=T.format,A=T.type;t.gl.bindBuffer(35051,m.handle),g=t.gl.bindFramebuffer(36160,d.handle),t.gl.readPixels(c[0],c[1],_,b,S,A,f)}finally{t.gl.bindBuffer(35051,null),g!==void 0&&t.gl.bindFramebuffer(36160,g),p&&d.destroy()}}function Nv(t,e){let{sourceTexture:r,destinationMipLevel:i=0,origin:o=[0,0],destinationOrigin:n=[0,0,0],destinationTexture:s}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:f}=Cb(r),[h=0,u=0]=o,[d,p,g]=n,m=t.gl.bindFramebuffer(36160,l.handle),_,b;if(s instanceof Et)_=s,a=Number.isFinite(a)?a:_.width,c=Number.isFinite(c)?c:_.height,_._bind(0),b=_.glTarget;else throw new Error("invalid destination");switch(b){case 3553:case 34067:t.gl.copyTexSubImage2D(b,i,d,p,h,u,a,c);break;case 35866:case 32879:t.gl.copyTexSubImage3D(b,i,d,p,g,h,u,a,c);break;default:}_&&_._unbind(),t.gl.bindFramebuffer(36160,m),f&&l.destroy()}function Cb(t){if(t instanceof B){let{width:e,height:r,id:i}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var Ec,Ib=E(()=>{F();Zi();yc();Ec=class extends hi{device;handle=null;commands=[];constructor(e,r={}){super(e,r),this.device=e}_executeCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":Cv(this.device,r.options);break;case"copy-buffer-to-texture":Iv(this.device,r.options);break;case"copy-texture-to-buffer":Ov(this.device,r.options);break;case"copy-texture-to-texture":Nv(this.device,r.options);break;default:throw new Error(r.name)}}}});var Dv,wc,Ob=E(()=>{F();gc();Xi();Dv=[1,2,4,8],wc=class extends Ct{device;handle=null;glParameters={};constructor(e,r){super(e,r),this.device=e;let i=this.props.framebuffer,o=!i||i.handle===null;o&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let n;if(!r?.parameters?.viewport)if(o){let[s,a]=e.getDefaultCanvasContext().getDrawingBufferSize();n=[0,0,s,a]}else{let{width:s,height:a}=i;n=[0,0,s,a]}if(this.device.pushState(),this.setParameters({viewport:n,...this.props.parameters}),o)this.device.gl.drawBuffers([1029]);else{let s=i.colorAttachments.map((a,c)=>36064+c);this.device.gl.drawBuffers(s)}this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let r={...this.glParameters};r.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(r.viewport=e.viewport.slice(0,4),r.depthRange=[e.viewport[4],e.viewport[5]]):r.viewport=e.viewport),e.scissorRect&&(r.scissorTest=!0,r.scissor=e.scissorRect),e.blendConstant&&(r.blendColor=e.blendConstant),e.stencilReference!==void 0&&(r[2967]=e.stencilReference,r[36003]=e.stencilReference),"colorMask"in e&&(r.colorMask=Dv.map(i=>Boolean(i&e.colorMask))),this.glParameters=r,Je(this.device.gl,r)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},r=0;this.props.clearColors&&this.props.clearColors.forEach((i,o)=>{i&&this.clearColorBuffer(o,i)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(r|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=1024,e.clearStencil=this.props.clearStencil),r!==0&&At(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){At(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,r);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,r);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,r);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var vn,Nb=E(()=>{F();Ib();Ob();vn=class extends fi{device;handle=null;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new Ec(e,{id:`${this.props.id}-command-buffer`})}destroy(){this.destroyResource()}finish(e){return e?.id&&this.commandBuffer.id!==e.id&&(this.commandBuffer.id=e.id,this.commandBuffer.props.id=e.id),this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new wc(this.device,this._applyTimeProfilingToPassProps(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,r,i){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(e,r){e.writeTimestamp(r)}}});function Db(t){let{target:e,source:r,start:i=0,count:o=1}=t,n=r.length,s=o*n,a=0;for(let c=i;a<n;a++)e[c++]=r[a]??0;for(;a<s;)a<s-a?(e.copyWithin(i+a,i,i+a),a*=2):(e.copyWithin(i+a,i,i+s-a),a=s);return t.target}var Bb=E(()=>{});function Bv(t){return Array.isArray(t)?new Float32Array(t):t}function Lv(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var qi,Lb=E(()=>{F();Zt();ku();Bb();qi=class extends di{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return ll()==="Chrome"}constructor(e,r){super(e,r),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 r=e;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(e,r){let i=r;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:o,type:n,stride:s,offset:a,normalized:c,integer:l,divisor:f}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,o,n,s,a):this.device.gl.vertexAttribPointer(e,o,n,c,s,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,f||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,r){this._enable(e,!1),this.attributes[e]=r}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 r=this.attributes[e];ArrayBuffer.isView(r)&&this.device.setConstantAttributeWebGL(e,r)}}_getAccessor(e){let r=this.attributeInfos[e];if(!r)throw new Error(`Unknown attribute location ${e}`);let i=Qa(r.bufferDataType);return{size:r.bufferComponents,type:i,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(e,r=!0){let o=qi.isConstantAttributeZeroSupported(this.device)||e!==0;(r||o)&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,r){let i=Bv(r),o=i.byteLength*e,n=i.length*e;if(this.buffer&&o!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${o} !== ${this.buffer.byteLength}.`);let s=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:o}),s||=!Lv(i,this.bufferValue),s){let a=af(r.constructor,n);Db({target:a,source:i,start:0,count:n}),this.buffer.write(a),this.bufferValue=r}return this.buffer}}});function Fb(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var Rc,Ub=E(()=>{F();Pc();Ju();Rc=class extends pi{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,r){super(e,r),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.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(bb(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[r,i]of Object.entries(e))this.setBuffer(r,i)})}setBuffer(e,r){let i=this._getVaryingIndex(e),{buffer:o,byteLength:n,byteOffset:s}=this._getBufferRange(r);if(i<0){this.unusedBuffers[e]=o,x.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:o,byteLength:n,byteOffset:s},this.bindOnUse||this._bindBuffer(i,o,s,n)}getBuffer(e){if(Fb(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return this.buffers[r]??null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof rt)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:i=0,byteLength:o=e.buffer.byteLength}=e;return{buffer:r,byteOffset:i,byteLength:o}}_getVaryingIndex(e){if(Fb(e))return Number(e);for(let r of this.layout.varyings||[])if(e===r.name)return r.location;return-1}_bindBuffers(){for(let[e,r]of Object.entries(this.buffers)){let{buffer:i,byteLength:o,byteOffset:n}=this._getBufferRange(r);this._bindBuffer(Number(e),i,n,o)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,r,i=0,o){let n=r&&r.handle;!n||o===void 0?this.gl.bindBufferBase(35982,e,n):this.gl.bindBufferRange(35982,e,n,i,o)}}});var vc,kb=E(()=>{F();vc=class extends gi{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){if(super(e,r),this.device=e,r.type==="timestamp"){if(r.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(r.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(r.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let i=this.device.gl.createQuery();if(!i)throw new Error("WebGL query not supported");this.handle=i}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let r of e.completedQueries)this._cancelPendingQuery(r),this.device.gl.deleteQuery(r.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type==="timestamp"?e===void 0?this._timestampPairs.some((r,i)=>this._isTimestampPairAvailable(i)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let r=e?.firstQuery||0,i=e?.queryCount||this.props.count-r;if(this._validateRange(r,i),this.props.type==="timestamp"){let o=new Array(i).fill(0n),n=Math.floor(r/2),s=Math.floor((r+i-1)/2);for(let a=n;a<=s;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,f=l+1;l>=r&&l<r+i&&(o[l-r]=0n),f>=r&&f<r+i&&(o[f-r]=c)}return o}if(!this._occlusionQuery)throw new Error("Occlusion query has not been started");return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(e,r){if(this.props.type!=="timestamp")throw new Error("Timestamp durations require a timestamp QuerySet");if(e<0||r>=this.props.count||r<=e)throw new Error("Timestamp duration range is out of bounds");if(e%2!==0||r!==e+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let i=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(i)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let r=this._getTimestampPairIndex(e),i=this._timestampPairs[r];if(e%2===0){if(i.activeQuery)throw new Error("Timestamp query pair is already active");let o=this.device.gl.createQuery();if(!o)throw new Error("WebGL query not supported");let n={handle:o,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,o),i.activeQuery=n;return}if(!i.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),i.completedQueries.push(i.activeQuery),i.activeQuery=null}_validateRange(e,r){if(e<0||r<0||e+r>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){let r=this._timestampPairs[e];return!r||r.completedQueries.length===0?!1:this._pollQueryAvailability(r.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let i=Boolean(this.device.gl.getParameter(36795));return e.disjoint=i,e.result=i?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let r=this._timestampPairs[e];if(!r||r.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let i=r.completedQueries.shift();try{return await this._consumeQueryResult(i)}finally{this.device.gl.deleteQuery(i.handle)}}_consumeQueryResult(e){return e.promise||(this._pendingReads.add(e),e.promise=new Promise((r,i)=>{e.resolve=r,e.reject=i;let o=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,r(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(o);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?i(new Error("GPU timestamp query was invalidated by a disjoint event")):r(e.result||0n)};o()})),e.promise}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let r=e.resolve;e.promise=null,e.resolve=null,e.reject=null,r(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}});var Mc,Vb=E(()=>{F();Mc=class extends mi{device;gl;handle;signaled;_signaled=!1;constructor(e,r={}){super(e,{}),this.device=e,this.gl=e.gl;let i=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!i)throw new Error("Failed to create WebGL fence");this.handle=i,this.signaled=new Promise(o=>{let n=()=>{let s=this.gl.clientWaitSync(this.handle,0,0);s===this.gl.ALREADY_SIGNALED||s===this.gl.CONDITION_SATISFIED?(this._signaled=!0,o()):setTimeout(n,1)};n()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function ed(t){switch(t){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 zb(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var Wb=E(()=>{});function jb(t,e){let{sourceX:r=0,sourceY:i=0,sourceAttachment:o=0}=e||{},{target:n=null,sourceWidth:s,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:f}=e||{},{framebuffer:h,deleteFramebuffer:u}=Hb(t),{gl:d,handle:p}=h;s||=h.width,a||=h.height;let g=h.colorAttachments[o]?.texture;if(!g)throw new Error(`Invalid framebuffer attachment ${o}`);c=g?.depth||1,l||=g?.glFormat||6408,f||=g?.glType||5121,n=Uv(n,f,l,s,a,c);let m=ue.getDataType(n);f=f||Sb(m);let _=d.bindFramebuffer(36160,p);return d.readBuffer(36064+o),d.readPixels(r,i,s,a,l,f,n),d.readBuffer(36064),d.bindFramebuffer(36160,_||null),u&&h.destroy(),n}function $b(t,e){let{target:r,sourceX:i=0,sourceY:o=0,sourceFormat:n=6408,targetByteOffset:s=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:f,deleteFramebuffer:h}=Hb(t);a=a||f.width,c=c||f.height;let u=f;l=l||5121;let d=r;if(!d){let g=ed(n),m=zb(l),_=s+a*c*g*m;d=u.device.createBuffer({byteLength:_})}let p=t.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:t,width:a,height:c,origin:[i,o],destinationBuffer:d,byteOffset:s}),p.destroy(),h&&f.destroy(),d}function Hb(t){return t instanceof at?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:Fv(t),deleteFramebuffer:!0}}function Fv(t,e){let{device:r,width:i,height:o,id:n}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${n}`,width:i,height:o,colorAttachments:[t]})}function Uv(t,e,r,i,o,n){if(t)return t;e||=5121;let s=mc(e),a=ue.getTypedArrayConstructor(s),c=ed(r);return new a(i*o*c)}var Xb=E(()=>{F();Ac();Wb();Qu()});var td={};Pt(td,{WebGLDevice:()=>it});function kv(t,e,r){switch(r.length){case 1:t.gl.vertexAttrib1fv(e,r);break;case 2:t.gl.vertexAttrib2fv(e,r);break;case 3:t.gl.vertexAttrib3fv(e,r);break;case 4:t.gl.vertexAttrib4fv(e,r);break;default:}}function Vv(t,e,r){t.gl.vertexAttribI4iv(e,r)}function zv(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function Wv(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var it,Cc=E(()=>{F();Uu();Yy();Za();qy();ob();nb();sb();ab();Ou();Nu();Zi();lb();cc();ub();gb();yc();nc();Ab();Mb();Nb();Lb();Ub();kb();Vb();Xb();Xi();gc();wn();it=class extends Te{static getDeviceFromContext(e){return e?e.luma?.device??null:null}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||cb("webgl-device")});let r=Te._getCanvasContextProps(e);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let i=r.canvas?.gl??null,o=it.getDeviceFromContext(i);if(o)throw new Error(`WebGL context already attached to device ${o.id}`);this.canvasContext=new sc(this,r),this.lost=new Promise(f=>{this._resolveContextLost=f});let n={...e.webgl};r.alphaMode==="premultiplied"&&(n.premultipliedAlpha=!0),e.powerPreference!==void 0&&(n.powerPreference=e.powerPreference),e.failIfMajorPerformanceCaveat!==void 0&&(n.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);let a=this.props._handle||Xy(this.canvasContext.canvas,{onContextLost:f=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:f=>console.log("WebGL context restored")},n);if(!a)throw new Error("WebGL context creation failed");if(o=it.getDeviceFromContext(a),o){if(e._reuseDevices)return x.log(1,`Not creating a new Device, instead returning a reference to Device ${o.id} already attached to WebGL context`,o)(),this.canvasContext.destroy(),o._reused=!0,o;throw new Error(`WebGL context already attached to device ${o.id}`)}this.handle=a,this.gl=a,this.spectorJS=Iy({...this.props,gl:this.handle});let c=Xr(this.handle);c.device=this,c.extensions||(c.extensions={}),this.extensions=c.extensions,this.info=Ky(this.gl,this.extensions),this.limits=new oc(this.gl),this.features=new ic(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new et(this.gl,{log:(...f)=>x.log(1,...f)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=By(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),x.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(x.level=Math.max(x.level,1)),this.commandEncoder=new vn(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(this.commandEncoder?.destroy(),!this.props._reuseDevices&&!this._reused){let e=Xr(this.handle);e.device=null}}get isLost(){return this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createPresentationContext(e){return new ac(this,e||{})}createBuffer(e){let r=this._normalizeBufferProps(e);return new rt(this,r)}createTexture(e){return new Et(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new pc(this,e)}createShader(e){return new fc(this,e)}createFramebuffer(e){return new xt(this,e)}createVertexArray(e){return new qi(this,e)}createTransformFeedback(e){return new Rc(this,e)}createQuerySet(e){return new vc(this,e)}createFence(){return new Mc(this)}createRenderPipeline(e){return new bc(this,e)}_createSharedRenderPipelineWebGL(e){return new Sc(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(e={}){return new vn(this,e)}submit(e){let r=null;e||({submittedCommandEncoder:r,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),r&&r.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=r._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,r=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:r}}readPixelsToArrayWebGL(e,r){return jb(e,r)}readPixelsToBufferWebGL(e,r){return $b(e,r)}setParametersWebGL(e){Je(this.gl,e)}getParametersWebGL(e){return Ga(this.gl,e)}withParametersWebGL(e,r){return At(this.gl,e,r)}resetWebGL(){x.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),zy(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return tb(this.gl,e,this.extensions)}loseDevice(){let e=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(e=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){et.get(this.gl).push()}popState(){et.get(this.gl).pop()}getGLKey(e,r){let i=Number(e);for(let o in this.gl)if(this.gl[o]===i)return`GL.${o}`;return r?.emptyIfUnknown?"":String(e)}getGLKeys(e){let r={emptyIfUnknown:!0};return Object.entries(e).reduce((i,[o,n])=>(i[`${o}:${this.getGLKey(o,r)}`]=`${n}:${this.getGLKey(n,r)}`,i),{})}setConstantAttributeWebGL(e,r){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let o=this._constants[e];switch(o&&Wv(o,r)&&x.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:kv(this,e,r);break;case Int32Array:Vv(this,e,r);break;case Uint32Array:zv(this,e,r);break;default:throw new Error("constant")}}getExtension(e){return tt(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,r,i){e.luma=r;let o={props:i.spector,id:i.spector.id};e.__SPECTOR_Metadata=o}}});function jv(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:Boolean(t&&typeof t.createVertexArray=="function")}var Mn,rd,Cn,Yb=E(()=>{F();vy();Ou();Nu();Mn=1,rd=class extends co{type="webgl";constructor(){super(),Te.defaultProps={...Te.defaultProps,...qa}}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&&x.warn("WebGL1 is not supported",e)(),!1)}async attach(e,r={}){let{WebGLDevice:i}=await Promise.resolve().then(()=>(Cc(),td));if(e instanceof i)return e;let o=i.getDeviceFromContext(e);if(o)return o;if(!jv(e))throw new Error("Invalid WebGL2RenderingContext");let n=r.createCanvasContext===!0?{}:r.createCanvasContext;return new i({...r,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...n}})}async create(e={}){let{WebGLDevice:r}=await Promise.resolve().then(()=>(Cc(),td)),i=[];(e.debugWebGL||e.debug)&&i.push(Dy()),e.debugSpectorJS&&i.push(Cy(e));let o=await Promise.allSettled(i);for(let n of o)n.status==="rejected"&&x.error(`Failed to initialize debug libraries ${n.reason}`)();try{let n=new r(e);x.groupCollapsed(Mn,`WebGLDevice ${n.id} created`)();let s=`${n._reused?"Reusing":"Created"} device with WebGL2 ${n.props.debug?"debug ":""}context: ${n.info.vendor}, ${n.info.renderer} for canvas: ${n.canvasContext.id}`;return x.probe(Mn,s)(),x.table(Mn,n.info)(),n}finally{x.groupEnd(Mn)(),x.info(Mn,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};Cn=new rd});var Pc=E(()=>{Yb();Cc();cc()});var Q2={};Pt(Q2,{AmbientLight:()=>Ui,Attribute:()=>Kt,AttributeManager:()=>Kr,COORDINATE_SYSTEM:()=>k,CompositeLayer:()=>T0,Controller:()=>be,Deck:()=>Ic,DeckGL:()=>Gn,DeckRenderer:()=>Hr,DirectionalLight:()=>kt,FirstPersonController:()=>Gr,FirstPersonView:()=>A0,FirstPersonViewport:()=>qc,FlyToInterpolator:()=>Zn,Layer:()=>jc,LayerExtension:()=>M0,LayerManager:()=>jr,LightingEffect:()=>_r,LinearInterpolator:()=>ae,MapController:()=>Yt,MapView:()=>ja,OPERATION:()=>V_,OrbitController:()=>Qr,OrbitView:()=>S0,OrbitViewport:()=>Xc,OrthographicController:()=>Jr,OrthographicView:()=>w0,OrthographicViewport:()=>Kc,PointLight:()=>Wi,PostProcessEffect:()=>hn,TRANSITION_EVENTS:()=>gn,TerrainController:()=>Yn,Tesselator:()=>qn,TransitionInterpolator:()=>$t,UNIT:()=>pr,VERSION:()=>ha,View:()=>ye,Viewport:()=>Se,WebMercatorViewport:()=>yr,Widget:()=>xr,_CameraLight:()=>cn,_Component:()=>Ji,_ComponentState:()=>Zr,_GlobeController:()=>ei,_GlobeView:()=>v0,_GlobeViewport:()=>$i,_LayersPass:()=>Ke,_PickLayersPass:()=>Vt,_SunLight:()=>ln,_applyStyles:()=>xn,_compareProps:()=>Vc,_count:()=>zc,_deepEqual:()=>Z,_fillArray:()=>La,_flatten:()=>Tr,_memoize:()=>ke,_mergeShaders:()=>zn,_registerLoggers:()=>fa,_removeStyles:()=>Ya,assert:()=>Y,color:()=>iu,createIterable:()=>Gi,fp64LowPart:()=>Au,getShaderAssembler:()=>Ca,gouraudMaterial:()=>Eo,log:()=>L,phongMaterial:()=>wo,picking:()=>Tu,project:()=>gr,project32:()=>pu,shadow:()=>Fi});var xh={};Pt(xh,{Buffer:()=>I,BufferTransform:()=>$e,CubeGeometry:()=>No,Device:()=>Te,Framebuffer:()=>at,Geometry:()=>He,GroupNode:()=>sr,Model:()=>ve,ModelNode:()=>Oo,ScenegraphNode:()=>ft,SphereGeometry:()=>Io,Texture:()=>B,TextureTransform:()=>Mo,attachDevice:()=>kE,createDevice:()=>VE,enforceWebGL2:()=>zE,getSupportedAdapters:()=>FE,setDefaultDeviceProps:()=>UE,stats:()=>LE});F();F();var sx=1,ax=1,Mr=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:r=0,duration:i=Number.POSITIVE_INFINITY,rate:o=1,repeat:n=1}=e,s=sx++,a={time:0,delay:r,duration:i,rate:o,repeat:n};return this._setChannelTime(a,this.time),this.channels.set(s,a),s}removeChannel(e){this.channels.delete(e);for(let[r,i]of this.animations)i.channel===e&&this.detachAnimation(r)}isFinished(e){let r=this.channels.get(e);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(e){if(e===void 0)return this.time;let r=this.channels.get(e);return r===void 0?-1:r.time}setTime(e){this.time=Math.max(0,e);let r=this.channels.values();for(let o of r)this._setChannelTime(o,this.time);let i=this.animations.values();for(let o of i){let{animation:n,channel:s}=o;n.setTime(this.getTime(s))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,r){let i=ax++;return this.animations.set(i,{animation:e,channel:r}),e.setTime(this.getTime(r)),i}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,r){let i=r-e.delay,o=e.duration*e.repeat;i>=o?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}};F();function Lp(t){let e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,t):setTimeout(()=>t(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function Fp(t){let e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,t);return}clearTimeout(t)}to();var cx=0,lx="Animation Loop",ff=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...ff.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Ne({id:`animation-loop-${cx++}`}),this.sharedStats=Qt.stats.get(lx),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),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),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this.props.onError(e),this._error=e}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}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;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let r=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(r),r}}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._lastFrameTime=0),this}redraw(e){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),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(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=Lp(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(Fp(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e){this._running&&(this.redraw(e),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 r=e?.canvas,i=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:r,useDevicePixels:i,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:r,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=r,this.animationProps.aspect=i,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 r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(r);let i=this.props.onAddHTML(r);i&&(r.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,r]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),i=e>0&&r>0?e/r:1;return{width:e,height:r,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let r=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let i=r-this._lastFrameTime;i>0&&this.frameRate.addTime(i)}this._lastFrameTime=r,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let r=this.sharedStats.get(e.name,e.type);r.sampleSize=e.sampleSize,r.time=e.time,r.count=e.count,r.samples=e.samples,r.lastTiming=e.lastTiming,r.lastSampleTime=e.lastSampleTime,r.lastSampleCount=e.lastSampleCount,r._count=e._count,r._time=e._time,r._samples=e._samples,r._startTime=e._startTime,r._timerPending=e._timerPending})}}_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}},yi=ff;M(yi,"defaultAnimationLoopProps",{device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:void 0,autoResizeViewport:!1});F();function Cr(t,e){if(!t){let r=new Error(e||"shadertools: assertion failed.");throw Error.captureStackTrace?.(r,Cr),r}}var hf={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function kp(t){let e={};for(let[r,i]of Object.entries(t))e[r]=fx(i);return e}function fx(t){let e=Up(t);if(e!=="object")return{value:t,...hf[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...hf[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=Up(t.value),{...t,...hf[e],type:e}):{type:"object",value:null};throw new Error("props")}function Up(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var Vp=`#ifdef MODULE_LOGDEPTH
|
|
18
|
+
<code><pre>${n}</pre></code>`,s&&(a.innerHTML+=`<br /><h1>Translated Source</h1><br /><br /><code><pre>${s}</pre></code>`),a.style.top="0",a.style.left="0",a.style.background="white",a.style.position="fixed",a.style.zIndex="9999",a.style.maxWidth="100vw",a.style.maxHeight="100vh",a.style.overflowY="auto",document.body.appendChild(a),a.querySelector(".luma-compiler-log-error")?.scrollIntoView(),a.querySelector("button#close").onclick=()=>{a.remove()},a.querySelector("button#copy").onclick=()=>{navigator.clipboard.writeText(this.source)}}},Jt=Vl;M(Jt,"defaultProps",{...D.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debugShaders:void 0})});var Wl,st,lp=E(()=>{ne();Ll();Ne();Wl=class extends D{get[Symbol.toStringTag](){return"Framebuffer"}width;height;constructor(e,r={}){super(e,r,Wl.defaultProps),this.width=this.props.width,this.height=this.props.height}clone(e){let r=this.colorAttachments.map(o=>o.texture.clone(e)),i=this.depthStencilAttachment&&this.depthStencilAttachment.texture.clone(e);return this.device.createFramebuffer({...this.props,...e,colorAttachments:r,depthStencilAttachment:i})}resize(e){let r=!e;if(e){let[i,o]=Array.isArray(e)?e:[e.width,e.height];r=r||o!==this.height||i!==this.width,this.width=i,this.height=o}r&&(x.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((r,i)=>{if(typeof r=="string"){let o=this.createColorTexture(r,i);return this.attachResource(o),o.view}return r instanceof B?r.view:r});let e=this.props.depthStencilAttachment;if(e)if(typeof e=="string"){let r=this.createDepthStencilTexture(e);this.attachResource(r),this.depthStencilAttachment=r.view}else e instanceof B?this.depthStencilAttachment=e.view:this.depthStencilAttachment=e}createColorTexture(e,r){return this.device.createTexture({id:`${this.id}-color-attachment-${r}`,usage:B.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:B.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,r){if(this.colorAttachments.forEach((i,o)=>{let n=i.texture.clone({width:e,height:r});this.destroyAttachedResource(i),this.colorAttachments[o]=n.view,this.attachResource(n.view)}),this.depthStencilAttachment){let i=this.depthStencilAttachment.texture.clone({width:e,height:r});this.destroyAttachedResource(this.depthStencilAttachment),this.depthStencilAttachment=i.view,this.attachResource(i)}this.updateAttachments()}},st=Wl;M(st,"defaultProps",{...D.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null})});var jl,Ee,$l=E(()=>{ne();jl=class extends D{get[Symbol.toStringTag](){return"RenderPipeline"}shaderLayout;bufferLayout;linkStatus="pending";hash="";sharedRenderPipeline=null;get isPending(){return this.linkStatus==="pending"||this.vs.compilationStatus==="pending"||this.fs?.compilationStatus==="pending"}get isErrored(){return this.linkStatus==="error"||this.vs.compilationStatus==="error"||this.fs?.compilationStatus==="error"}constructor(e,r){super(e,r,jl.defaultProps),this.shaderLayout=this.props.shaderLayout,this.bufferLayout=this.props.bufferLayout||[],this.sharedRenderPipeline=this.props._sharedRenderPipeline||null}},Ee=jl;M(Ee,"defaultProps",{...D.defaultProps,vs:null,vertexEntryPoint:"vertexMain",vsConstants:{},fs:null,fragmentEntryPoint:"fragmentMain",fsConstants:{},shaderLayout:null,bufferLayout:[],topology:"triangle-list",colorAttachmentFormats:void 0,depthStencilAttachmentFormat:void 0,parameters:{},varyings:void 0,bufferMode:void 0,disableWarnings:!1,_sharedRenderPipeline:void 0,bindings:void 0,bindGroups:void 0})});var uo,fp=E(()=>{ne();uo=class extends D{get[Symbol.toStringTag](){return"SharedRenderPipeline"}constructor(e,r){super(e,r,{...D.defaultProps,handle:void 0,vs:void 0,fs:void 0,varyings:void 0,bufferMode:void 0})}}});var Hl,ci,hp=E(()=>{ne();Hl=class extends D{get[Symbol.toStringTag](){return"ComputePipeline"}hash="";shaderLayout;constructor(e,r){super(e,r,Hl.defaultProps),this.shaderLayout=r.shaderLayout}},ci=Hl;M(ci,"defaultProps",{...D.defaultProps,shader:void 0,entryPoint:void 0,constants:{},shaderLayout:void 0})});var Xl,li,up=E(()=>{hp();$l();Ne();ni();Xl=class{static getDefaultPipelineFactory(e){let r=e.getModuleData("@luma.gl/core");return r.defaultPipelineFactory||=new Xl(e),r.defaultPipelineFactory}device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};_sharedRenderPipelineCache={};get[Symbol.toStringTag](){return"PipelineFactory"}toString(){return`PipelineFactory(${this.device.id})`}constructor(e){this.device=e}createRenderPipeline(e){if(!this.device.props._cachePipelines)return this.device.createRenderPipeline(e);let r={...Ee.defaultProps,...e},i=this._renderPipelineCache,o=this._hashRenderPipeline(r),n=i[o]?.resource;if(n)i[o].useCount++,this.device.props.debugFactories&&x.log(3,`${this}: ${i[o].resource} reused, count=${i[o].useCount}, (id=${e.id})`)();else{let s=this.device.type==="webgl"&&this.device.props._sharePipelines?this.createSharedRenderPipeline(r):void 0;n=this.device.createRenderPipeline({...r,id:r.id?`${r.id}-cached`:ot("unnamed-cached"),_sharedRenderPipeline:s}),n.hash=o,i[o]={resource:n,useCount:1},this.device.props.debugFactories&&x.log(3,`${this}: ${n} created, count=${i[o].useCount}`)()}return n}createComputePipeline(e){if(!this.device.props._cachePipelines)return this.device.createComputePipeline(e);let r={...ci.defaultProps,...e},i=this._computePipelineCache,o=this._hashComputePipeline(r),n=i[o]?.resource;return n?(i[o].useCount++,this.device.props.debugFactories&&x.log(3,`${this}: ${i[o].resource} reused, count=${i[o].useCount}, (id=${e.id})`)()):(n=this.device.createComputePipeline({...r,id:r.id?`${r.id}-cached`:void 0}),n.hash=o,i[o]={resource:n,useCount:1},this.device.props.debugFactories&&x.log(3,`${this}: ${n} created, count=${i[o].useCount}`)()),n}release(e){if(!this.device.props._cachePipelines){e.destroy();return}let r=this._getCache(e),i=e.hash;r[i].useCount--,r[i].useCount===0?(this._destroyPipeline(e),this.device.props.debugFactories&&x.log(3,`${this}: ${e} released and destroyed`)()):r[i].useCount<0?(x.error(`${this}: ${e} released, useCount < 0, resetting`)(),r[i].useCount=0):this.device.props.debugFactories&&x.log(3,`${this}: ${e} released, count=${r[i].useCount}`)()}createSharedRenderPipeline(e){let r=this._hashSharedRenderPipeline(e),i=this._sharedRenderPipelineCache[r];return i||(i={resource:this.device._createSharedRenderPipelineWebGL(e),useCount:0},this._sharedRenderPipelineCache[r]=i),i.useCount++,i.resource}releaseSharedRenderPipeline(e){if(!e.sharedRenderPipeline)return;let r=this._hashSharedRenderPipeline(e.sharedRenderPipeline.props),i=this._sharedRenderPipelineCache[r];i&&(i.useCount--,i.useCount===0&&(i.resource.destroy(),delete this._sharedRenderPipelineCache[r]))}_destroyPipeline(e){let r=this._getCache(e);return this.device.props._destroyPipelines?(delete r[e.hash],e.destroy(),e instanceof Ee&&this.releaseSharedRenderPipeline(e),!0):!1}_getCache(e){let r;if(e instanceof ci&&(r=this._computePipelineCache),e instanceof Ee&&(r=this._renderPipelineCache),!r)throw new Error(`${this}`);if(!r[e.hash])throw new Error(`${this}: ${e} matched incorrect entry`);return r}_hashComputePipeline(e){let{type:r}=this.device,i=this._getHash(e.shader.source),o=this._getHash(JSON.stringify(e.shaderLayout));return`${r}/C/${i}SL${o}`}_hashRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,o=this._getWebGLVaryingHash(e),n=this._getHash(JSON.stringify(e.shaderLayout)),s=this._getHash(JSON.stringify(e.bufferLayout)),{type:a}=this.device;switch(a){case"webgl":let c=this._getHash(JSON.stringify(e.parameters));return`${a}/R/${r}/${i}V${o}T${e.topology}P${c}SL${n}BL${s}`;case"webgpu":default:let l=this._getHash(JSON.stringify({vertexEntryPoint:e.vertexEntryPoint,fragmentEntryPoint:e.fragmentEntryPoint})),f=this._getHash(JSON.stringify(e.parameters)),h=this._getWebGPUAttachmentHash(e);return`${a}/R/${r}/${i}V${o}T${e.topology}EP${l}P${f}SL${n}BL${s}A${h}`}}_hashSharedRenderPipeline(e){let r=e.vs?this._getHash(e.vs.source):0,i=e.fs?this._getHash(e.fs.source):0,o=this._getWebGLVaryingHash(e);return`webgl/S/${r}/${i}V${o}`}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}_getWebGLVaryingHash(e){let{varyings:r=[],bufferMode:i=null}=e;return this._getHash(JSON.stringify({varyings:r,bufferMode:i}))}_getWebGPUAttachmentHash(e){let r=e.colorAttachmentFormats??[this.device.preferredColorFormat],i=e.parameters?.depthWriteEnabled?e.depthStencilAttachmentFormat||this.device.preferredDepthFormat:null;return this._getHash(JSON.stringify({colorAttachmentFormats:r,depthStencilAttachmentFormat:i}))}},li=Xl;M(li,"defaultProps",{...Ee.defaultProps})});var Yl,fi,dp=E(()=>{zl();Ne();Yl=class{static getDefaultShaderFactory(e){let r=e.getModuleData("@luma.gl/core");return r.defaultShaderFactory||=new Yl(e),r.defaultShaderFactory}device;_cache={};get[Symbol.toStringTag](){return"ShaderFactory"}toString(){return`${this[Symbol.toStringTag]}(${this.device.id})`}constructor(e){this.device=e}createShader(e){if(!this.device.props._cacheShaders)return this.device.createShader(e);let r=this._hashShader(e),i=this._cache[r];if(i)i.useCount++,this.device.props.debugFactories&&x.log(3,`${this}: Reusing shader ${i.resource.id} count=${i.useCount}`)();else{let o=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[r]=i={resource:o,useCount:1},this.device.props.debugFactories&&x.log(3,`${this}: Created new shader ${o.id}`)()}return i.resource}release(e){if(!this.device.props._cacheShaders){e.destroy();return}let r=this._hashShader(e),i=this._cache[r];if(i)if(i.useCount--,i.useCount===0)this.device.props._destroyShaders&&(delete this._cache[r],i.resource.destroy(),this.device.props.debugFactories&&x.log(3,`${this}: Releasing shader ${e.id}, destroyed`)());else{if(i.useCount<0)throw new Error(`ShaderFactory: Shader ${e.id} released too many times`);this.device.props.debugFactories&&x.log(3,`${this}: Releasing shader ${e.id} count=${i.useCount}`)()}}_hashShader(e){return`${e.stage}:${e.source}`}},fi=Yl;M(fi,"defaultProps",{...Jt.defaultProps})});function pp(t,e,r){let i=t.bindings.find(o=>o.name===e||`${o.name.toLocaleLowerCase()}uniforms`===e.toLocaleLowerCase());return!i&&!r?.ignoreWarnings&&x.warn(`Binding ${e} not set: Not found in shader layout.`)(),i||null}function po(t,e){if(!e)return{};if(UT(e))return Object.fromEntries(Object.entries(e).map(([o,n])=>[Number(o),{...n}]));let r={};for(let[i,o]of Object.entries(e)){let s=pp(t,i)?.group??0;r[s]||={},r[s][i]=o}return r}function bs(t){let e={};for(let r of Object.values(t))Object.assign(e,r);return e}function UT(t){let e=Object.keys(t);return e.length>0&&e.every(r=>/^\d+$/.test(r))}var gp=E(()=>{Ne()});var Pr,Mt,mp=E(()=>{ne();Pr=class extends D{get[Symbol.toStringTag](){return"RenderPass"}constructor(e,r){r=Pr.normalizeProps(e,r),super(e,r,Pr.defaultProps)}static normalizeProps(e,r){return r}},Mt=Pr;M(Mt,"defaultClearColor",[0,0,0,1]),M(Mt,"defaultClearDepth",1),M(Mt,"defaultClearStencil",0),M(Mt,"defaultProps",{...D.defaultProps,framebuffer:null,parameters:void 0,clearColor:Pr.defaultClearColor,clearColors:void 0,clearDepth:Pr.defaultClearDepth,clearStencil:Pr.defaultClearStencil,depthReadOnly:!1,stencilReadOnly:!1,discard:!1,occlusionQuerySet:void 0,timestampQuerySet:void 0,beginTimestampIndex:void 0,endTimestampIndex:void 0})});var Kl,hi,_p=E(()=>{ne();Kl=class extends D{get[Symbol.toStringTag](){return"CommandEncoder"}_timeProfilingQuerySet=null;_timeProfilingSlotCount=0;_gpuTimeMs;constructor(e,r){super(e,r,Kl.defaultProps),this._timeProfilingQuerySet=r.timeProfilingQuerySet??null,this._timeProfilingSlotCount=0,this._gpuTimeMs=void 0}async resolveTimeProfilingQuerySet(){if(this._gpuTimeMs=void 0,!this._timeProfilingQuerySet)return;let e=Math.floor(this._timeProfilingSlotCount/2);if(e<=0)return;let r=e*2,i=await this._timeProfilingQuerySet.readResults({firstQuery:0,queryCount:r}),o=0n;for(let n=0;n<r;n+=2)o+=i[n+1]-i[n];this._gpuTimeMs=Number(o)/1e6}getTimeProfilingSlotCount(){return this._timeProfilingSlotCount}getTimeProfilingQuerySet(){return this._timeProfilingQuerySet}_applyTimeProfilingToPassProps(e){let r=e||{};if(!this._supportsTimestampQueries()||!this._timeProfilingQuerySet||r.timestampQuerySet!==void 0||r.beginTimestampIndex!==void 0||r.endTimestampIndex!==void 0)return r;let i=this._timeProfilingSlotCount;return i+1>=this._timeProfilingQuerySet.props.count?r:(this._timeProfilingSlotCount+=2,{...r,timestampQuerySet:this._timeProfilingQuerySet,beginTimestampIndex:i,endTimestampIndex:i+1})}_supportsTimestampQueries(){return this.device.features.has("timestamp-query")}},hi=Kl;M(hi,"defaultProps",{...D.defaultProps,measureExecutionTime:void 0,timeProfilingQuerySet:void 0})});var Zl,ui,yp=E(()=>{ne();Zl=class extends D{get[Symbol.toStringTag](){return"CommandBuffer"}constructor(e,r){super(e,r,Zl.defaultProps)}},ui=Zl;M(ui,"defaultProps",{...D.defaultProps})});function di(t){let e=Ts(t),r=WT[e];if(!r)throw new Error(`Unsupported variable shader type: ${t}`);return r}function bp(t){let e=Tp(t),r=zT[e];if(!r)throw new Error(`Unsupported attribute shader type: ${t}`);let[i,o]=r,n=i==="i32"||i==="u32",s=i!=="u32",a=VT[i]*o;return{primitiveType:i,components:o,byteLength:a,integer:n,signed:s}}function kT(t,e){return e===1?t:`vec${e}<${t}>`}function Tp(t){return jT[t]||t}function Ts(t){return $T[t]||t}var ql,Gl,VT,zT,WT,jT,$T,xs=E(()=>{ql=class{getVariableShaderTypeInfo(e){return di(e)}getAttributeShaderTypeInfo(e){return bp(e)}makeShaderAttributeType(e,r){return kT(e,r)}resolveAttributeShaderTypeAlias(e){return Tp(e)}resolveVariableShaderTypeAlias(e){return Ts(e)}};Gl=new ql,VT={f32:4,f16:2,i32:4,u32:4},zT={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]},WT={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}},jT={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>"},$T={vec2i:"vec2<i32>",vec3i:"vec3<i32>",vec4i:"vec4<i32>",vec2u:"vec2<u32>",vec3u:"vec3<u32>",vec4u:"vec4<u32>",vec2f:"vec2<f32>",vec3f:"vec3<f32>",vec4f:"vec4<f32>",vec2h:"vec2<f16>",vec3h:"vec3<f16>",vec4h:"vec4<f16>",mat2x2f:"mat2x2<f32>",mat2x3f:"mat2x3<f32>",mat2x4f:"mat2x4<f32>",mat3x2f:"mat3x2<f32>",mat3x3f:"mat3x3<f32>",mat3x4f:"mat3x4<f32>",mat4x2f:"mat4x2<f32>",mat4x3f:"mat4x3<f32>",mat4x4f:"mat4x4<f32>",mat2x2i:"mat2x2<i32>",mat2x3i:"mat2x3<i32>",mat2x4i:"mat2x4<i32>",mat3x2i:"mat3x2<i32>",mat3x3i:"mat3x3<i32>",mat3x4i:"mat3x4<i32>",mat4x2i:"mat4x2<i32>",mat4x3i:"mat4x3<i32>",mat4x4i:"mat4x4<i32>",mat2x2u:"mat2x2<u32>",mat2x3u:"mat2x3<u32>",mat2x4u:"mat2x4<u32>",mat3x2u:"mat3x2<u32>",mat3x3u:"mat3x3<u32>",mat3x4u:"mat3x4<u32>",mat4x2u:"mat4x2<u32>",mat4x3u:"mat4x3<u32>",mat4x4u:"mat4x4<u32>",mat2x2h:"mat2x2<f16>",mat2x3h:"mat2x3<f16>",mat2x4h:"mat2x4<f16>",mat3x2h:"mat3x2<f16>",mat3x3h:"mat3x3<f16>",mat3x4h:"mat3x4<f16>",mat4x2h:"mat4x2<f16>",mat4x3h:"mat4x3<f16>",mat4x4h:"mat4x4<f16>"}});function As(t,e){let r={};for(let i of t.attributes){let o=HT(t,e,i.name);o&&(r[i.name]=o)}return r}function xp(t,e,r=16){let i=As(t,e),o=new Array(r).fill(null);for(let n of Object.values(i))o[n.location]=n;return o}function HT(t,e,r){let i=XT(t,r),o=YT(e,r);if(!i)return null;let n=Gl.getAttributeShaderTypeInfo(i.type),s=Pt.getCompatibleVertexFormat(n),a=o?.vertexFormat||s,c=Pt.getVertexFormatInfo(a);return{attributeName:o?.attributeName||i.name,bufferName:o?.bufferName||i.name,location:i.location,shaderType:i.type,primitiveType:n.primitiveType,shaderComponents:n.components,vertexFormat:a,bufferDataType:c.type,bufferComponents:c.components,normalized:c.normalized,integer:n.integer,stepMode:o?.stepMode||i.stepMode||"vertex",byteOffset:o?.byteOffset||0,byteStride:o?.byteStride||0}}function XT(t,e){let r=t.attributes.find(i=>i.name===e);return r||x.warn(`shader layout attribute "${e}" not present in shader`),r||null}function YT(t,e){KT(t);let r=ZT(t,e);return r||(r=qT(t,e),r)?r:(x.warn(`layout for attribute "${e}" not present in buffer layout`),null)}function KT(t){for(let e of t)(e.attributes&&e.format||!e.attributes&&!e.format)&&x.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}function ZT(t,e){for(let r of t)if(r.format&&r.name===e)return{attributeName:r.name,bufferName:e,stepMode:r.stepMode,vertexFormat:r.format,byteOffset:0,byteStride:r.byteStride||0};return null}function qT(t,e){for(let r of t){let i=r.byteStride;if(typeof r.byteStride!="number")for(let n of r.attributes||[]){let s=Pt.getVertexFormatInfo(n.format);i+=s.byteLength}let o=r.attributes?.find(n=>n.attribute===e);if(o)return{attributeName:o.attribute,bufferName:r.name,stepMode:r.stepMode,vertexFormat:o.format,byteOffset:o.byteOffset,byteStride:i}}return null}var Ql=E(()=>{Ne();xs();ls()});var Jl,pi,Ap=E(()=>{Ql();ne();Jl=class extends D{get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,r){super(e,r,Jl.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=xp(r.shaderLayout,r.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,r){this.device.reportError(new Error("constant attributes not supported"),this)()}},pi=Jl;M(pi,"defaultProps",{...D.defaultProps,shaderLayout:void 0,bufferLayout:[]})});var ef,gi,Sp=E(()=>{ne();ef=class extends D{get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,r){super(e,r,ef.defaultProps)}},gi=ef;M(gi,"defaultProps",{...D.defaultProps,layout:void 0,buffers:{}})});var tf,mi,Ep=E(()=>{ne();tf=class extends D{get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){super(e,r,tf.defaultProps)}},mi=tf;M(mi,"defaultProps",{...D.defaultProps,type:void 0,count:void 0})});var rf,_i,wp=E(()=>{ne();rf=class extends D{get[Symbol.toStringTag](){return"Fence"}constructor(e,r={}){super(e,r,rf.defaultProps)}},_i=rf;M(_i,"defaultProps",{...D.defaultProps})});function at(t,e){switch(e){case 1:return t;case 2:return t+t%2;default:return t+(4-t%4)%4}}function go(t){let[,,,,e]=GT[t];return e}var GT,of=E(()=>{GT={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 Pp(t,e={}){let r={...t},i=e.layout??"std140",o={},n=0;for(let[s,a]of Object.entries(r))n=nf(o,s,a,n,i);return n=at(n,er(r,i)),{layout:i,byteLength:n*4,uniformTypes:r,fields:o}}function mo(t,e){let r=Ts(t),i=di(r),o=/^mat(\d)x(\d)<.+>$/.exec(r);if(o){let s=Number(o[1]),a=Number(o[2]),c=Rp(a,r,i.type,e),l=JT(c.size,c.alignment,e);return{alignment:c.alignment,size:s*l,components:s*a,columns:s,rows:a,columnStride:l,shaderType:r,type:i.type}}let n=/^vec(\d)<.+>$/.exec(r);return n?Rp(Number(n[1]),r,i.type,e):{alignment:1,size:1,components:1,columns:1,rows:1,columnStride:1,shaderType:r,type:i.type}}function sf(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)}function nf(t,e,r,i,o){if(typeof r=="string"){let n=mo(r,o),s=at(i,n.alignment);return t[e]={offset:s,...n},s+n.size}if(Array.isArray(r)){if(Array.isArray(r[0]))throw new Error(`Nested arrays are not supported for ${e}`);let n=r[0],s=r[1],a=Mp(n,o),c=at(i,er(r,o));for(let l=0;l<s;l++)nf(t,`${e}[${l}]`,n,c+l*a,o);return c+a*s}if(sf(r)){let n=er(r,o),s=at(i,n);for(let[a,c]of Object.entries(r))s=nf(t,`${e}.${a}`,c,s,o);return at(s,n)}throw new Error(`Unsupported CompositeShaderType for ${e}`)}function vp(t,e){if(typeof t=="string")return mo(t,e).size;if(Array.isArray(t)){let i=t[0],o=t[1];if(Array.isArray(i))throw new Error("Nested arrays are not supported");return Mp(i,e)*o}let r=0;for(let i of Object.values(t)){let o=i;r=at(r,er(o,e)),r+=vp(o,e)}return at(r,er(t,e))}function er(t,e){if(typeof t=="string")return mo(t,e).alignment;if(Array.isArray(t)){let i=t[0],o=er(i,e);return Cp(e)?Math.max(o,4):o}let r=1;for(let i of Object.values(t)){let o=er(i,e);r=Math.max(r,o)}return ex(e)?Math.max(r,4):r}function Rp(t,e,r,i){return{alignment:t===2?2:4,size:t===3?3:t,components:t,columns:1,rows:t,columnStride:t===3?3:t,shaderType:e,type:r}}function Mp(t,e){let r=vp(t,e),i=er(t,e);return QT(r,i,e)}function QT(t,e,r){return at(t,Cp(r)?4:e)}function JT(t,e,r){return r==="std140"?4:at(t,e)}function Cp(t){return t==="std140"||t==="wgsl-uniform"}function ex(t){return t==="std140"||t==="wgsl-uniform"}var af=E(()=>{of();xs()});function cf(t){return(!Ss||Ss.byteLength<t)&&(Ss=new ArrayBuffer(t)),Ss}function lf(t,e){let r=cf(t.BYTES_PER_ELEMENT*e);return new t(r,0,e)}var Ss,ff=E(()=>{});function tx(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function yi(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":tx(t)}var hf=E(()=>{});function rx(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}function ix(t,e,r){return Array.prototype.slice.call(t,e,r)}var Es,Ip=E(()=>{ff();hf();Ne();af();Es=class{layout;constructor(e){this.layout=e}has(e){return Boolean(this.layout.fields[e])}get(e){let r=this.layout.fields[e];return r?{offset:r.offset,size:r.size}:void 0}getFlatUniformValues(e){let r={};for(let[i,o]of Object.entries(e)){let n=this.layout.uniformTypes[i];n?this._flattenCompositeValue(r,i,n,o):this.layout.fields[i]&&(r[i]=o)}return r}getData(e){let r=cf(this.layout.byteLength);new Uint8Array(r,0,this.layout.byteLength).fill(0);let i={i32:new Int32Array(r),u32:new Uint32Array(r),f32:new Float32Array(r),f16:new Uint16Array(r)},o=this.getFlatUniformValues(e);for(let[n,s]of Object.entries(o))this._writeLeafValue(i,n,s);return new Uint8Array(r,0,this.layout.byteLength)}_flattenCompositeValue(e,r,i,o){if(o!==void 0){if(typeof i=="string"||this.layout.fields[r]){e[r]=o;return}if(Array.isArray(i)){let n=i[0],s=i[1];if(Array.isArray(n))throw new Error(`Nested arrays are not supported for ${r}`);if(typeof n=="string"&&yi(o)){this._flattenPackedArray(e,r,n,s,o);return}if(!Array.isArray(o)){x.warn(`Unsupported uniform array value for ${r}:`,o)();return}for(let a=0;a<Math.min(o.length,s);a++){let c=o[a];c!==void 0&&this._flattenCompositeValue(e,`${r}[${a}]`,n,c)}return}if(sf(i)&&rx(o)){for(let[n,s]of Object.entries(o)){if(s===void 0)continue;let a=`${r}.${n}`;this._flattenCompositeValue(e,a,i[n],s)}return}x.warn(`Unsupported uniform value for ${r}:`,o)()}}_flattenPackedArray(e,r,i,o,n){let s=n,c=mo(i,this.layout.layout).components;for(let l=0;l<o;l++){let f=l*c;if(f>=s.length)break;c===1?e[`${r}[${l}]`]=Number(s[f]):e[`${r}[${l}]`]=ix(n,f,f+c)}}_writeLeafValue(e,r,i){let o=this.layout.fields[r];if(!o){x.warn(`Uniform ${r} not found in layout`)();return}let{type:n,components:s,columns:a,rows:c,offset:l,columnStride:f}=o,h=e[n];if(s===1){h[l]=Number(i);return}let u=i;if(a===1){for(let p=0;p<s;p++)h[l+p]=Number(u[p]??0);return}let d=0;for(let p=0;p<a;p++){let g=l+p*f;for(let m=0;m<c;m++)h[g+m]=Number(u[d++]??0)}}}});function Op(t,e,r=16){if(t===e)return!0;let i=t,o=e;if(!yi(i)||!yi(o)||i.length!==o.length)return!1;let n=Math.min(r,ox);if(i.length>n)return!1;for(let s=0;s<i.length;++s)if(o[s]!==i[s])return!1;return!0}function Np(t){return yi(t)?t.slice():t}var ox,Dp=E(()=>{hf();ox=128});var ws,Bp=E(()=>{Dp();ws=class{name;uniforms={};modifiedUniforms={};modified=!0;bindingLayout={};needsRedraw="initialized";constructor(e){if(this.name=e?.name||"unnamed",e?.name&&e?.shaderLayout){let r=e?.shaderLayout.bindings?.find(o=>o.type==="uniform"&&o.name===e?.name);if(!r)throw new Error(e?.name);let i=r;for(let o of i.uniforms||[])this.bindingLayout[o.name]=o}}setUniforms(e){for(let[r,i]of Object.entries(e))this._setUniform(r,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${r}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,r){Op(this.uniforms[e],r)||(this.uniforms[e]=Np(r),this.modifiedUniforms[e]=!0,this.modified=!0)}}});function sx(t){return t.type==="webgpu"?"wgsl-uniform":"std140"}var nx,_o,Fp=E(()=>{as();Ne();af();Bp();Ip();nx=1024,_o=class{device;uniformBlocks=new Map;shaderBlockLayouts=new Map;shaderBlockWriters=new Map;uniformBuffers=new Map;constructor(e,r){this.device=e;for(let[i,o]of Object.entries(r)){let n=i,s=Pp(o.uniformTypes??{},{layout:o.layout??sx(e)}),a=new Es(s);this.shaderBlockLayouts.set(n,s),this.shaderBlockWriters.set(n,a);let c=new ws({name:i});c.setUniforms(a.getFlatUniformValues(o.defaultUniforms||{})),this.uniformBlocks.set(n,c)}}destroy(){for(let e of this.uniformBuffers.values())e.destroy()}setUniforms(e){for(let[r,i]of Object.entries(e)){let o=r,s=this.shaderBlockWriters.get(o)?.getFlatUniformValues(i||{});this.uniformBlocks.get(o)?.setUniforms(s||{})}this.updateUniformBuffers()}getUniformBufferByteLength(e){let r=this.shaderBlockLayouts.get(e)?.byteLength||0;return Math.max(r,nx)}getUniformBufferData(e){let r=this.uniformBlocks.get(e)?.getAllUniforms()||{};return this.shaderBlockWriters.get(e)?.getData(r)||new Uint8Array(0)}createUniformBuffer(e,r){r&&this.setUniforms(r);let i=this.getUniformBufferByteLength(e),o=this.device.createBuffer({usage:I.UNIFORM|I.COPY_DST,byteLength:i}),n=this.getUniformBufferData(e);return o.write(n),o}getManagedUniformBuffer(e){if(!this.uniformBuffers.get(e)){let r=this.getUniformBufferByteLength(e),i=this.device.createBuffer({usage:I.UNIFORM|I.COPY_DST,byteLength:r});this.uniformBuffers.set(e,i)}return this.uniformBuffers.get(e)}updateUniformBuffers(){let e=!1;for(let r of this.uniformBlocks.keys()){let i=this.updateUniformBuffer(r);e||=i}return e&&x.log(3,`UniformStore.updateUniformBuffers(): ${e}`)(),e}updateUniformBuffer(e){let r=this.uniformBlocks.get(e),i=this.uniformBuffers.get(e),o=!1;if(i&&r?.needsRedraw){o||=r.needsRedraw;let n=this.getUniformBufferData(e);i=this.uniformBuffers.get(e),i?.write(n);let s=this.uniformBlocks.get(e)?.getAllUniforms();x.log(4,`Writing to uniform buffer ${String(e)}`,n,s)()}return o}}});var L=E(()=>{qd();Gd();Ol();ip();op();as();Ll();np();zl();Fl();lp();$l();fp();up();dp();mp();_p();yp();Ap();Sp();Ep();wp();Fp();cs();of();xs();ls();ds();Ml();Ne();gp();Dl();ff();Ql()});var xr,Ry=E(()=>{(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(xr||(xr={}))});var Py=E(()=>{Ry()});function vy(t=!0){let e=HTMLCanvasElement.prototype;if(!t&&e.originalGetContext){e.getContext=e.originalGetContext,e.originalGetContext=void 0;return}e.originalGetContext=e.getContext,e.getContext=function(r,i){if(r==="webgl"||r==="experimental-webgl"){let o=this.originalGetContext("webgl2",i);return o instanceof HTMLElement&&jP(o),o}return this.originalGetContext(r,i)}}function jP(t){t.getExtension("EXT_color_buffer_float");let e={...kP,WEBGL_disjoint_timer_query:t.getExtension("EXT_disjoint_timer_query_webgl2"),WEBGL_draw_buffers:VP(t),OES_vertex_array_object:zP(t),ANGLE_instanced_arrays:WP(t)},r=t.getExtension;t.getExtension=function(o){let n=r.call(t,o);return n||(o in e?e[o]:null)};let i=t.getSupportedExtensions;t.getSupportedExtensions=function(){return(i.apply(t)||[])?.concat(Object.keys(e))}}var kP,VP,zP,WP,My=E(()=>{kP={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:{}},VP=t=>({drawBuffersWEBGL(e){return t.drawBuffers(e)},COLOR_ATTACHMENT0_WEBGL:36064,COLOR_ATTACHMENT1_WEBGL:36065,COLOR_ATTACHMENT2_WEBGL:36066,COLOR_ATTACHMENT3_WEBGL:36067}),zP=t=>({VERTEX_ARRAY_BINDING_OES:34229,createVertexArrayOES(){return t.createVertexArray()},deleteVertexArrayOES(e){return t.deleteVertexArray(e)},isVertexArrayOES(e){return t.isVertexArray(e)},bindVertexArrayOES(e){return t.bindVertexArray(e)}}),WP=t=>({VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE:35070,drawArraysInstancedANGLE(...e){return t.drawArraysInstanced(...e)},drawElementsInstancedANGLE(...e){return t.drawElementsInstanced(...e)},vertexAttribDivisorANGLE(...e){return t.vertexAttribDivisor(...e)}})});async function qa(t,e){let r=document.getElementsByTagName("head")[0];if(!r)throw new Error("loadScript");let i=document.createElement("script");return i.setAttribute("type","text/javascript"),i.setAttribute("src",t),e&&(i.id=e),new Promise((o,n)=>{i.onload=o,i.onerror=s=>n(new Error(`Unable to load script '${t}': ${s}`)),r.appendChild(i)})}var Ou=E(()=>{});function Yr(t){let e=t.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return e._polyfilled??=!1,e.extensions||={},t.luma=e,e}var Ga=E(()=>{});async function Iy(t){if(!globalThis.SPECTOR)try{await qa(t.debugSpectorJSUrl||Qa.debugSpectorJSUrl)}catch(e){x.warn(String(e))}}function Oy(t){if(t={...Qa,...t},!t.debugSpectorJS)return null;if(!Ce&&globalThis.SPECTOR&&!globalThis.luma?.spector){x.probe($P,"SPECTOR found and initialized. Start with `luma.spector.displayUI()`")();let{Spector:e}=globalThis.SPECTOR;Ce=new e,globalThis.luma&&(globalThis.luma.spector=Ce)}if(!Ce)return null;if(Cy||(Cy=!0,Ce.spyCanvases(),Ce?.onCaptureStarted.add(e=>x.info("Spector capture started:",e)()),Ce?.onCapture.add(e=>{x.info("Spector capture complete:",e)(),Ce?.getResultUI(),Ce?.resultView.display(),Ce?.resultView.addCapture(e)})),t.gl){let e=t.gl,r=Yr(e),i=r.device;Ce?.startCapture(t.gl,500),r.device=i,new Promise(o=>setTimeout(o,2e3)).then(o=>{x.info("Spector capture stopped after 2 seconds")(),Ce?.stopCapture()})}return Ce}var $P,Ce,Cy,Qa,Nu=E(()=>{L();Ou();Ga();$P=1,Ce=null,Cy=!1,Qa={debugSpectorJS:x.get("debug-spectorjs"),debugSpectorJSUrl:"https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js",gl:void 0}});function Dy(t){return t.luma=t.luma||{},t.luma}async function By(){le()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await qa(HP))}function Fy(t,e={}){return e.debugWebGL||e.traceWebGL?YP(t,e):XP(t)}function XP(t){let e=Dy(t);return e.realContext?e.realContext:t}function YP(t,e){if(!globalThis.WebGLDebugUtils)return x.warn("webgl-debug not loaded")(),t;let r=Dy(t);if(r.debugContext)return r.debugContext;globalThis.WebGLDebugUtils.init({...xr,...t});let i=globalThis.WebGLDebugUtils.makeDebugContext(t,KP.bind(null,e),ZP.bind(null,e));for(let s in xr)!(s in i)&&typeof xr[s]=="number"&&(i[s]=xr[s]);class o{}Object.setPrototypeOf(i,Object.getPrototypeOf(t)),Object.setPrototypeOf(o,i);let n=Object.create(o);return r.realContext=t,r.debugContext=n,n.luma=r,n.debug=!0,n}function Ny(t,e){e=Array.from(e).map(i=>i===void 0?"undefined":i);let r=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return r=`${r.slice(0,100)}${r.length>100?"...":""}`,`gl.${t}(${r})`}function KP(t,e,r,i){i=Array.from(i).map(a=>a===void 0?"undefined":a);let o=globalThis.WebGLDebugUtils.glEnumToString(e),n=globalThis.WebGLDebugUtils.glFunctionArgsToString(r,i),s=`${o} in gl.${r}(${n})`;x.error("%cWebGL","color: white; background: red; padding: 2px 6px; border-radius: 3px;",s)();debugger;throw new Error(s)}function ZP(t,e,r){let i="";t.traceWebGL&&x.level>=1&&(i=Ny(e,r),x.info(1,"%cWebGL","color: white; background: blue; padding: 2px 6px; border-radius: 3px;",i)());for(let o of r)if(o===void 0){i=i||Ny(e,r);debugger}}var HP,Du=E(()=>{L();Py();Kt();Ou();HP="https://unpkg.com/webgl-debug@2.0.1/index.js"});function Bu(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function G(t,e,r){return e[t]!==void 0?e[t]:r[t]}var wn,re,Ly,Ie,Uy,En,ky,Vy,Fu,bt,Lu,zy,Uu=E(()=>{wn={[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},re=(t,e,r)=>e?t.enable(r):t.disable(r),Ly=(t,e,r)=>t.hint(r,e),Ie=(t,e,r)=>t.pixelStorei(r,e),Uy=(t,e,r)=>{let i=r===36006?36009:36008;return t.bindFramebuffer(i,e)},En=(t,e,r)=>{let o={[34964]:34962,[36662]:36662,[36663]:36663,[35053]:35051,[35055]:35052}[r];t.bindBuffer(o,e)};ky={[3042]:re,[32773]:(t,e)=>t.blendColor(...e),[32777]:"blendEquation",[34877]:"blendEquation",[32969]:"blendFunc",[32968]:"blendFunc",[32971]:"blendFunc",[32970]:"blendFunc",[3106]:(t,e)=>t.clearColor(...e),[3107]:(t,e)=>t.colorMask(...e),[2884]:re,[2885]:(t,e)=>t.cullFace(e),[2929]:re,[2931]:(t,e)=>t.clearDepth(e),[2932]:(t,e)=>t.depthFunc(e),[2928]:(t,e)=>t.depthRange(...e),[2930]:(t,e)=>t.depthMask(e),[3024]:re,[35723]:Ly,[35725]:(t,e)=>t.useProgram(e),[36007]:(t,e)=>t.bindRenderbuffer(36161,e),[36389]:(t,e)=>t.bindTransformFeedback?.(36386,e),[34229]:(t,e)=>t.bindVertexArray(e),[36006]:Uy,[36010]:Uy,[34964]:En,[36662]:En,[36663]:En,[35053]:En,[35055]:En,[2886]:(t,e)=>t.frontFace(e),[33170]:Ly,[2849]:(t,e)=>t.lineWidth(e),[32823]:re,[32824]:"polygonOffset",[10752]:"polygonOffset",[35977]:re,[32926]:re,[32928]:re,[32938]:"sampleCoverage",[32939]:"sampleCoverage",[3089]:re,[3088]:(t,e)=>t.scissor(...e),[2960]:re,[2961]:(t,e)=>t.clearStencil(e),[2968]:(t,e)=>t.stencilMaskSeparate(1028,e),[36005]:(t,e)=>t.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]:(t,e)=>t.viewport(...e),[34383]:re,[10754]:re,[12288]:re,[12289]:re,[12290]:re,[12291]:re,[12292]:re,[12293]:re,[12294]:re,[12295]:re,[3333]:Ie,[3317]:Ie,[37440]:Ie,[37441]:Ie,[37443]:Ie,[3330]:Ie,[3332]:Ie,[3331]:Ie,[3314]:Ie,[32878]:Ie,[3316]:Ie,[3315]:Ie,[32877]:Ie,framebuffer:(t,e)=>{let r=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,r)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{let r=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...r)},blendFunc:(t,e)=>{let r=e?.length===2?[...e,...e]:e;t.blendFuncSeparate(...r)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(e[0],e[1]||!1),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=Bu(e)?e:[e,e];let[r,i]=e;t.stencilMaskSeparate(1028,r),t.stencilMaskSeparate(1029,i)},stencilFunc:(t,e)=>{e=Bu(e)&&e.length===3?[...e,...e]:e;let[r,i,o,n,s,a]=e;t.stencilFuncSeparate(1028,r,i,o),t.stencilFuncSeparate(1029,n,s,a)},stencilOp:(t,e)=>{e=Bu(e)&&e.length===3?[...e,...e]:e;let[r,i,o,n,s,a]=e;t.stencilOpSeparate(1028,r,i,o),t.stencilOpSeparate(1029,n,s,a)},viewport:(t,e)=>t.viewport(...e)};Vy={blendEquation:(t,e,r)=>t.blendEquationSeparate(G(32777,e,r),G(34877,e,r)),blendFunc:(t,e,r)=>t.blendFuncSeparate(G(32969,e,r),G(32968,e,r),G(32971,e,r),G(32970,e,r)),polygonOffset:(t,e,r)=>t.polygonOffset(G(32824,e,r),G(10752,e,r)),sampleCoverage:(t,e,r)=>t.sampleCoverage(G(32938,e,r),G(32939,e,r)),stencilFuncFront:(t,e,r)=>t.stencilFuncSeparate(1028,G(2962,e,r),G(2967,e,r),G(2963,e,r)),stencilFuncBack:(t,e,r)=>t.stencilFuncSeparate(1029,G(34816,e,r),G(36003,e,r),G(36004,e,r)),stencilOpFront:(t,e,r)=>t.stencilOpSeparate(1028,G(2964,e,r),G(2965,e,r),G(2966,e,r)),stencilOpBack:(t,e,r)=>t.stencilOpSeparate(1029,G(34817,e,r),G(34818,e,r),G(34819,e,r))},Fu={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,r)=>t({[e]:r}),hint:(t,e,r)=>t({[e]:r}),useProgram:(t,e)=>t({[35725]:e}),bindRenderbuffer:(t,e,r)=>t({[36007]:r}),bindTransformFeedback:(t,e,r)=>t({[36389]:r}),bindVertexArray:(t,e)=>t({[34229]:e}),bindFramebuffer:(t,e,r)=>{switch(e){case 36160:return t({[36006]:r,[36010]:r});case 36009:return t({[36006]:r});case 36008:return t({[36010]:r});default:return null}},bindBuffer:(t,e,r)=>{let i={[34962]:[34964],[36662]:[36662],[36663]:[36663],[35051]:[35053],[35052]:[35055]}[e];return i?t({[i]:r}):{valueChanged:!0}},blendColor:(t,e,r,i,o)=>t({[32773]:new Float32Array([e,r,i,o])}),blendEquation:(t,e)=>t({[32777]:e,[34877]:e}),blendEquationSeparate:(t,e,r)=>t({[32777]:e,[34877]:r}),blendFunc:(t,e,r)=>t({[32969]:e,[32968]:r,[32971]:e,[32970]:r}),blendFuncSeparate:(t,e,r,i,o)=>t({[32969]:e,[32968]:r,[32971]:i,[32970]:o}),clearColor:(t,e,r,i,o)=>t({[3106]:new Float32Array([e,r,i,o])}),clearDepth:(t,e)=>t({[2931]:e}),clearStencil:(t,e)=>t({[2961]:e}),colorMask:(t,e,r,i,o)=>t({[3107]:[e,r,i,o]}),cullFace:(t,e)=>t({[2885]:e}),depthFunc:(t,e)=>t({[2932]:e}),depthRange:(t,e,r)=>t({[2928]:new Float32Array([e,r])}),depthMask:(t,e)=>t({[2930]:e}),frontFace:(t,e)=>t({[2886]:e}),lineWidth:(t,e)=>t({[2849]:e}),polygonOffset:(t,e,r)=>t({[32824]:e,[10752]:r}),sampleCoverage:(t,e,r)=>t({[32938]:e,[32939]:r}),scissor:(t,e,r,i,o)=>t({[3088]:new Int32Array([e,r,i,o])}),stencilMask:(t,e)=>t({[2968]:e,[36005]:e}),stencilMaskSeparate:(t,e,r)=>t({[e===1028?2968:36005]:r}),stencilFunc:(t,e,r,i)=>t({[2962]:e,[2967]:r,[2963]:i,[34816]:e,[36003]:r,[36004]:i}),stencilFuncSeparate:(t,e,r,i,o)=>t({[e===1028?2962:34816]:r,[e===1028?2967:36003]:i,[e===1028?2963:36004]:o}),stencilOp:(t,e,r,i)=>t({[2964]:e,[2965]:r,[2966]:i,[34817]:e,[34818]:r,[34819]:i}),stencilOpSeparate:(t,e,r,i,o)=>t({[e===1028?2964:34817]:r,[e===1028?2965:34818]:i,[e===1028?2966:34819]:o}),viewport:(t,e,r,i,o)=>t({[2978]:[e,r,i,o]})},bt=(t,e)=>t.isEnabled(e),Lu={[3042]:bt,[2884]:bt,[2929]:bt,[3024]:bt,[32823]:bt,[32926]:bt,[32928]:bt,[3089]:bt,[2960]:bt,[35977]:bt},zy=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 Qe(t,e){if(qP(e))return;let r={};for(let o in e){let n=Number(o),s=ky[o];s&&(typeof s=="string"?r[s]=!0:s(t,e[o],n))}let i=t.lumaState?.cache;if(i)for(let o in r){let n=Vy[o];n(t,e,i)}}function Ja(t,e=wn){if(typeof e=="number"){let o=e,n=Lu[o];return n?n(t,o):t.getParameter(o)}let r=Array.isArray(e)?e:Object.keys(e),i={};for(let o of r){let n=Lu[o];i[o]=n?n(t,Number(o)):t.getParameter(Number(o))}return i}function Wy(t){Qe(t,wn)}function qP(t){for(let e in t)return!1;return!0}var Yi=E(()=>{Uu()});function $y(t,e){if(t===e)return!0;if(jy(t)&&jy(e)&&t.length===e.length){for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}return!1}function jy(t){return Array.isArray(t)||ArrayBuffer.isView(t)}var Hy=E(()=>{});function Xy(t,e){let r=t[e].bind(t);t[e]=function(o){if(o===void 0||zy.has(o))return r(o);let n=Je.get(t);return o in n.cache||(n.cache[o]=r(o)),n.enable?n.cache[o]:r(o)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function GP(t,e,r){if(!t[e])return;let i=t[e].bind(t);t[e]=function(...n){let s=Je.get(t),{valueChanged:a,oldValue:c}=r(s._updateCache,...n);return a&&i(...n),c},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function QP(t){let e=t.useProgram.bind(t);t.useProgram=function(i){let o=Je.get(t);o.program!==i&&(e(i),o.program=i)}}var Je,ku=E(()=>{Yi();Hy();Uu();Je=class{static get(e){return e.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(e,r){this.gl=e,this.log=r?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){let e=this.stateStack[this.stateStack.length-1];Qe(this.gl,e),this.stateStack.pop()}trackState(e,r){if(this.cache=r?.copyState?Ja(e):Object.assign({},wn),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,QP(e);for(let i in Fu){let o=Fu[i];GP(e,i,o)}Xy(e,"getParameter"),Xy(e,"isEnabled")}_updateCache(e){let r=!1,i,o=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let n in e){let s=e[n],a=this.cache[n];$y(s,a)||(r=!0,i=a,o&&!(n in o)&&(o[n]=a),this.cache[n]=s)}return{valueChanged:r,oldValue:i}}}});function Yy(t,e,r){let i="",o=c=>{let l=c.statusMessage;l&&(i||=l)};t.addEventListener("webglcontextcreationerror",o,!1);let n=r.failIfMajorPerformanceCaveat!==!0,s={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},a=null;try{a||=t.getContext("webgl2",s),!a&&s.failIfMajorPerformanceCaveat&&(i||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&n&&(s.failIfMajorPerformanceCaveat=!1,a=t.getContext("webgl2",s),c=!0),a||(a=t.getContext("webgl",{}),a&&(a=null,i||="Your browser only supports WebGL1")),!a)throw i||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${i}`);let l=Yr(a);l.softwareRenderer=c;let{onContextLost:f,onContextRestored:h}=e;return t.addEventListener("webglcontextlost",u=>f(u),!1),t.addEventListener("webglcontextrestored",u=>h(u),!1),a}finally{t.removeEventListener("webglcontextcreationerror",o,!1)}}var Ky=E(()=>{Ga()});function et(t,e,r){return r[e]===void 0&&(r[e]=t.getExtension(e)||null),r[e]}var Rn=E(()=>{});function Zy(t,e){let r=t.getParameter(7936),i=t.getParameter(7937);et(t,"WEBGL_debug_renderer_info",e);let o=e.WEBGL_debug_renderer_info,n=t.getParameter(o?o.UNMASKED_VENDOR_WEBGL:7936),s=t.getParameter(o?o.UNMASKED_RENDERER_WEBGL:7937),a=n||r,c=s||i,l=t.getParameter(7938),f=qy(a,c),h=JP(a,c),u=ev(a,c);return{type:"webgl",gpu:f,gpuType:u,gpuBackend:h,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function qy(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function JP(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function ev(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(qy(t,e)){case"apple":return tv(t,e)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function tv(t,e){return/Apple (M\d|A\d|GPU)/i.test(`${t} ${e}`)}var Gy=E(()=>{Rn()});function ec(t){switch(t){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(t))}var Vu=E(()=>{});function eb(t){return t in rc}function Hu(t,e,r){return tb(t,e,r,new Set)}function tb(t,e,r,i){let o=rc[e];if(!o||i.has(e))return!1;i.add(e);let n=(o.features||[]).every(s=>tb(t,s,r,i));return i.delete(e),n?(o.extensions||[]).every(s=>Boolean(et(t,s,r))):!1}function rb(t,e,r){let i=e.create,o=ic[e.format];o?.gl===void 0&&(i=!1),o?.x&&(i=i&&Boolean(et(t,o.x,r))),e.format==="stencil8"&&(i=!1);let n=o?.r===!1?!1:o?.r===void 0||Hu(t,o.r,r),s=i&&e.render&&n&&lv(t,e.format,r);return{format:e.format,create:i&&e.create,render:s,filter:i&&e.filter,blend:i&&e.blend,store:i&&e.store}}function lv(t,e,r){let i=ic[e],o=i?.gl;if(o===void 0||i?.x&&!et(t,i.x,r))return!1;let n=t.getParameter(32873),s=t.getParameter(36006),a=t.createTexture(),c=t.createFramebuffer();if(!a||!c)return!1;let l=Number(0),f=Number(t.getError());for(;f!==l;)f=t.getError();let h=!1;try{if(t.bindTexture(3553,a),t.texStorage2D(3553,1,o,1,1),Number(t.getError())!==l)return!1;t.bindFramebuffer(36160,c),t.framebufferTexture2D(36160,36064,3553,a,0),h=Number(t.checkFramebufferStatus(36160))===Number(36053)&&Number(t.getError())===l}finally{t.bindFramebuffer(36160,s),t.deleteFramebuffer(c),t.bindTexture(3553,n),t.deleteTexture(a)}return h}function oc(t){let e=ic[t],r=hv(t),i=ue.getInfo(t);return i.compressed&&(e.dataFormat=r),{internalFormat:r,format:e?.dataFormat||fv(i.channels,i.integer,i.normalized,r),type:i.dataType?ec(i.dataType):e?.types?.[0]||5121,compressed:i.compressed||!1}}function ib(t){switch(ue.getInfo(t).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${t}`)}}function fv(t,e,r,i){if(i===6408||i===6407)return i;switch(t){case"r":return e&&!r?36244:6403;case"rg":return e&&!r?33320:33319;case"rgb":return e&&!r?36248:6407;case"rgba":return e&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function hv(t){let r=ic[t]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${t}`);return r}var Pn,vn,Ki,Zi,rv,iv,ov,nv,sv,av,Qy,Jy,zu,Wu,ju,$u,tc,cv,rc,ic,qi=E(()=>{L();Rn();Vu();Pn="WEBGL_compressed_texture_s3tc",vn="WEBGL_compressed_texture_s3tc_srgb",Ki="EXT_texture_compression_rgtc",Zi="EXT_texture_compression_bptc",rv="WEBGL_compressed_texture_etc",iv="WEBGL_compressed_texture_astc",ov="WEBGL_compressed_texture_etc1",nv="WEBGL_compressed_texture_pvrtc",sv="WEBGL_compressed_texture_atc",av="EXT_texture_norm16",Qy="EXT_render_snorm",Jy="EXT_color_buffer_float",zu="snorm8-renderable-webgl",Wu="norm16-renderable-webgl",ju="snorm16-renderable-webgl",$u="float16-renderable-webgl",tc="float32-renderable-webgl",cv="rgb9e5ufloat-renderable-webgl",rc={"float32-renderable-webgl":{extensions:[Jy]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[Qy]},"norm16-webgl":{extensions:[av]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[Qy]},"float32-filterable":{extensions:["OES_texture_float_linear"]},"float16-filterable-webgl":{extensions:["OES_texture_half_float_linear"]},"texture-filterable-anisotropic-webgl":{extensions:["EXT_texture_filter_anisotropic"]},"texture-blend-float-webgl":{extensions:["EXT_float_blend"]},"texture-compression-bc":{extensions:[Pn,vn,Ki,Zi]},"texture-compression-bc5-webgl":{extensions:[Ki]},"texture-compression-bc7-webgl":{extensions:[Zi]},"texture-compression-etc2":{extensions:[rv]},"texture-compression-astc":{extensions:[iv]},"texture-compression-etc1-webgl":{extensions:[ov]},"texture-compression-pvrtc-webgl":{extensions:[nv]},"texture-compression-atc-webgl":{extensions:[sv]}};ic={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:zu},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:zu},rg8uint:{gl:33336,rb:!0},rg8sint:{gl:33335,rb:!0},r16uint:{gl:33332,rb:!0},r16sint:{gl:33331,rb:!0},r16float:{gl:33325,rb:!0,r:$u},r16unorm:{gl:33322,rb:!0,r:Wu},r16snorm:{gl:36760,r:ju},"rgba4unorm-webgl":{gl:32854,rb:!0},"rgb565unorm-webgl":{gl:36194,rb:!0},"rgb5a1unorm-webgl":{gl:32855,rb:!0},"rgb8unorm-webgl":{gl:32849},"rgb8snorm-webgl":{gl:36758},rgba8unorm:{gl:32856},"rgba8unorm-srgb":{gl:35907},rgba8snorm:{gl:36759,r:zu},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:$u},rg16unorm:{gl:33324,r:Wu},rg16snorm:{gl:36761,r:ju},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:tc},rgb9e5ufloat:{gl:35901,r:cv},rg11b10ufloat:{gl:35898,rb:!0},rgb10a2unorm:{gl:32857,rb:!0},rgb10a2uint:{gl:36975,rb:!0},"rgb16unorm-webgl":{gl:32852,r:!1},"rgb16snorm-webgl":{gl:36762,r:!1},rg32uint:{gl:33340,rb:!0},rg32sint:{gl:33339,rb:!0},rg32float:{gl:33328,rb:!0,r:tc},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:$u},rgba16unorm:{gl:32859,rb:!0,r:Wu},rgba16snorm:{gl:36763,r:ju},"rgb32float-webgl":{gl:34837,x:Jy,r:tc,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:tc},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:Pn},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:vn},"bc1-rgba-unorm":{gl:33777,x:Pn},"bc1-rgba-unorm-srgb":{gl:35916,x:vn},"bc2-rgba-unorm":{gl:33778,x:Pn},"bc2-rgba-unorm-srgb":{gl:35918,x:vn},"bc3-rgba-unorm":{gl:33779,x:Pn},"bc3-rgba-unorm-srgb":{gl:35919,x:vn},"bc4-r-unorm":{gl:36283,x:Ki},"bc4-r-snorm":{gl:36284,x:Ki},"bc5-rg-unorm":{gl:36285,x:Ki},"bc5-rg-snorm":{gl:36286,x:Ki},"bc6h-rgb-ufloat":{gl:36495,x:Zi},"bc6h-rgb-float":{gl:36494,x:Zi},"bc7-rgba-unorm":{gl:36492,x:Zi},"bc7-rgba-unorm-srgb":{gl:36493,x:Zi},"etc2-rgb8unorm":{gl:37492},"etc2-rgb8unorm-srgb":{gl:37494},"etc2-rgb8a1unorm":{gl:37496},"etc2-rgb8a1unorm-srgb":{gl:37497},"etc2-rgba8unorm":{gl:37493},"etc2-rgba8unorm-srgb":{gl:37495},"eac-r11unorm":{gl:37488},"eac-r11snorm":{gl:37489},"eac-rg11unorm":{gl:37490},"eac-rg11snorm":{gl:37491},"astc-4x4-unorm":{gl:37808},"astc-4x4-unorm-srgb":{gl:37840},"astc-5x4-unorm":{gl:37809},"astc-5x4-unorm-srgb":{gl:37841},"astc-5x5-unorm":{gl:37810},"astc-5x5-unorm-srgb":{gl:37842},"astc-6x5-unorm":{gl:37811},"astc-6x5-unorm-srgb":{gl:37843},"astc-6x6-unorm":{gl:37812},"astc-6x6-unorm-srgb":{gl:37844},"astc-8x5-unorm":{gl:37813},"astc-8x5-unorm-srgb":{gl:37845},"astc-8x6-unorm":{gl:37814},"astc-8x6-unorm-srgb":{gl:37846},"astc-8x8-unorm":{gl:37815},"astc-8x8-unorm-srgb":{gl:37847},"astc-10x5-unorm":{gl:37816},"astc-10x5-unorm-srgb":{gl:37848},"astc-10x6-unorm":{gl:37817},"astc-10x6-unorm-srgb":{gl:37849},"astc-10x8-unorm":{gl:37818},"astc-10x8-unorm-srgb":{gl:37850},"astc-10x10-unorm":{gl:37819},"astc-10x10-unorm-srgb":{gl:37851},"astc-12x10-unorm":{gl:37820},"astc-12x10-unorm-srgb":{gl:37852},"astc-12x12-unorm":{gl:37821},"astc-12x12-unorm-srgb":{gl:37853},"pvrtc-rgb4unorm-webgl":{gl:35840},"pvrtc-rgba4unorm-webgl":{gl:35842},"pvrtc-rgb2unorm-webgl":{gl:35841},"pvrtc-rgba2unorm-webgl":{gl:35843},"etc1-rbg-unorm-webgl":{gl:36196},"atc-rgb-unorm-webgl":{gl:35986},"atc-rgba-unorm-webgl":{gl:35986},"atc-rgbai-unorm-webgl":{gl:34798}}});var ob,nc,nb=E(()=>{L();Rn();qi();ob={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"},nc=class extends co{gl;extensions;testedFeatures=new Set;constructor(e,r,i){super([],i),this.gl=e,this.extensions=r,et(e,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let e=this.getFeatures();for(let r of e)this.has(r)&&(yield r);return[]}has(e){return this.disabledFeatures?.[e]?!1:(this.testedFeatures.has(e)||(this.testedFeatures.add(e),eb(e)&&Hu(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(r=>r!=="polygon-mode-webgl");for(let r of e)this.has(r)}getFeatures(){return[...Object.keys(ob),...Object.keys(rc)]}getWebGLFeature(e){let r=ob[e];return Boolean(typeof r=="string"?et(this.gl,r,this.extensions):r)}}});var sc,sb=E(()=>{L();sc=class extends ao{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 uv(t){return t<34069?t+34069:t}function dv(t){switch(t){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`${t}`}}var Tt,ac=E(()=>{L();qi();Tt=class extends st{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(e,r){super(e,r);let i=r.handle===null;this.device=e,this.gl=e.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),i||(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 r=0;r<this.colorAttachments.length;++r){let i=this.colorAttachments[r];if(i){let o=36064+r;this._attachTextureView(o,i)}}if(this.depthStencilAttachment){let r=ib(this.depthStencilAttachment.props.format);this._attachTextureView(r,this.depthStencilAttachment)}if(this.device.props.debug){let r=this.gl.checkFramebufferStatus(36160);if(r!==36053)throw new Error(`Framebuffer ${dv(r)}`)}this.gl.bindFramebuffer(36160,e)}_attachTextureView(e,r){let{gl:i}=this.device,{texture:o}=r,n=r.props.baseMipLevel,s=r.props.baseArrayLayer;switch(i.bindTexture(o.glTarget,o.handle),o.glTarget){case 35866:case 32879:i.framebufferTextureLayer(36160,e,o.handle,n,s);break;case 34067:let a=uv(s);i.framebufferTexture2D(36160,e,a,o.handle,n);break;case 3553:i.framebufferTexture2D(36160,e,3553,o.handle,n);break;default:throw new Error("Illegal texture type")}i.bindTexture(o.glTarget,null)}resizeAttachments(e,r){if(this.handle===null){this.width=e,this.height=r;return}super.resizeAttachments(e,r)}}});var cc,ab=E(()=>{L();ac();cc=class extends ai{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(e,r){super(r),this.device=e,this._setAutoCreatedCanvasId(`${this.device.id}-canvas`),this._configureDevice()}_configureDevice(){(this.drawingBufferWidth!==this._framebuffer?.width||this.drawingBufferHeight!==this._framebuffer?.height)&&this._framebuffer?.resize([this.drawingBufferWidth,this.drawingBufferHeight])}_getCurrentFramebuffer(){return this._framebuffer||=new Tt(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var lc,cb=E(()=>{L();lc=class extends ho{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(e,r={}){super(r),this.device=e;let i=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${i}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let n=this.canvas.getContext("2d");if(!n)throw new Error(`${i}: Failed to create 2d presentation context`);this.context2d=n,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let e=this.device.getDefaultCanvasContext(),[r,i]=e.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||r===0||i===0||e.canvas.width===0||e.canvas.height===0)){if(r!==this.drawingBufferWidth||i!==this.drawingBufferHeight||e.canvas.width!==this.drawingBufferWidth||e.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${r}x${i} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(e.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(e){let r=this.device.getDefaultCanvasContext();return r.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),r.getCurrentFramebuffer(e)}}});function lb(t="id"){Xu[t]=Xu[t]||1;let e=Xu[t]++;return`${t}-${e}`}var Xu,fb=E(()=>{Xu={}});function pv(t){return t&I.INDEX?34963:t&I.VERTEX?34962:t&I.UNIFORM?35345:34962}function gv(t){return t&I.INDEX||t&I.VERTEX?35044:t&I.UNIFORM?35048:35044}var tt,fc=E(()=>{L();tt=class extends I{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(e,r={}){super(e,r),this.device=e,this.gl=this.device.gl;let i=typeof r=="object"?r.handle:void 0;this.handle=i||this.gl.createBuffer(),e._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=pv(this.props.usage),this.glUsage=gv(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Buffer"):(this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle)),this.destroyed=!0,this.handle=null)}_initWithData(e,r=0,i=e.byteLength+r){let o=this.glTarget;this.gl.bindBuffer(o,this.handle),this.gl.bufferData(o,i,this.glUsage),this.gl.bufferSubData(o,r,e),this.gl.bindBuffer(o,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,r,i),this.props.handle?this.trackReferencedMemory(i,"Buffer"):this.trackAllocatedMemory(i)}_initWithByteLength(e){let r=e;e===0&&(r=new Float32Array(0));let i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,r,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.props.handle?this.trackReferencedMemory(e,"Buffer"):this.trackAllocatedMemory(e),this}write(e,r=0){let i=ArrayBuffer.isView(e)?e:new Uint8Array(e),o=0,n=void 0,s=36663;this.gl.bindBuffer(s,this.handle),o!==0||n!==void 0?this.gl.bufferSubData(s,r,i,o,n):this.gl.bufferSubData(s,r,i),this.gl.bindBuffer(s,null),this._setDebugData(e,r,e.byteLength)}async mapAndWriteAsync(e,r=0,i=this.byteLength-r){let o=new ArrayBuffer(i);await e(o,"copied"),this.write(o,r)}async readAsync(e=0,r){return this.readSyncWebGL(e,r)}async mapAndReadAsync(e,r=0,i){let o=await this.readAsync(r,i);return await e(o.buffer,"copied")}readSyncWebGL(e=0,r){r=r??this.byteLength-e;let i=new Uint8Array(r),o=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,o,r),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,r),i}}});function hb(t){let e=t.split(/\r?\n/),r=[];for(let i of e){if(i.length<=1)continue;let o=i.trim(),n=i.split(":"),s=n[0]?.trim();if(n.length===2){let[d,p]=n;if(!d||!p){r.push({message:o,type:hc(s||"info"),lineNum:0,linePos:0});continue}r.push({message:p.trim(),type:hc(d),lineNum:0,linePos:0});continue}let[a,c,l,...f]=n;if(!a||!c||!l){r.push({message:n.slice(1).join(":").trim()||o,type:hc(s||"info"),lineNum:0,linePos:0});continue}let h=parseInt(l,10);Number.isNaN(h)&&(h=0);let u=parseInt(c,10);Number.isNaN(u)&&(u=0),r.push({message:f.join(":").trim(),type:hc(a),lineNum:h,linePos:u})}return r}function hc(t){let e=["warning","error","info"],r=t.toLowerCase();return e.includes(r)?r:"info"}var ub=E(()=>{});var uc,db=E(()=>{L();ub();uc=class extends Jt{device;handle;constructor(e,r){switch(super(e,r),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});let i=this._compile(this.source);i&&typeof i.catch=="function"&&i.catch(()=>{this.compilationStatus="error"})}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?hb(e):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(e){e=e.startsWith("#version ")?e:`#version 300 es
|
|
19
|
+
${e}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,e),r.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}return x.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{x.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let e=async o=>await new Promise(n=>setTimeout(n,o));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}});function gb(t,e,r,i){if(bv(e))return i(t);let o=t;o.pushState();try{return mv(t,e),Qe(o.gl,r),i(t)}finally{o.popState()}}function mv(t,e){let r=t,{gl:i}=r;if(e.cullMode)switch(e.cullMode){case"none":i.disable(2884);break;case"front":i.enable(2884),i.cullFace(1028);break;case"back":i.enable(2884),i.cullFace(1029);break}if(e.frontFace&&i.frontFace(Kr("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&i.enable(34383),e.depthBias!==void 0&&(i.enable(32823),i.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){let n=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,s=Kr("provokingVertex",e.provokingVertex,{first:36429,last:36430});n?.provokingVertexWEBGL(s)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){let n=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,s=Kr("polygonMode",e.polygonMode,{fill:6914,line:6913});n?.polygonModeWEBGL(1028,s),n?.polygonModeWEBGL(1029,s)}e.polygonOffsetLine&&i.enable(10754)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&i.enable(12288),e.clipDistance1&&i.enable(12289),e.clipDistance2&&i.enable(12290),e.clipDistance3&&i.enable(12291),e.clipDistance4&&i.enable(12292),e.clipDistance5&&i.enable(12293),e.clipDistance6&&i.enable(12294),e.clipDistance7&&i.enable(12295)),e.depthWriteEnabled!==void 0&&i.depthMask(yv("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?i.enable(2929):i.disable(2929),i.depthFunc(pc("depthCompare",e.depthCompare))),e.clearDepth!==void 0&&i.clearDepth(e.clearDepth),e.stencilWriteMask){let o=e.stencilWriteMask;i.stencilMaskSeparate(1028,o),i.stencilMaskSeparate(1029,o)}if(e.stencilReadMask&&x.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){let o=e.stencilReadMask||4294967295,n=pc("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?i.enable(2960):i.disable(2960),i.stencilFuncSeparate(1028,n,0,o),i.stencilFuncSeparate(1029,n,0,o)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){let o=Yu("stencilPassOperation",e.stencilPassOperation),n=Yu("stencilFailOperation",e.stencilFailOperation),s=Yu("stencilDepthFailOperation",e.stencilDepthFailOperation);i.stencilOpSeparate(1028,n,s,o),i.stencilOpSeparate(1029,n,s,o)}switch(e.blend){case!0:i.enable(3042);break;case!1:i.disable(3042);break;default:}if(e.blendColorOperation||e.blendAlphaOperation){let o=pb("blendColorOperation",e.blendColorOperation||"add"),n=pb("blendAlphaOperation",e.blendAlphaOperation||"add");i.blendEquationSeparate(o,n);let s=dc("blendColorSrcFactor",e.blendColorSrcFactor||"one"),a=dc("blendColorDstFactor",e.blendColorDstFactor||"zero"),c=dc("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),l=dc("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");i.blendFuncSeparate(s,a,c,l)}}function pc(t,e){return Kr(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Yu(t,e){return Kr(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function pb(t,e){return Kr(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function dc(t,e,r="color"){return Kr(t,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:r==="color"?32769:32771,"one-minus-constant":r==="color"?32770:32772,src1:768,"one-minus-src1":769,"src1-alpha":770,"one-minus-src1-alpha":771})}function _v(t,e){return`Illegal parameter ${e} for ${t}`}function Kr(t,e,r){if(!(e in r))throw new Error(_v(t,e));return r[e]}function yv(t,e){return e}function bv(t){let e=!0;for(let r in t){e=!1;break}return e}var Ku=E(()=>{L();Yi()});function gc(t){let e={};return t.addressModeU&&(e[10242]=Zu(t.addressModeU)),t.addressModeV&&(e[10243]=Zu(t.addressModeV)),t.addressModeW&&(e[32882]=Zu(t.addressModeW)),t.magFilter&&(e[10240]=qu(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=Tv(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[33082]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[33083]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[34892]=34894),t.compare&&(e[34893]=pc("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function Zu(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function qu(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function Tv(t,e="none"){if(!e)return qu(t);switch(e){case"none":return qu(t);case"nearest":switch(t){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(t){case"nearest":return 9986;case"linear":return 9987}}}var Gu=E(()=>{Ku()});var mc,mb=E(()=>{L();Gu();mc=class extends De{device;handle;parameters;constructor(e,r){super(e,r),this.device=e,this.parameters=gc(r),this.handle=r.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[r,i]of Object.entries(e)){let o=Number(r);switch(o){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,o,i);break;default:this.device.gl.samplerParameteri(this.handle,o,i);break}}}}});function xt(t,e,r){if(xv(e))return r(t);let{nocatch:i=!0}=e,o=Je.get(t);o.push(),Qe(t,e);let n;if(i)n=r(t),o.pop();else try{n=r(t)}finally{o.pop()}return n}function xv(t){for(let e in t)return!1;return!0}var _c=E(()=>{Yi();ku()});var At,Qu=E(()=>{L();At=class extends Qt{device;gl;handle;texture;constructor(e,r){super(e,{...B.defaultProps,...r}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}});function yc(t){return Av[t]}var Av,Ju=E(()=>{Av={[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 Sv(t,e=0){return e?new t.constructor(t.buffer,t.byteOffset+e,(t.byteLength-e)/t.BYTES_PER_ELEMENT):t}function Ev(t,e){if(e%t.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${e} must align to typed array element size ${t.BYTES_PER_ELEMENT}`);return e/t.BYTES_PER_ELEMENT}function wv(t){switch(t){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(t)}function bc(t,e,r){return e==="cube"?34069+r:t}var St,Tc=E(()=>{L();qi();Gu();_c();Qu();Ju();St=class extends B{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(e,r){super(e,r,{byteAlignment:1}),this.device=e,this.gl=this.device.gl;let i=oc(this.props.format);this.glTarget=wv(this.props.dimension),this.glInternalFormat=i.internalFormat,this.glFormat=i.format,this.glType=i.type,this.compressed=i.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:o,width:n,height:s,depth:a,mipLevels:c,glTarget:l,glInternalFormat:f}=this;if(!this.compressed)switch(o){case"2d":case"cube":this.gl.texStorage2D(l,c,f,n,s);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,f,n,s,a);break;default:throw new Error(o)}this.gl.bindTexture(this.glTarget,null),this._initializeData(r.data),this.props.handle?this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"):this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"),this.setSampler(this.props.sampler),this.view=new At(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.props.handle?this.trackDeallocatedReferencedMemory("Texture"):(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")),this.destroyed=!0)}createView(e){return new At(this.device,{...e,texture:this})}setSampler(e={}){super.setSampler(e);let r=gc(this.sampler.props);this._setSamplerParameters(r)}copyExternalImage(e){let r=this._normalizeCopyExternalImageOptions(e);if(r.sourceX||r.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:i,glType:o}=this,{image:n,depth:s,mipLevel:a,x:c,y:l,z:f,width:h,height:u}=r,d=bc(this.glTarget,this.dimension,f),p=r.flipY?{[37440]:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),xt(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(d,a,c,l,h,u,i,o,n);break;case"2d-array":case"3d":this.gl.texSubImage3D(d,a,c,l,f,h,u,s,i,o,n);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyImageData(e){super.copyImageData(e)}readBuffer(e={},r){if(!r)throw new Error(`${this} readBuffer requires a destination buffer`);let i=this._getSupportedColorReadOptions(e),o=e.byteOffset??0,n=this.computeMemoryLayout(i);if(r.byteLength<o+n.byteLength)throw new Error(`${this} readBuffer target is too small (${r.byteLength} < ${o+n.byteLength})`);let s=r;this.gl.bindBuffer(35051,s.handle);try{this._readColorTextureLayers(i,n,a=>{this.gl.readPixels(i.x,i.y,i.width,i.height,this.glFormat,this.glType,o+a)})}finally{this.gl.bindBuffer(35051,null)}return r}async readDataAsync(e={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(e,r={}){let i=this._normalizeTextureWriteOptions(r),{width:o,height:n,depthOrArrayLayers:s,mipLevel:a,byteOffset:c,x:l,y:f,z:h}=i,{glFormat:u,glType:d,compressed:p}=this,g=bc(this.glTarget,this.dimension,h);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:m}=this.device.getTextureFormatInfo(this.format),_=m?i.bytesPerRow/m:void 0,b={[3317]:this.byteAlignment,..._!==void 0?{[3314]:_}:{},[32878]:i.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,e.handle),xt(this.gl,b,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(g,a,l,f,o,n,u,d,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(g,a,l,f,h,o,n,s,u,d,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(e,r={}){let i=this._normalizeTextureWriteOptions(r),o=ArrayBuffer.isView(e)?e:new Uint8Array(e),{width:n,height:s,depthOrArrayLayers:a,mipLevel:c,x:l,y:f,z:h,byteOffset:u}=i,{glFormat:d,glType:p,compressed:g}=this,m=bc(this.glTarget,this.dimension,h),_;if(!g){let{bytesPerPixel:w}=this.device.getTextureFormatInfo(this.format);w&&(_=i.bytesPerRow/w)}let b=this.compressed?{}:{[3317]:this.byteAlignment,..._!==void 0?{[3314]:_}:{},[32878]:i.rowsPerImage},y=Ev(o,u),T=g?Sv(o,u):o,S=this._getMipLevelSize(c),A=l===0&&f===0&&h===0&&n===S.width&&s===S.height&&a===S.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),xt(this.gl,b,()=>{switch(this.dimension){case"2d":case"cube":g?A?this.gl.compressedTexImage2D(m,c,d,n,s,0,T):this.gl.compressedTexSubImage2D(m,c,l,f,n,s,d,T):this.gl.texSubImage2D(m,c,l,f,n,s,d,p,o,y);break;case"2d-array":case"3d":g?A?this.gl.compressedTexImage3D(m,c,d,n,s,a,0,T):this.gl.compressedTexSubImage3D(m,c,l,f,h,n,s,a,d,T):this.gl.texSubImage3D(m,c,l,f,h,n,s,a,d,p,o,y);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(e,r){return 1}_getFramebuffer(){return this._framebuffer||=this.device.createFramebuffer({id:`framebuffer-for-${this.id}`,width:this.width,height:this.height,colorAttachments:[this]}),this._framebuffer}readDataSyncWebGL(e={}){let r=this._getSupportedColorReadOptions(e),i=this.computeMemoryLayout(r),o=yc(this.glType),n=go(o),s=new n(i.byteLength/n.BYTES_PER_ELEMENT);return this._readColorTextureLayers(r,i,a=>{let c=new n(s.buffer,s.byteOffset+a,i.bytesPerImage/n.BYTES_PER_ELEMENT);this.gl.readPixels(r.x,r.y,r.width,r.height,this.glFormat,this.glType,c)}),s.buffer}_readColorTextureLayers(e,r,i){let o=this._getFramebuffer(),n=r.bytesPerRow/r.bytesPerPixel,s={[3333]:this.byteAlignment,...n!==e.width?{[3330]:n}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,o.handle);try{this.gl.readBuffer(36064),xt(this.gl,s,()=>{for(let l=0;l<e.depthOrArrayLayers;l++)this._attachReadSubresource(o,e.mipLevel,e.z+l),i(l*r.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,c||null),this.gl.readBuffer(a)}}_attachReadSubresource(e,r,i){let o=`${r}:${i}`;if(this._framebufferAttachmentKey!==o){switch(this.dimension){case"2d":this.gl.framebufferTexture2D(36160,36064,3553,this.handle,r);break;case"cube":this.gl.framebufferTexture2D(36160,36064,bc(this.glTarget,this.dimension,i),this.handle,r);break;case"2d-array":case"3d":this.gl.framebufferTextureLayer(36160,36064,this.handle,r,i);break;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){let n=Number(this.gl.checkFramebufferStatus(36160));if(n!==Number(36053))throw new Error(`${e} incomplete for ${this} readback (${n})`)}this._framebufferAttachmentKey=o}}generateMipmapsWebGL(e){if(!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(x.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(i){x.warn(`Error generating mipmap for ${this}: ${i.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(e){x.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(e))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,i]of Object.entries(e)){let o=Number(r),n=i;switch(o){case 33082:case 33083:this.gl.texParameterf(this.glTarget,o,n);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,o,n);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,o,n);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,o,n);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,o,n);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(e){let{gl:r}=this;return e!==void 0&&(this._textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.glTarget,this.handle),e}_unbind(e){let{gl:r}=this;return e!==void 0&&(this._textureUnit=e,r.activeTexture(33984+e)),r.bindTexture(this.glTarget,null),e}}});function _b(t,e,r,i){let o=t,n=i;n===!0&&(n=1),n===!1&&(n=0);let s=typeof n=="number"?[n]:n;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof i!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,i);case 5126:return t.uniform1fv(e,s);case 35664:return t.uniform2fv(e,s);case 35665:return t.uniform3fv(e,s);case 35666:return t.uniform4fv(e,s);case 5124:return t.uniform1iv(e,s);case 35667:return t.uniform2iv(e,s);case 35668:return t.uniform3iv(e,s);case 35669:return t.uniform4iv(e,s);case 35670:return t.uniform1iv(e,s);case 35671:return t.uniform2iv(e,s);case 35672:return t.uniform3iv(e,s);case 35673:return t.uniform4iv(e,s);case 5125:return o.uniform1uiv(e,s,1);case 36294:return o.uniform2uiv(e,s,2);case 36295:return o.uniform3uiv(e,s,3);case 36296:return o.uniform4uiv(e,s,4);case 35674:return t.uniformMatrix2fv(e,!1,s);case 35675:return t.uniformMatrix3fv(e,!1,s);case 35676:return t.uniformMatrix4fv(e,!1,s);case 35685:return o.uniformMatrix2x3fv(e,!1,s);case 35686:return o.uniformMatrix2x4fv(e,!1,s);case 35687:return o.uniformMatrix3x2fv(e,!1,s);case 35688:return o.uniformMatrix3x4fv(e,!1,s);case 35689:return o.uniformMatrix4x2fv(e,!1,s);case 35690:return o.uniformMatrix4x3fv(e,!1,s)}throw new Error("Illegal uniform")}var yb=E(()=>{});function bb(t){switch(t){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(t)}}function Tb(t){switch(t){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(t)}}var ed=E(()=>{});function Rv(t,e){let r={...t,attributes:t.attributes.map(i=>({...i})),bindings:t.bindings.map(i=>({...i}))};for(let i of e?.attributes||[]){let o=r.attributes.find(n=>n.name===i.name);o?(o.type=i.type||o.type,o.stepMode=i.stepMode||o.stepMode):x.warn(`shader layout attribute ${i.name} not present in shader`)}for(let i of e?.bindings||[]){let o=Ab(r,i.name);if(!o){x.warn(`shader layout binding ${i.name} not present in shader`);continue}Object.assign(o,i)}return r}function Ab(t,e){return t.bindings.find(r=>r.name===e||r.name===`${e}Uniforms`||`${r.name}Uniforms`===e)}function xb(t,e){return t[e]||t[`${e}Uniforms`]||t[e.replace(/Uniforms$/,"")]}var xc,Sb=E(()=>{L();Ku();yb();fc();ac();Tc();Qu();ed();xc=class extends Ee{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(e,r){super(e,r),this.device=e;let i=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(r);this.sharedRenderPipeline=i,this.handle=i.handle,this.vs=i.vs,this.fs=i.fs,this.linkStatus=i.linkStatus,this.introspectedLayout=i.introspectedLayout,this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=r.shaderLayout?Rv(this.introspectedLayout,r.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(e,r){let i=bs(po(this.shaderLayout,e));for(let[o,n]of Object.entries(i)){let s=Ab(this.shaderLayout,o);if(s){switch(n||x.warn(`Unsetting binding "${o}" in render pipeline "${this.id}"`)(),s.type){case"uniform":if(!(n instanceof tt)&&!(n.buffer instanceof tt))throw new Error("buffer value");break;case"texture":if(!(n instanceof At||n instanceof St||n instanceof Tt))throw new Error(`${this} Bad texture binding for ${o}`);break;case"sampler":x.warn(`Ignoring sampler ${o}`)();break;default:throw new Error(s.type)}this.bindings[o]=n}else{let a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");r?.disableWarnings||x.warn(`No binding "${o}" in render pipeline "${this.id}", expected one of ${a}`,n)()}}}draw(e){this._syncLinkStatus();let r=e.bindGroups?bs(e.bindGroups):e.bindings||this.bindings,{renderPass:i,parameters:o=this.props.parameters,topology:n=this.props.topology,vertexArray:s,vertexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:f=0,transformFeedback:h,uniforms:u=this.uniforms}=e,d=bb(n),p=Boolean(s.indexBuffer),g=s.indexBuffer?.glIndexType;if(this.linkStatus!=="success")return x.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable(r))return x.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(this.handle),s.bindBeforeRender(i),h&&h.begin(this.props.topology),this._applyBindings(r,{disableWarnings:this.props.disableWarnings}),this._applyUniforms(u);let m=i;return gb(this.device,o,m.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(d,a||0,g,f,c||0):p?this.device.gl.drawElements(d,a||0,g,f):l?this.device.gl.drawArraysInstanced(d,f,a||0,c||0):this.device.gl.drawArrays(d,f,a||0),h&&h.end()}),s.unbindAfterRender(i),!0}_areTexturesRenderable(e){let r=!0;for(let i of this.shaderLayout.bindings)xb(e,i.name)||(x.warn(`Binding ${i.name} not found in ${this.id}`)(),r=!1);return r}_applyBindings(e,r){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:i}=this.device;i.useProgram(this.handle);let o=0,n=0;for(let s of this.shaderLayout.bindings){let a=xb(e,s.name);if(!a)throw new Error(`No value for binding ${s.name} in ${this.id}`);switch(s.type){case"uniform":let{name:c}=s,l=i.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);if(i.uniformBlockBinding(this.handle,l,n),a instanceof tt)i.bindBufferBase(35345,n,a.handle);else{let h=a;i.bindBufferRange(35345,n,h.buffer.handle,h.offset||0,h.size||h.buffer.byteLength-(h.offset||0))}n+=1;break;case"texture":if(!(a instanceof At||a instanceof St||a instanceof Tt))throw new Error("texture");let f;if(a instanceof At)f=a.texture;else if(a instanceof St)f=a;else if(a instanceof Tt&&a.colorAttachments[0]instanceof At)x.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),f=a.colorAttachments[0].texture;else throw new Error("No texture");i.activeTexture(33984+o),i.bindTexture(f.glTarget,f.handle),o+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${s.type}' not supported in WebGL`)}}}_applyUniforms(e){for(let r of this.shaderLayout.uniforms||[]){let{name:i,location:o,type:n,textureUnit:s}=r,a=e[i]??s;a!==void 0&&_b(this.device.gl,o,n,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});function Eb(t){return vv[t]}function Ac(t){return Pv[t]}function Sc(t){return Boolean(Rb[t])}function wb(t){return Rb[t]}var Pv,Rb,vv,Ec=E(()=>{Pv={[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>"},Rb={[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"}},vv={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 Pb(t,e){let r={attributes:[],bindings:[]};r.attributes=Mv(t,e);let i=Ov(t,e);for(let a of i){let c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));r.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 o=Iv(t,e),n=0;for(let a of o)if(Sc(a.type)){let{viewDimension:c,sampleType:l}=wb(a.type);r.bindings.push({type:"texture",name:a.name,group:0,location:n,viewDimension:c,sampleType:l}),a.textureUnit=n,n+=1}o.length&&(r.uniforms=o);let s=Cv(t,e);return s?.length&&(r.varyings=s),r}function Mv(t,e){let r=[],i=t.getProgramParameter(e,35721);for(let o=0;o<i;o++){let n=t.getActiveAttrib(e,o);if(!n)throw new Error("activeInfo");let{name:s,type:a}=n,c=t.getAttribLocation(e,s);if(c>=0){let l=Ac(a),f=/instance/i.test(s)?"instance":"vertex";r.push({name:s,location:c,stepMode:f,type:l})}}return r.sort((o,n)=>o.location-n.location),r}function Cv(t,e){let r=[],i=t.getProgramParameter(e,35971);for(let o=0;o<i;o++){let n=t.getTransformFeedbackVarying(e,o);if(!n)throw new Error("activeInfo");let{name:s,type:a,size:c}=n,l=Ac(a),{type:f,components:h}=di(l);r.push({location:o,name:s,type:f,size:c*h})}return r.sort((o,n)=>o.location-n.location),r}function Iv(t,e){let r=[],i=t.getProgramParameter(e,35718);for(let o=0;o<i;o++){let n=t.getActiveUniform(e,o);if(!n)throw new Error("activeInfo");let{name:s,size:a,type:c}=n,{name:l,isArray:f}=Nv(s),h=t.getUniformLocation(e,l),u={location:h,name:l,size:a,type:c,isArray:f};if(r.push(u),u.size>1)for(let d=0;d<u.size;d++){let p=`${l}[${d}]`;h=t.getUniformLocation(e,p);let g={...u,name:p,location:h};r.push(g)}}return r}function Ov(t,e){let r=(n,s)=>t.getActiveUniformBlockParameter(e,n,s),i=[],o=t.getProgramParameter(e,35382);for(let n=0;n<o;n++){let s={name:t.getActiveUniformBlockName(e,n)||"",location:r(n,35391),byteLength:r(n,35392),vertex:r(n,35396),fragment:r(n,35398),uniformCount:r(n,35394),uniforms:[]},a=r(n,35395)||[],c=t.getActiveUniforms(e,a,35383),l=t.getActiveUniforms(e,a,35384),f=t.getActiveUniforms(e,a,35387),h=t.getActiveUniforms(e,a,35388);for(let p=0;p<s.uniformCount;++p){let g=a[p];if(g!==void 0){let m=t.getActiveUniform(e,g);if(!m)throw new Error("activeInfo");let _=Ac(c[p]);s.uniforms.push({name:m.name,format:_,type:c[p],arrayLength:l[p],byteOffset:f[p],byteStride:h[p]})}}let u=new Set(s.uniforms.map(p=>p.name.split(".")[0]).filter(p=>Boolean(p))),d=s.name.replace(/Uniforms$/,"");if(u.size===1&&!u.has(s.name)&&!u.has(d)){let[p]=u;x.warn(`Uniform block "${s.name}" uses GLSL instance "${p}". luma.gl binds uniform buffers by block name ("${s.name}") and alias ("${d}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}i.push(s)}return i.sort((n,s)=>n.location-s.location),i}function Nv(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(t);return{name:Rr(r?.[1],`Failed to parse GLSL uniform name ${t}`),length:r?.[2]?1:0,isArray:Boolean(r?.[2])}}var vb=E(()=>{L();Ec()});var Mb,wc,Cb=E(()=>{L();vb();Ec();Mb=4,wc=class extends uo{device;handle;vs;fs;introspectedLayout={attributes:[],bindings:[],uniforms:[]};linkStatus="pending";constructor(e,r){super(e,r),this.device=e,this.handle=r.handle||this.device.gl.createProgram(),this.vs=r.vs,this.fs=r.fs,r.varyings&&r.varyings.length>0&&this.device.gl.transformFeedbackVaryings(this.handle,r.varyings,r.bufferMode||35981),this._linkShaders(),x.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Pb(this.device.gl,this.handle),x.timeEnd(3,`RenderPipeline ${this.id} - shaderLayout introspection`)()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),x.time(Mb,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),x.timeEnd(Mb,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let i=this._getLinkStatus();this._reportLinkStatus(i);return}x.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),x.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}async _reportLinkStatus(e){switch(e){case"success":return;default:let r=e==="link-error"?"Link error":"Validation error";switch(this.vs.compilationStatus){case"error":throw this.vs.debugShader(),new Error(`${this} ${r} 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} ${r} during compilation of ${this.fs}`);case"pending":await this.fs.asyncCompilationStatus,this.fs.debugShader();break;case"success":break}let i=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${e}: ${i}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:e}=this.device;return e.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),e.validateProgram(this.handle),e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:e}=this.device;e.useProgram(this.handle);let r=0,i=e.getProgramParameter(this.handle,35718);for(let o=0;o<i;o++){let n=e.getActiveUniform(this.handle,o);if(n&&Sc(n.type)){let s=n.name.endsWith("[0]"),a=s?n.name.slice(0,-3):n.name,c=e.getUniformLocation(this.handle,a);c!==null&&(r=this._assignSamplerUniform(c,n,s,r))}}}_assignSamplerUniform(e,r,i,o){let{gl:n}=this.device;if(i&&r.size>1){let s=Int32Array.from({length:r.size},(a,c)=>o+c);return n.uniform1iv(e,s),o+r.size}return n.uniform1i(e,o),o+1}async _waitForLinkComplete(){let e=async o=>await new Promise(n=>setTimeout(n,o));if(!this.device.features.has("compilation-status-async-webgl")){await e(10);return}let{gl:i}=this.device;for(;;){if(i.getProgramParameter(this.handle,37297))return;await e(10)}}}});function Dv(t,e){let r=e.sourceBuffer,i=e.destinationBuffer;t.gl.bindBuffer(36662,r.handle),t.gl.bindBuffer(36663,i.handle),t.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(36662,null),t.gl.bindBuffer(36663,null)}function Bv(t,e){throw new Error("copyBufferToTexture is not supported in WebGL")}function Fv(t,e){let{sourceTexture:r,mipLevel:i=0,aspect:o="all",width:n=e.sourceTexture.width,height:s=e.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:f=0,bytesPerRow:h,rowsPerImage:u}=e;if(r instanceof B){r.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:n,height:s,depthOrArrayLayers:a,mipLevel:i,aspect:o,byteOffset:f},l);return}if(o!=="all")throw new Error("aspect not supported in WebGL");if(i!==0||a!==void 0||h||u)throw new Error("not implemented");let{framebuffer:d,destroyFramebuffer:p}=Ib(r),g;try{let m=l,_=n||d.width,b=s||d.height,y=Rr(d.colorAttachments[0]),T=oc(y.texture.props.format),S=T.format,A=T.type;t.gl.bindBuffer(35051,m.handle),g=t.gl.bindFramebuffer(36160,d.handle),t.gl.readPixels(c[0],c[1],_,b,S,A,f)}finally{t.gl.bindBuffer(35051,null),g!==void 0&&t.gl.bindFramebuffer(36160,g),p&&d.destroy()}}function Lv(t,e){let{sourceTexture:r,destinationMipLevel:i=0,origin:o=[0,0],destinationOrigin:n=[0,0,0],destinationTexture:s}=e,{width:a=e.destinationTexture.width,height:c=e.destinationTexture.height}=e,{framebuffer:l,destroyFramebuffer:f}=Ib(r),[h=0,u=0]=o,[d,p,g]=n,m=t.gl.bindFramebuffer(36160,l.handle),_,b;if(s instanceof St)_=s,a=Number.isFinite(a)?a:_.width,c=Number.isFinite(c)?c:_.height,_._bind(0),b=_.glTarget;else throw new Error("invalid destination");switch(b){case 3553:case 34067:t.gl.copyTexSubImage2D(b,i,d,p,h,u,a,c);break;case 35866:case 32879:t.gl.copyTexSubImage3D(b,i,d,p,g,h,u,a,c);break;default:}_&&_._unbind(),t.gl.bindFramebuffer(36160,m),f&&l.destroy()}function Ib(t){if(t instanceof B){let{width:e,height:r,id:i}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${i}`,width:e,height:r,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}var Rc,Ob=E(()=>{L();qi();Tc();Rc=class extends ui{device;handle=null;commands=[];constructor(e,r={}){super(e,r),this.device=e}_executeCommands(e=this.commands){for(let r of e)switch(r.name){case"copy-buffer-to-buffer":Dv(this.device,r.options);break;case"copy-buffer-to-texture":Bv(this.device,r.options);break;case"copy-texture-to-buffer":Fv(this.device,r.options);break;case"copy-texture-to-texture":Lv(this.device,r.options);break;default:throw new Error(r.name)}}}});var Uv,Pc,Nb=E(()=>{L();_c();Yi();Uv=[1,2,4,8],Pc=class extends Mt{device;handle=null;glParameters={};constructor(e,r){super(e,r),this.device=e;let i=this.props.framebuffer,o=!i||i.handle===null;o&&e.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let n;if(!r?.parameters?.viewport)if(o){let[s,a]=e.getDefaultCanvasContext().getDrawingBufferSize();n=[0,0,s,a]}else{let{width:s,height:a}=i;n=[0,0,s,a]}if(this.device.pushState(),this.setParameters({viewport:n,...this.props.parameters}),o)this.device.gl.drawBuffers([1029]);else{let s=i.colorAttachments.map((a,c)=>36064+c);this.device.gl.drawBuffers(s)}this.clear(),this.props.timestampQuerySet&&this.props.beginTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.beginTimestampIndex)}end(){this.destroyed||(this.props.timestampQuerySet&&this.props.endTimestampIndex!==void 0&&this.props.timestampQuerySet.writeTimestamp(this.props.endTimestampIndex),this.device.popState(),this.destroy())}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){let r={...this.glParameters};r.framebuffer=this.props.framebuffer||null,this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(r.viewport=e.viewport.slice(0,4),r.depthRange=[e.viewport[4],e.viewport[5]]):r.viewport=e.viewport),e.scissorRect&&(r.scissorTest=!0,r.scissor=e.scissorRect),e.blendConstant&&(r.blendColor=e.blendConstant),e.stencilReference!==void 0&&(r[2967]=e.stencilReference,r[36003]=e.stencilReference),"colorMask"in e&&(r.colorMask=Uv.map(i=>Boolean(i&e.colorMask))),this.glParameters=r,Qe(this.device.gl,r)}beginOcclusionQuery(e){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let e={...this.glParameters},r=0;this.props.clearColors&&this.props.clearColors.forEach((i,o)=>{i&&this.clearColorBuffer(o,i)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(r|=16384,e.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=256,e.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=1024,e.clearStencil=this.props.clearStencil),r!==0&&xt(this.device.gl,e,()=>{this.device.gl.clear(r)})}clearColorBuffer(e=0,r=[0,0,0,0]){xt(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,e,r);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,e,r);break;case Float32Array:this.device.gl.clearBufferfv(6144,e,r);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var Mn,Db=E(()=>{L();Ob();Nb();Mn=class extends hi{device;handle=null;commandBuffer;constructor(e,r){super(e,r),this.device=e,this.commandBuffer=new Rc(e,{id:`${this.props.id}-command-buffer`})}destroy(){this.destroyResource()}finish(e){return e?.id&&this.commandBuffer.id!==e.id&&(this.commandBuffer.id=e.id,this.commandBuffer.props.id=e.id),this.destroy(),this.commandBuffer}beginRenderPass(e={}){return new Pc(this.device,this._applyTimeProfilingToPassProps(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,r,i){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(e,r){e.writeTimestamp(r)}}});function Bb(t){let{target:e,source:r,start:i=0,count:o=1}=t,n=r.length,s=o*n,a=0;for(let c=i;a<n;a++)e[c++]=r[a]??0;for(;a<s;)a<s-a?(e.copyWithin(i+a,i,i+a),a*=2):(e.copyWithin(i+a,i,i+s-a),a=s);return t.target}var Fb=E(()=>{});function kv(t){return Array.isArray(t)?new Float32Array(t):t}function Vv(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var Gi,Lb=E(()=>{L();Kt();Vu();Fb();Gi=class extends pi{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return hl()==="Chrome"}constructor(e,r){super(e,r),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 r=e;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(e,r){let i=r;if(i.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:o,type:n,stride:s,offset:a,normalized:c,integer:l,divisor:f}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,o,n,s,a):this.device.gl.vertexAttribPointer(e,o,n,c,s,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,f||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,r){this._enable(e,!1),this.attributes[e]=r}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 r=this.attributes[e];ArrayBuffer.isView(r)&&this.device.setConstantAttributeWebGL(e,r)}}_getAccessor(e){let r=this.attributeInfos[e];if(!r)throw new Error(`Unknown attribute location ${e}`);let i=ec(r.bufferDataType);return{size:r.bufferComponents,type:i,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(e,r=!0){let o=Gi.isConstantAttributeZeroSupported(this.device)||e!==0;(r||o)&&(e=Number(e),this.device.gl.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(e):this.device.gl.disableVertexAttribArray(e),this.device.gl.bindVertexArray(null))}getConstantBuffer(e,r){let i=kv(r),o=i.byteLength*e,n=i.length*e;if(this.buffer&&o!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${o} !== ${this.buffer.byteLength}.`);let s=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:o}),s||=!Vv(i,this.bufferValue),s){let a=lf(r.constructor,n);Bb({target:a,source:i,start:0,count:n}),this.buffer.write(a),this.bufferValue=r}return this.buffer}}});function Ub(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}var vc,kb=E(()=>{L();Mc();ed();vc=class extends gi{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(e,r){super(e,r),this.device=e,this.gl=e.gl,this.handle=this.props.handle||this.gl.createTransformFeedback(),this.layout=this.props.layout,r.buffers&&this.setBuffers(r.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(Tb(e))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(e){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[r,i]of Object.entries(e))this.setBuffer(r,i)})}setBuffer(e,r){let i=this._getVaryingIndex(e),{buffer:o,byteLength:n,byteOffset:s}=this._getBufferRange(r);if(i<0){this.unusedBuffers[e]=o,x.warn(`${this.id} unusedBuffers varying buffer ${e}`)();return}this.buffers[i]={buffer:o,byteLength:n,byteOffset:s},this.bindOnUse||this._bindBuffer(i,o,s,n)}getBuffer(e){if(Ub(e))return this.buffers[e]||null;let r=this._getVaryingIndex(e);return this.buffers[r]??null}bind(e=this.handle){if(typeof e!="function")return this.gl.bindTransformFeedback(36386,e),this;let r;return this._bound?r=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof tt)return{buffer:e,byteOffset:0,byteLength:e.byteLength};let{buffer:r,byteOffset:i=0,byteLength:o=e.buffer.byteLength}=e;return{buffer:r,byteOffset:i,byteLength:o}}_getVaryingIndex(e){if(Ub(e))return Number(e);for(let r of this.layout.varyings||[])if(e===r.name)return r.location;return-1}_bindBuffers(){for(let[e,r]of Object.entries(this.buffers)){let{buffer:i,byteLength:o,byteOffset:n}=this._getBufferRange(r);this._bindBuffer(Number(e),i,n,o)}}_unbindBuffers(){for(let e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,r,i=0,o){let n=r&&r.handle;!n||o===void 0?this.gl.bindBufferBase(35982,e,n):this.gl.bindBufferRange(35982,e,n,i,o)}}});var Cc,Vb=E(()=>{L();Cc=class extends mi{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(e,r){if(super(e,r),this.device=e,r.type==="timestamp"){if(r.count<2)throw new Error("Timestamp QuerySet requires at least two query slots");this._timestampPairs=new Array(Math.ceil(r.count/2)).fill(null).map(()=>({activeQuery:null,completedQueries:[]})),this.handle=null}else{if(r.count>1)throw new Error("WebGL occlusion QuerySet can only have one value");let i=this.device.gl.createQuery();if(!i)throw new Error("WebGL query not supported");this.handle=i}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let e of this._timestampPairs){e.activeQuery&&(this._cancelPendingQuery(e.activeQuery),this.device.gl.deleteQuery(e.activeQuery.handle));for(let r of e.completedQueries)this._cancelPendingQuery(r),this.device.gl.deleteQuery(r.handle)}this._occlusionQuery&&(this._cancelPendingQuery(this._occlusionQuery),this.device.gl.deleteQuery(this._occlusionQuery.handle));for(let e of Array.from(this._pendingReads))this._cancelPendingQuery(e);this.destroyResource()}}isResultAvailable(e){return this.props.type==="timestamp"?e===void 0?this._timestampPairs.some((r,i)=>this._isTimestampPairAvailable(i)):this._isTimestampPairAvailable(this._getTimestampPairIndex(e)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(e){let r=e?.firstQuery||0,i=e?.queryCount||this.props.count-r;if(this._validateRange(r,i),this.props.type==="timestamp"){let o=new Array(i).fill(0n),n=Math.floor(r/2),s=Math.floor((r+i-1)/2);for(let a=n;a<=s;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,f=l+1;l>=r&&l<r+i&&(o[l-r]=0n),f>=r&&f<r+i&&(o[f-r]=c)}return o}if(!this._occlusionQuery)throw new Error("Occlusion query has not been started");return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(e,r){if(this.props.type!=="timestamp")throw new Error("Timestamp durations require a timestamp QuerySet");if(e<0||r>=this.props.count||r<=e)throw new Error("Timestamp duration range is out of bounds");if(e%2!==0||r!==e+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let i=await this._consumeTimestampPairResult(this._getTimestampPairIndex(e));return Number(i)/1e6}beginOcclusionQuery(){if(this.props.type!=="occlusion")throw new Error("Occlusion queries require an occlusion QuerySet");if(!this.handle)throw new Error("WebGL occlusion query is not available");if(this._occlusionActive)throw new Error("Occlusion query is already active");this.device.gl.beginQuery(35887,this.handle),this._occlusionQuery={handle:this.handle,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null},this._occlusionActive=!0}endOcclusionQuery(){if(!this._occlusionActive)throw new Error("Occlusion query is not active");this.device.gl.endQuery(35887),this._occlusionActive=!1}writeTimestamp(e){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let r=this._getTimestampPairIndex(e),i=this._timestampPairs[r];if(e%2===0){if(i.activeQuery)throw new Error("Timestamp query pair is already active");let o=this.device.gl.createQuery();if(!o)throw new Error("WebGL query not supported");let n={handle:o,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,o),i.activeQuery=n;return}if(!i.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),i.completedQueries.push(i.activeQuery),i.activeQuery=null}_validateRange(e,r){if(e<0||r<0||e+r>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(e){if(e<0||e>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(e/2)}_isTimestampPairAvailable(e){let r=this._timestampPairs[e];return!r||r.completedQueries.length===0?!1:this._pollQueryAvailability(r.completedQueries[0])}_pollQueryAvailability(e){if(e.cancelled||this.destroyed)return e.result=0n,!0;if(e.result!==null||e.disjoint)return!0;if(!this.device.gl.getQueryParameter(e.handle,34919))return!1;let i=Boolean(this.device.gl.getParameter(36795));return e.disjoint=i,e.result=i?0n:BigInt(this.device.gl.getQueryParameter(e.handle,34918)),!0}async _consumeTimestampPairResult(e){let r=this._timestampPairs[e];if(!r||r.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let i=r.completedQueries.shift();try{return await this._consumeQueryResult(i)}finally{this.device.gl.deleteQuery(i.handle)}}_consumeQueryResult(e){return e.promise||(this._pendingReads.add(e),e.promise=new Promise((r,i)=>{e.resolve=r,e.reject=i;let o=()=>{if(e.pollRequestId=null,e.cancelled||this.destroyed){this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,r(0n);return}if(!this._pollQueryAvailability(e)){e.pollRequestId=this._requestAnimationFrame(o);return}this._pendingReads.delete(e),e.promise=null,e.resolve=null,e.reject=null,e.disjoint?i(new Error("GPU timestamp query was invalidated by a disjoint event")):r(e.result||0n)};o()})),e.promise}_cancelPendingQuery(e){if(this._pendingReads.delete(e),e.cancelled=!0,e.pollRequestId!==null&&(this._cancelAnimationFrame(e.pollRequestId),e.pollRequestId=null),e.resolve){let r=e.resolve;e.promise=null,e.resolve=null,e.reject=null,r(0n)}}_requestAnimationFrame(e){return requestAnimationFrame(e)}_cancelAnimationFrame(e){cancelAnimationFrame(e)}}});var Ic,zb=E(()=>{L();Ic=class extends _i{device;gl;handle;signaled;_signaled=!1;constructor(e,r={}){super(e,{}),this.device=e,this.gl=e.gl;let i=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!i)throw new Error("Failed to create WebGL fence");this.handle=i,this.signaled=new Promise(o=>{let n=()=>{let s=this.gl.clientWaitSync(this.handle,0,0);s===this.gl.ALREADY_SIGNALED||s===this.gl.CONDITION_SATISFIED?(this._signaled=!0,o()):setTimeout(n,1)};n()})}isSignaled(){if(this._signaled)return!0;let e=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=e===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function td(t){switch(t){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 Wb(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var jb=E(()=>{});function $b(t,e){let{sourceX:r=0,sourceY:i=0,sourceAttachment:o=0}=e||{},{target:n=null,sourceWidth:s,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:f}=e||{},{framebuffer:h,deleteFramebuffer:u}=Xb(t),{gl:d,handle:p}=h;s||=h.width,a||=h.height;let g=h.colorAttachments[o]?.texture;if(!g)throw new Error(`Invalid framebuffer attachment ${o}`);c=g?.depth||1,l||=g?.glFormat||6408,f||=g?.glType||5121,n=Wv(n,f,l,s,a,c);let m=he.getDataType(n);f=f||Eb(m);let _=d.bindFramebuffer(36160,p);return d.readBuffer(36064+o),d.readPixels(r,i,s,a,l,f,n),d.readBuffer(36064),d.bindFramebuffer(36160,_||null),u&&h.destroy(),n}function Hb(t,e){let{target:r,sourceX:i=0,sourceY:o=0,sourceFormat:n=6408,targetByteOffset:s=0}=e||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=e||{},{framebuffer:f,deleteFramebuffer:h}=Xb(t);a=a||f.width,c=c||f.height;let u=f;l=l||5121;let d=r;if(!d){let g=td(n),m=Wb(l),_=s+a*c*g*m;d=u.device.createBuffer({byteLength:_})}let p=t.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:t,width:a,height:c,origin:[i,o],destinationBuffer:d,byteOffset:s}),p.destroy(),h&&f.destroy(),d}function Xb(t){return t instanceof st?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:zv(t),deleteFramebuffer:!0}}function zv(t,e){let{device:r,width:i,height:o,id:n}=t;return r.createFramebuffer({...e,id:`framebuffer-for-${n}`,width:i,height:o,colorAttachments:[t]})}function Wv(t,e,r,i,o,n){if(t)return t;e||=5121;let s=yc(e),a=he.getTypedArrayConstructor(s),c=td(r);return new a(i*o*c)}var Yb=E(()=>{L();Ec();jb();Ju()});var rd={};Rt(rd,{WebGLDevice:()=>rt});function jv(t,e,r){switch(r.length){case 1:t.gl.vertexAttrib1fv(e,r);break;case 2:t.gl.vertexAttrib2fv(e,r);break;case 3:t.gl.vertexAttrib3fv(e,r);break;case 4:t.gl.vertexAttrib4fv(e,r);break;default:}}function $v(t,e,r){t.gl.vertexAttribI4iv(e,r)}function Hv(t,e,r){t.gl.vertexAttribI4uiv(e,r)}function Xv(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let r=0;r<t.length;++r)if(t[r]!==e[r])return!1;return!0}var rt,Oc=E(()=>{L();ku();Ky();Ga();Gy();nb();sb();ab();cb();Nu();Du();qi();fb();fc();db();mb();Tc();ac();Sb();Cb();Db();Lb();kb();Vb();zb();Yb();Yi();_c();Rn();rt=class extends be{static getDeviceFromContext(e){return e?e.luma?.device??null:null}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||lb("webgl-device")});let r=be._getCanvasContextProps(e);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let i=r.canvas?.gl??null,o=rt.getDeviceFromContext(i);if(o)throw new Error(`WebGL context already attached to device ${o.id}`);this.canvasContext=new cc(this,r),this.lost=new Promise(f=>{this._resolveContextLost=f});let n={...e.webgl};r.alphaMode==="premultiplied"&&(n.premultipliedAlpha=!0),e.powerPreference!==void 0&&(n.powerPreference=e.powerPreference),e.failIfMajorPerformanceCaveat!==void 0&&(n.failIfMajorPerformanceCaveat=e.failIfMajorPerformanceCaveat);let a=this.props._handle||Yy(this.canvasContext.canvas,{onContextLost:f=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:f=>console.log("WebGL context restored")},n);if(!a)throw new Error("WebGL context creation failed");if(o=rt.getDeviceFromContext(a),o){if(e._reuseDevices)return x.log(1,`Not creating a new Device, instead returning a reference to Device ${o.id} already attached to WebGL context`,o)(),this.canvasContext.destroy(),o._reused=!0,o;throw new Error(`WebGL context already attached to device ${o.id}`)}this.handle=a,this.gl=a,this.spectorJS=Oy({...this.props,gl:this.handle});let c=Yr(this.handle);c.device=this,c.extensions||(c.extensions={}),this.extensions=c.extensions,this.info=Zy(this.gl,this.extensions),this.limits=new sc(this.gl),this.features=new nc(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new Je(this.gl,{log:(...f)=>x.log(1,...f)()}).trackState(this.gl,{copyState:!1}),(e.debug||e.debugWebGL)&&(this.gl=Fy(this.gl,{debugWebGL:!0,traceWebGL:e.debugWebGL}),x.warn("WebGL debug mode activated. Performance reduced.")()),e.debugWebGL&&(x.level=Math.max(x.level,1)),this.commandEncoder=new Mn(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(this.commandEncoder?.destroy(),!this.props._reuseDevices&&!this._reused){let e=Yr(this.handle);e.device=null}}get isLost(){return this.gl.isContextLost()}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createPresentationContext(e){return new lc(this,e||{})}createBuffer(e){let r=this._normalizeBufferProps(e);return new tt(this,r)}createTexture(e){return new St(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new mc(this,e)}createShader(e){return new uc(this,e)}createFramebuffer(e){return new Tt(this,e)}createVertexArray(e){return new Gi(this,e)}createTransformFeedback(e){return new vc(this,e)}createQuerySet(e){return new Cc(this,e)}createFence(){return new Ic(this)}createRenderPipeline(e){return new xc(this,e)}_createSharedRenderPipelineWebGL(e){return new wc(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}createCommandEncoder(e={}){return new Mn(this,e)}submit(e){let r=null;e||({submittedCommandEncoder:r,commandBuffer:e}=this._finalizeDefaultCommandEncoderForSubmit());try{e._executeCommands(),r&&r.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=r._gpuTimeMs}).catch(()=>{})}finally{e.destroy()}}_finalizeDefaultCommandEncoderForSubmit(){let e=this.commandEncoder,r=e.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:e.props.id,timeProfilingQuerySet:e.getTimeProfilingQuerySet()}),{submittedCommandEncoder:e,commandBuffer:r}}readPixelsToArrayWebGL(e,r){return $b(e,r)}readPixelsToBufferWebGL(e,r){return Hb(e,r)}setParametersWebGL(e){Qe(this.gl,e)}getParametersWebGL(e){return Ja(this.gl,e)}withParametersWebGL(e,r){return xt(this.gl,e,r)}resetWebGL(){x.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),Wy(this.gl)}_getDeviceSpecificTextureFormatCapabilities(e){return rb(this.gl,e,this.extensions)}loseDevice(){let e=!1,i=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return i&&(e=!0,i.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){Je.get(this.gl).push()}popState(){Je.get(this.gl).pop()}getGLKey(e,r){let i=Number(e);for(let o in this.gl)if(this.gl[o]===i)return`GL.${o}`;return r?.emptyIfUnknown?"":String(e)}getGLKeys(e){let r={emptyIfUnknown:!0};return Object.entries(e).reduce((i,[o,n])=>(i[`${o}:${this.getGLKey(o,r)}`]=`${n}:${this.getGLKey(n,r)}`,i),{})}setConstantAttributeWebGL(e,r){let i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);let o=this._constants[e];switch(o&&Xv(o,r)&&x.info(1,`setConstantAttributeWebGL(${e}) could have been skipped, value unchanged`)(),this._constants[e]=r,r.constructor){case Float32Array:jv(this,e,r);break;case Int32Array:$v(this,e,r);break;case Uint32Array:Hv(this,e,r);break;default:throw new Error("constant")}}getExtension(e){return et(this.gl,e,this.extensions),this.extensions}_setWebGLDebugMetadata(e,r,i){e.luma=r;let o={props:i.spector,id:i.spector.id};e.__SPECTOR_Metadata=o}}});function Yv(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:Boolean(t&&typeof t.createVertexArray=="function")}var Cn,id,In,Kb=E(()=>{L();My();Nu();Du();Cn=1,id=class extends lo{type="webgl";constructor(){super(),be.defaultProps={...be.defaultProps,...Qa}}enforceWebGL2(e){vy(e)}isSupported(){return typeof WebGL2RenderingContext<"u"}isDeviceHandle(e){return typeof WebGL2RenderingContext<"u"&&e instanceof WebGL2RenderingContext?!0:(typeof WebGLRenderingContext<"u"&&e instanceof WebGLRenderingContext&&x.warn("WebGL1 is not supported",e)(),!1)}async attach(e,r={}){let{WebGLDevice:i}=await Promise.resolve().then(()=>(Oc(),rd));if(e instanceof i)return e;let o=i.getDeviceFromContext(e);if(o)return o;if(!Yv(e))throw new Error("Invalid WebGL2RenderingContext");let n=r.createCanvasContext===!0?{}:r.createCanvasContext;return new i({...r,_handle:e,createCanvasContext:{canvas:e.canvas,autoResize:!1,...n}})}async create(e={}){let{WebGLDevice:r}=await Promise.resolve().then(()=>(Oc(),rd)),i=[];(e.debugWebGL||e.debug)&&i.push(By()),e.debugSpectorJS&&i.push(Iy(e));let o=await Promise.allSettled(i);for(let n of o)n.status==="rejected"&&x.error(`Failed to initialize debug libraries ${n.reason}`)();try{let n=new r(e);x.groupCollapsed(Cn,`WebGLDevice ${n.id} created`)();let s=`${n._reused?"Reusing":"Created"} device with WebGL2 ${n.props.debug?"debug ":""}context: ${n.info.vendor}, ${n.info.renderer} for canvas: ${n.canvasContext.id}`;return x.probe(Cn,s)(),x.table(Cn,n.info)(),n}finally{x.groupEnd(Cn)(),x.info(Cn,"%cWebGL call tracing: luma.log.set('debug-webgl') ","color: white; background: blue; padding: 2px 6px; border-radius: 3px;")()}}};In=new id});var Mc=E(()=>{Kb();Oc();fc()});var rM={};Rt(rM,{AmbientLight:()=>ki,Attribute:()=>Yt,AttributeManager:()=>Zr,COORDINATE_SYSTEM:()=>kr,CompositeLayer:()=>x0,Controller:()=>ye,Deck:()=>Nc,DeckGL:()=>Qn,DeckRenderer:()=>Xr,DirectionalLight:()=>Ut,FirstPersonController:()=>Qr,FirstPersonView:()=>S0,FirstPersonViewport:()=>Qc,FlyToInterpolator:()=>qn,Layer:()=>Hc,LayerExtension:()=>C0,LayerManager:()=>$r,LightingEffect:()=>mr,LinearInterpolator:()=>se,MapController:()=>Xt,MapView:()=>Ha,OPERATION:()=>z_,OrbitController:()=>Jr,OrbitView:()=>E0,OrbitViewport:()=>Kc,OrthographicController:()=>ei,OrthographicView:()=>R0,OrthographicViewport:()=>qc,PointLight:()=>ji,PostProcessEffect:()=>un,TRANSITION_EVENTS:()=>mn,TerrainController:()=>Kn,Tesselator:()=>Gn,TransitionInterpolator:()=>jt,UNIT:()=>dr,VERSION:()=>ua,View:()=>_e,Viewport:()=>Ae,WebMercatorViewport:()=>_r,Widget:()=>Tr,_CameraLight:()=>ln,_Component:()=>eo,_ComponentState:()=>qr,_GlobeController:()=>ti,_GlobeView:()=>M0,_GlobeViewport:()=>Hi,_LayersPass:()=>Ye,_PickLayersPass:()=>kt,_SunLight:()=>fn,_applyStyles:()=>An,_compareProps:()=>Wc,_count:()=>jc,_deepEqual:()=>K,_fillArray:()=>Ua,_flatten:()=>br,_memoize:()=>Ue,_mergeShaders:()=>Wn,_registerLoggers:()=>ha,_removeStyles:()=>Za,assert:()=>X,color:()=>nu,createIterable:()=>Qi,fp64LowPart:()=>Eu,getShaderAssembler:()=>Ia,gouraudMaterial:()=>wo,log:()=>F,phongMaterial:()=>Ro,picking:()=>Au,project:()=>pr,project32:()=>mu,shadow:()=>Ui});var Sh={};Rt(Sh,{Buffer:()=>I,BufferTransform:()=>je,CubeGeometry:()=>Do,Device:()=>be,Framebuffer:()=>st,Geometry:()=>$e,GroupNode:()=>nr,Model:()=>Pe,ModelNode:()=>No,ScenegraphNode:()=>lt,SphereGeometry:()=>Oo,Texture:()=>B,TextureTransform:()=>Co,attachDevice:()=>VE,createDevice:()=>zE,enforceWebGL2:()=>WE,getSupportedAdapters:()=>UE,setDefaultDeviceProps:()=>kE,stats:()=>LE});L();L();var ax=1,cx=1,vr=class{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){let{delay:r=0,duration:i=Number.POSITIVE_INFINITY,rate:o=1,repeat:n=1}=e,s=ax++,a={time:0,delay:r,duration:i,rate:o,repeat:n};return this._setChannelTime(a,this.time),this.channels.set(s,a),s}removeChannel(e){this.channels.delete(e);for(let[r,i]of this.animations)i.channel===e&&this.detachAnimation(r)}isFinished(e){let r=this.channels.get(e);return r===void 0?!1:this.time>=r.delay+r.duration*r.repeat}getTime(e){if(e===void 0)return this.time;let r=this.channels.get(e);return r===void 0?-1:r.time}setTime(e){this.time=Math.max(0,e);let r=this.channels.values();for(let o of r)this._setChannelTime(o,this.time);let i=this.animations.values();for(let o of i){let{animation:n,channel:s}=o;n.setTime(this.getTime(s))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,r){let i=cx++;return this.animations.set(i,{animation:e,channel:r}),e.setTime(this.getTime(r)),i}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,r){let i=r-e.delay,o=e.duration*e.repeat;i>=o?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}};L();function Lp(t){let e=typeof window<"u"?window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame:null;return e?e.call(window,t):setTimeout(()=>t(typeof performance<"u"?performance.now():Date.now()),1e3/60)}function Up(t){let e=typeof window<"u"?window.cancelAnimationFrame||window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame:null;if(e){e.call(window,t);return}clearTimeout(t)}ro();var lx=0,fx="Animation Loop",uf=class{device=null;canvas=null;props;animationProps=null;timeline=null;stats;sharedStats;cpuTime;gpuTime;frameRate;display;_needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;_error=null;_lastFrameTime=0;constructor(e){if(this.props={...uf.defaultAnimationLoopProps,...e},e=this.props,!e.device)throw new Error("No device provided");this.stats=e.stats||new Oe({id:`animation-loop-${lx++}`}),this.sharedStats=Gt.stats.get(fx),this.frameRate=this.stats.get("Frame Rate"),this.frameRate.setSampleSize(1),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),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),this.device?._disableDebugGPUTime()}delete(){this.destroy()}reportError(e){this.props.onError(e),this._error=e}setNeedsRedraw(e){return this._needsRedraw=this._needsRedraw||e,this}needsRedraw(){let e=this._needsRedraw;return this._needsRedraw=!1,e}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;if(!this._initialized){if(this._initialized=!0,await this._initDevice(),this._initialize(),!this._running)return null;await this.props.onInitialize(this._getAnimationProps())}return this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){let r=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(r),r}}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._lastFrameTime=0),this}redraw(e){return this.device?.isLost||this._error?this:(this._beginFrameTimers(e),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(),this.device?._enableDebugGPUTime()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=Lp(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(Up(this._animationFrameId),this._animationFrameId=null)}_animationFrame(e){this._running&&(this.redraw(e),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 r=e?.canvas,i=e.props.useDevicePixels;this.animationProps={animationLoop:this,device:this.device,canvasContext:e,canvas:r,useDevicePixels:i,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:r,aspect:i}=this._getSizeAndAspect();(e!==this.animationProps.width||r!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=r,this.animationProps.aspect=i,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 r=document.createElement("div");r.style.position="absolute",r.style.left="10px",r.style.bottom="10px",r.style.width="300px",r.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(r);let i=this.props.onAddHTML(r);i&&(r.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};let[e,r]=this.device.getDefaultCanvasContext().getDrawingBufferSize(),i=e>0&&r>0?e/r:1;return{width:e,height:r,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_beginFrameTimers(e){let r=e??(typeof performance<"u"?performance.now():Date.now());if(this._lastFrameTime){let i=r-this._lastFrameTime;i>0&&this.frameRate.addTime(i)}this._lastFrameTime=r,this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeStart()}_endFrameTimers(){this.device?._isDebugGPUTimeEnabled()&&this._consumeEncodedGpuTime(),this.cpuTime.timeEnd(),this._updateSharedStats()}_consumeEncodedGpuTime(){if(!this.device)return;let e=this.device.commandEncoder._gpuTimeMs;e!==void 0&&(this.gpuTime.addTime(e),this.device.commandEncoder._gpuTimeMs=void 0)}_updateSharedStats(){if(this.stats!==this.sharedStats){for(let e of Object.keys(this.sharedStats.stats))this.stats.stats[e]||delete this.sharedStats.stats[e];this.stats.forEach(e=>{let r=this.sharedStats.get(e.name,e.type);r.sampleSize=e.sampleSize,r.time=e.time,r.count=e.count,r.samples=e.samples,r.lastTiming=e.lastTiming,r.lastSampleTime=e.lastSampleTime,r.lastSampleCount=e.lastSampleCount,r._count=e._count,r._time=e._time,r._samples=e._samples,r._startTime=e._startTime,r._timerPending=e._timerPending})}}_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}},bi=uf;M(bi,"defaultAnimationLoopProps",{device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:void 0,autoResizeViewport:!1});L();function Mr(t,e){if(!t){let r=new Error(e||"shadertools: assertion failed.");throw Error.captureStackTrace?.(r,Mr),r}}var df={number:{type:"number",validate(t,e){return Number.isFinite(t)&&typeof e=="object"&&(e.max===void 0||t<=e.max)&&(e.min===void 0||t>=e.min)}},array:{type:"array",validate(t,e){return Array.isArray(t)||ArrayBuffer.isView(t)}}};function Vp(t){let e={};for(let[r,i]of Object.entries(t))e[r]=hx(i);return e}function hx(t){let e=kp(t);if(e!=="object")return{value:t,...df[e],type:e};if(typeof t=="object")return t?t.type!==void 0?{...t,...df[t.type],type:t.type}:t.value===void 0?{type:"object",value:t}:(e=kp(t.value),{...t,...df[e],type:e}):{type:"object",value:null};throw new Error("props")}function kp(t){return Array.isArray(t)||ArrayBuffer.isView(t)?"array":typeof t}var zp=`#ifdef MODULE_LOGDEPTH
|
|
20
20
|
logdepth_adjustPosition(gl_Position);
|
|
21
21
|
#endif
|
|
22
|
-
`,
|
|
22
|
+
`,Wp=`#ifdef MODULE_MATERIAL
|
|
23
23
|
fragColor = material_filterColor(fragColor);
|
|
24
24
|
#endif
|
|
25
25
|
|
|
@@ -39,10 +39,10 @@ ${e}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,e),r.compileShader(thi
|
|
|
39
39
|
#ifdef MODULE_LOGDEPTH
|
|
40
40
|
logdepth_setFragDepth();
|
|
41
41
|
#endif
|
|
42
|
-
`;var
|
|
42
|
+
`;var ux={vertex:zp,fragment:Wp},jp=/void\s+main\s*\([^)]*\)\s*\{\n?/,$p=/}\n?[^{}]*$/,pf=[],yo="__LUMA_INJECT_DECLARATIONS__";function Hp(t){let e={vertex:{},fragment:{}};for(let r in t){let i=t[r],o=dx(r);typeof i=="string"&&(i={order:0,injection:i}),e[o][r]=i}return e}function dx(t){let e=t.slice(0,2);switch(e){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(e)}}function bo(t,e,r,i=!1){let o=e==="vertex";for(let n in r){let s=r[n];s.sort((c,l)=>c.order-l.order),pf.length=s.length;for(let c=0,l=s.length;c<l;++c)pf[c]=s[c].injection;let a=`${pf.join(`
|
|
43
43
|
`)}
|
|
44
|
-
`;switch(n){case"vs:#decl":o&&(t=t.replace(
|
|
45
|
-
`)){let s=n.replace(/\/\/.*$/,"").trim();if(!s||s.startsWith("#"))continue;let a=e==="wgsl"?s.match(/^([A-Za-z0-9_]+)\s*:/):s.match(
|
|
44
|
+
`;switch(n){case"vs:#decl":o&&(t=t.replace(yo,a));break;case"vs:#main-start":o&&(t=t.replace(jp,c=>c+a));break;case"vs:#main-end":o&&(t=t.replace($p,c=>a+c));break;case"fs:#decl":o||(t=t.replace(yo,a));break;case"fs:#main-start":o||(t=t.replace(jp,c=>c+a));break;case"fs:#main-end":o||(t=t.replace($p,c=>a+c));break;default:t=t.replace(n,c=>c+a)}}return t=t.replace(yo,""),i&&(t=t.replace(/\}\s*$/,n=>n+ux[e])),t}function Cr(t){t.map(e=>Rs(e))}function Rs(t){if(t.instance)return;Cr(t.dependencies||[]);let{propTypes:e={},deprecations:r=[],inject:i={}}=t,o={normalizedInjections:Hp(i),parsedDeprecations:px(r)};e&&(o.propValidators=Vp(e)),t.instance=o;let n={};e&&(n=Object.entries(e).reduce((s,[a,c])=>{let l=c?.value;return l&&(s[a]=l),s},{})),t.defaultUniforms={...t.defaultUniforms,...n}}function gf(t,e,r){t.deprecations?.forEach(i=>{i.regex?.test(e)&&(i.deprecated?r.deprecated(i.old,i.new)():r.removed(i.old,i.new)())})}function px(t){return t.forEach(e=>{switch(e.type){case"function":e.regex=new RegExp(`\\b${e.old}\\(`);break;default:e.regex=new RegExp(`${e.type} ${e.old};`)}}),t}function Ti(t){Cr(t);let e={},r={};Xp({modules:t,level:0,moduleMap:e,moduleDepth:r});let i=Object.keys(r).sort((o,n)=>r[n]-r[o]).map(o=>e[o]);return Cr(i),i}function Xp(t){let{modules:e,level:r,moduleMap:i,moduleDepth:o}=t;if(r>=5)throw new Error("Possible loop in shader dependency graph");for(let n of e)i[n.name]=n,(o[n.name]===void 0||o[n.name]<r)&&(o[n.name]=r);for(let n of e)n.dependencies&&Xp({modules:n.dependencies,level:r+1,moduleMap:i,moduleDepth:o})}var gx=/^(?:uniform\s+)?(?:(?:lowp|mediump|highp)\s+)?[A-Za-z0-9_]+(?:<[^>]+>)?\s+([A-Za-z0-9_]+)(?:\s*\[[^\]]+\])?\s*;/,mx=/((?:layout\s*\([^)]*\)\s*)*)uniform\s+([A-Za-z_][A-Za-z0-9_]*)\s*\{([\s\S]*?)\}\s*([A-Za-z_][A-Za-z0-9_]*)?\s*;/g;function Kp(t){return`${t.name}Uniforms`}function _x(t,e){let r=e==="wgsl"?t.source:e==="vertex"?t.vs:t.fs;if(!r)return null;let i=Kp(t);return bx(r,e==="wgsl"?"wgsl":"glsl",i)}function yx(t,e){let r=Object.keys(t.uniformTypes||{});if(!r.length)return null;let i=_x(t,e);return i?{moduleName:t.name,uniformBlockName:Kp(t),stage:e,expectedUniformNames:r,actualUniformNames:i,matches:Ax(r,i)}:null}function Zp(t,e,r={}){let i=yx(t,e);if(!i||i.matches)return i;let o=Sx(i);return r.log?.error?.(o,i)(),r.throwOnError!==!1&&Mr(!1,o),i}function qp(t){let e=[],r=Ex(t);for(let i of r.matchAll(mx)){let o=i[1]?.trim()||null;e.push({blockName:i[2],body:i[3],instanceName:i[4]||null,layoutQualifier:o,hasLayoutQualifier:Boolean(o),isStd140:Boolean(o&&/\blayout\s*\([^)]*\bstd140\b[^)]*\)/.exec(o))})}return e}function Gp(t,e,r,i){let o=qp(t).filter(s=>!s.isStd140),n=new Set;for(let s of o){if(n.has(s.blockName))continue;n.add(s.blockName);let a=i?.label?`${i.label} `:"",c=s.hasLayoutQualifier?`declares ${wx(s.layoutQualifier)} instead of layout(std140)`:"does not declare layout(std140)",l=`${a}${e} shader uniform block ${s.blockName} ${c}. luma.gl host-side shader block packing assumes explicit layout(std140) for GLSL uniform blocks. Add \`layout(std140)\` to the block declaration.`;r?.warn?.(l,s)()}return o}function bx(t,e,r){let i=e==="wgsl"?Tx(t,r):xx(t,r);if(!i)return null;let o=[];for(let n of i.split(`
|
|
45
|
+
`)){let s=n.replace(/\/\/.*$/,"").trim();if(!s||s.startsWith("#"))continue;let a=e==="wgsl"?s.match(/^([A-Za-z0-9_]+)\s*:/):s.match(gx);a&&o.push(a[1])}return o}function Tx(t,e){let r=new RegExp(`\\bstruct\\s+${e}\\b`,"m").exec(t);if(!r)return null;let i=t.indexOf("{",r.index);if(i<0)return null;let o=0;for(let n=i;n<t.length;n++){let s=t[n];if(s==="{"){o++;continue}if(s==="}"&&(o--,o===0))return t.slice(i+1,n)}return null}function xx(t,e){return qp(t).find(i=>i.blockName===e)?.body||null}function Ax(t,e){if(t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}function Sx(t){let{expectedUniformNames:e,actualUniformNames:r}=t,i=e.filter(a=>!r.includes(a)),o=r.filter(a=>!e.includes(a)),n=[`Expected ${e.length} fields, found ${r.length}.`],s=Rx(e,r);return s&&n.push(s),i.length&&n.push(`Missing from shader block (${i.length}): ${Yp(i)}.`),o.length&&n.push(`Unexpected in shader block (${o.length}): ${Yp(o)}.`),e.length<=12&&r.length<=12&&(i.length||o.length)&&(n.push(`Expected: ${e.join(", ")}.`),n.push(`Actual: ${r.join(", ")}.`)),`${t.moduleName}: ${t.stage} shader uniform block ${t.uniformBlockName} does not match module.uniformTypes. ${n.join(" ")}`}function Ex(t){return t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}function wx(t){return t.replace(/\s+/g," ").trim()}function Rx(t,e){let r=Math.min(t.length,e.length);for(let i=0;i<r;i++)if(t[i]!==e[i])return`First mismatch at field ${i+1}: expected ${t[i]}, found ${e[i]}.`;return t.length>e.length?`Shader block ends after field ${e.length}; expected next field ${t[e.length]}.`:e.length>t.length?`Shader block has extra field ${e.length}: ${e[t.length]}.`:null}function Yp(t,e=8){if(t.length<=e)return t.join(", ");let r=t.length-e;return`${t.slice(0,e).join(", ")}, ... (${r} more)`}function Qp(t){switch(t?.gpu.toLowerCase()){case"apple":return`#define APPLE_GPU
|
|
46
46
|
// Apple optimizes away the calculation necessary for emulated fp64
|
|
47
47
|
#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1
|
|
48
48
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
@@ -66,51 +66,51 @@ ${e}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,e),r.compileShader(thi
|
|
|
66
66
|
#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1
|
|
67
67
|
// If the GPU doesn't have full 32 bits precision, will causes overflow
|
|
68
68
|
#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1
|
|
69
|
-
`}}function
|
|
70
|
-
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],
|
|
69
|
+
`}}function eg(t,e){if(Number(t.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 t=Jp(t,Px),t;case"fragment":return t=Jp(t,vx),t;default:throw new Error(e)}}var tg=[[/^(#version[ \t]+(100|300[ \t]+es))?[ \t]*\n/,`#version 300 es
|
|
70
|
+
`],[/\btexture(2D|2DProj|Cube)Lod(EXT)?\(/g,"textureLod("],[/\btexture(2D|2DProj|Cube)(EXT)?\(/g,"texture("]],Px=[...tg,[mf("attribute"),"in $1"],[mf("varying"),"out $1"]],vx=[...tg,[mf("varying"),"in $1"]];function Jp(t,e){for(let[r,i]of e)t=t.replace(r,i);return t}function mf(t){return new RegExp(`\\b${t}[ \\t]+(\\w+[ \\t]+\\w+(\\[\\w+\\])?;)`,"g")}function _f(t,e){let r="";for(let i in t){let o=t[i];if(r+=`void ${o.signature} {
|
|
71
71
|
`,o.header&&(r+=` ${o.header}`),e[i]){let n=e[i];n.sort((s,a)=>s.order-a.order);for(let s of n)r+=` ${s.injection}
|
|
72
72
|
`}o.footer&&(r+=` ${o.footer}`),r+=`}
|
|
73
|
-
`}return r}function
|
|
73
|
+
`}return r}function yf(t){let e={vertex:{},fragment:{}};for(let r of t){let i,o;typeof r!="string"?(i=r,o=i.hook):(i={},o=r),o=o.trim();let[n,s]=o.split(":"),a=o.replace(/\(.+/,""),c=Object.assign(i,{signature:s});switch(n){case"vs":e.vertex[a]=c;break;case"fs":e.fragment[a]=c;break;default:throw new Error(n)}}return e}function rg(t,e){return{name:Mx(t,e),language:"glsl",version:Cx(t)}}function Mx(t,e="unnamed"){let i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(t);return i?i[1]:e}function Cx(t){let e=100,r=t.match(/[^\s]+/g);if(r&&r.length>=2&&r[0]==="#version"){let i=parseInt(r[1],10);Number.isFinite(i)&&(e=i)}if(e!==100&&e!==300)throw new Error(`Invalid GLSL version ${e}`);return e}var we="(?:var<\\s*(uniform|storage(?:\\s*,\\s*[A-Za-z_][A-Za-z0-9_]*)?)\\s*>|var)\\s+([A-Za-z_][A-Za-z0-9_]*)",Be="\\s*",xi=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Be}@group\\(\\s*(\\d+)\\s*\\)${Be}${we}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Be}@binding\\(\\s*(auto|\\d+)\\s*\\)${Be}${we}`,"g")],Ps=[new RegExp(`@binding\\(\\s*(auto|\\d+)\\s*\\)${Be}@group\\(\\s*(\\d+)\\s*\\)${Be}${we}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Be}@binding\\(\\s*(auto|\\d+)\\s*\\)${Be}${we}`,"g")],ig=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)${Be}@group\\(\\s*(\\d+)\\s*\\)${Be}${we}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)${Be}@binding\\(\\s*(\\d+)\\s*\\)${Be}${we}`,"g")],Ix=[new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${we}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)\\s*${we}`,"g"),new RegExp(`@binding\\(\\s*(auto)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${we}`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(auto)\\s*\\)(?:[\\s\\n\\r]*@[A-Za-z_][^\\n\\r]*)*[\\s\\n\\r]*${we}`,"g")];function vs(t){let e=t.split(""),r=0,i=0,o=!1,n=!1,s=!1;for(;r<t.length;){let a=t[r],c=t[r+1];if(n){s?s=!1:a==="\\"?s=!0:a==='"'&&(n=!1),r++;continue}if(o){a===`
|
|
74
74
|
`||a==="\r"?o=!1:e[r]=" ",r++;continue}if(i>0){if(a==="/"&&c==="*"){e[r]=" ",e[r+1]=" ",i++,r+=2;continue}if(a==="*"&&c==="/"){e[r]=" ",e[r+1]=" ",i--,r+=2;continue}a!==`
|
|
75
|
-
`&&a!=="\r"&&(e[r]=" "),r++;continue}if(a==='"'){n=!0,r++;continue}if(a==="/"&&c==="/"){e[r]=" ",e[r+1]=" ",o=!0,r+=2;continue}if(a==="/"&&c==="*"){e[r]=" ",e[r+1]=" ",i=1,r+=2;continue}r++}return e.join("")}function
|
|
75
|
+
`&&a!=="\r"&&(e[r]=" "),r++;continue}if(a==='"'){n=!0,r++;continue}if(a==="/"&&c==="/"){e[r]=" ",e[r+1]=" ",o=!0,r+=2;continue}if(a==="/"&&c==="*"){e[r]=" ",e[r+1]=" ",i=1,r+=2;continue}r++}return e.join("")}function Ir(t,e){let r=vs(t),i=[];for(let o of e){o.lastIndex=0;let n;for(n=o.exec(r);n;){let s=o===e[0],a=n.index,c=n[0].length;i.push({match:t.slice(a,a+c),index:a,length:c,bindingToken:n[s?1:2],groupToken:n[s?2:1],accessDeclaration:n[3]?.trim(),name:n[4]}),n=o.exec(r)}}return i.sort((o,n)=>o.index-n.index)}function bf(t,e,r){let i=Ir(t,e);if(!i.length)return t;let o="",n=0;for(let s of i)o+=t.slice(n,s.index),o+=r(s),n=s.index+s.length;return o+=t.slice(n),o}function Tf(t){return/@binding\(\s*auto\s*\)/.test(vs(t))}function og(t,e){return Ir(t,e===xi||e===Ps?Ix:e).find(i=>i.bindingToken==="auto")}var ng=[new RegExp(`@binding\\(\\s*(\\d+)\\s*\\)\\s*@group\\(\\s*(\\d+)\\s*\\)\\s*${we}\\s*:\\s*([^;]+);`,"g"),new RegExp(`@group\\(\\s*(\\d+)\\s*\\)\\s*@binding\\(\\s*(\\d+)\\s*\\)\\s*${we}\\s*:\\s*([^;]+);`,"g")];function Ms(t,e=[]){let r=vs(t),i=new Map;for(let n of e)i.set(sg(n.name,n.group,n.location),n.moduleName);let o=[];for(let n of ng){n.lastIndex=0;let s;for(s=n.exec(r);s;){let a=n===ng[0],c=Number(s[a?1:2]),l=Number(s[a?2:1]),f=s[3]?.trim(),h=s[4],u=s[5].trim(),d=i.get(sg(h,l,c));o.push(Ox({name:h,group:l,binding:c,owner:d?"module":"application",moduleName:d,accessDeclaration:f,resourceType:u})),s=n.exec(r)}}return o.sort((n,s)=>n.group!==s.group?n.group-s.group:n.binding!==s.binding?n.binding-s.binding:n.name.localeCompare(s.name))}function Ox(t){let e={name:t.name,group:t.group,binding:t.binding,owner:t.owner,kind:"unknown",moduleName:t.moduleName,resourceType:t.resourceType};if(t.accessDeclaration){let r=t.accessDeclaration.split(",").map(i=>i.trim());if(r[0]==="uniform")return{...e,kind:"uniform",access:"uniform"};if(r[0]==="storage"){let i=r[1]||"read_write";return{...e,kind:i==="read"?"read-only-storage":"storage",access:i}}}return t.resourceType==="sampler"||t.resourceType==="sampler_comparison"?{...e,kind:"sampler",samplerKind:t.resourceType==="sampler_comparison"?"comparison":"filtering"}:t.resourceType.startsWith("texture_storage_")?{...e,kind:"storage-texture",access:Dx(t.resourceType),viewDimension:ag(t.resourceType)}:t.resourceType.startsWith("texture_")?{...e,kind:"texture",viewDimension:ag(t.resourceType),sampleType:Nx(t.resourceType),multisampled:t.resourceType.startsWith("texture_multisampled_")}:e}function sg(t,e,r){return`${e}:${r}:${t}`}function ag(t){if(t.includes("cube_array"))return"cube-array";if(t.includes("2d_array"))return"2d-array";if(t.includes("cube"))return"cube";if(t.includes("3d"))return"3d";if(t.includes("2d"))return"2d";if(t.includes("1d"))return"1d"}function Nx(t){if(t.startsWith("texture_depth_"))return"depth";if(t.includes("<i32>"))return"sint";if(t.includes("<u32>"))return"uint";if(t.includes("<f32>"))return"float"}function Dx(t){return/,\s*([A-Za-z_][A-Za-z0-9_]*)\s*>$/.exec(t)?.[1]}var xf=`
|
|
76
76
|
|
|
77
|
-
${
|
|
78
|
-
`,
|
|
79
|
-
`;function
|
|
77
|
+
${yo}
|
|
78
|
+
`,To=100,Bx=`precision highp float;
|
|
79
|
+
`;function hg(t){let e=Ti(t.modules||[]),{source:r,bindingAssignments:i}=Fx(t.platformInfo,{...t,source:t.source,stage:"vertex",modules:e});return{source:r,getUniforms:dg(e),bindingAssignments:i,bindingTable:Ms(r,i)}}function ug(t){let{vs:e,fs:r}=t,i=Ti(t.modules||[]);return{vs:cg(t.platformInfo,{...t,source:e,stage:"vertex",modules:i}),fs:cg(t.platformInfo,{...t,source:r,stage:"fragment",modules:i}),getUniforms:dg(i)}}function Fx(t,e){let{source:r,stage:i,modules:o,hookFunctions:n=[],inject:s={},log:a}=e;Mr(typeof r=="string","shader source must be a string");let c=r,l="",f=yf(n),h={},u={},d={};for(let y in s){let T=typeof s[y]=="string"?{injection:s[y],order:0}:s[y],S=/^(v|f)s:(#)?([\w-]+)$/.exec(y);if(S){let A=S[2],w=S[3];A?w==="decl"?u[y]=[T]:d[y]=[T]:h[y]=[T]}else d[y]=[T]}let p=o,g=kx(c),m=Ux(g.source),_=jx(p,e._bindingRegistry,m),b=[];for(let y of p){a&&gf(y,c,a);let T=Vx(pg(y,"wgsl",a),y,{usedBindingsByGroup:m,bindingRegistry:e._bindingRegistry,reservedBindingKeysByGroup:_});b.push(...T.bindingAssignments);let S=T.source;l+=S;let A=y.injections?.[i]||{};for(let w in A){let P=/^(v|f)s:#([\w-]+)$/.exec(w);if(P){let v=P[2]==="decl"?u:d;v[w]=v[w]||[],v[w].push(A[w])}else h[w]=h[w]||[],h[w].push(A[w])}}return l+=xf,l=bo(l,i,u),l+=_f(f[i],h),l+=Kx(b),l+=g.source,l=bo(l,i,d),Yx(l),{source:l,bindingAssignments:b}}function cg(t,e){let{source:r,stage:i,language:o="glsl",modules:n,defines:s={},hookFunctions:a=[],inject:c={},prologue:l=!0,log:f}=e;Mr(typeof r=="string","shader source must be a string");let h=o==="glsl"?rg(r).version:-1,u=t.shaderLanguageVersion,d=h===100?"#version 100":"#version 300 es",g=r.split(`
|
|
80
80
|
`).slice(1).join(`
|
|
81
81
|
`),m={};n.forEach(A=>{Object.assign(m,A.defines)}),Object.assign(m,s);let _="";switch(o){case"wgsl":break;case"glsl":_=l?`${d}
|
|
82
82
|
|
|
83
83
|
// ----- PROLOGUE -------------------------
|
|
84
84
|
${`#define SHADER_TYPE_${i.toUpperCase()}`}
|
|
85
85
|
|
|
86
|
-
${
|
|
87
|
-
${i==="fragment"?
|
|
86
|
+
${Qp(t)}
|
|
87
|
+
${i==="fragment"?Bx:""}
|
|
88
88
|
|
|
89
89
|
// ----- APPLICATION DEFINES -------------------------
|
|
90
90
|
|
|
91
91
|
${Lx(m)}
|
|
92
92
|
|
|
93
93
|
`:`${d}
|
|
94
|
-
`;break}let b=
|
|
95
|
-
`)}return e}function
|
|
94
|
+
`;break}let b=yf(a),y={},T={},S={};for(let A in c){let w=typeof c[A]=="string"?{injection:c[A],order:0}:c[A],P=/^(v|f)s:(#)?([\w-]+)$/.exec(A);if(P){let R=P[2],v=P[3];R?v==="decl"?T[A]=[w]:S[A]=[w]:y[A]=[w]}else S[A]=[w]}for(let A of n){f&&gf(A,g,f);let w=pg(A,i,f);_+=w;let P=A.instance?.normalizedInjections[i]||{};for(let R in P){let v=/^(v|f)s:#([\w-]+)$/.exec(R);if(v){let C=v[2]==="decl"?T:S;C[R]=C[R]||[],C[R].push(P[R])}else y[R]=y[R]||[],y[R].push(P[R])}}return _+="// ----- MAIN SHADER SOURCE -------------------------",_+=xf,_=bo(_,i,T),_+=_f(b[i],y),_+=g,_=bo(_,i,S),o==="glsl"&&h!==u&&(_=eg(_,i)),o==="glsl"&&Gp(_,i,f),_.trim()}function dg(t){return function(r){let i={};for(let o of t){let n=o.getUniforms?.(r,i);Object.assign(i,n)}return i}}function Lx(t={}){let e="";for(let r in t){let i=t[r];(i||Number.isFinite(i))&&(e+=`#define ${r.toUpperCase()} ${t[r]}
|
|
95
|
+
`)}return e}function pg(t,e,r){let i;switch(e){case"vertex":i=t.vs||"";break;case"fragment":i=t.fs||"";break;case"wgsl":i=t.source||"";break;default:Mr(!1)}if(!t.name)throw new Error("Shader module must have a name");Zp(t,e,{log:r});let o=t.name.toUpperCase().replace(/[^0-9a-z]/gi,"_"),n=`// ----- MODULE ${t.name} ---------------
|
|
96
96
|
|
|
97
97
|
`;return e!=="wgsl"&&(n+=`#define MODULE_${o}
|
|
98
98
|
`),n+=`${i}
|
|
99
|
-
`,n}function
|
|
99
|
+
`,n}function Ux(t){let e=new Map;for(let r of Ir(t,ig)){let i=Number(r.bindingToken),o=Number(r.groupToken);Af(o,i,r.name),Ai(e,o,i,`application binding "${r.name}"`)}return e}function kx(t){let e=Ir(t,Ps),r=new Map;for(let n of e){if(n.bindingToken==="auto")continue;let s=Number(n.bindingToken),a=Number(n.groupToken);Af(a,s,n.name),Ai(r,a,s,`application binding "${n.name}"`)}let i={sawSupportedBindingDeclaration:e.length>0},o=bf(t,Ps,n=>Wx(n,r,i));if(Tf(t)&&!i.sawSupportedBindingDeclaration)throw new Error('Unsupported @binding(auto) declaration form in application WGSL. Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.');return{source:o}}function Vx(t,e,r){let i=[],n={sawSupportedBindingDeclaration:Ir(t,xi).length>0,nextHintedBindingLocation:typeof e.firstBindingSlot=="number"?e.firstBindingSlot:null},s=bf(t,xi,a=>zx(a,{module:e,context:r,bindingAssignments:i,relocationState:n}));if(Tf(t)&&!n.sawSupportedBindingDeclaration)throw new Error(`Unsupported @binding(auto) declaration form in module "${e.name}". Use adjacent "@group(N)" and "@binding(auto)" decorators followed by a bindable "var" declaration.`);return{source:s,bindingAssignments:i}}function zx(t,e){let{module:r,context:i,bindingAssignments:o,relocationState:n}=e,{match:s,bindingToken:a,groupToken:c,name:l}=t,f=Number(c);if(a==="auto"){let u=gg(f,r.name,l),d=i.bindingRegistry?.get(u),p=d!==void 0?d:n.nextHintedBindingLocation===null?fg(f,i.usedBindingsByGroup):fg(f,i.usedBindingsByGroup,n.nextHintedBindingLocation);return lg(r.name,f,p,l),d!==void 0&&$x(i.reservedBindingKeysByGroup,f,p,u)?(o.push({moduleName:r.name,name:l,group:f,location:p}),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`)):(Ai(i.usedBindingsByGroup,f,p,`module "${r.name}" binding "${l}"`),i.bindingRegistry?.set(u,p),o.push({moduleName:r.name,name:l,group:f,location:p}),n.nextHintedBindingLocation!==null&&d===void 0&&(n.nextHintedBindingLocation=p+1),s.replace(/@binding\(\s*auto\s*\)/,`@binding(${p})`))}let h=Number(a);return lg(r.name,f,h,l),Ai(i.usedBindingsByGroup,f,h,`module "${r.name}" binding "${l}"`),o.push({moduleName:r.name,name:l,group:f,location:h}),s}function Wx(t,e,r){let{match:i,bindingToken:o,groupToken:n,name:s}=t,a=Number(n);if(o==="auto"){let c=Xx(a,e);return Af(a,c,s),Ai(e,a,c,`application binding "${s}"`),i.replace(/@binding\(\s*auto\s*\)/,`@binding(${c})`)}return r.sawSupportedBindingDeclaration=!0,i}function jx(t,e,r){let i=new Map;if(!e)return i;for(let o of t)for(let n of Hx(o)){let s=gg(n.group,o.name,n.name),a=e.get(s);if(a!==void 0){let c=i.get(n.group)||new Map,l=c.get(a);if(l&&l!==s)throw new Error(`Duplicate WGSL binding reservation for modules "${l}" and "${s}": group ${n.group}, binding ${a}.`);Ai(r,n.group,a,`registered module binding "${s}"`),c.set(a,s),i.set(n.group,c)}}return i}function $x(t,e,r,i){let o=t.get(e);if(!o)return!1;let n=o.get(r);if(!n)return!1;if(n!==i)throw new Error(`Registered module binding "${i}" collided with "${n}": group ${e}, binding ${r}.`);return!0}function Hx(t){let e=[],r=t.source||"";for(let i of Ir(r,xi))e.push({name:i.name,group:Number(i.groupToken)});return e}function Af(t,e,r){if(t===0&&e>=To)throw new Error(`Application binding "${r}" in group 0 uses reserved binding ${e}. Application-owned explicit group-0 bindings must stay below ${To}.`)}function lg(t,e,r,i){if(e===0&&r<To)throw new Error(`Module "${t}" binding "${i}" in group 0 uses reserved application binding ${r}. Module-owned explicit group-0 bindings must be ${To} or higher.`)}function Ai(t,e,r,i){let o=t.get(e)||new Set;if(o.has(r))throw new Error(`Duplicate WGSL binding assignment for ${i}: group ${e}, binding ${r}.`);o.add(r),t.set(e,o)}function fg(t,e,r){let i=e.get(t)||new Set,o=r??(t===0?To:i.size>0?Math.max(...i)+1:0);for(;i.has(o);)o++;return o}function Xx(t,e){let r=e.get(t)||new Set,i=0;for(;r.has(i);)i++;return i}function Yx(t){let e=og(t,xi);if(!e)return;let r=Zx(t,e.index);throw r?new Error(`Unresolved @binding(auto) for module "${r}" binding "${e.name}" remained in assembled WGSL source.`):qx(t,e.index)?new Error(`Unresolved @binding(auto) for application binding "${e.name}" remained in assembled WGSL source.`):new Error(`Unresolved @binding(auto) remained in assembled WGSL source near "${Gx(e.match)}".`)}function Kx(t){if(t.length===0)return"";let e=`// ----- MODULE WGSL BINDING ASSIGNMENTS ---------------
|
|
100
100
|
`;for(let r of t)e+=`// ${r.moduleName}.${r.name} -> @group(${r.group}) @binding(${r.location})
|
|
101
101
|
`;return e+=`
|
|
102
|
-
`,e}function
|
|
103
|
-
`),i=[],o=[],n=!0;for(let s of r){let a=s.match(
|
|
104
|
-
`)}var
|
|
102
|
+
`,e}function gg(t,e,r){return`${t}:${e}:${r}`}function Zx(t,e){let r=/^\/\/ ----- MODULE ([^\n]+) ---------------$/gm,i,o;for(o=r.exec(t);o&&o.index<=e;)i=o[1],o=r.exec(t);return i}function qx(t,e){let r=t.indexOf(xf);return r>=0?e>r:!0}function Gx(t){return t.replace(/\s+/g," ").trim()}var Sf="([a-zA-Z_][a-zA-Z0-9_]*)",Qx=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Sf}\\s*$`),Jx=new RegExp(`^\\s*\\#\\s*ifndef\\s*${Sf}\\s*(?:\\/\\/.*)?$`),eA=/^\s*\#\s*else\s*(?:\/\/.*)?$/,tA=/^\s*\#\s*endif\s*$/,rA=new RegExp(`^\\s*\\#\\s*ifdef\\s*${Sf}\\s*(?:\\/\\/.*)?$`),iA=/^\s*\#\s*endif\s*(?:\/\/.*)?$/;function mg(t,e){let r=t.split(`
|
|
103
|
+
`),i=[],o=[],n=!0;for(let s of r){let a=s.match(rA)||s.match(Qx),c=s.match(Jx),l=s.match(eA),f=s.match(iA)||s.match(tA);if(a||c){let h=(a||c)?.[1],u=Boolean(e?.defines?.[h]),d=a?u:!u,p=n&&d;o.push({parentActive:n,branchTaken:d,active:p}),n=p}else if(l){let h=o[o.length-1];if(!h)throw new Error("Encountered #else without matching #ifdef or #ifndef");h.active=h.parentActive&&!h.branchTaken,h.branchTaken=!0,n=h.active}else f?(o.pop(),n=o.length?o[o.length-1].active:!0):n&&i.push(s)}if(o.length>0)throw new Error("Unterminated conditional block in shader source");return i.join(`
|
|
104
|
+
`)}var Si=class{_hookFunctions=[];_defaultModules=[];_wgslBindingRegistry=new Map;static getDefaultShaderAssembler(){return Si.defaultShaderAssembler=Si.defaultShaderAssembler||new Si,Si.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(r=>r.name===(typeof e=="string"?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){let r=typeof e=="string"?e:e.name;this._defaultModules=this._defaultModules.filter(i=>i.name!==r)}addShaderHook(e,r){r&&(e=Object.assign(r,{hook:e})),this._hookFunctions.push(e)}assembleWGSLShader(e){let r=this._getModuleList(e.modules),i=this._hookFunctions,{source:o,getUniforms:n,bindingAssignments:s}=hg({...e,source:e.source,_bindingRegistry:this._wgslBindingRegistry,modules:r,hookFunctions:i}),a={...r.reduce((l,f)=>(Object.assign(l,f.defines),l),{}),...e.defines},c=e.platformInfo.shaderLanguage==="wgsl"?mg(o,{defines:a}):o;return{source:c,getUniforms:n,modules:r,bindingAssignments:s,bindingTable:Ms(c,s)}}assembleGLSLShaderPair(e){let r=this._getModuleList(e.modules),i=this._hookFunctions;return{...ug({...e,vs:e.vs,fs:e.fs,modules:r,hookFunctions:i}),modules:r}}_getModuleList(e=[]){let r=new Array(this._defaultModules.length+e.length),i={},o=0;for(let n=0,s=this._defaultModules.length;n<s;++n){let a=this._defaultModules[n],c=a.name;r[o++]=a,i[c]=!0}for(let n=0,s=e.length;n<s;++n){let a=e[n],c=a.name;i[c]||(r[o++]=a,i[c]=!0)}return r.length=o,Cr(r),r}},tr=Si;M(tr,"defaultShaderAssembler");var oA=`out vec4 transform_output;
|
|
105
105
|
void main() {
|
|
106
106
|
transform_output = vec4(0);
|
|
107
|
-
}`,
|
|
108
|
-
${
|
|
107
|
+
}`,nA=`#version 300 es
|
|
108
|
+
${oA}`;function xo(t){let{input:e,inputChannels:r,output:i}=t||{};if(!e)return nA;if(!r)throw new Error("inputChannels");let o=sA(r),n=_g(e,r);return`#version 300 es
|
|
109
109
|
in ${o} ${e};
|
|
110
110
|
out vec4 ${i};
|
|
111
111
|
void main() {
|
|
112
112
|
${i} = ${n};
|
|
113
|
-
}`}function nA(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${t}`)}}function mg(t,e){switch(e){case 1:return`vec4(${t}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${t}, 0.0, 1.0)`;case 3:return`vec4(${t}, 1.0)`;case 4:return t;default:throw new Error(`invalid channels: ${e}`)}}var sA=1/Math.PI*180,aA=1/180*Math.PI,cA={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...cA}};var te=globalThis.mathgl.config;function xo(t,{precision:e=te.precision}={}){return t=lA(t),`${parseFloat(t.toPrecision(e))}`}function It(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Si(t,e){return Af(t,r=>r*aA,e)}function ir(t,e){return Af(t,r=>r*sA,e)}function U(t,e,r){return Af(t,i=>Math.max(e,Math.min(r,i)))}function Ot(t,e,r){return It(t)?t.map((i,o)=>Ot(i,e[o],r)):r*e+(1-r)*t}function Pe(t,e,r){let i=te.EPSILON;r&&(te.EPSILON=r);try{if(t===e)return!0;if(It(t)&&It(e)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;++o)if(!Pe(t[o],e[o]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=te.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{te.EPSILON=i}}function lA(t){return Math.round(t/te.EPSILON)*te.EPSILON}function fA(t){return t.clone?t.clone():new Array(t.length)}function Af(t,e,r){if(It(t)){let i=t;r=r||fA(i);for(let o=0;o<r.length&&o<i.length;++o){let n=typeof t=="number"?t:t[o];r[o]=e(n,o,r)}return r}return e(t)}var Ei=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let i=0;i<this.ELEMENTS;++i)this[i]=e[i+r];return this.check()}toArray(e=[],r=0){for(let i=0;i<this.ELEMENTS;++i)e[r+i]=this[i];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:It(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(te)}formatString(e){let r="";for(let i=0;i<this.ELEMENTS;++i)r+=(i>0?", ":"")+xo(this[i],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Pe(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,i){if(i===void 0)return this.lerp(this,e,r);for(let o=0;o<this.ELEMENTS;++o){let n=e[o],s=typeof r=="number"?r:r[o];this[o]=n+i*(s-n)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],e[i]),r[i]);return this.check()}add(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]+=r[i];return this.check()}subtract(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]-=r[i];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(te.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 r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],e),r);return this.check()}get elements(){return this}};function hA(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function le(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function Ms(t,e,r=""){if(te.debug&&!hA(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}function Sf(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var Cs=class extends Ei{get x(){return this[0]}set x(e){this[0]=le(e)}get y(){return this[1]}set y(e){this[1]=le(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let i=0;i<this.ELEMENTS;++i){let o=this[i]-e[i];r+=o*o}return le(r)}dot(e){let r=0;for(let i=0;i<this.ELEMENTS;++i)r+=this[i]*e[i];return le(r)}normalize(){let e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]*=r[i];return this.check()}divide(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]/=r[i];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Sf(e>=0&&e<this.ELEMENTS,"index is out of range"),le(this[e])}setComponent(e,r){return Sf(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){return this.add(new this.constructor(e).multiplyScalar(r))}};var ee={};Pt(ee,{add:()=>mA,angle:()=>BA,ceil:()=>_A,clone:()=>uA,copy:()=>pA,create:()=>_g,cross:()=>vA,dist:()=>$A,distance:()=>xg,div:()=>jA,divide:()=>Tg,dot:()=>PA,equals:()=>kA,exactEquals:()=>UA,floor:()=>yA,forEach:()=>YA,fromValues:()=>dA,inverse:()=>wA,len:()=>VA,length:()=>Sg,lerp:()=>MA,max:()=>TA,min:()=>bA,mul:()=>WA,multiply:()=>bg,negate:()=>EA,normalize:()=>RA,random:()=>CA,rotate:()=>DA,round:()=>xA,scale:()=>AA,scaleAndAdd:()=>SA,set:()=>gA,sqrDist:()=>HA,sqrLen:()=>XA,squaredDistance:()=>Ag,squaredLength:()=>Eg,str:()=>FA,sub:()=>zA,subtract:()=>yg,transformMat2:()=>IA,transformMat2d:()=>OA,transformMat3:()=>NA,transformMat4:()=>Ef,zero:()=>LA});var q=typeof Float32Array<"u"?Float32Array:Array,lt=Math.random;function Fe(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var uD=Math.PI/180;function _g(){let t=new q(2);return q!=Float32Array&&(t[0]=0,t[1]=0),t}function uA(t){let e=new q(2);return e[0]=t[0],e[1]=t[1],e}function dA(t,e){let r=new q(2);return r[0]=t,r[1]=e,r}function pA(t,e){return t[0]=e[0],t[1]=e[1],t}function gA(t,e,r){return t[0]=e,t[1]=r,t}function mA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function yg(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function bg(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function Tg(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function _A(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function yA(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function bA(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function TA(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function xA(t,e){return t[0]=Fe(e[0]),t[1]=Fe(e[1]),t}function AA(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function SA(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t}function xg(t,e){let r=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(r*r+i*i)}function Ag(t,e){let r=e[0]-t[0],i=e[1]-t[1];return r*r+i*i}function Sg(t){let e=t[0],r=t[1];return Math.sqrt(e*e+r*r)}function Eg(t){let e=t[0],r=t[1];return e*e+r*r}function EA(t,e){return t[0]=-e[0],t[1]=-e[1],t}function wA(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function RA(t,e){let r=e[0],i=e[1],o=r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t}function PA(t,e){return t[0]*e[0]+t[1]*e[1]}function vA(t,e,r){let i=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=i,t}function MA(t,e,r,i){let o=e[0],n=e[1];return t[0]=o+i*(r[0]-o),t[1]=n+i*(r[1]-n),t}function CA(t,e){e=e===void 0?1:e;let r=lt()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function IA(t,e,r){let i=e[0],o=e[1];return t[0]=r[0]*i+r[2]*o,t[1]=r[1]*i+r[3]*o,t}function OA(t,e,r){let i=e[0],o=e[1];return t[0]=r[0]*i+r[2]*o+r[4],t[1]=r[1]*i+r[3]*o+r[5],t}function NA(t,e,r){let i=e[0],o=e[1];return t[0]=r[0]*i+r[3]*o+r[6],t[1]=r[1]*i+r[4]*o+r[7],t}function Ef(t,e,r){let i=e[0],o=e[1];return t[0]=r[0]*i+r[4]*o+r[12],t[1]=r[1]*i+r[5]*o+r[13],t}function DA(t,e,r,i){let o=e[0]-r[0],n=e[1]-r[1],s=Math.sin(i),a=Math.cos(i);return t[0]=o*a-n*s+r[0],t[1]=o*s+n*a+r[1],t}function BA(t,e){let r=t[0],i=t[1],o=e[0],n=e[1],s=Math.sqrt((r*r+i*i)*(o*o+n*n)),a=s&&(r*o+i*n)/s;return Math.acos(Math.min(Math.max(a,-1),1))}function LA(t){return t[0]=0,t[1]=0,t}function FA(t){return`vec2(${t[0]}, ${t[1]})`}function UA(t,e){return t[0]===e[0]&&t[1]===e[1]}function kA(t,e){let r=t[0],i=t[1],o=e[0],n=e[1];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-n)<=1e-6*Math.max(1,Math.abs(i),Math.abs(n))}var VA=Sg,zA=yg,WA=bg,jA=Tg,$A=xg,HA=Ag,XA=Eg,YA=function(){let t=_g();return function(e,r,i,o,n,s){let a,c;for(r||(r=2),i||(i=0),o?c=Math.min(o*r+i,e.length):c=e.length,a=i;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],n(t,t,s),e[a]=t[0],e[a+1]=t[1];return e}}();function wg(t,e,r){let i=e[0],o=e[1],n=r[3]*i+r[7]*o||1;return t[0]=(r[0]*i+r[4]*o)/n,t[1]=(r[1]*i+r[5]*o)/n,t}function Os(t,e,r){let i=e[0],o=e[1],n=e[2],s=r[3]*i+r[7]*o+r[11]*n||1;return t[0]=(r[0]*i+r[4]*o+r[8]*n)/s,t[1]=(r[1]*i+r[5]*o+r[9]*n)/s,t[2]=(r[2]*i+r[6]*o+r[10]*n)/s,t}function Rg(t,e,r){let i=e[0],o=e[1];return t[0]=r[0]*i+r[2]*o,t[1]=r[1]*i+r[3]*o,t[2]=e[2],t}var pe={};Pt(pe,{add:()=>QA,angle:()=>Of,bezier:()=>u1,ceil:()=>JA,clone:()=>KA,copy:()=>qA,create:()=>Pg,cross:()=>Rf,dist:()=>x1,distance:()=>Ig,div:()=>T1,divide:()=>Cg,dot:()=>wf,equals:()=>_1,exactEquals:()=>m1,floor:()=>e1,forEach:()=>w1,fromValues:()=>ZA,hermite:()=>h1,inverse:()=>a1,len:()=>S1,length:()=>Ns,lerp:()=>l1,max:()=>r1,min:()=>t1,mul:()=>b1,multiply:()=>Mg,negate:()=>s1,normalize:()=>c1,random:()=>d1,rotateX:()=>Mf,rotateY:()=>Cf,rotateZ:()=>If,round:()=>i1,scale:()=>o1,scaleAndAdd:()=>n1,set:()=>GA,slerp:()=>f1,sqrDist:()=>A1,sqrLen:()=>E1,squaredDistance:()=>Og,squaredLength:()=>Ng,str:()=>g1,sub:()=>y1,subtract:()=>vg,transformMat3:()=>Pf,transformMat4:()=>Ao,transformQuat:()=>vf,zero:()=>p1});function Pg(){let t=new q(3);return q!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function KA(t){let e=new q(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Ns(t){let e=t[0],r=t[1],i=t[2];return Math.sqrt(e*e+r*r+i*i)}function ZA(t,e,r){let i=new q(3);return i[0]=t,i[1]=e,i[2]=r,i}function qA(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function GA(t,e,r,i){return t[0]=e,t[1]=r,t[2]=i,t}function QA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function vg(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function Mg(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function Cg(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function JA(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function e1(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function t1(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function r1(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function i1(t,e){return t[0]=Fe(e[0]),t[1]=Fe(e[1]),t[2]=Fe(e[2]),t}function o1(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function n1(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t}function Ig(t,e){let r=e[0]-t[0],i=e[1]-t[1],o=e[2]-t[2];return Math.sqrt(r*r+i*i+o*o)}function Og(t,e){let r=e[0]-t[0],i=e[1]-t[1],o=e[2]-t[2];return r*r+i*i+o*o}function Ng(t){let e=t[0],r=t[1],i=t[2];return e*e+r*r+i*i}function s1(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function a1(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function c1(t,e){let r=e[0],i=e[1],o=e[2],n=r*r+i*i+o*o;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function wf(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Rf(t,e,r){let i=e[0],o=e[1],n=e[2],s=r[0],a=r[1],c=r[2];return t[0]=o*c-n*a,t[1]=n*s-i*c,t[2]=i*a-o*s,t}function l1(t,e,r,i){let o=e[0],n=e[1],s=e[2];return t[0]=o+i*(r[0]-o),t[1]=n+i*(r[1]-n),t[2]=s+i*(r[2]-s),t}function f1(t,e,r,i){let o=Math.acos(Math.min(Math.max(wf(e,r),-1),1)),n=Math.sin(o),s=Math.sin((1-i)*o)/n,a=Math.sin(i*o)/n;return t[0]=s*e[0]+a*r[0],t[1]=s*e[1]+a*r[1],t[2]=s*e[2]+a*r[2],t}function h1(t,e,r,i,o,n){let s=n*n,a=s*(2*n-3)+1,c=s*(n-2)+n,l=s*(n-1),f=s*(3-2*n);return t[0]=e[0]*a+r[0]*c+i[0]*l+o[0]*f,t[1]=e[1]*a+r[1]*c+i[1]*l+o[1]*f,t[2]=e[2]*a+r[2]*c+i[2]*l+o[2]*f,t}function u1(t,e,r,i,o,n){let s=1-n,a=s*s,c=n*n,l=a*s,f=3*n*a,h=3*c*s,u=c*n;return t[0]=e[0]*l+r[0]*f+i[0]*h+o[0]*u,t[1]=e[1]*l+r[1]*f+i[1]*h+o[1]*u,t[2]=e[2]*l+r[2]*f+i[2]*h+o[2]*u,t}function d1(t,e){e=e===void 0?1:e;let r=lt()*2*Math.PI,i=lt()*2-1,o=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*o,t[1]=Math.sin(r)*o,t[2]=i*e,t}function Ao(t,e,r){let i=e[0],o=e[1],n=e[2],s=r[3]*i+r[7]*o+r[11]*n+r[15];return s=s||1,t[0]=(r[0]*i+r[4]*o+r[8]*n+r[12])/s,t[1]=(r[1]*i+r[5]*o+r[9]*n+r[13])/s,t[2]=(r[2]*i+r[6]*o+r[10]*n+r[14])/s,t}function Pf(t,e,r){let i=e[0],o=e[1],n=e[2];return t[0]=i*r[0]+o*r[3]+n*r[6],t[1]=i*r[1]+o*r[4]+n*r[7],t[2]=i*r[2]+o*r[5]+n*r[8],t}function vf(t,e,r){let i=r[0],o=r[1],n=r[2],s=r[3],a=e[0],c=e[1],l=e[2],f=o*l-n*c,h=n*a-i*l,u=i*c-o*a,d=o*u-n*h,p=n*f-i*u,g=i*h-o*f,m=s*2;return f*=m,h*=m,u*=m,d*=2,p*=2,g*=2,t[0]=a+f+d,t[1]=c+h+p,t[2]=l+u+g,t}function Mf(t,e,r,i){let o=[],n=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],n[0]=o[0],n[1]=o[1]*Math.cos(i)-o[2]*Math.sin(i),n[2]=o[1]*Math.sin(i)+o[2]*Math.cos(i),t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function Cf(t,e,r,i){let o=[],n=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],n[0]=o[2]*Math.sin(i)+o[0]*Math.cos(i),n[1]=o[1],n[2]=o[2]*Math.cos(i)-o[0]*Math.sin(i),t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function If(t,e,r,i){let o=[],n=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],n[0]=o[0]*Math.cos(i)-o[1]*Math.sin(i),n[1]=o[0]*Math.sin(i)+o[1]*Math.cos(i),n[2]=o[2],t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function Of(t,e){let r=t[0],i=t[1],o=t[2],n=e[0],s=e[1],a=e[2],c=Math.sqrt((r*r+i*i+o*o)*(n*n+s*s+a*a)),l=c&&wf(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function p1(t){return t[0]=0,t[1]=0,t[2]=0,t}function g1(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function m1(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function _1(t,e){let r=t[0],i=t[1],o=t[2],n=e[0],s=e[1],a=e[2];return Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(i-s)<=1e-6*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(o-a)<=1e-6*Math.max(1,Math.abs(o),Math.abs(a))}var y1=vg,b1=Mg,T1=Cg,x1=Ig,A1=Og,S1=Ns,E1=Ng,w1=function(){let t=Pg();return function(e,r,i,o,n,s){let a,c;for(r||(r=3),i||(i=0),o?c=Math.min(o*r+i,e.length):c=e.length,a=i;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],n(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();var Nf=[0,0,0],Ds,$=class extends Cs{static get ZERO(){return Ds||(Ds=new $(0,0,0),Object.freeze(Ds)),Ds}constructor(e=0,r=0,i=0){super(-0,-0,-0),arguments.length===1&&It(e)?this.copy(e):(te.debug&&(le(e),le(r),le(i)),this[0]=e,this[1]=r,this[2]=i)}set(e,r,i){return this[0]=e,this[1]=r,this[2]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return te.debug&&(le(e.x),le(e.y),le(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]=le(e)}angle(e){return Of(this,e)}cross(e){return Rf(this,this,e),this.check()}rotateX({radians:e,origin:r=Nf}){return Mf(this,this,r,e),this.check()}rotateY({radians:e,origin:r=Nf}){return Cf(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=Nf}){return If(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Ao(this,this,e),this.check()}transformAsVector(e){return Os(this,this,e),this.check()}transformByMatrix3(e){return Pf(this,this,e),this.check()}transformByMatrix2(e){return Rg(this,this,e),this.check()}transformByQuaternion(e){return vf(this,this,e),this.check()}};var Bs=class extends Ei{toString(){let e="[";if(te.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let i=0;i<this.RANK;++i)e+=` ${this[i*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,i){return this[r*this.RANK+e]=le(i),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let i=e*this.RANK;for(let o=0;o<this.RANK;++o)r[o]=this[i+o];return r}setColumn(e,r){let i=e*this.RANK;for(let o=0;o<this.RANK;++o)this[i+o]=r[o];return this}};var re={};Pt(re,{add:()=>q1,adjoint:()=>I1,clone:()=>P1,copy:()=>v1,create:()=>R1,decompose:()=>z1,determinant:()=>Lf,equals:()=>eS,exactEquals:()=>J1,frob:()=>Z1,fromQuat:()=>jf,fromQuat2:()=>U1,fromRotation:()=>D1,fromRotationTranslation:()=>Bg,fromRotationTranslationScale:()=>W1,fromRotationTranslationScaleOrigin:()=>j1,fromScaling:()=>N1,fromTranslation:()=>O1,fromValues:()=>M1,fromXRotation:()=>B1,fromYRotation:()=>L1,fromZRotation:()=>F1,frustum:()=>$f,getRotation:()=>V1,getScaling:()=>Lg,getTranslation:()=>k1,identity:()=>Dg,invert:()=>Bf,lookAt:()=>Yf,mul:()=>tS,multiply:()=>So,multiplyScalar:()=>G1,multiplyScalarAndAdd:()=>Q1,ortho:()=>Xf,orthoNO:()=>Ug,orthoZO:()=>X1,perspective:()=>Hf,perspectiveFromFieldOfView:()=>H1,perspectiveNO:()=>Fg,perspectiveZO:()=>$1,rotate:()=>kf,rotateX:()=>Vf,rotateY:()=>zf,rotateZ:()=>Wf,scale:()=>Uf,set:()=>C1,str:()=>K1,sub:()=>rS,subtract:()=>kg,targetTo:()=>Y1,translate:()=>Ff,transpose:()=>Df});function R1(){let t=new q(16);return q!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function P1(t){let e=new q(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function v1(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function M1(t,e,r,i,o,n,s,a,c,l,f,h,u,d,p,g){let m=new q(16);return m[0]=t,m[1]=e,m[2]=r,m[3]=i,m[4]=o,m[5]=n,m[6]=s,m[7]=a,m[8]=c,m[9]=l,m[10]=f,m[11]=h,m[12]=u,m[13]=d,m[14]=p,m[15]=g,m}function C1(t,e,r,i,o,n,s,a,c,l,f,h,u,d,p,g,m){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t[4]=n,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=f,t[10]=h,t[11]=u,t[12]=d,t[13]=p,t[14]=g,t[15]=m,t}function Dg(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Df(t,e){if(t===e){let r=e[1],i=e[2],o=e[3],n=e[6],s=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=n,t[11]=e[14],t[12]=o,t[13]=s,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Bf(t,e){let r=e[0],i=e[1],o=e[2],n=e[3],s=e[4],a=e[5],c=e[6],l=e[7],f=e[8],h=e[9],u=e[10],d=e[11],p=e[12],g=e[13],m=e[14],_=e[15],b=r*a-i*s,y=r*c-o*s,T=r*l-n*s,S=i*c-o*a,A=i*l-n*a,w=o*l-n*c,P=f*g-h*p,R=f*m-u*p,v=f*_-d*p,O=h*m-u*g,C=h*_-d*g,W=u*_-d*m,V=b*W-y*C+T*O+S*v-A*R+w*P;return V?(V=1/V,t[0]=(a*W-c*C+l*O)*V,t[1]=(o*C-i*W-n*O)*V,t[2]=(g*w-m*A+_*S)*V,t[3]=(u*A-h*w-d*S)*V,t[4]=(c*v-s*W-l*R)*V,t[5]=(r*W-o*v+n*R)*V,t[6]=(m*T-p*w-_*y)*V,t[7]=(f*w-u*T+d*y)*V,t[8]=(s*C-a*v+l*P)*V,t[9]=(i*v-r*C-n*P)*V,t[10]=(p*A-g*T+_*b)*V,t[11]=(h*T-f*A-d*b)*V,t[12]=(a*R-s*O-c*P)*V,t[13]=(r*O-i*R+o*P)*V,t[14]=(g*y-p*S-m*b)*V,t[15]=(f*S-h*y+u*b)*V,t):null}function I1(t,e){let r=e[0],i=e[1],o=e[2],n=e[3],s=e[4],a=e[5],c=e[6],l=e[7],f=e[8],h=e[9],u=e[10],d=e[11],p=e[12],g=e[13],m=e[14],_=e[15],b=r*a-i*s,y=r*c-o*s,T=r*l-n*s,S=i*c-o*a,A=i*l-n*a,w=o*l-n*c,P=f*g-h*p,R=f*m-u*p,v=f*_-d*p,O=h*m-u*g,C=h*_-d*g,W=u*_-d*m;return t[0]=a*W-c*C+l*O,t[1]=o*C-i*W-n*O,t[2]=g*w-m*A+_*S,t[3]=u*A-h*w-d*S,t[4]=c*v-s*W-l*R,t[5]=r*W-o*v+n*R,t[6]=m*T-p*w-_*y,t[7]=f*w-u*T+d*y,t[8]=s*C-a*v+l*P,t[9]=i*v-r*C-n*P,t[10]=p*A-g*T+_*b,t[11]=h*T-f*A-d*b,t[12]=a*R-s*O-c*P,t[13]=r*O-i*R+o*P,t[14]=g*y-p*S-m*b,t[15]=f*S-h*y+u*b,t}function Lf(t){let e=t[0],r=t[1],i=t[2],o=t[3],n=t[4],s=t[5],a=t[6],c=t[7],l=t[8],f=t[9],h=t[10],u=t[11],d=t[12],p=t[13],g=t[14],m=t[15],_=e*s-r*n,b=e*a-i*n,y=r*a-i*s,T=l*p-f*d,S=l*g-h*d,A=f*g-h*p,w=e*A-r*S+i*T,P=n*A-s*S+a*T,R=l*y-f*b+h*_,v=d*y-p*b+g*_;return c*w-o*P+m*R-u*v}function So(t,e,r){let i=e[0],o=e[1],n=e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],h=e[8],u=e[9],d=e[10],p=e[11],g=e[12],m=e[13],_=e[14],b=e[15],y=r[0],T=r[1],S=r[2],A=r[3];return t[0]=y*i+T*a+S*h+A*g,t[1]=y*o+T*c+S*u+A*m,t[2]=y*n+T*l+S*d+A*_,t[3]=y*s+T*f+S*p+A*b,y=r[4],T=r[5],S=r[6],A=r[7],t[4]=y*i+T*a+S*h+A*g,t[5]=y*o+T*c+S*u+A*m,t[6]=y*n+T*l+S*d+A*_,t[7]=y*s+T*f+S*p+A*b,y=r[8],T=r[9],S=r[10],A=r[11],t[8]=y*i+T*a+S*h+A*g,t[9]=y*o+T*c+S*u+A*m,t[10]=y*n+T*l+S*d+A*_,t[11]=y*s+T*f+S*p+A*b,y=r[12],T=r[13],S=r[14],A=r[15],t[12]=y*i+T*a+S*h+A*g,t[13]=y*o+T*c+S*u+A*m,t[14]=y*n+T*l+S*d+A*_,t[15]=y*s+T*f+S*p+A*b,t}function Ff(t,e,r){let i=r[0],o=r[1],n=r[2],s,a,c,l,f,h,u,d,p,g,m,_;return e===t?(t[12]=e[0]*i+e[4]*o+e[8]*n+e[12],t[13]=e[1]*i+e[5]*o+e[9]*n+e[13],t[14]=e[2]*i+e[6]*o+e[10]*n+e[14],t[15]=e[3]*i+e[7]*o+e[11]*n+e[15]):(s=e[0],a=e[1],c=e[2],l=e[3],f=e[4],h=e[5],u=e[6],d=e[7],p=e[8],g=e[9],m=e[10],_=e[11],t[0]=s,t[1]=a,t[2]=c,t[3]=l,t[4]=f,t[5]=h,t[6]=u,t[7]=d,t[8]=p,t[9]=g,t[10]=m,t[11]=_,t[12]=s*i+f*o+p*n+e[12],t[13]=a*i+h*o+g*n+e[13],t[14]=c*i+u*o+m*n+e[14],t[15]=l*i+d*o+_*n+e[15]),t}function Uf(t,e,r){let i=r[0],o=r[1],n=r[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function kf(t,e,r,i){let o=i[0],n=i[1],s=i[2],a=Math.sqrt(o*o+n*n+s*s),c,l,f,h,u,d,p,g,m,_,b,y,T,S,A,w,P,R,v,O,C,W,V,J;return a<1e-6?null:(a=1/a,o*=a,n*=a,s*=a,l=Math.sin(r),c=Math.cos(r),f=1-c,h=e[0],u=e[1],d=e[2],p=e[3],g=e[4],m=e[5],_=e[6],b=e[7],y=e[8],T=e[9],S=e[10],A=e[11],w=o*o*f+c,P=n*o*f+s*l,R=s*o*f-n*l,v=o*n*f-s*l,O=n*n*f+c,C=s*n*f+o*l,W=o*s*f+n*l,V=n*s*f-o*l,J=s*s*f+c,t[0]=h*w+g*P+y*R,t[1]=u*w+m*P+T*R,t[2]=d*w+_*P+S*R,t[3]=p*w+b*P+A*R,t[4]=h*v+g*O+y*C,t[5]=u*v+m*O+T*C,t[6]=d*v+_*O+S*C,t[7]=p*v+b*O+A*C,t[8]=h*W+g*V+y*J,t[9]=u*W+m*V+T*J,t[10]=d*W+_*V+S*J,t[11]=p*W+b*V+A*J,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Vf(t,e,r){let i=Math.sin(r),o=Math.cos(r),n=e[4],s=e[5],a=e[6],c=e[7],l=e[8],f=e[9],h=e[10],u=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=n*o+l*i,t[5]=s*o+f*i,t[6]=a*o+h*i,t[7]=c*o+u*i,t[8]=l*o-n*i,t[9]=f*o-s*i,t[10]=h*o-a*i,t[11]=u*o-c*i,t}function zf(t,e,r){let i=Math.sin(r),o=Math.cos(r),n=e[0],s=e[1],a=e[2],c=e[3],l=e[8],f=e[9],h=e[10],u=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*o-l*i,t[1]=s*o-f*i,t[2]=a*o-h*i,t[3]=c*o-u*i,t[8]=n*i+l*o,t[9]=s*i+f*o,t[10]=a*i+h*o,t[11]=c*i+u*o,t}function Wf(t,e,r){let i=Math.sin(r),o=Math.cos(r),n=e[0],s=e[1],a=e[2],c=e[3],l=e[4],f=e[5],h=e[6],u=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*o+l*i,t[1]=s*o+f*i,t[2]=a*o+h*i,t[3]=c*o+u*i,t[4]=l*o-n*i,t[5]=f*o-s*i,t[6]=h*o-a*i,t[7]=u*o-c*i,t}function O1(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function N1(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function D1(t,e,r){let i=r[0],o=r[1],n=r[2],s=Math.sqrt(i*i+o*o+n*n),a,c,l;return s<1e-6?null:(s=1/s,i*=s,o*=s,n*=s,c=Math.sin(e),a=Math.cos(e),l=1-a,t[0]=i*i*l+a,t[1]=o*i*l+n*c,t[2]=n*i*l-o*c,t[3]=0,t[4]=i*o*l-n*c,t[5]=o*o*l+a,t[6]=n*o*l+i*c,t[7]=0,t[8]=i*n*l+o*c,t[9]=o*n*l-i*c,t[10]=n*n*l+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function B1(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function L1(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function F1(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Bg(t,e,r){let i=e[0],o=e[1],n=e[2],s=e[3],a=i+i,c=o+o,l=n+n,f=i*a,h=i*c,u=i*l,d=o*c,p=o*l,g=n*l,m=s*a,_=s*c,b=s*l;return t[0]=1-(d+g),t[1]=h+b,t[2]=u-_,t[3]=0,t[4]=h-b,t[5]=1-(f+g),t[6]=p+m,t[7]=0,t[8]=u+_,t[9]=p-m,t[10]=1-(f+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function U1(t,e){let r=new q(3),i=-e[0],o=-e[1],n=-e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],h=i*i+o*o+n*n+s*s;return h>0?(r[0]=(a*s+f*i+c*n-l*o)*2/h,r[1]=(c*s+f*o+l*i-a*n)*2/h,r[2]=(l*s+f*n+a*o-c*i)*2/h):(r[0]=(a*s+f*i+c*n-l*o)*2,r[1]=(c*s+f*o+l*i-a*n)*2,r[2]=(l*s+f*n+a*o-c*i)*2),Bg(t,e,r),t}function k1(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function Lg(t,e){let r=e[0],i=e[1],o=e[2],n=e[4],s=e[5],a=e[6],c=e[8],l=e[9],f=e[10];return t[0]=Math.sqrt(r*r+i*i+o*o),t[1]=Math.sqrt(n*n+s*s+a*a),t[2]=Math.sqrt(c*c+l*l+f*f),t}function V1(t,e){let r=new q(3);Lg(r,e);let i=1/r[0],o=1/r[1],n=1/r[2],s=e[0]*i,a=e[1]*o,c=e[2]*n,l=e[4]*i,f=e[5]*o,h=e[6]*n,u=e[8]*i,d=e[9]*o,p=e[10]*n,g=s+f+p,m=0;return g>0?(m=Math.sqrt(g+1)*2,t[3]=.25*m,t[0]=(h-d)/m,t[1]=(u-c)/m,t[2]=(a-l)/m):s>f&&s>p?(m=Math.sqrt(1+s-f-p)*2,t[3]=(h-d)/m,t[0]=.25*m,t[1]=(a+l)/m,t[2]=(u+c)/m):f>p?(m=Math.sqrt(1+f-s-p)*2,t[3]=(u-c)/m,t[0]=(a+l)/m,t[1]=.25*m,t[2]=(h+d)/m):(m=Math.sqrt(1+p-s-f)*2,t[3]=(a-l)/m,t[0]=(u+c)/m,t[1]=(h+d)/m,t[2]=.25*m),t}function z1(t,e,r,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];let o=i[0],n=i[1],s=i[2],a=i[4],c=i[5],l=i[6],f=i[8],h=i[9],u=i[10];r[0]=Math.sqrt(o*o+n*n+s*s),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(f*f+h*h+u*u);let d=1/r[0],p=1/r[1],g=1/r[2],m=o*d,_=n*p,b=s*g,y=a*d,T=c*p,S=l*g,A=f*d,w=h*p,P=u*g,R=m+T+P,v=0;return R>0?(v=Math.sqrt(R+1)*2,t[3]=.25*v,t[0]=(S-w)/v,t[1]=(A-b)/v,t[2]=(_-y)/v):m>T&&m>P?(v=Math.sqrt(1+m-T-P)*2,t[3]=(S-w)/v,t[0]=.25*v,t[1]=(_+y)/v,t[2]=(A+b)/v):T>P?(v=Math.sqrt(1+T-m-P)*2,t[3]=(A-b)/v,t[0]=(_+y)/v,t[1]=.25*v,t[2]=(S+w)/v):(v=Math.sqrt(1+P-m-T)*2,t[3]=(_-y)/v,t[0]=(A+b)/v,t[1]=(S+w)/v,t[2]=.25*v),t}function W1(t,e,r,i){let o=e[0],n=e[1],s=e[2],a=e[3],c=o+o,l=n+n,f=s+s,h=o*c,u=o*l,d=o*f,p=n*l,g=n*f,m=s*f,_=a*c,b=a*l,y=a*f,T=i[0],S=i[1],A=i[2];return t[0]=(1-(p+m))*T,t[1]=(u+y)*T,t[2]=(d-b)*T,t[3]=0,t[4]=(u-y)*S,t[5]=(1-(h+m))*S,t[6]=(g+_)*S,t[7]=0,t[8]=(d+b)*A,t[9]=(g-_)*A,t[10]=(1-(h+p))*A,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function j1(t,e,r,i,o){let n=e[0],s=e[1],a=e[2],c=e[3],l=n+n,f=s+s,h=a+a,u=n*l,d=n*f,p=n*h,g=s*f,m=s*h,_=a*h,b=c*l,y=c*f,T=c*h,S=i[0],A=i[1],w=i[2],P=o[0],R=o[1],v=o[2],O=(1-(g+_))*S,C=(d+T)*S,W=(p-y)*S,V=(d-T)*A,J=(1-(u+_))*A,wt=(m+b)*A,Rt=(p+y)*w,md=(m-b)*w,_d=(1-(u+g))*w;return t[0]=O,t[1]=C,t[2]=W,t[3]=0,t[4]=V,t[5]=J,t[6]=wt,t[7]=0,t[8]=Rt,t[9]=md,t[10]=_d,t[11]=0,t[12]=r[0]+P-(O*P+V*R+Rt*v),t[13]=r[1]+R-(C*P+J*R+md*v),t[14]=r[2]+v-(W*P+wt*R+_d*v),t[15]=1,t}function jf(t,e){let r=e[0],i=e[1],o=e[2],n=e[3],s=r+r,a=i+i,c=o+o,l=r*s,f=i*s,h=i*a,u=o*s,d=o*a,p=o*c,g=n*s,m=n*a,_=n*c;return t[0]=1-h-p,t[1]=f+_,t[2]=u-m,t[3]=0,t[4]=f-_,t[5]=1-l-p,t[6]=d+g,t[7]=0,t[8]=u+m,t[9]=d-g,t[10]=1-l-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function $f(t,e,r,i,o,n,s){let a=1/(r-e),c=1/(o-i),l=1/(n-s);return t[0]=n*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(o+i)*c,t[10]=(s+n)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*n*2*l,t[15]=0,t}function Fg(t,e,r,i,o){let n=1/Math.tan(e/2);if(t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let s=1/(i-o);t[10]=(o+i)*s,t[14]=2*o*i*s}else t[10]=-1,t[14]=-2*i;return t}var Hf=Fg;function $1(t,e,r,i,o){let n=1/Math.tan(e/2);if(t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let s=1/(i-o);t[10]=o*s,t[14]=o*i*s}else t[10]=-1,t[14]=-i;return t}function H1(t,e,r,i){let o=Math.tan(e.upDegrees*Math.PI/180),n=Math.tan(e.downDegrees*Math.PI/180),s=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(s+a),l=2/(o+n);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((s-a)*c*.5),t[9]=(o-n)*l*.5,t[10]=i/(r-i),t[11]=-1,t[12]=0,t[13]=0,t[14]=i*r/(r-i),t[15]=0,t}function Ug(t,e,r,i,o,n,s){let a=1/(e-r),c=1/(i-o),l=1/(n-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+i)*c,t[14]=(s+n)*l,t[15]=1,t}var Xf=Ug;function X1(t,e,r,i,o,n,s){let a=1/(e-r),c=1/(i-o),l=1/(n-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+i)*c,t[14]=n*l,t[15]=1,t}function Yf(t,e,r,i){let o,n,s,a,c,l,f,h,u,d,p=e[0],g=e[1],m=e[2],_=i[0],b=i[1],y=i[2],T=r[0],S=r[1],A=r[2];return Math.abs(p-T)<1e-6&&Math.abs(g-S)<1e-6&&Math.abs(m-A)<1e-6?Dg(t):(h=p-T,u=g-S,d=m-A,o=1/Math.sqrt(h*h+u*u+d*d),h*=o,u*=o,d*=o,n=b*d-y*u,s=y*h-_*d,a=_*u-b*h,o=Math.sqrt(n*n+s*s+a*a),o?(o=1/o,n*=o,s*=o,a*=o):(n=0,s=0,a=0),c=u*a-d*s,l=d*n-h*a,f=h*s-u*n,o=Math.sqrt(c*c+l*l+f*f),o?(o=1/o,c*=o,l*=o,f*=o):(c=0,l=0,f=0),t[0]=n,t[1]=c,t[2]=h,t[3]=0,t[4]=s,t[5]=l,t[6]=u,t[7]=0,t[8]=a,t[9]=f,t[10]=d,t[11]=0,t[12]=-(n*p+s*g+a*m),t[13]=-(c*p+l*g+f*m),t[14]=-(h*p+u*g+d*m),t[15]=1,t)}function Y1(t,e,r,i){let o=e[0],n=e[1],s=e[2],a=i[0],c=i[1],l=i[2],f=o-r[0],h=n-r[1],u=s-r[2],d=f*f+h*h+u*u;d>0&&(d=1/Math.sqrt(d),f*=d,h*=d,u*=d);let p=c*u-l*h,g=l*f-a*u,m=a*h-c*f;return d=p*p+g*g+m*m,d>0&&(d=1/Math.sqrt(d),p*=d,g*=d,m*=d),t[0]=p,t[1]=g,t[2]=m,t[3]=0,t[4]=h*m-u*g,t[5]=u*p-f*m,t[6]=f*g-h*p,t[7]=0,t[8]=f,t[9]=h,t[10]=u,t[11]=0,t[12]=o,t[13]=n,t[14]=s,t[15]=1,t}function K1(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function Z1(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function q1(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function kg(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function G1(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function Q1(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t[4]=e[4]+r[4]*i,t[5]=e[5]+r[5]*i,t[6]=e[6]+r[6]*i,t[7]=e[7]+r[7]*i,t[8]=e[8]+r[8]*i,t[9]=e[9]+r[9]*i,t[10]=e[10]+r[10]*i,t[11]=e[11]+r[11]*i,t[12]=e[12]+r[12]*i,t[13]=e[13]+r[13]*i,t[14]=e[14]+r[14]*i,t[15]=e[15]+r[15]*i,t}function J1(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function eS(t,e){let r=t[0],i=t[1],o=t[2],n=t[3],s=t[4],a=t[5],c=t[6],l=t[7],f=t[8],h=t[9],u=t[10],d=t[11],p=t[12],g=t[13],m=t[14],_=t[15],b=e[0],y=e[1],T=e[2],S=e[3],A=e[4],w=e[5],P=e[6],R=e[7],v=e[8],O=e[9],C=e[10],W=e[11],V=e[12],J=e[13],wt=e[14],Rt=e[15];return Math.abs(r-b)<=1e-6*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(o-T)<=1e-6*Math.max(1,Math.abs(o),Math.abs(T))&&Math.abs(n-S)<=1e-6*Math.max(1,Math.abs(n),Math.abs(S))&&Math.abs(s-A)<=1e-6*Math.max(1,Math.abs(s),Math.abs(A))&&Math.abs(a-w)<=1e-6*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(c-P)<=1e-6*Math.max(1,Math.abs(c),Math.abs(P))&&Math.abs(l-R)<=1e-6*Math.max(1,Math.abs(l),Math.abs(R))&&Math.abs(f-v)<=1e-6*Math.max(1,Math.abs(f),Math.abs(v))&&Math.abs(h-O)<=1e-6*Math.max(1,Math.abs(h),Math.abs(O))&&Math.abs(u-C)<=1e-6*Math.max(1,Math.abs(u),Math.abs(C))&&Math.abs(d-W)<=1e-6*Math.max(1,Math.abs(d),Math.abs(W))&&Math.abs(p-V)<=1e-6*Math.max(1,Math.abs(p),Math.abs(V))&&Math.abs(g-J)<=1e-6*Math.max(1,Math.abs(g),Math.abs(J))&&Math.abs(m-wt)<=1e-6*Math.max(1,Math.abs(m),Math.abs(wt))&&Math.abs(_-Rt)<=1e-6*Math.max(1,Math.abs(_),Math.abs(Rt))}var tS=So,rS=kg;var xe={};Pt(xe,{add:()=>aS,ceil:()=>cS,clone:()=>iS,copy:()=>nS,create:()=>Vg,cross:()=>bS,dist:()=>CS,distance:()=>$g,div:()=>MS,divide:()=>jg,dot:()=>yS,equals:()=>RS,exactEquals:()=>wS,floor:()=>lS,forEach:()=>DS,fromValues:()=>oS,inverse:()=>mS,len:()=>OS,length:()=>Xg,lerp:()=>TS,max:()=>hS,min:()=>fS,mul:()=>vS,multiply:()=>Wg,negate:()=>gS,normalize:()=>_S,random:()=>xS,round:()=>uS,scale:()=>dS,scaleAndAdd:()=>pS,set:()=>sS,sqrDist:()=>IS,sqrLen:()=>NS,squaredDistance:()=>Hg,squaredLength:()=>Yg,str:()=>ES,sub:()=>PS,subtract:()=>zg,transformMat4:()=>Kf,transformQuat:()=>AS,zero:()=>SS});function Vg(){let t=new q(4);return q!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function iS(t){let e=new q(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function oS(t,e,r,i){let o=new q(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=i,o}function nS(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function sS(t,e,r,i,o){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t}function aS(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function zg(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function Wg(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function jg(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function cS(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function lS(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function fS(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}function hS(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}function uS(t,e){return t[0]=Fe(e[0]),t[1]=Fe(e[1]),t[2]=Fe(e[2]),t[3]=Fe(e[3]),t}function dS(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function pS(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t}function $g(t,e){let r=e[0]-t[0],i=e[1]-t[1],o=e[2]-t[2],n=e[3]-t[3];return Math.sqrt(r*r+i*i+o*o+n*n)}function Hg(t,e){let r=e[0]-t[0],i=e[1]-t[1],o=e[2]-t[2],n=e[3]-t[3];return r*r+i*i+o*o+n*n}function Xg(t){let e=t[0],r=t[1],i=t[2],o=t[3];return Math.sqrt(e*e+r*r+i*i+o*o)}function Yg(t){let e=t[0],r=t[1],i=t[2],o=t[3];return e*e+r*r+i*i+o*o}function gS(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function mS(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function _S(t,e){let r=e[0],i=e[1],o=e[2],n=e[3],s=r*r+i*i+o*o+n*n;return s>0&&(s=1/Math.sqrt(s)),t[0]=r*s,t[1]=i*s,t[2]=o*s,t[3]=n*s,t}function yS(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function bS(t,e,r,i){let o=r[0]*i[1]-r[1]*i[0],n=r[0]*i[2]-r[2]*i[0],s=r[0]*i[3]-r[3]*i[0],a=r[1]*i[2]-r[2]*i[1],c=r[1]*i[3]-r[3]*i[1],l=r[2]*i[3]-r[3]*i[2],f=e[0],h=e[1],u=e[2],d=e[3];return t[0]=h*l-u*c+d*a,t[1]=-(f*l)+u*s-d*n,t[2]=f*c-h*s+d*o,t[3]=-(f*a)+h*n-u*o,t}function TS(t,e,r,i){let o=e[0],n=e[1],s=e[2],a=e[3];return t[0]=o+i*(r[0]-o),t[1]=n+i*(r[1]-n),t[2]=s+i*(r[2]-s),t[3]=a+i*(r[3]-a),t}function xS(t,e){e=e===void 0?1:e;let r,i,o,n,s,a;do r=lt()*2-1,i=lt()*2-1,s=r*r+i*i;while(s>=1);do o=lt()*2-1,n=lt()*2-1,a=o*o+n*n;while(a>=1);let c=Math.sqrt((1-s)/a);return t[0]=e*r,t[1]=e*i,t[2]=e*o*c,t[3]=e*n*c,t}function Kf(t,e,r){let i=e[0],o=e[1],n=e[2],s=e[3];return t[0]=r[0]*i+r[4]*o+r[8]*n+r[12]*s,t[1]=r[1]*i+r[5]*o+r[9]*n+r[13]*s,t[2]=r[2]*i+r[6]*o+r[10]*n+r[14]*s,t[3]=r[3]*i+r[7]*o+r[11]*n+r[15]*s,t}function AS(t,e,r){let i=e[0],o=e[1],n=e[2],s=r[0],a=r[1],c=r[2],l=r[3],f=l*i+a*n-c*o,h=l*o+c*i-s*n,u=l*n+s*o-a*i,d=-s*i-a*o-c*n;return t[0]=f*l+d*-s+h*-c-u*-a,t[1]=h*l+d*-a+u*-s-f*-c,t[2]=u*l+d*-c+f*-a-h*-s,t[3]=e[3],t}function SS(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function ES(t){return`vec4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}function wS(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function RS(t,e){let r=t[0],i=t[1],o=t[2],n=t[3],s=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(o-c)<=1e-6*Math.max(1,Math.abs(o),Math.abs(c))&&Math.abs(n-l)<=1e-6*Math.max(1,Math.abs(n),Math.abs(l))}var PS=zg,vS=Wg,MS=jg,CS=$g,IS=Hg,OS=Xg,NS=Yg,DS=function(){let t=Vg();return function(e,r,i,o,n,s){let a,c;for(r||(r=4),i||(i=0),o?c=Math.min(o*r+i,e.length):c=e.length,a=i;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],n(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();var Gf;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(Gf||(Gf={}));var BS=45*Math.PI/180,LS=1,Zf=.1,qf=500,FS=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),z=class extends Bs{static get IDENTITY(){return kS()}static get ZERO(){return US()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Gf}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,r,i,o,n,s,a,c,l,f,h,u,d,p,g,m){return this[0]=e,this[1]=r,this[2]=i,this[3]=o,this[4]=n,this[5]=s,this[6]=a,this[7]=c,this[8]=l,this[9]=f,this[10]=h,this[11]=u,this[12]=d,this[13]=p,this[14]=g,this[15]=m,this.check()}setRowMajor(e,r,i,o,n,s,a,c,l,f,h,u,d,p,g,m){return this[0]=e,this[1]=n,this[2]=l,this[3]=d,this[4]=r,this[5]=s,this[6]=f,this[7]=p,this[8]=i,this[9]=a,this[10]=h,this[11]=g,this[12]=o,this[13]=c,this[14]=u,this[15]=m,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(FS)}fromObject(e){return this.check()}fromQuaternion(e){return jf(this,e),this.check()}frustum(e){let{left:r,right:i,bottom:o,top:n,near:s=Zf,far:a=qf}=e;return a===1/0?VS(this,r,i,o,n,s):$f(this,r,i,o,n,s,a),this.check()}lookAt(e){let{eye:r,center:i=[0,0,0],up:o=[0,1,0]}=e;return Yf(this,r,i,o),this.check()}ortho(e){let{left:r,right:i,bottom:o,top:n,near:s=Zf,far:a=qf}=e;return Xf(this,r,i,o,n,s,a),this.check()}orthographic(e){let{fovy:r=BS,aspect:i=LS,focalDistance:o=1,near:n=Zf,far:s=qf}=e;Kg(r);let a=r/2,c=o*Math.tan(a),l=c*i;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:n,far:s})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:i=1,near:o=.1,far:n=500}=e;return Kg(r),Hf(this,r,i,o,n),this.check()}determinant(){return Lf(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,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let i=this.getScale(r),o=1/i[0],n=1/i[1],s=1/i[2];return e[0]=this[0]*o,e[1]=this[1]*n,e[2]=this[2]*s,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*n,e[6]=this[6]*s,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*n,e[10]=this[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let i=this.getScale(r),o=1/i[0],n=1/i[1],s=1/i[2];return e[0]=this[0]*o,e[1]=this[1]*n,e[2]=this[2]*s,e[3]=this[4]*o,e[4]=this[5]*n,e[5]=this[6]*s,e[6]=this[8]*o,e[7]=this[9]*n,e[8]=this[10]*s,e}transpose(){return Df(this,this),this.check()}invert(){return Bf(this,this),this.check()}multiplyLeft(e){return So(this,e,this),this.check()}multiplyRight(e){return So(this,this,e),this.check()}rotateX(e){return Vf(this,this,e),this.check()}rotateY(e){return zf(this,this,e),this.check()}rotateZ(e){return Wf(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,r){return kf(this,this,e,r),this.check()}scale(e){return Uf(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return Ff(this,this,e),this.check()}transform(e,r){return e.length===4?(r=Kf(r||[-0,-0,-0,-0],e,this),Ms(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:i}=e,o;switch(i){case 2:o=Ef(r||[-0,-0],e,this);break;case 3:o=Ao(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ms(o,e.length),o}transformAsVector(e,r){let i;switch(e.length){case 2:i=wg(r||[-0,-0],e,this);break;case 3:i=Os(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Ms(i,e.length),i}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,i){return this.identity().translate([e,r,i])}},Ls,Fs;function US(){return Ls||(Ls=new z([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Ls)),Ls}function kS(){return Fs||(Fs=new z,Object.freeze(Fs)),Fs}function Kg(t){if(t>Math.PI*2)throw Error("expected radians")}function VS(t,e,r,i,o,n){let s=2*n/(r-e),a=2*n/(o-i),c=(r+e)/(r-e),l=(o+i)/(o-i),f=-1,h=-1,u=-2*n;return t[0]=s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=f,t[11]=h,t[12]=0,t[13]=0,t[14]=u,t[15]=0,t}var Zg=1e-6,zS=6371e3,je=class{constructor({phi:e=0,theta:r=0,radius:i=1,bearing:o,pitch:n,altitude:s,radiusScale:a=zS}={}){this.phi=e,this.theta=r,this.radius=i||s||1,this.radiusScale=a||1,o!==void 0&&(this.bearing=o),n!==void 0&&(this.pitch=n),this.check()}toString(){return this.formatString(te)}formatString({printTypes:e=!1}){let r=xo;return`${e?"Spherical":""}[rho:${r(this.radius)},theta:${r(this.theta)},phi:${r(this.phi)}]`}equals(e){return Pe(this.radius,e.radius)&&Pe(this.theta,e.theta)&&Pe(this.phi,e.phi)}exactEquals(e){return this.radius===e.radius&&this.theta===e.theta&&this.phi===e.phi}get bearing(){return 180-ir(this.phi)}set bearing(e){this.phi=Math.PI-Si(e)}get pitch(){return ir(this.theta)}set pitch(e){this.theta=Si(e)}get longitude(){return ir(this.phi)}get latitude(){return ir(this.theta)}get lng(){return ir(this.phi)}get lat(){return ir(this.theta)}get z(){return(this.radius-1)*this.radiusScale}set(e,r,i){return this.radius=e,this.phi=r,this.theta=i,this.check()}clone(){return new je().copy(this)}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this.check()}fromLngLatZ([e,r,i]){return this.radius=1+i/this.radiusScale,this.phi=Si(r),this.theta=Si(e),this.check()}fromVector3(e){return this.radius=Ns(e),this.radius>0&&(this.theta=Math.atan2(e[0],e[1]),this.phi=Math.acos(U(e[2]/this.radius,-1,1))),this.check()}toVector3(){return new $(0,0,this.radius).rotateX({radians:this.theta}).rotateZ({radians:this.phi})}makeSafe(){return this.phi=Math.max(Zg,Math.min(Math.PI-Zg,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 Qf(t,e=[],r=0){let i=Math.fround(t),o=t-i;return e[r]=i,e[r+1]=o,e}function qg(t){return t-Math.fround(t)}function Gg(t){let e=new Float32Array(32);for(let r=0;r<4;++r)for(let i=0;i<4;++i){let o=r*4+i;Qf(t[i*4+r],e,o*2)}return e}function Us(t,e=!0){return t??e}function Jf(t=[0,0,0],e=!0){return e?t.map(r=>r/255):[...t]}function Qg(t,e=!0){let r=Jf(t.slice(0,3),e),i=Number.isFinite(t[3]),o=i?t[3]:1;return[r[0],r[1],r[2],e&&i?o/255:o]}var WS=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
|
|
113
|
+
}`}function sA(t){switch(t){case 1:return"float";case 2:return"vec2";case 3:return"vec3";case 4:return"vec4";default:throw new Error(`invalid channels: ${t}`)}}function _g(t,e){switch(e){case 1:return`vec4(${t}, 0.0, 0.0, 1.0)`;case 2:return`vec4(${t}, 0.0, 1.0)`;case 3:return`vec4(${t}, 1.0)`;case 4:return t;default:throw new Error(`invalid channels: ${e}`)}}var aA=1/Math.PI*180,cA=1/180*Math.PI,lA={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...lA}};var ee=globalThis.mathgl.config;function Ao(t,{precision:e=ee.precision}={}){return t=fA(t),`${parseFloat(t.toPrecision(e))}`}function Ct(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Ei(t,e){return Ef(t,r=>r*cA,e)}function rr(t,e){return Ef(t,r=>r*aA,e)}function U(t,e,r){return Ef(t,i=>Math.max(e,Math.min(r,i)))}function It(t,e,r){return Ct(t)?t.map((i,o)=>It(i,e[o],r)):r*e+(1-r)*t}function Re(t,e,r){let i=ee.EPSILON;r&&(ee.EPSILON=r);try{if(t===e)return!0;if(Ct(t)&&Ct(e)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;++o)if(!Re(t[o],e[o]))return!1;return!0}return t&&t.equals?t.equals(e):e&&e.equals?e.equals(t):typeof t=="number"&&typeof e=="number"?Math.abs(t-e)<=ee.EPSILON*Math.max(1,Math.abs(t),Math.abs(e)):!1}finally{ee.EPSILON=i}}function fA(t){return Math.round(t/ee.EPSILON)*ee.EPSILON}function hA(t){return t.clone?t.clone():new Array(t.length)}function Ef(t,e,r){if(Ct(t)){let i=t;r=r||hA(i);for(let o=0;o<r.length&&o<i.length;++o){let n=typeof t=="number"?t:t[o];r[o]=e(n,o,r)}return r}return e(t)}var wi=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(e,r=0){for(let i=0;i<this.ELEMENTS;++i)this[i]=e[i+r];return this.check()}toArray(e=[],r=0){for(let i=0;i<this.ELEMENTS;++i)e[r+i]=this[i];return e}toObject(e){return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:Ct(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(ee)}formatString(e){let r="";for(let i=0;i<this.ELEMENTS;++i)r+=(i>0?", ":"")+Ao(this[i],e);return`${e.printTypes?this.constructor.name:""}[${r}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!Re(this[r],e[r]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==e[r])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,r,i){if(i===void 0)return this.lerp(this,e,r);for(let o=0;o<this.ELEMENTS;++o){let n=e[o],s=typeof r=="number"?r:r[o];this[o]=n+i*(s-n)}return this.check()}min(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(e[r],this[r]);return this.check()}max(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(e[r],this[r]);return this.check()}clamp(e,r){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],e[i]),r[i]);return this.check()}add(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]+=r[i];return this.check()}subtract(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]-=r[i];return this.check()}scale(e){if(typeof e=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;else for(let r=0;r<this.ELEMENTS&&r<e.length;++r)this[r]*=e[r];return this.check()}multiplyByScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}check(){if(ee.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 r=0;r<this.ELEMENTS;++r)e=e&&Number.isFinite(this[r]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]=e;return this.check()}addScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let r=0;r<this.ELEMENTS;++r)this[r]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,r){for(let i=0;i<this.ELEMENTS;++i)this[i]=Math.min(Math.max(this[i],e),r);return this.check()}get elements(){return this}};function uA(t,e){if(t.length!==e)return!1;for(let r=0;r<t.length;++r)if(!Number.isFinite(t[r]))return!1;return!0}function ce(t){if(!Number.isFinite(t))throw new Error(`Invalid number ${JSON.stringify(t)}`);return t}function Cs(t,e,r=""){if(ee.debug&&!uA(t,e))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return t}function wf(t,e){if(!t)throw new Error(`math.gl assertion ${e}`)}var Is=class extends wi{get x(){return this[0]}set x(e){this[0]=ce(e)}get y(){return this[1]}set y(e){this[1]=ce(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let r=0;r<this.ELEMENTS;++r)e+=this[r]*this[r];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let r=0;for(let i=0;i<this.ELEMENTS;++i){let o=this[i]-e[i];r+=o*o}return ce(r)}dot(e){let r=0;for(let i=0;i<this.ELEMENTS;++i)r+=this[i]*e[i];return ce(r)}normalize(){let e=this.magnitude();if(e!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=e;return this.check()}multiply(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]*=r[i];return this.check()}divide(...e){for(let r of e)for(let i=0;i<this.ELEMENTS;++i)this[i]/=r[i];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return wf(e>=0&&e<this.ELEMENTS,"index is out of range"),ce(this[e])}setComponent(e,r){return wf(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=r,this.check()}addVectors(e,r){return this.copy(e).add(r)}subVectors(e,r){return this.copy(e).subtract(r)}multiplyVectors(e,r){return this.copy(e).multiply(r)}addScaledVector(e,r){return this.add(new this.constructor(e).multiplyScalar(r))}};var J={};Rt(J,{add:()=>_A,angle:()=>FA,ceil:()=>yA,clone:()=>dA,copy:()=>gA,create:()=>yg,cross:()=>MA,dist:()=>HA,distance:()=>Ag,div:()=>$A,divide:()=>xg,dot:()=>vA,equals:()=>VA,exactEquals:()=>kA,floor:()=>bA,forEach:()=>KA,fromValues:()=>pA,inverse:()=>RA,len:()=>zA,length:()=>Eg,lerp:()=>CA,max:()=>xA,min:()=>TA,mul:()=>jA,multiply:()=>Tg,negate:()=>wA,normalize:()=>PA,random:()=>IA,rotate:()=>BA,round:()=>AA,scale:()=>SA,scaleAndAdd:()=>EA,set:()=>mA,sqrDist:()=>XA,sqrLen:()=>YA,squaredDistance:()=>Sg,squaredLength:()=>wg,str:()=>UA,sub:()=>WA,subtract:()=>bg,transformMat2:()=>OA,transformMat2d:()=>NA,transformMat3:()=>DA,transformMat4:()=>Rf,zero:()=>LA});var Z=typeof Float32Array<"u"?Float32Array:Array,ct=Math.random;function Fe(t){return t>=0?Math.round(t):t%.5===0?Math.floor(t):Math.round(t)}var mD=Math.PI/180;function yg(){let t=new Z(2);return Z!=Float32Array&&(t[0]=0,t[1]=0),t}function dA(t){let e=new Z(2);return e[0]=t[0],e[1]=t[1],e}function pA(t,e){let r=new Z(2);return r[0]=t,r[1]=e,r}function gA(t,e){return t[0]=e[0],t[1]=e[1],t}function mA(t,e,r){return t[0]=e,t[1]=r,t}function _A(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t}function bg(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t}function Tg(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t}function xg(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t}function yA(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function bA(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function TA(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t}function xA(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t}function AA(t,e){return t[0]=Fe(e[0]),t[1]=Fe(e[1]),t}function SA(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t}function EA(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t}function Ag(t,e){let r=e[0]-t[0],i=e[1]-t[1];return Math.sqrt(r*r+i*i)}function Sg(t,e){let r=e[0]-t[0],i=e[1]-t[1];return r*r+i*i}function Eg(t){let e=t[0],r=t[1];return Math.sqrt(e*e+r*r)}function wg(t){let e=t[0],r=t[1];return e*e+r*r}function wA(t,e){return t[0]=-e[0],t[1]=-e[1],t}function RA(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function PA(t,e){let r=e[0],i=e[1],o=r*r+i*i;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t}function vA(t,e){return t[0]*e[0]+t[1]*e[1]}function MA(t,e,r){let i=e[0]*r[1]-e[1]*r[0];return t[0]=t[1]=0,t[2]=i,t}function CA(t,e,r,i){let o=e[0],n=e[1];return t[0]=o+i*(r[0]-o),t[1]=n+i*(r[1]-n),t}function IA(t,e){e=e===void 0?1:e;let r=ct()*2*Math.PI;return t[0]=Math.cos(r)*e,t[1]=Math.sin(r)*e,t}function OA(t,e,r){let i=e[0],o=e[1];return t[0]=r[0]*i+r[2]*o,t[1]=r[1]*i+r[3]*o,t}function NA(t,e,r){let i=e[0],o=e[1];return t[0]=r[0]*i+r[2]*o+r[4],t[1]=r[1]*i+r[3]*o+r[5],t}function DA(t,e,r){let i=e[0],o=e[1];return t[0]=r[0]*i+r[3]*o+r[6],t[1]=r[1]*i+r[4]*o+r[7],t}function Rf(t,e,r){let i=e[0],o=e[1];return t[0]=r[0]*i+r[4]*o+r[12],t[1]=r[1]*i+r[5]*o+r[13],t}function BA(t,e,r,i){let o=e[0]-r[0],n=e[1]-r[1],s=Math.sin(i),a=Math.cos(i);return t[0]=o*a-n*s+r[0],t[1]=o*s+n*a+r[1],t}function FA(t,e){let r=t[0],i=t[1],o=e[0],n=e[1],s=Math.sqrt((r*r+i*i)*(o*o+n*n)),a=s&&(r*o+i*n)/s;return Math.acos(Math.min(Math.max(a,-1),1))}function LA(t){return t[0]=0,t[1]=0,t}function UA(t){return`vec2(${t[0]}, ${t[1]})`}function kA(t,e){return t[0]===e[0]&&t[1]===e[1]}function VA(t,e){let r=t[0],i=t[1],o=e[0],n=e[1];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(i-n)<=1e-6*Math.max(1,Math.abs(i),Math.abs(n))}var zA=Eg,WA=bg,jA=Tg,$A=xg,HA=Ag,XA=Sg,YA=wg,KA=function(){let t=yg();return function(e,r,i,o,n,s){let a,c;for(r||(r=2),i||(i=0),o?c=Math.min(o*r+i,e.length):c=e.length,a=i;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],n(t,t,s),e[a]=t[0],e[a+1]=t[1];return e}}();function Rg(t,e,r){let i=e[0],o=e[1],n=r[3]*i+r[7]*o||1;return t[0]=(r[0]*i+r[4]*o)/n,t[1]=(r[1]*i+r[5]*o)/n,t}function Ns(t,e,r){let i=e[0],o=e[1],n=e[2],s=r[3]*i+r[7]*o+r[11]*n||1;return t[0]=(r[0]*i+r[4]*o+r[8]*n)/s,t[1]=(r[1]*i+r[5]*o+r[9]*n)/s,t[2]=(r[2]*i+r[6]*o+r[10]*n)/s,t}function Pg(t,e,r){let i=e[0],o=e[1];return t[0]=r[0]*i+r[2]*o,t[1]=r[1]*i+r[3]*o,t[2]=e[2],t}var de={};Rt(de,{add:()=>JA,angle:()=>Df,bezier:()=>d1,ceil:()=>e1,clone:()=>ZA,copy:()=>GA,create:()=>vg,cross:()=>vf,dist:()=>A1,distance:()=>Og,div:()=>x1,divide:()=>Ig,dot:()=>Pf,equals:()=>y1,exactEquals:()=>_1,floor:()=>t1,forEach:()=>R1,fromValues:()=>qA,hermite:()=>u1,inverse:()=>c1,len:()=>E1,length:()=>Ds,lerp:()=>f1,max:()=>i1,min:()=>r1,mul:()=>T1,multiply:()=>Cg,negate:()=>a1,normalize:()=>l1,random:()=>p1,rotateX:()=>If,rotateY:()=>Of,rotateZ:()=>Nf,round:()=>o1,scale:()=>n1,scaleAndAdd:()=>s1,set:()=>QA,slerp:()=>h1,sqrDist:()=>S1,sqrLen:()=>w1,squaredDistance:()=>Ng,squaredLength:()=>Dg,str:()=>m1,sub:()=>b1,subtract:()=>Mg,transformMat3:()=>Mf,transformMat4:()=>So,transformQuat:()=>Cf,zero:()=>g1});function vg(){let t=new Z(3);return Z!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function ZA(t){let e=new Z(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Ds(t){let e=t[0],r=t[1],i=t[2];return Math.sqrt(e*e+r*r+i*i)}function qA(t,e,r){let i=new Z(3);return i[0]=t,i[1]=e,i[2]=r,i}function GA(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function QA(t,e,r,i){return t[0]=e,t[1]=r,t[2]=i,t}function JA(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function Mg(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function Cg(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function Ig(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t}function e1(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t}function t1(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t}function r1(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t}function i1(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t}function o1(t,e){return t[0]=Fe(e[0]),t[1]=Fe(e[1]),t[2]=Fe(e[2]),t}function n1(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function s1(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t}function Og(t,e){let r=e[0]-t[0],i=e[1]-t[1],o=e[2]-t[2];return Math.sqrt(r*r+i*i+o*o)}function Ng(t,e){let r=e[0]-t[0],i=e[1]-t[1],o=e[2]-t[2];return r*r+i*i+o*o}function Dg(t){let e=t[0],r=t[1],i=t[2];return e*e+r*r+i*i}function a1(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t}function c1(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t}function l1(t,e){let r=e[0],i=e[1],o=e[2],n=r*r+i*i+o*o;return n>0&&(n=1/Math.sqrt(n)),t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function Pf(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function vf(t,e,r){let i=e[0],o=e[1],n=e[2],s=r[0],a=r[1],c=r[2];return t[0]=o*c-n*a,t[1]=n*s-i*c,t[2]=i*a-o*s,t}function f1(t,e,r,i){let o=e[0],n=e[1],s=e[2];return t[0]=o+i*(r[0]-o),t[1]=n+i*(r[1]-n),t[2]=s+i*(r[2]-s),t}function h1(t,e,r,i){let o=Math.acos(Math.min(Math.max(Pf(e,r),-1),1)),n=Math.sin(o),s=Math.sin((1-i)*o)/n,a=Math.sin(i*o)/n;return t[0]=s*e[0]+a*r[0],t[1]=s*e[1]+a*r[1],t[2]=s*e[2]+a*r[2],t}function u1(t,e,r,i,o,n){let s=n*n,a=s*(2*n-3)+1,c=s*(n-2)+n,l=s*(n-1),f=s*(3-2*n);return t[0]=e[0]*a+r[0]*c+i[0]*l+o[0]*f,t[1]=e[1]*a+r[1]*c+i[1]*l+o[1]*f,t[2]=e[2]*a+r[2]*c+i[2]*l+o[2]*f,t}function d1(t,e,r,i,o,n){let s=1-n,a=s*s,c=n*n,l=a*s,f=3*n*a,h=3*c*s,u=c*n;return t[0]=e[0]*l+r[0]*f+i[0]*h+o[0]*u,t[1]=e[1]*l+r[1]*f+i[1]*h+o[1]*u,t[2]=e[2]*l+r[2]*f+i[2]*h+o[2]*u,t}function p1(t,e){e=e===void 0?1:e;let r=ct()*2*Math.PI,i=ct()*2-1,o=Math.sqrt(1-i*i)*e;return t[0]=Math.cos(r)*o,t[1]=Math.sin(r)*o,t[2]=i*e,t}function So(t,e,r){let i=e[0],o=e[1],n=e[2],s=r[3]*i+r[7]*o+r[11]*n+r[15];return s=s||1,t[0]=(r[0]*i+r[4]*o+r[8]*n+r[12])/s,t[1]=(r[1]*i+r[5]*o+r[9]*n+r[13])/s,t[2]=(r[2]*i+r[6]*o+r[10]*n+r[14])/s,t}function Mf(t,e,r){let i=e[0],o=e[1],n=e[2];return t[0]=i*r[0]+o*r[3]+n*r[6],t[1]=i*r[1]+o*r[4]+n*r[7],t[2]=i*r[2]+o*r[5]+n*r[8],t}function Cf(t,e,r){let i=r[0],o=r[1],n=r[2],s=r[3],a=e[0],c=e[1],l=e[2],f=o*l-n*c,h=n*a-i*l,u=i*c-o*a,d=o*u-n*h,p=n*f-i*u,g=i*h-o*f,m=s*2;return f*=m,h*=m,u*=m,d*=2,p*=2,g*=2,t[0]=a+f+d,t[1]=c+h+p,t[2]=l+u+g,t}function If(t,e,r,i){let o=[],n=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],n[0]=o[0],n[1]=o[1]*Math.cos(i)-o[2]*Math.sin(i),n[2]=o[1]*Math.sin(i)+o[2]*Math.cos(i),t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function Of(t,e,r,i){let o=[],n=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],n[0]=o[2]*Math.sin(i)+o[0]*Math.cos(i),n[1]=o[1],n[2]=o[2]*Math.cos(i)-o[0]*Math.sin(i),t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function Nf(t,e,r,i){let o=[],n=[];return o[0]=e[0]-r[0],o[1]=e[1]-r[1],o[2]=e[2]-r[2],n[0]=o[0]*Math.cos(i)-o[1]*Math.sin(i),n[1]=o[0]*Math.sin(i)+o[1]*Math.cos(i),n[2]=o[2],t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2],t}function Df(t,e){let r=t[0],i=t[1],o=t[2],n=e[0],s=e[1],a=e[2],c=Math.sqrt((r*r+i*i+o*o)*(n*n+s*s+a*a)),l=c&&Pf(t,e)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function g1(t){return t[0]=0,t[1]=0,t[2]=0,t}function m1(t){return`vec3(${t[0]}, ${t[1]}, ${t[2]})`}function _1(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function y1(t,e){let r=t[0],i=t[1],o=t[2],n=e[0],s=e[1],a=e[2];return Math.abs(r-n)<=1e-6*Math.max(1,Math.abs(r),Math.abs(n))&&Math.abs(i-s)<=1e-6*Math.max(1,Math.abs(i),Math.abs(s))&&Math.abs(o-a)<=1e-6*Math.max(1,Math.abs(o),Math.abs(a))}var b1=Mg,T1=Cg,x1=Ig,A1=Og,S1=Ng,E1=Ds,w1=Dg,R1=function(){let t=vg();return function(e,r,i,o,n,s){let a,c;for(r||(r=3),i||(i=0),o?c=Math.min(o*r+i,e.length):c=e.length,a=i;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],n(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2];return e}}();var Bf=[0,0,0],Bs,j=class extends Is{static get ZERO(){return Bs||(Bs=new j(0,0,0),Object.freeze(Bs)),Bs}constructor(e=0,r=0,i=0){super(-0,-0,-0),arguments.length===1&&Ct(e)?this.copy(e):(ee.debug&&(ce(e),ce(r),ce(i)),this[0]=e,this[1]=r,this[2]=i)}set(e,r,i){return this[0]=e,this[1]=r,this[2]=i,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return ee.debug&&(ce(e.x),ce(e.y),ce(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]=ce(e)}angle(e){return Df(this,e)}cross(e){return vf(this,this,e),this.check()}rotateX({radians:e,origin:r=Bf}){return If(this,this,r,e),this.check()}rotateY({radians:e,origin:r=Bf}){return Of(this,this,r,e),this.check()}rotateZ({radians:e,origin:r=Bf}){return Nf(this,this,r,e),this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return So(this,this,e),this.check()}transformAsVector(e){return Ns(this,this,e),this.check()}transformByMatrix3(e){return Mf(this,this,e),this.check()}transformByMatrix2(e){return Pg(this,this,e),this.check()}transformByQuaternion(e){return Cf(this,this,e),this.check()}};var Fs=class extends wi{toString(){let e="[";if(ee.printRowMajor){e+="row-major:";for(let r=0;r<this.RANK;++r)for(let i=0;i<this.RANK;++i)e+=` ${this[i*this.RANK+r]}`}else{e+="column-major:";for(let r=0;r<this.ELEMENTS;++r)e+=` ${this[r]}`}return e+="]",e}getElementIndex(e,r){return r*this.RANK+e}getElement(e,r){return this[r*this.RANK+e]}setElement(e,r,i){return this[r*this.RANK+e]=ce(i),this}getColumn(e,r=new Array(this.RANK).fill(-0)){let i=e*this.RANK;for(let o=0;o<this.RANK;++o)r[o]=this[i+o];return r}setColumn(e,r){let i=e*this.RANK;for(let o=0;o<this.RANK;++o)this[i+o]=r[o];return this}};var te={};Rt(te,{add:()=>G1,adjoint:()=>O1,clone:()=>v1,copy:()=>M1,create:()=>P1,decompose:()=>W1,determinant:()=>Uf,equals:()=>tS,exactEquals:()=>eS,frob:()=>q1,fromQuat:()=>Hf,fromQuat2:()=>k1,fromRotation:()=>B1,fromRotationTranslation:()=>Fg,fromRotationTranslationScale:()=>j1,fromRotationTranslationScaleOrigin:()=>$1,fromScaling:()=>D1,fromTranslation:()=>N1,fromValues:()=>C1,fromXRotation:()=>F1,fromYRotation:()=>L1,fromZRotation:()=>U1,frustum:()=>Xf,getRotation:()=>z1,getScaling:()=>Lg,getTranslation:()=>V1,identity:()=>Bg,invert:()=>Lf,lookAt:()=>Zf,mul:()=>rS,multiply:()=>Eo,multiplyScalar:()=>Q1,multiplyScalarAndAdd:()=>J1,ortho:()=>Kf,orthoNO:()=>kg,orthoZO:()=>Y1,perspective:()=>Yf,perspectiveFromFieldOfView:()=>X1,perspectiveNO:()=>Ug,perspectiveZO:()=>H1,rotate:()=>zf,rotateX:()=>Wf,rotateY:()=>jf,rotateZ:()=>$f,scale:()=>Vf,set:()=>I1,str:()=>Z1,sub:()=>iS,subtract:()=>Vg,targetTo:()=>K1,translate:()=>kf,transpose:()=>Ff});function P1(){let t=new Z(16);return Z!=Float32Array&&(t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0),t[0]=1,t[5]=1,t[10]=1,t[15]=1,t}function v1(t){let e=new Z(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function M1(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function C1(t,e,r,i,o,n,s,a,c,l,f,h,u,d,p,g){let m=new Z(16);return m[0]=t,m[1]=e,m[2]=r,m[3]=i,m[4]=o,m[5]=n,m[6]=s,m[7]=a,m[8]=c,m[9]=l,m[10]=f,m[11]=h,m[12]=u,m[13]=d,m[14]=p,m[15]=g,m}function I1(t,e,r,i,o,n,s,a,c,l,f,h,u,d,p,g,m){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t[4]=n,t[5]=s,t[6]=a,t[7]=c,t[8]=l,t[9]=f,t[10]=h,t[11]=u,t[12]=d,t[13]=p,t[14]=g,t[15]=m,t}function Bg(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Ff(t,e){if(t===e){let r=e[1],i=e[2],o=e[3],n=e[6],s=e[7],a=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=r,t[6]=e[9],t[7]=e[13],t[8]=i,t[9]=n,t[11]=e[14],t[12]=o,t[13]=s,t[14]=a}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t}function Lf(t,e){let r=e[0],i=e[1],o=e[2],n=e[3],s=e[4],a=e[5],c=e[6],l=e[7],f=e[8],h=e[9],u=e[10],d=e[11],p=e[12],g=e[13],m=e[14],_=e[15],b=r*a-i*s,y=r*c-o*s,T=r*l-n*s,S=i*c-o*a,A=i*l-n*a,w=o*l-n*c,P=f*g-h*p,R=f*m-u*p,v=f*_-d*p,O=h*m-u*g,C=h*_-d*g,z=u*_-d*m,k=b*z-y*C+T*O+S*v-A*R+w*P;return k?(k=1/k,t[0]=(a*z-c*C+l*O)*k,t[1]=(o*C-i*z-n*O)*k,t[2]=(g*w-m*A+_*S)*k,t[3]=(u*A-h*w-d*S)*k,t[4]=(c*v-s*z-l*R)*k,t[5]=(r*z-o*v+n*R)*k,t[6]=(m*T-p*w-_*y)*k,t[7]=(f*w-u*T+d*y)*k,t[8]=(s*C-a*v+l*P)*k,t[9]=(i*v-r*C-n*P)*k,t[10]=(p*A-g*T+_*b)*k,t[11]=(h*T-f*A-d*b)*k,t[12]=(a*R-s*O-c*P)*k,t[13]=(r*O-i*R+o*P)*k,t[14]=(g*y-p*S-m*b)*k,t[15]=(f*S-h*y+u*b)*k,t):null}function O1(t,e){let r=e[0],i=e[1],o=e[2],n=e[3],s=e[4],a=e[5],c=e[6],l=e[7],f=e[8],h=e[9],u=e[10],d=e[11],p=e[12],g=e[13],m=e[14],_=e[15],b=r*a-i*s,y=r*c-o*s,T=r*l-n*s,S=i*c-o*a,A=i*l-n*a,w=o*l-n*c,P=f*g-h*p,R=f*m-u*p,v=f*_-d*p,O=h*m-u*g,C=h*_-d*g,z=u*_-d*m;return t[0]=a*z-c*C+l*O,t[1]=o*C-i*z-n*O,t[2]=g*w-m*A+_*S,t[3]=u*A-h*w-d*S,t[4]=c*v-s*z-l*R,t[5]=r*z-o*v+n*R,t[6]=m*T-p*w-_*y,t[7]=f*w-u*T+d*y,t[8]=s*C-a*v+l*P,t[9]=i*v-r*C-n*P,t[10]=p*A-g*T+_*b,t[11]=h*T-f*A-d*b,t[12]=a*R-s*O-c*P,t[13]=r*O-i*R+o*P,t[14]=g*y-p*S-m*b,t[15]=f*S-h*y+u*b,t}function Uf(t){let e=t[0],r=t[1],i=t[2],o=t[3],n=t[4],s=t[5],a=t[6],c=t[7],l=t[8],f=t[9],h=t[10],u=t[11],d=t[12],p=t[13],g=t[14],m=t[15],_=e*s-r*n,b=e*a-i*n,y=r*a-i*s,T=l*p-f*d,S=l*g-h*d,A=f*g-h*p,w=e*A-r*S+i*T,P=n*A-s*S+a*T,R=l*y-f*b+h*_,v=d*y-p*b+g*_;return c*w-o*P+m*R-u*v}function Eo(t,e,r){let i=e[0],o=e[1],n=e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],h=e[8],u=e[9],d=e[10],p=e[11],g=e[12],m=e[13],_=e[14],b=e[15],y=r[0],T=r[1],S=r[2],A=r[3];return t[0]=y*i+T*a+S*h+A*g,t[1]=y*o+T*c+S*u+A*m,t[2]=y*n+T*l+S*d+A*_,t[3]=y*s+T*f+S*p+A*b,y=r[4],T=r[5],S=r[6],A=r[7],t[4]=y*i+T*a+S*h+A*g,t[5]=y*o+T*c+S*u+A*m,t[6]=y*n+T*l+S*d+A*_,t[7]=y*s+T*f+S*p+A*b,y=r[8],T=r[9],S=r[10],A=r[11],t[8]=y*i+T*a+S*h+A*g,t[9]=y*o+T*c+S*u+A*m,t[10]=y*n+T*l+S*d+A*_,t[11]=y*s+T*f+S*p+A*b,y=r[12],T=r[13],S=r[14],A=r[15],t[12]=y*i+T*a+S*h+A*g,t[13]=y*o+T*c+S*u+A*m,t[14]=y*n+T*l+S*d+A*_,t[15]=y*s+T*f+S*p+A*b,t}function kf(t,e,r){let i=r[0],o=r[1],n=r[2],s,a,c,l,f,h,u,d,p,g,m,_;return e===t?(t[12]=e[0]*i+e[4]*o+e[8]*n+e[12],t[13]=e[1]*i+e[5]*o+e[9]*n+e[13],t[14]=e[2]*i+e[6]*o+e[10]*n+e[14],t[15]=e[3]*i+e[7]*o+e[11]*n+e[15]):(s=e[0],a=e[1],c=e[2],l=e[3],f=e[4],h=e[5],u=e[6],d=e[7],p=e[8],g=e[9],m=e[10],_=e[11],t[0]=s,t[1]=a,t[2]=c,t[3]=l,t[4]=f,t[5]=h,t[6]=u,t[7]=d,t[8]=p,t[9]=g,t[10]=m,t[11]=_,t[12]=s*i+f*o+p*n+e[12],t[13]=a*i+h*o+g*n+e[13],t[14]=c*i+u*o+m*n+e[14],t[15]=l*i+d*o+_*n+e[15]),t}function Vf(t,e,r){let i=r[0],o=r[1],n=r[2];return t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t[3]=e[3]*i,t[4]=e[4]*o,t[5]=e[5]*o,t[6]=e[6]*o,t[7]=e[7]*o,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function zf(t,e,r,i){let o=i[0],n=i[1],s=i[2],a=Math.sqrt(o*o+n*n+s*s),c,l,f,h,u,d,p,g,m,_,b,y,T,S,A,w,P,R,v,O,C,z,k,Q;return a<1e-6?null:(a=1/a,o*=a,n*=a,s*=a,l=Math.sin(r),c=Math.cos(r),f=1-c,h=e[0],u=e[1],d=e[2],p=e[3],g=e[4],m=e[5],_=e[6],b=e[7],y=e[8],T=e[9],S=e[10],A=e[11],w=o*o*f+c,P=n*o*f+s*l,R=s*o*f-n*l,v=o*n*f-s*l,O=n*n*f+c,C=s*n*f+o*l,z=o*s*f+n*l,k=n*s*f-o*l,Q=s*s*f+c,t[0]=h*w+g*P+y*R,t[1]=u*w+m*P+T*R,t[2]=d*w+_*P+S*R,t[3]=p*w+b*P+A*R,t[4]=h*v+g*O+y*C,t[5]=u*v+m*O+T*C,t[6]=d*v+_*O+S*C,t[7]=p*v+b*O+A*C,t[8]=h*z+g*k+y*Q,t[9]=u*z+m*k+T*Q,t[10]=d*z+_*k+S*Q,t[11]=p*z+b*k+A*Q,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)}function Wf(t,e,r){let i=Math.sin(r),o=Math.cos(r),n=e[4],s=e[5],a=e[6],c=e[7],l=e[8],f=e[9],h=e[10],u=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=n*o+l*i,t[5]=s*o+f*i,t[6]=a*o+h*i,t[7]=c*o+u*i,t[8]=l*o-n*i,t[9]=f*o-s*i,t[10]=h*o-a*i,t[11]=u*o-c*i,t}function jf(t,e,r){let i=Math.sin(r),o=Math.cos(r),n=e[0],s=e[1],a=e[2],c=e[3],l=e[8],f=e[9],h=e[10],u=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*o-l*i,t[1]=s*o-f*i,t[2]=a*o-h*i,t[3]=c*o-u*i,t[8]=n*i+l*o,t[9]=s*i+f*o,t[10]=a*i+h*o,t[11]=c*i+u*o,t}function $f(t,e,r){let i=Math.sin(r),o=Math.cos(r),n=e[0],s=e[1],a=e[2],c=e[3],l=e[4],f=e[5],h=e[6],u=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=n*o+l*i,t[1]=s*o+f*i,t[2]=a*o+h*i,t[3]=c*o+u*i,t[4]=l*o-n*i,t[5]=f*o-s*i,t[6]=h*o-a*i,t[7]=u*o-c*i,t}function N1(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function D1(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function B1(t,e,r){let i=r[0],o=r[1],n=r[2],s=Math.sqrt(i*i+o*o+n*n),a,c,l;return s<1e-6?null:(s=1/s,i*=s,o*=s,n*=s,c=Math.sin(e),a=Math.cos(e),l=1-a,t[0]=i*i*l+a,t[1]=o*i*l+n*c,t[2]=n*i*l-o*c,t[3]=0,t[4]=i*o*l-n*c,t[5]=o*o*l+a,t[6]=n*o*l+i*c,t[7]=0,t[8]=i*n*l+o*c,t[9]=o*n*l-i*c,t[10]=n*n*l+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}function F1(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=i,t[6]=r,t[7]=0,t[8]=0,t[9]=-r,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function L1(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=0,t[2]=-r,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=r,t[9]=0,t[10]=i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function U1(t,e){let r=Math.sin(e),i=Math.cos(e);return t[0]=i,t[1]=r,t[2]=0,t[3]=0,t[4]=-r,t[5]=i,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Fg(t,e,r){let i=e[0],o=e[1],n=e[2],s=e[3],a=i+i,c=o+o,l=n+n,f=i*a,h=i*c,u=i*l,d=o*c,p=o*l,g=n*l,m=s*a,_=s*c,b=s*l;return t[0]=1-(d+g),t[1]=h+b,t[2]=u-_,t[3]=0,t[4]=h-b,t[5]=1-(f+g),t[6]=p+m,t[7]=0,t[8]=u+_,t[9]=p-m,t[10]=1-(f+d),t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function k1(t,e){let r=new Z(3),i=-e[0],o=-e[1],n=-e[2],s=e[3],a=e[4],c=e[5],l=e[6],f=e[7],h=i*i+o*o+n*n+s*s;return h>0?(r[0]=(a*s+f*i+c*n-l*o)*2/h,r[1]=(c*s+f*o+l*i-a*n)*2/h,r[2]=(l*s+f*n+a*o-c*i)*2/h):(r[0]=(a*s+f*i+c*n-l*o)*2,r[1]=(c*s+f*o+l*i-a*n)*2,r[2]=(l*s+f*n+a*o-c*i)*2),Fg(t,e,r),t}function V1(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}function Lg(t,e){let r=e[0],i=e[1],o=e[2],n=e[4],s=e[5],a=e[6],c=e[8],l=e[9],f=e[10];return t[0]=Math.sqrt(r*r+i*i+o*o),t[1]=Math.sqrt(n*n+s*s+a*a),t[2]=Math.sqrt(c*c+l*l+f*f),t}function z1(t,e){let r=new Z(3);Lg(r,e);let i=1/r[0],o=1/r[1],n=1/r[2],s=e[0]*i,a=e[1]*o,c=e[2]*n,l=e[4]*i,f=e[5]*o,h=e[6]*n,u=e[8]*i,d=e[9]*o,p=e[10]*n,g=s+f+p,m=0;return g>0?(m=Math.sqrt(g+1)*2,t[3]=.25*m,t[0]=(h-d)/m,t[1]=(u-c)/m,t[2]=(a-l)/m):s>f&&s>p?(m=Math.sqrt(1+s-f-p)*2,t[3]=(h-d)/m,t[0]=.25*m,t[1]=(a+l)/m,t[2]=(u+c)/m):f>p?(m=Math.sqrt(1+f-s-p)*2,t[3]=(u-c)/m,t[0]=(a+l)/m,t[1]=.25*m,t[2]=(h+d)/m):(m=Math.sqrt(1+p-s-f)*2,t[3]=(a-l)/m,t[0]=(u+c)/m,t[1]=(h+d)/m,t[2]=.25*m),t}function W1(t,e,r,i){e[0]=i[12],e[1]=i[13],e[2]=i[14];let o=i[0],n=i[1],s=i[2],a=i[4],c=i[5],l=i[6],f=i[8],h=i[9],u=i[10];r[0]=Math.sqrt(o*o+n*n+s*s),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(f*f+h*h+u*u);let d=1/r[0],p=1/r[1],g=1/r[2],m=o*d,_=n*p,b=s*g,y=a*d,T=c*p,S=l*g,A=f*d,w=h*p,P=u*g,R=m+T+P,v=0;return R>0?(v=Math.sqrt(R+1)*2,t[3]=.25*v,t[0]=(S-w)/v,t[1]=(A-b)/v,t[2]=(_-y)/v):m>T&&m>P?(v=Math.sqrt(1+m-T-P)*2,t[3]=(S-w)/v,t[0]=.25*v,t[1]=(_+y)/v,t[2]=(A+b)/v):T>P?(v=Math.sqrt(1+T-m-P)*2,t[3]=(A-b)/v,t[0]=(_+y)/v,t[1]=.25*v,t[2]=(S+w)/v):(v=Math.sqrt(1+P-m-T)*2,t[3]=(_-y)/v,t[0]=(A+b)/v,t[1]=(S+w)/v,t[2]=.25*v),t}function j1(t,e,r,i){let o=e[0],n=e[1],s=e[2],a=e[3],c=o+o,l=n+n,f=s+s,h=o*c,u=o*l,d=o*f,p=n*l,g=n*f,m=s*f,_=a*c,b=a*l,y=a*f,T=i[0],S=i[1],A=i[2];return t[0]=(1-(p+m))*T,t[1]=(u+y)*T,t[2]=(d-b)*T,t[3]=0,t[4]=(u-y)*S,t[5]=(1-(h+m))*S,t[6]=(g+_)*S,t[7]=0,t[8]=(d+b)*A,t[9]=(g-_)*A,t[10]=(1-(h+p))*A,t[11]=0,t[12]=r[0],t[13]=r[1],t[14]=r[2],t[15]=1,t}function $1(t,e,r,i,o){let n=e[0],s=e[1],a=e[2],c=e[3],l=n+n,f=s+s,h=a+a,u=n*l,d=n*f,p=n*h,g=s*f,m=s*h,_=a*h,b=c*l,y=c*f,T=c*h,S=i[0],A=i[1],w=i[2],P=o[0],R=o[1],v=o[2],O=(1-(g+_))*S,C=(d+T)*S,z=(p-y)*S,k=(d-T)*A,Q=(1-(u+_))*A,Et=(m+b)*A,wt=(p+y)*w,_d=(m-b)*w,yd=(1-(u+g))*w;return t[0]=O,t[1]=C,t[2]=z,t[3]=0,t[4]=k,t[5]=Q,t[6]=Et,t[7]=0,t[8]=wt,t[9]=_d,t[10]=yd,t[11]=0,t[12]=r[0]+P-(O*P+k*R+wt*v),t[13]=r[1]+R-(C*P+Q*R+_d*v),t[14]=r[2]+v-(z*P+Et*R+yd*v),t[15]=1,t}function Hf(t,e){let r=e[0],i=e[1],o=e[2],n=e[3],s=r+r,a=i+i,c=o+o,l=r*s,f=i*s,h=i*a,u=o*s,d=o*a,p=o*c,g=n*s,m=n*a,_=n*c;return t[0]=1-h-p,t[1]=f+_,t[2]=u-m,t[3]=0,t[4]=f-_,t[5]=1-l-p,t[6]=d+g,t[7]=0,t[8]=u+m,t[9]=d-g,t[10]=1-l-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function Xf(t,e,r,i,o,n,s){let a=1/(r-e),c=1/(o-i),l=1/(n-s);return t[0]=n*2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n*2*c,t[6]=0,t[7]=0,t[8]=(r+e)*a,t[9]=(o+i)*c,t[10]=(s+n)*l,t[11]=-1,t[12]=0,t[13]=0,t[14]=s*n*2*l,t[15]=0,t}function Ug(t,e,r,i,o){let n=1/Math.tan(e/2);if(t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let s=1/(i-o);t[10]=(o+i)*s,t[14]=2*o*i*s}else t[10]=-1,t[14]=-2*i;return t}var Yf=Ug;function H1(t,e,r,i,o){let n=1/Math.tan(e/2);if(t[0]=n/r,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=n,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[11]=-1,t[12]=0,t[13]=0,t[15]=0,o!=null&&o!==1/0){let s=1/(i-o);t[10]=o*s,t[14]=o*i*s}else t[10]=-1,t[14]=-i;return t}function X1(t,e,r,i){let o=Math.tan(e.upDegrees*Math.PI/180),n=Math.tan(e.downDegrees*Math.PI/180),s=Math.tan(e.leftDegrees*Math.PI/180),a=Math.tan(e.rightDegrees*Math.PI/180),c=2/(s+a),l=2/(o+n);return t[0]=c,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=l,t[6]=0,t[7]=0,t[8]=-((s-a)*c*.5),t[9]=(o-n)*l*.5,t[10]=i/(r-i),t[11]=-1,t[12]=0,t[13]=0,t[14]=i*r/(r-i),t[15]=0,t}function kg(t,e,r,i,o,n,s){let a=1/(e-r),c=1/(i-o),l=1/(n-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+i)*c,t[14]=(s+n)*l,t[15]=1,t}var Kf=kg;function Y1(t,e,r,i,o,n,s){let a=1/(e-r),c=1/(i-o),l=1/(n-s);return t[0]=-2*a,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*c,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=l,t[11]=0,t[12]=(e+r)*a,t[13]=(o+i)*c,t[14]=n*l,t[15]=1,t}function Zf(t,e,r,i){let o,n,s,a,c,l,f,h,u,d,p=e[0],g=e[1],m=e[2],_=i[0],b=i[1],y=i[2],T=r[0],S=r[1],A=r[2];return Math.abs(p-T)<1e-6&&Math.abs(g-S)<1e-6&&Math.abs(m-A)<1e-6?Bg(t):(h=p-T,u=g-S,d=m-A,o=1/Math.sqrt(h*h+u*u+d*d),h*=o,u*=o,d*=o,n=b*d-y*u,s=y*h-_*d,a=_*u-b*h,o=Math.sqrt(n*n+s*s+a*a),o?(o=1/o,n*=o,s*=o,a*=o):(n=0,s=0,a=0),c=u*a-d*s,l=d*n-h*a,f=h*s-u*n,o=Math.sqrt(c*c+l*l+f*f),o?(o=1/o,c*=o,l*=o,f*=o):(c=0,l=0,f=0),t[0]=n,t[1]=c,t[2]=h,t[3]=0,t[4]=s,t[5]=l,t[6]=u,t[7]=0,t[8]=a,t[9]=f,t[10]=d,t[11]=0,t[12]=-(n*p+s*g+a*m),t[13]=-(c*p+l*g+f*m),t[14]=-(h*p+u*g+d*m),t[15]=1,t)}function K1(t,e,r,i){let o=e[0],n=e[1],s=e[2],a=i[0],c=i[1],l=i[2],f=o-r[0],h=n-r[1],u=s-r[2],d=f*f+h*h+u*u;d>0&&(d=1/Math.sqrt(d),f*=d,h*=d,u*=d);let p=c*u-l*h,g=l*f-a*u,m=a*h-c*f;return d=p*p+g*g+m*m,d>0&&(d=1/Math.sqrt(d),p*=d,g*=d,m*=d),t[0]=p,t[1]=g,t[2]=m,t[3]=0,t[4]=h*m-u*g,t[5]=u*p-f*m,t[6]=f*g-h*p,t[7]=0,t[8]=f,t[9]=h,t[10]=u,t[11]=0,t[12]=o,t[13]=n,t[14]=s,t[15]=1,t}function Z1(t){return`mat4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]}, ${t[4]}, ${t[5]}, ${t[6]}, ${t[7]}, ${t[8]}, ${t[9]}, ${t[10]}, ${t[11]}, ${t[12]}, ${t[13]}, ${t[14]}, ${t[15]})`}function q1(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]+t[3]*t[3]+t[4]*t[4]+t[5]*t[5]+t[6]*t[6]+t[7]*t[7]+t[8]*t[8]+t[9]*t[9]+t[10]*t[10]+t[11]*t[11]+t[12]*t[12]+t[13]*t[13]+t[14]*t[14]+t[15]*t[15])}function G1(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t[4]=e[4]+r[4],t[5]=e[5]+r[5],t[6]=e[6]+r[6],t[7]=e[7]+r[7],t[8]=e[8]+r[8],t[9]=e[9]+r[9],t[10]=e[10]+r[10],t[11]=e[11]+r[11],t[12]=e[12]+r[12],t[13]=e[13]+r[13],t[14]=e[14]+r[14],t[15]=e[15]+r[15],t}function Vg(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t[4]=e[4]-r[4],t[5]=e[5]-r[5],t[6]=e[6]-r[6],t[7]=e[7]-r[7],t[8]=e[8]-r[8],t[9]=e[9]-r[9],t[10]=e[10]-r[10],t[11]=e[11]-r[11],t[12]=e[12]-r[12],t[13]=e[13]-r[13],t[14]=e[14]-r[14],t[15]=e[15]-r[15],t}function Q1(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*r,t[5]=e[5]*r,t[6]=e[6]*r,t[7]=e[7]*r,t[8]=e[8]*r,t[9]=e[9]*r,t[10]=e[10]*r,t[11]=e[11]*r,t[12]=e[12]*r,t[13]=e[13]*r,t[14]=e[14]*r,t[15]=e[15]*r,t}function J1(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t[4]=e[4]+r[4]*i,t[5]=e[5]+r[5]*i,t[6]=e[6]+r[6]*i,t[7]=e[7]+r[7]*i,t[8]=e[8]+r[8]*i,t[9]=e[9]+r[9]*i,t[10]=e[10]+r[10]*i,t[11]=e[11]+r[11]*i,t[12]=e[12]+r[12]*i,t[13]=e[13]+r[13]*i,t[14]=e[14]+r[14]*i,t[15]=e[15]+r[15]*i,t}function eS(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function tS(t,e){let r=t[0],i=t[1],o=t[2],n=t[3],s=t[4],a=t[5],c=t[6],l=t[7],f=t[8],h=t[9],u=t[10],d=t[11],p=t[12],g=t[13],m=t[14],_=t[15],b=e[0],y=e[1],T=e[2],S=e[3],A=e[4],w=e[5],P=e[6],R=e[7],v=e[8],O=e[9],C=e[10],z=e[11],k=e[12],Q=e[13],Et=e[14],wt=e[15];return Math.abs(r-b)<=1e-6*Math.max(1,Math.abs(r),Math.abs(b))&&Math.abs(i-y)<=1e-6*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(o-T)<=1e-6*Math.max(1,Math.abs(o),Math.abs(T))&&Math.abs(n-S)<=1e-6*Math.max(1,Math.abs(n),Math.abs(S))&&Math.abs(s-A)<=1e-6*Math.max(1,Math.abs(s),Math.abs(A))&&Math.abs(a-w)<=1e-6*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(c-P)<=1e-6*Math.max(1,Math.abs(c),Math.abs(P))&&Math.abs(l-R)<=1e-6*Math.max(1,Math.abs(l),Math.abs(R))&&Math.abs(f-v)<=1e-6*Math.max(1,Math.abs(f),Math.abs(v))&&Math.abs(h-O)<=1e-6*Math.max(1,Math.abs(h),Math.abs(O))&&Math.abs(u-C)<=1e-6*Math.max(1,Math.abs(u),Math.abs(C))&&Math.abs(d-z)<=1e-6*Math.max(1,Math.abs(d),Math.abs(z))&&Math.abs(p-k)<=1e-6*Math.max(1,Math.abs(p),Math.abs(k))&&Math.abs(g-Q)<=1e-6*Math.max(1,Math.abs(g),Math.abs(Q))&&Math.abs(m-Et)<=1e-6*Math.max(1,Math.abs(m),Math.abs(Et))&&Math.abs(_-wt)<=1e-6*Math.max(1,Math.abs(_),Math.abs(wt))}var rS=Eo,iS=Vg;var Te={};Rt(Te,{add:()=>cS,ceil:()=>lS,clone:()=>oS,copy:()=>sS,create:()=>zg,cross:()=>TS,dist:()=>IS,distance:()=>Hg,div:()=>CS,divide:()=>$g,dot:()=>bS,equals:()=>PS,exactEquals:()=>RS,floor:()=>fS,forEach:()=>BS,fromValues:()=>nS,inverse:()=>_S,len:()=>NS,length:()=>Yg,lerp:()=>xS,max:()=>uS,min:()=>hS,mul:()=>MS,multiply:()=>jg,negate:()=>mS,normalize:()=>yS,random:()=>AS,round:()=>dS,scale:()=>pS,scaleAndAdd:()=>gS,set:()=>aS,sqrDist:()=>OS,sqrLen:()=>DS,squaredDistance:()=>Xg,squaredLength:()=>Kg,str:()=>wS,sub:()=>vS,subtract:()=>Wg,transformMat4:()=>qf,transformQuat:()=>SS,zero:()=>ES});function zg(){let t=new Z(4);return Z!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t}function oS(t){let e=new Z(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function nS(t,e,r,i){let o=new Z(4);return o[0]=t,o[1]=e,o[2]=r,o[3]=i,o}function sS(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function aS(t,e,r,i,o){return t[0]=e,t[1]=r,t[2]=i,t[3]=o,t}function cS(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t[3]=e[3]+r[3],t}function Wg(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t[3]=e[3]-r[3],t}function jg(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t[3]=e[3]*r[3],t}function $g(t,e,r){return t[0]=e[0]/r[0],t[1]=e[1]/r[1],t[2]=e[2]/r[2],t[3]=e[3]/r[3],t}function lS(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t}function fS(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t}function hS(t,e,r){return t[0]=Math.min(e[0],r[0]),t[1]=Math.min(e[1],r[1]),t[2]=Math.min(e[2],r[2]),t[3]=Math.min(e[3],r[3]),t}function uS(t,e,r){return t[0]=Math.max(e[0],r[0]),t[1]=Math.max(e[1],r[1]),t[2]=Math.max(e[2],r[2]),t[3]=Math.max(e[3],r[3]),t}function dS(t,e){return t[0]=Fe(e[0]),t[1]=Fe(e[1]),t[2]=Fe(e[2]),t[3]=Fe(e[3]),t}function pS(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t}function gS(t,e,r,i){return t[0]=e[0]+r[0]*i,t[1]=e[1]+r[1]*i,t[2]=e[2]+r[2]*i,t[3]=e[3]+r[3]*i,t}function Hg(t,e){let r=e[0]-t[0],i=e[1]-t[1],o=e[2]-t[2],n=e[3]-t[3];return Math.sqrt(r*r+i*i+o*o+n*n)}function Xg(t,e){let r=e[0]-t[0],i=e[1]-t[1],o=e[2]-t[2],n=e[3]-t[3];return r*r+i*i+o*o+n*n}function Yg(t){let e=t[0],r=t[1],i=t[2],o=t[3];return Math.sqrt(e*e+r*r+i*i+o*o)}function Kg(t){let e=t[0],r=t[1],i=t[2],o=t[3];return e*e+r*r+i*i+o*o}function mS(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t}function _S(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t}function yS(t,e){let r=e[0],i=e[1],o=e[2],n=e[3],s=r*r+i*i+o*o+n*n;return s>0&&(s=1/Math.sqrt(s)),t[0]=r*s,t[1]=i*s,t[2]=o*s,t[3]=n*s,t}function bS(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]}function TS(t,e,r,i){let o=r[0]*i[1]-r[1]*i[0],n=r[0]*i[2]-r[2]*i[0],s=r[0]*i[3]-r[3]*i[0],a=r[1]*i[2]-r[2]*i[1],c=r[1]*i[3]-r[3]*i[1],l=r[2]*i[3]-r[3]*i[2],f=e[0],h=e[1],u=e[2],d=e[3];return t[0]=h*l-u*c+d*a,t[1]=-(f*l)+u*s-d*n,t[2]=f*c-h*s+d*o,t[3]=-(f*a)+h*n-u*o,t}function xS(t,e,r,i){let o=e[0],n=e[1],s=e[2],a=e[3];return t[0]=o+i*(r[0]-o),t[1]=n+i*(r[1]-n),t[2]=s+i*(r[2]-s),t[3]=a+i*(r[3]-a),t}function AS(t,e){e=e===void 0?1:e;let r,i,o,n,s,a;do r=ct()*2-1,i=ct()*2-1,s=r*r+i*i;while(s>=1);do o=ct()*2-1,n=ct()*2-1,a=o*o+n*n;while(a>=1);let c=Math.sqrt((1-s)/a);return t[0]=e*r,t[1]=e*i,t[2]=e*o*c,t[3]=e*n*c,t}function qf(t,e,r){let i=e[0],o=e[1],n=e[2],s=e[3];return t[0]=r[0]*i+r[4]*o+r[8]*n+r[12]*s,t[1]=r[1]*i+r[5]*o+r[9]*n+r[13]*s,t[2]=r[2]*i+r[6]*o+r[10]*n+r[14]*s,t[3]=r[3]*i+r[7]*o+r[11]*n+r[15]*s,t}function SS(t,e,r){let i=e[0],o=e[1],n=e[2],s=r[0],a=r[1],c=r[2],l=r[3],f=l*i+a*n-c*o,h=l*o+c*i-s*n,u=l*n+s*o-a*i,d=-s*i-a*o-c*n;return t[0]=f*l+d*-s+h*-c-u*-a,t[1]=h*l+d*-a+u*-s-f*-c,t[2]=u*l+d*-c+f*-a-h*-s,t[3]=e[3],t}function ES(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function wS(t){return`vec4(${t[0]}, ${t[1]}, ${t[2]}, ${t[3]})`}function RS(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]}function PS(t,e){let r=t[0],i=t[1],o=t[2],n=t[3],s=e[0],a=e[1],c=e[2],l=e[3];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(o-c)<=1e-6*Math.max(1,Math.abs(o),Math.abs(c))&&Math.abs(n-l)<=1e-6*Math.max(1,Math.abs(n),Math.abs(l))}var vS=Wg,MS=jg,CS=$g,IS=Hg,OS=Xg,NS=Yg,DS=Kg,BS=function(){let t=zg();return function(e,r,i,o,n,s){let a,c;for(r||(r=4),i||(i=0),o?c=Math.min(o*r+i,e.length):c=e.length,a=i;a<c;a+=r)t[0]=e[a],t[1]=e[a+1],t[2]=e[a+2],t[3]=e[a+3],n(t,t,s),e[a]=t[0],e[a+1]=t[1],e[a+2]=t[2],e[a+3]=t[3];return e}}();var Jf;(function(t){t[t.COL0ROW0=0]="COL0ROW0",t[t.COL0ROW1=1]="COL0ROW1",t[t.COL0ROW2=2]="COL0ROW2",t[t.COL0ROW3=3]="COL0ROW3",t[t.COL1ROW0=4]="COL1ROW0",t[t.COL1ROW1=5]="COL1ROW1",t[t.COL1ROW2=6]="COL1ROW2",t[t.COL1ROW3=7]="COL1ROW3",t[t.COL2ROW0=8]="COL2ROW0",t[t.COL2ROW1=9]="COL2ROW1",t[t.COL2ROW2=10]="COL2ROW2",t[t.COL2ROW3=11]="COL2ROW3",t[t.COL3ROW0=12]="COL3ROW0",t[t.COL3ROW1=13]="COL3ROW1",t[t.COL3ROW2=14]="COL3ROW2",t[t.COL3ROW3=15]="COL3ROW3"})(Jf||(Jf={}));var FS=45*Math.PI/180,LS=1,Gf=.1,Qf=500,US=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),V=class extends Fs{static get IDENTITY(){return VS()}static get ZERO(){return kS()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Jf}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,r,i,o,n,s,a,c,l,f,h,u,d,p,g,m){return this[0]=e,this[1]=r,this[2]=i,this[3]=o,this[4]=n,this[5]=s,this[6]=a,this[7]=c,this[8]=l,this[9]=f,this[10]=h,this[11]=u,this[12]=d,this[13]=p,this[14]=g,this[15]=m,this.check()}setRowMajor(e,r,i,o,n,s,a,c,l,f,h,u,d,p,g,m){return this[0]=e,this[1]=n,this[2]=l,this[3]=d,this[4]=r,this[5]=s,this[6]=f,this[7]=p,this[8]=i,this[9]=a,this[10]=h,this[11]=g,this[12]=o,this[13]=c,this[14]=u,this[15]=m,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(US)}fromObject(e){return this.check()}fromQuaternion(e){return Hf(this,e),this.check()}frustum(e){let{left:r,right:i,bottom:o,top:n,near:s=Gf,far:a=Qf}=e;return a===1/0?zS(this,r,i,o,n,s):Xf(this,r,i,o,n,s,a),this.check()}lookAt(e){let{eye:r,center:i=[0,0,0],up:o=[0,1,0]}=e;return Zf(this,r,i,o),this.check()}ortho(e){let{left:r,right:i,bottom:o,top:n,near:s=Gf,far:a=Qf}=e;return Kf(this,r,i,o,n,s,a),this.check()}orthographic(e){let{fovy:r=FS,aspect:i=LS,focalDistance:o=1,near:n=Gf,far:s=Qf}=e;Zg(r);let a=r/2,c=o*Math.tan(a),l=c*i;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:n,far:s})}perspective(e){let{fovy:r=45*Math.PI/180,aspect:i=1,near:o=.1,far:n=500}=e;return Zg(r),Yf(this,r,i,o,n),this.check()}determinant(){return Uf(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,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let i=this.getScale(r),o=1/i[0],n=1/i[1],s=1/i[2];return e[0]=this[0]*o,e[1]=this[1]*n,e[2]=this[2]*s,e[3]=0,e[4]=this[4]*o,e[5]=this[5]*n,e[6]=this[6]*s,e[7]=0,e[8]=this[8]*o,e[9]=this[9]*n,e[10]=this[10]*s,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,r){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let i=this.getScale(r),o=1/i[0],n=1/i[1],s=1/i[2];return e[0]=this[0]*o,e[1]=this[1]*n,e[2]=this[2]*s,e[3]=this[4]*o,e[4]=this[5]*n,e[5]=this[6]*s,e[6]=this[8]*o,e[7]=this[9]*n,e[8]=this[10]*s,e}transpose(){return Ff(this,this),this.check()}invert(){return Lf(this,this),this.check()}multiplyLeft(e){return Eo(this,e,this),this.check()}multiplyRight(e){return Eo(this,this,e),this.check()}rotateX(e){return Wf(this,this,e),this.check()}rotateY(e){return jf(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,r){return zf(this,this,e,r),this.check()}scale(e){return Vf(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return kf(this,this,e),this.check()}transform(e,r){return e.length===4?(r=qf(r||[-0,-0,-0,-0],e,this),Cs(r,4),r):this.transformAsPoint(e,r)}transformAsPoint(e,r){let{length:i}=e,o;switch(i){case 2:o=Rf(r||[-0,-0],e,this);break;case 3:o=So(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Cs(o,e.length),o}transformAsVector(e,r){let i;switch(e.length){case 2:i=Rg(r||[-0,-0],e,this);break;case 3:i=Ns(r||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return Cs(i,e.length),i}transformPoint(e,r){return this.transformAsPoint(e,r)}transformVector(e,r){return this.transformAsPoint(e,r)}transformDirection(e,r){return this.transformAsVector(e,r)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,r,i){return this.identity().translate([e,r,i])}},Ls,Us;function kS(){return Ls||(Ls=new V([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Ls)),Ls}function VS(){return Us||(Us=new V,Object.freeze(Us)),Us}function Zg(t){if(t>Math.PI*2)throw Error("expected radians")}function zS(t,e,r,i,o,n){let s=2*n/(r-e),a=2*n/(o-i),c=(r+e)/(r-e),l=(o+i)/(o-i),f=-1,h=-1,u=-2*n;return t[0]=s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=a,t[6]=0,t[7]=0,t[8]=c,t[9]=l,t[10]=f,t[11]=h,t[12]=0,t[13]=0,t[14]=u,t[15]=0,t}var qg=1e-6,WS=6371e3,We=class{constructor({phi:e=0,theta:r=0,radius:i=1,bearing:o,pitch:n,altitude:s,radiusScale:a=WS}={}){this.phi=e,this.theta=r,this.radius=i||s||1,this.radiusScale=a||1,o!==void 0&&(this.bearing=o),n!==void 0&&(this.pitch=n),this.check()}toString(){return this.formatString(ee)}formatString({printTypes:e=!1}){let r=Ao;return`${e?"Spherical":""}[rho:${r(this.radius)},theta:${r(this.theta)},phi:${r(this.phi)}]`}equals(e){return Re(this.radius,e.radius)&&Re(this.theta,e.theta)&&Re(this.phi,e.phi)}exactEquals(e){return this.radius===e.radius&&this.theta===e.theta&&this.phi===e.phi}get bearing(){return 180-rr(this.phi)}set bearing(e){this.phi=Math.PI-Ei(e)}get pitch(){return rr(this.theta)}set pitch(e){this.theta=Ei(e)}get longitude(){return rr(this.phi)}get latitude(){return rr(this.theta)}get lng(){return rr(this.phi)}get lat(){return rr(this.theta)}get z(){return(this.radius-1)*this.radiusScale}set(e,r,i){return this.radius=e,this.phi=r,this.theta=i,this.check()}clone(){return new We().copy(this)}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this.check()}fromLngLatZ([e,r,i]){return this.radius=1+i/this.radiusScale,this.phi=Ei(r),this.theta=Ei(e),this.check()}fromVector3(e){return this.radius=Ds(e),this.radius>0&&(this.theta=Math.atan2(e[0],e[1]),this.phi=Math.acos(U(e[2]/this.radius,-1,1))),this.check()}toVector3(){return new j(0,0,this.radius).rotateX({radians:this.theta}).rotateZ({radians:this.phi})}makeSafe(){return this.phi=Math.max(qg,Math.min(Math.PI-qg,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 eh(t,e=[],r=0){let i=Math.fround(t),o=t-i;return e[r]=i,e[r+1]=o,e}function Gg(t){return t-Math.fround(t)}function Qg(t){let e=new Float32Array(32);for(let r=0;r<4;++r)for(let i=0;i<4;++i){let o=r*4+i;eh(t[i*4+r],e,o*2)}return e}function ks(t,e=!0){return t??e}function th(t=[0,0,0],e=!0){return e?t.map(r=>r/255):[...t]}function Jg(t,e=!0){let r=th(t.slice(0,3),e),i=Number.isFinite(t[3]),o=i?t[3]:1;return[r[0],r[1],r[2],e&&i?o/255:o]}var jS=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
|
|
114
114
|
|
|
115
115
|
// All these functions are for substituting tan() function from Intel GPU only
|
|
116
116
|
const float TWO_PI = 6.2831854820251465;
|
|
@@ -260,7 +260,7 @@ float tan_fp32(float a) {
|
|
|
260
260
|
return tan(a);
|
|
261
261
|
#endif
|
|
262
262
|
}
|
|
263
|
-
`,
|
|
263
|
+
`,rh={name:"fp32",vs:jS};var ih=`
|
|
264
264
|
layout(std140) uniform fp64arithmeticUniforms {
|
|
265
265
|
uniform float ONE;
|
|
266
266
|
uniform float SPLIT;
|
|
@@ -459,7 +459,7 @@ vec2 sqrt_fp64(vec2 a) {
|
|
|
459
459
|
return sum_fp64(vec2(yn, 0.0), prod);
|
|
460
460
|
#endif
|
|
461
461
|
}
|
|
462
|
-
`;var
|
|
462
|
+
`;var em=`struct Fp64ArithmeticUniforms {
|
|
463
463
|
ONE: f32,
|
|
464
464
|
SPLIT: f32,
|
|
465
465
|
};
|
|
@@ -665,7 +665,7 @@ fn sqrt_fp64(a: vec2f) -> vec2f {
|
|
|
665
665
|
return sum_fp64(vec2f(yn, 0.0), prod);
|
|
666
666
|
#endif
|
|
667
667
|
}
|
|
668
|
-
`;var
|
|
668
|
+
`;var $S={ONE:1,SPLIT:4097},oh={name:"fp64arithmetic",source:em,fs:ih,vs:ih,defaultUniforms:$S,uniformTypes:{ONE:"f32",SPLIT:"f32"},fp64ify:eh,fp64LowPart:Gg,fp64ifyMatrix4:Qg};var tm=`layout(std140) uniform floatColorsUniforms {
|
|
669
669
|
float useByteColors;
|
|
670
670
|
} floatColors;
|
|
671
671
|
|
|
@@ -692,7 +692,7 @@ vec4 floatColors_premultiply_alpha(vec4 inputColor) {
|
|
|
692
692
|
vec4 floatColors_unpremultiply_alpha(vec4 inputColor) {
|
|
693
693
|
return floatColors_unpremultiplyAlpha(inputColor);
|
|
694
694
|
}
|
|
695
|
-
|
|
695
|
+
`,HS=`struct floatColorsUniforms {
|
|
696
696
|
useByteColors: f32
|
|
697
697
|
};
|
|
698
698
|
|
|
@@ -725,7 +725,7 @@ fn floatColors_premultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {
|
|
|
725
725
|
fn floatColors_unpremultiply_alpha(inputColor: vec4<f32>) -> vec4<f32> {
|
|
726
726
|
return floatColors_unpremultiplyAlpha(inputColor);
|
|
727
727
|
}
|
|
728
|
-
`,
|
|
728
|
+
`,Vs={name:"floatColors",props:{},uniforms:{},vs:tm,fs:tm,source:HS,uniformTypes:{useByteColors:"f32"},defaultUniforms:{useByteColors:!0}};var XS=[0,1,1,1],YS=`layout(std140) uniform pickingUniforms {
|
|
729
729
|
float isActive;
|
|
730
730
|
float isAttribute;
|
|
731
731
|
float isHighlightActive;
|
|
@@ -796,7 +796,7 @@ void picking_setPickingAttribute(vec3 value) {
|
|
|
796
796
|
picking_vRGBcolor_Avalid.rgb = value;
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
|
-
`,
|
|
799
|
+
`,KS=`layout(std140) uniform pickingUniforms {
|
|
800
800
|
float isActive;
|
|
801
801
|
float isAttribute;
|
|
802
802
|
float isHighlightActive;
|
|
@@ -852,7 +852,7 @@ vec4 picking_filterColor(vec4 color) {
|
|
|
852
852
|
vec4 highlightColor = picking_filterHighlightColor(color);
|
|
853
853
|
return picking_filterPickingColor(highlightColor);
|
|
854
854
|
}
|
|
855
|
-
`,
|
|
855
|
+
`,zs={props:{},uniforms:{},name:"picking",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useByteColors:"f32",highlightedObjectColor:"vec3<f32>",highlightColor:"vec4<f32>"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useByteColors:!0,highlightedObjectColor:[0,0,0],highlightColor:XS},vs:YS,fs:KS,getUniforms:ZS};function ZS(t={},e){let r={},i=ks(t.useByteColors,!0);if(t.highlightedObjectColor!==void 0)if(t.highlightedObjectColor===null)r.isHighlightActive=!1;else{r.isHighlightActive=!0;let o=t.highlightedObjectColor.slice(0,3);r.highlightedObjectColor=o}return t.highlightColor&&(r.highlightColor=Jg(t.highlightColor,i)),t.isActive!==void 0&&(r.isActive=Boolean(t.isActive),r.isAttribute=Boolean(t.isAttribute)),t.useByteColors!==void 0&&(r.useByteColors=Boolean(t.useByteColors)),r}L();var nh=`precision highp int;
|
|
856
856
|
|
|
857
857
|
// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
858
858
|
struct AmbientLight {
|
|
@@ -932,7 +932,7 @@ float getSpotLightAttenuation(SpotLight spotLight, vec3 positionWorldspace) {
|
|
|
932
932
|
}
|
|
933
933
|
|
|
934
934
|
// #endif
|
|
935
|
-
`;var
|
|
935
|
+
`;var rm=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
|
|
936
936
|
const MAX_LIGHTS: i32 = 5;
|
|
937
937
|
|
|
938
938
|
struct AmbientLight {
|
|
@@ -1011,14 +1011,14 @@ fn getSpotLightAttenuation(spotLight: SpotLight, positionWorldspace: vec3<f32>)
|
|
|
1011
1011
|
);
|
|
1012
1012
|
return distanceAttenuation / max(coneFactor, 0.0001);
|
|
1013
1013
|
}
|
|
1014
|
-
`;var
|
|
1014
|
+
`;var Or=5,qS={color:"vec3<f32>",position:"vec3<f32>",direction:"vec3<f32>",attenuation:"vec3<f32>",coneCos:"vec2<f32>"},$s={props:{},uniforms:{},name:"lighting",defines:{},uniformTypes:{enabled:"i32",directionalLightCount:"i32",pointLightCount:"i32",spotLightCount:"i32",ambientColor:"vec3<f32>",lights:[qS,Or]},defaultUniforms:js(),bindingLayout:[{name:"lighting",group:2}],firstBindingSlot:0,source:rm,vs:nh,fs:nh,getUniforms:GS};function GS(t,e={}){if(t=t&&{...t},!t)return js();t.lights&&(t={...t,...JS(t.lights),lights:void 0});let{useByteColors:r,ambientLight:i,pointLights:o,spotLights:n,directionalLights:s}=t||{};if(!(i||o&&o.length>0||n&&n.length>0||s&&s.length>0))return{...js(),enabled:0};let c={...js(),...QS({useByteColors:r,ambientLight:i,pointLights:o,spotLights:n,directionalLights:s})};return t.enabled!==void 0&&(c.enabled=t.enabled?1:0),c}function QS({useByteColors:t,ambientLight:e,pointLights:r=[],spotLights:i=[],directionalLights:o=[]}){let n=im(),s=0,a=0,c=0,l=0;for(let f of r){if(s>=Or)break;n[s]={...n[s],color:Ws(f,t),position:f.position,attenuation:f.attenuation||[1,0,0]},s++,a++}for(let f of i){if(s>=Or)break;n[s]={...n[s],color:Ws(f,t),position:f.position,direction:f.direction,attenuation:f.attenuation||[1,0,0],coneCos:tE(f)},s++,c++}for(let f of o){if(s>=Or)break;n[s]={...n[s],color:Ws(f,t),direction:f.direction},s++,l++}return r.length+i.length+o.length>Or&&x.warn(`MAX_LIGHTS exceeded, truncating to ${Or}`)(),{ambientColor:Ws(e,t),directionalLightCount:l,pointLightCount:a,spotLightCount:c,lights:n}}function JS(t){let e={pointLights:[],spotLights:[],directionalLights:[]};for(let r of t||[])switch(r.type){case"ambient":e.ambientLight=r;break;case"directional":e.directionalLights?.push(r);break;case"point":e.pointLights?.push(r);break;case"spot":e.spotLights?.push(r);break;default:}return e}function Ws(t={},e){let{color:r=[0,0,0],intensity:i=1}=t;return th(r,ks(e,!0)).map(n=>n*i)}function js(){return{enabled:1,directionalLightCount:0,pointLightCount:0,spotLightCount:0,ambientColor:[.1,.1,.1],lights:im()}}function im(){return Array.from({length:Or},()=>eE())}function eE(){return{color:[1,1,1],position:[1,1,2],direction:[1,1,1],attenuation:[1,0,0],coneCos:[1,0]}}function tE(t){let e=t.innerConeAngle??0,r=t.outerConeAngle??Math.PI/4;return[Math.cos(e),Math.cos(r)]}var Hs=`layout(std140) uniform phongMaterialUniforms {
|
|
1015
1015
|
uniform bool unlit;
|
|
1016
1016
|
uniform float ambient;
|
|
1017
1017
|
uniform float diffuse;
|
|
1018
1018
|
uniform float shininess;
|
|
1019
1019
|
uniform vec3 specularColor;
|
|
1020
1020
|
} material;
|
|
1021
|
-
`,
|
|
1021
|
+
`,Xs=`layout(std140) uniform phongMaterialUniforms {
|
|
1022
1022
|
uniform bool unlit;
|
|
1023
1023
|
uniform float ambient;
|
|
1024
1024
|
uniform float diffuse;
|
|
@@ -1075,7 +1075,7 @@ vec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 positio
|
|
|
1075
1075
|
|
|
1076
1076
|
return lightColor;
|
|
1077
1077
|
}
|
|
1078
|
-
`;var
|
|
1078
|
+
`;var Ys=`struct phongMaterialUniforms {
|
|
1079
1079
|
unlit: u32,
|
|
1080
1080
|
ambient: f32,
|
|
1081
1081
|
diffuse: f32,
|
|
@@ -1198,7 +1198,7 @@ fn lighting_getSpecularLightColor(cameraPosition: vec3<f32>, position_worldspace
|
|
|
1198
1198
|
}
|
|
1199
1199
|
return lightColor;
|
|
1200
1200
|
}
|
|
1201
|
-
`;var tE=[38.25,38.25,38.25],Eo={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:Hs.replace("phongMaterial","gouraudMaterial"),fs:$s.replace("phongMaterial","gouraudMaterial"),source:Xs.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[js,ks],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:tE},getUniforms(t){return{...Eo.defaultUniforms,...t}}};var rE=[38.25,38.25,38.25],wo={name:"phongMaterial",firstBindingSlot:0,bindingLayout:[{name:"phongMaterial",group:3}],dependencies:[js,ks],source:Xs,vs:$s,fs:Hs,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:rE},getUniforms(t){return{...wo.defaultUniforms,...t}}};F();var oh={};function ne(t="id"){oh[t]=oh[t]||1;let e=oh[t]++;return`${t}-${e}`}var Ys=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||ne("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&I.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 im(t,e){if(e instanceof Ys)return e;let r=iE(t,e),{attributes:i,bufferLayout:o}=oE(t,e);return new Ys({topology:e.topology||"triangle-list",bufferLayout:o,vertexCount:e.vertexCount,indices:r,attributes:i})}function iE(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:I.INDEX,data:r})}function oE(t,e){let r=[],i={};for(let[n,s]of Object.entries(e.attributes)){let a=n;switch(n){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"TEXCOORD_1":a="texCoords1";break;case"COLOR_0":a="colors";break}if(s){i[a]=t.createBuffer({data:s.value,id:`${n}-buffer`});let{value:c,size:l,normalized:f}=s;if(l===void 0)throw new Error(`Attribute ${n} is missing a size`);r.push({name:a,format:vt.getVertexFormatFromAttribute(c,l,f)})}}let o=e._calculateVertexCount(e.attributes,e.indices);return{attributes:i,bufferLayout:r,vertexCount:o}}function om(t,e){let r={},i="Values";if(t.attributes.length===0&&!t.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let o of t.attributes)if(o){let n=`${o.location} ${o.name}: ${o.type}`;r[`in ${n}`]={[i]:o.stepMode||"vertex"}}for(let o of t.varyings||[]){let n=`${o.location} ${o.name}`;r[`out ${n}`]={[i]:JSON.stringify(o)}}return r}var nm="__debugFramebufferState";function am(t,e,r){if(t.device.type!=="webgl")return;let i=aE(t.device);if(!i.flushing){if(lE(t)){nE(t,r,i);return}e&&cE(e)&&e.handle!==null&&(i.queuedFramebuffers.includes(e)||i.queuedFramebuffers.push(e))}}function nE(t,e,r){if(r.queuedFramebuffers.length===0)return;let i=t.device,{gl:o}=i,n=o.getParameter(36010),s=o.getParameter(36006),[a,c]=t.device.getDefaultCanvasContext().getDrawingBufferSize(),l=sm(e.top,8),f=sm(e.left,8);r.flushing=!0;try{for(let h of r.queuedFramebuffers){let[u,d,p,g,m]=sE({framebuffer:h,targetWidth:a,targetHeight:c,topPx:l,leftPx:f,minimap:e.minimap});o.bindFramebuffer(36008,h.handle),o.bindFramebuffer(36009,null),o.blitFramebuffer(0,0,h.width,h.height,u,d,p,g,16384,9728),l+=m+8}}finally{o.bindFramebuffer(36008,n),o.bindFramebuffer(36009,s),r.flushing=!1}}function sE(t){let{framebuffer:e,targetWidth:r,targetHeight:i,topPx:o,leftPx:n,minimap:s}=t,a=s?Math.max(Math.floor(r/4),1):r,c=s?Math.max(Math.floor(i/4),1):i,l=Math.min(a/e.width,c/e.height),f=Math.max(Math.floor(e.width*l),1),h=Math.max(Math.floor(e.height*l),1),u=n,d=Math.max(i-o-h,0),p=u+f,g=d+h;return[u,d,p,g,h]}function aE(t){return t.userData[nm]||={flushing:!1,queuedFramebuffers:[]},t.userData[nm]}function cE(t){return"colorAttachments"in t}function lE(t){let e=t.props.framebuffer;return!e||e.handle===null}function sm(t,e){if(!t)return e;let r=Number.parseInt(t,10);return Number.isFinite(r)?r:e}function Ks(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!Ks(t[i],e[i],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(let n of i)if(!e.hasOwnProperty(n)||!Ks(t[n],e[n],r-1))return!1;return!0}return!1}F();var wi=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(r=>r.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(r=>r.attribute):[e.name]}mergeBufferLayouts(e,r){let i=[...e];for(let o of r){let n=i.findIndex(s=>s.name===o.name);n<0?i.push(o):i[n]=o}return i}getBufferIndex(e){let r=this.bufferLayouts.findIndex(i=>i.name===e);return r===-1&&x.warn(`BufferLayout: Missing buffer for "${e}".`)(),r}};function cm(t,e){let r=1/0;for(let i of t){let o=e[i];o!==void 0&&(r=Math.min(r,o))}return r}function lm(t,e){let r=Object.fromEntries(t.attributes.map(o=>[o.name,o.location])),i=e.slice();return i.sort((o,n)=>{let s=o.attributes?o.attributes.map(f=>f.attribute):[o.name],a=n.attributes?n.attributes.map(f=>f.attribute):[n.name],c=cm(s,r),l=cm(a,r);return c-l}),i}function nh(t,e){if(!t||!e.some(i=>i.bindingLayout?.length))return t;let r={...t,bindings:t.bindings.map(i=>({...i}))};"attributes"in(t||{})&&(r.attributes=t?.attributes||[]);for(let i of e)for(let o of i.bindingLayout||[])for(let n of fE(o.name)){let s=r.bindings.find(a=>a.name===n);s?.group===0&&(s.group=o.group)}return r}function fm(t){return Boolean(t.uniformTypes&&!hE(t.uniformTypes))}function fE(t){let e=new Set([t,`${t}Uniforms`]);return t.endsWith("Uniforms")||e.add(`${t}Sampler`),[...e]}function hE(t){for(let e in t)return!1;return!0}F();function hm(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function um(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":!1}function sh(t){return hm(t)||um(t)}function uE(t){return sh(t)||typeof t=="number"||typeof t=="boolean"}function dm(t,e={}){let r={bindings:{},uniforms:{}};return Object.keys(t).forEach(i=>{let o=t[i];Object.prototype.hasOwnProperty.call(e,i)||uE(o)?r.uniforms[i]=o:r.bindings[i]=o}),r}var Zs=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,r){Object.assign(this.options,r);let i=bi(Object.values(e).filter(dE));for(let o of i)e[o.name]=o;x.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[o,n]of Object.entries(e))n&&(this._addModule(n),n.name&&o!==n.name&&!this.options.disableWarnings&&x.warn(`Module name: ${o} vs ${n.name}`)())}destroy(){}setProps(e){for(let r of Object.keys(e)){let i=r,o=e[i]||{},n=this.modules[i];if(!n)this.options.disableWarnings||x.warn(`Module ${r} not found`)();else{let s=this.moduleUniforms[i],a=this.moduleBindings[i],c=n.getUniforms?.(o,s)||o,{uniforms:l,bindings:f}=dm(c,n.uniformTypes);this.moduleUniforms[i]=pm(s,l,n.uniformTypes),this.moduleBindings[i]={...a,...f}}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let r of Object.values(this.moduleBindings))Object.assign(e,r);return e}getDebugTable(){let e={};for(let[r,i]of Object.entries(this.moduleUniforms))for(let[o,n]of Object.entries(i))e[`${r}.${o}`]={type:this.modules[r].uniformTypes?.[o],value:String(n)};return e}_addModule(e){let r=e.name;this.moduleUniforms[r]=pm({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[r]={}}};function pm(t={},e={},r={}){let i={...t};for(let[o,n]of Object.entries(e))n!==void 0&&(i[o]=ah(t[o],n,r[o]));return i}function ah(t,e,r){if(!r||typeof r=="string")return Ro(e);if(Array.isArray(r)){if(ch(e)||!Array.isArray(e))return Ro(e);let s=Array.isArray(t)&&!ch(t)?[...t]:[],a=s.slice();for(let c=0;c<e.length;c++){let l=e[c];l!==void 0&&(a[c]=ah(s[c],l,r[0]))}return a}if(!lh(e))return Ro(e);let i=r,o=lh(t)?t:{},n={...o};for(let[s,a]of Object.entries(e))a!==void 0&&(n[s]=ah(o[s],a,i[s]));return n}function Ro(t){return ArrayBuffer.isView(t)?Array.prototype.slice.call(t):Array.isArray(t)?ch(t)?t.slice():t.map(r=>r===void 0?void 0:Ro(r)):lh(t)?Object.fromEntries(Object.entries(t).map(([e,r])=>[e,r===void 0?void 0:Ro(r)])):t}function ch(t){return ArrayBuffer.isView(t)||Array.isArray(t)&&(t.length===0||typeof t[0]=="number")}function lh(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}function dE(t){return Boolean(t?.dependencies)}F();F();var fh={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function Po(t){return t?Array.isArray(t)?t[0]??null:t:null}function gm(t){let{dimension:e,data:r}=t;if(!r)return null;switch(e){case"1d":{let i=Po(r);if(!i)return null;let{width:o}=vo(i);return{width:o,height:1}}case"2d":{let i=Po(r);return i?vo(i):null}case"3d":case"2d-array":{if(!Array.isArray(r)||r.length===0)return null;let i=Po(r[0]);return i?vo(i):null}case"cube":{let i=Object.keys(r)[0]??null;if(!i)return null;let o=r[i],n=Po(o);return n?vo(n):null}case"cube-array":{if(!Array.isArray(r)||r.length===0)return null;let i=r[0],o=Object.keys(i)[0]??null;if(!o)return null;let n=Po(i[o]);return n?vo(n):null}default:return null}}function vo(t){if(ni(t))return no(t);if(typeof t=="object"&&"width"in t&&"height"in t)return{width:t.width,height:t.height};throw new Error("Unsupported mip-level data")}function pE(t){return typeof t=="object"&&t!==null&&"data"in t&&"width"in t&&"height"in t}function gE(t){return ArrayBuffer.isView(t)}function hh(t){let{textureFormat:e,format:r}=t;if(e&&r&&e!==r)throw new Error(`Conflicting texture formats "${e}" and "${r}" provided for the same mip level`);return e??r}function mm(t){let e=fh[t];if(e===void 0)throw new Error(`Invalid cube face: ${t}`);return e}function mE(t,e){return 6*t+mm(e)}function uh(t){throw new Error("setTexture1DData not supported in WebGL.")}function _E(t){return Array.isArray(t)?t:[t]}function Dr(t,e,r,i){let o=_E(e),n=t,s=[];for(let a=0;a<o.length;a++){let c=o[a];if(ni(c))s.push({type:"external-image",image:c,z:n,mipLevel:a});else if(pE(c))s.push({type:"texture-data",data:c,textureFormat:hh(c),z:n,mipLevel:a});else if(gE(c)&&r)s.push({type:"texture-data",data:{data:c,width:Math.max(1,r.width>>a),height:Math.max(1,r.height>>a),...i?{format:i}:{}},textureFormat:i,z:n,mipLevel:a});else throw new Error("Unsupported 2D mip-level payload")}return s}function dh(t){let e=[];for(let r=0;r<t.length;r++)e.push(...Dr(r,t[r]));return e}function ph(t){let e=[];for(let r=0;r<t.length;r++)e.push(...Dr(r,t[r]));return e}function gh(t){let e=[];for(let[r,i]of Object.entries(t)){let o=mm(r);e.push(...Dr(o,i))}return e}function mh(t){let e=[];return t.forEach((r,i)=>{for(let[o,n]of Object.entries(r)){let s=mE(i,o);e.push(...Dr(s,n))}}),e}var yh=class{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get texture(){if(!this._texture)throw new Error("Texture not initialized yet");return this._texture}get sampler(){if(!this._sampler)throw new Error("Sampler not initialized yet");return this._sampler}get view(){if(!this._view)throw new Error("View not initialized yet");return this._view}get[Symbol.toStringTag](){return"DynamicTexture"}toString(){let e=this._texture?.width??this.props.width??"?",r=this._texture?.height??this.props.height??"?";return`DynamicTexture:"${this.id}":${e}x${r}px:(${this.isReady?"ready":"loading..."})`}constructor(e,r){this.device=e;let i=ne("dynamic-texture"),o=r;this.props={...yh.defaultProps,id:i,...r,data:null},this.id=this.props.id,this.ready=new Promise((n,s)=>{this.resolveReady=n,this.rejectReady=s}),this.initAsync(o)}async initAsync(e){try{let r=await this._loadAllData(e);this._checkNotDestroyed();let i=r.data?yE({...r,width:e.width,height:e.height,format:e.format}):[],o="format"in e&&e.format!==void 0,n="usage"in e&&e.usage!==void 0,a=(()=>{if(this.props.width&&this.props.height)return{width:this.props.width,height:this.props.height};let g=gm(r);return g||{width:this.props.width||1,height:this.props.height||1}})();if(!a||a.width<=0||a.height<=0)throw new Error(`${this} size could not be determined or was zero`);let c=bE(this.device,i,a,{format:o?e.format:void 0}),l=c.format??this.props.format,f={...this.props,...a,format:l,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(l)&&!n&&(f.usage=B.SAMPLE|B.COPY_DST);let h=this.props.mipmaps&&!c.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(l);if(this.device.type==="webgpu"&&h){let g=this.props.dimension==="3d"?B.SAMPLE|B.STORAGE|B.COPY_DST|B.COPY_SRC:B.SAMPLE|B.RENDER|B.COPY_DST|B.COPY_SRC;f.usage|=g}let u=this.device.getMipLevelCount(f.width,f.height),d=c.hasExplicitMipChain?c.mipLevels:this.props.mipLevels==="auto"?u:Math.max(1,Math.min(u,this.props.mipLevels??1)),p={...f,mipLevels:d};this._texture=this.device.createTexture(p),this._sampler=this.texture.sampler,this._view=this.texture.view,c.subresources.length&&this._setTextureSubresources(c.subresources),this.props.mipmaps&&!c.hasExplicitMipChain&&!h&&x.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),h&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),x.info(0,`${this} created`)()}catch(r){let i=r instanceof Error?r:new Error(String(r));this.rejectReady(i)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){this.device.type==="webgl"?this.texture.generateMipmapsWebGL():this.device.type==="webgpu"?this.device.generateMipmapsWebGPU(this.texture):x.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();let r=e instanceof Be?e:this.device.createSampler(e);this.texture.setSampler(r),this._sampler=r}async readBuffer(e={}){this.isReady||await this.ready;let r=e.width??this.texture.width,i=e.height??this.texture.height,o=e.depthOrArrayLayers??this.texture.depth,n=this.texture.computeMemoryLayout({width:r,height:i,depthOrArrayLayers:o}),s=this.device.createBuffer({byteLength:n.byteLength,usage:I.COPY_DST|I.MAP_READ});this.texture.readBuffer({...e,width:r,height:i,depthOrArrayLayers:o},s);let a=this.device.createFence();return await a.signaled,a.destroy(),s}async readAsync(e={}){this.isReady||await this.ready;let r=e.width??this.texture.width,i=e.height??this.texture.height,o=e.depthOrArrayLayers??this.texture.depth,n=this.texture.computeMemoryLayout({width:r,height:i,depthOrArrayLayers:o}),s=await this.readBuffer(e),a=await s.readAsync(0,n.byteLength);return s.destroy(),a.buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;let r=this.texture;return this._texture=r.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,r.destroy(),x.info(`${this} resized`),!0}getCubeFaceIndex(e){let r=fh[e];if(r===void 0)throw new Error(`Invalid cube face: ${e}`);return r}getCubeArrayFaceIndex(e,r){return 6*e+this.getCubeFaceIndex(r)}setTexture1DData(e){if(this._checkReady(),this.texture.props.dimension!=="1d")throw new Error(`${this} is not 1d`);let r=uh(e);this._setTextureSubresources(r)}setTexture2DData(e,r=0){if(this._checkReady(),this.texture.props.dimension!=="2d")throw new Error(`${this} is not 2d`);let i=Dr(r,e);this._setTextureSubresources(i)}setTexture3DData(e){if(this.texture.props.dimension!=="3d")throw new Error(`${this} is not 3d`);let r=dh(e);this._setTextureSubresources(r)}setTextureArrayData(e){if(this.texture.props.dimension!=="2d-array")throw new Error(`${this} is not 2d-array`);let r=ph(e);this._setTextureSubresources(r)}setTextureCubeData(e){if(this.texture.props.dimension!=="cube")throw new Error(`${this} is not cube`);let r=gh(e);this._setTextureSubresources(r)}setTextureCubeArrayData(e){if(this.texture.props.dimension!=="cube-array")throw new Error(`${this} is not cube-array`);let r=mh(e);this._setTextureSubresources(r)}_setTextureSubresources(e){for(let r of e){let{z:i,mipLevel:o}=r;switch(r.type){case"external-image":let{image:n,flipY:s}=r;this.texture.copyExternalImage({image:n,z:i,mipLevel:o,flipY:s});break;case"texture-data":let{data:a,textureFormat:c}=r;if(c&&c!==this.texture.format)throw new Error(`${this} mip level ${o} uses format "${c}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:i,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:o});break;default:throw new Error("Unsupported 2D mip-level payload")}}}async _loadAllData(e){let r=await _h(e.data);return{dimension:e.dimension??"2d",data:r??null}}_checkNotDestroyed(){this.destroyed&&x.warn(`${this} already destroyed`)}_checkReady(){this.isReady||x.warn(`${this} Cannot perform this operation before ready`)}},or=yh;M(or,"defaultProps",{...B.defaultProps,dimension:"2d",data:null,mipmaps:!1});function yE(t){if(!t.data)return[];let e=t.width&&t.height?{width:t.width,height:t.height}:void 0,r="format"in t?t.format:void 0;switch(t.dimension){case"1d":return uh(t.data);case"2d":return Dr(0,t.data,e,r);case"3d":return dh(t.data);case"2d-array":return ph(t.data);case"cube":return gh(t.data);case"cube-array":return mh(t.data);default:throw new Error(`Unhandled dimension ${t.dimension}`)}}function bE(t,e,r,i){if(e.length===0)return{subresources:e,mipLevels:1,format:i.format,hasExplicitMipChain:!1};let o=new Map;for(let f of e){let h=o.get(f.z)??[];h.push(f),o.set(f.z,h)}let n=e.some(f=>f.mipLevel>0),s=i.format,a=Number.POSITIVE_INFINITY,c=[];for(let[f,h]of o){let u=[...h].sort((b,y)=>b.mipLevel-y.mipLevel),d=u[0];if(!d||d.mipLevel!==0)throw new Error(`DynamicTexture: slice ${f} is missing mip level 0`);let p=ym(t,d);if(p.width!==r.width||p.height!==r.height)throw new Error(`DynamicTexture: slice ${f} base level dimensions ${p.width}x${p.height} do not match expected ${r.width}x${r.height}`);let g=_m(d);if(g){if(s&&s!==g)throw new Error(`DynamicTexture: slice ${f} base level format "${g}" does not match texture format "${s}"`);s=g}let m=s&&t.isTextureFormatCompressed(s)?TE(t,p.width,p.height,s):t.getMipLevelCount(p.width,p.height),_=0;for(let b=0;b<u.length;b++){let y=u[b];if(!y||y.mipLevel!==b||b>=m)break;let T=ym(t,y),S=Math.max(1,p.width>>b),A=Math.max(1,p.height>>b);if(T.width!==S||T.height!==A)break;let w=_m(y);if(w&&(s||(s=w),w!==s))break;_++,c.push(y)}a=Math.min(a,_)}let l=Number.isFinite(a)?Math.max(1,a):1;return{subresources:c.filter(f=>f.mipLevel<l),mipLevels:l,format:s,hasExplicitMipChain:n}}function _m(t){if(t.type==="texture-data")return t.textureFormat??hh(t.data)}function ym(t,e){switch(e.type){case"external-image":return t.getExternalImageSize(e.image);case"texture-data":return{width:e.data.width,height:e.data.height};default:throw new Error("Unsupported texture subresource")}}function TE(t,e,r,i){let{blockWidth:o=1,blockHeight:n=1}=t.getTextureFormatInfo(i),s=1;for(let a=1;;a++){let c=Math.max(1,e>>a),l=Math.max(1,r>>a);if(c<o||l<n)break;s++}return s}async function _h(t){if(t=await t,Array.isArray(t))return await Promise.all(t.map(_h));if(t&&typeof t=="object"&&t.constructor===Object){let e=t,r=await Promise.all(Object.values(e).map(_h)),i=Object.keys(e),o={};for(let n=0;n<i.length;n++)o[i[n]]=r[n];return o}return t}var nr=2,xE=1e4,bm="render pipeline initialization failed",bh=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;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,r){this.props={...bh.defaultProps,...r},r=this.props,this.id=r.id||ne("model"),this.device=e,Object.assign(this.userData,r.userData),this.material=r.material||null;let i=Object.fromEntries(this.props.modules?.map(c=>[c.name,c])||[]),o=r.shaderInputs||new Zs(i,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(o);let n=AE(e),s=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.props.shaderLayout=nh(this.props.shaderLayout,s)||null,this.device.type==="webgpu"&&this.props.source){let{source:c,getUniforms:l,bindingTable:f}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:n,...this.props,modules:s});this.source=c,this._getModuleUniforms=l,this._bindingTable=f;let h=e.getShaderLayout?.(this.source);this.props.shaderLayout=nh(this.props.shaderLayout||h||null,s)||null}else{let{vs:c,fs:l,getUniforms:f}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:n,...this.props,modules:s});this.vs=c,this.fs=l,this._getModuleUniforms=f,this._bindingTable=[]}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,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||ci.getDefaultPipelineFactory(this.device),this.shaderFactory=r.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 r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&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}getBindingDebugTable(){return this._bindingTable}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let r=this._areBindingsLoading();if(r)return x.info(nr,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let i,o=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),o=this.pipeline.isErrored,o)x.info(nr,`>>> DRAWING ABORTED ${this.id}: ${bm}`)(),i=!1;else{let n=this._getBindings(),s=this._getBindGroups(),{indexBuffer:a}=this.vertexArray,c=a?a.byteLength/(a.indexType==="uint32"?4:2):void 0;i=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:c,transformFeedback:this.transformFeedback||void 0,bindings:n,bindGroups:s,_bindGroupCacheKeys:this._getBindGroupCacheKeys(),uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):o?this._needsRedraw=bm:this._needsRedraw="waiting for resource initialization",i}setGeometry(e){this._gpuGeometry?.destroy();let r=e&&im(this.device,e);if(r){this.setTopology(r.topology||"triangle-list");let i=new wi(this.bufferLayout);this.bufferLayout=i.mergeBufferLayouts(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)}this._gpuGeometry=r}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let r=new wi(this.bufferLayout);this.bufferLayout=this._gpuGeometry?r.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){Ks(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 mo(this.device,this.shaderInputs.modules);for(let[r,i]of Object.entries(this.shaderInputs.modules))if(fm(i)&&!this.material?.ownsModule(r)){let o=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=o}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this._getNonMaterialBindings(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,r){let i=r?.disableWarnings??this.props.disableWarnings;e.indices&&x.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=lm(this.pipeline.shaderLayout,this.bufferLayout);let o=new wi(this.bufferLayout);for(let[n,s]of Object.entries(e)){let a=o.getBufferLayout(n);if(!a){i||x.warn(`Model(${this.id}): Missing layout for buffer "${n}".`)();continue}let c=o.getAttributeNamesForBuffer(a),l=!1;for(let f of c){let h=this._attributeInfos[f];if(h){let u=this.device.type==="webgpu"?o.getBufferIndex(h.bufferName):h.location;this.vertexArray.setBuffer(u,s),l=!0}}!l&&!i&&x.warn(`Model(${this.id}): Ignoring buffer "${s.id}" for unknown attribute "${n}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,r){for(let[i,o]of Object.entries(e)){let n=this._attributeInfos[i];n?this.vertexArray.setConstantWebGL(n.location,o):(r?.disableWarnings??this.props.disableWarnings)||x.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(e instanceof or&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(e instanceof or&&!e.isReady)return e.id;return!1}_getBindings(){let e={};for(let[r,i]of Object.entries(this.bindings))i instanceof or?i.isReady&&(e[r]=i.texture):e[r]=i;return e}_getBindGroups(){let e=this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]},r=e.bindings.length?uo(e,this._getBindings()):{0:this._getBindings()};if(!this.material)return r;for(let[i,o]of Object.entries(this.material.getBindingsByGroup())){let n=Number(i);r[n]={...r[n]||{},...o}}return r}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof Jt?e=Math.max(e,r.texture.updateTimestamp):r instanceof I||r instanceof B?e=Math.max(e,r.updateTimestamp):r instanceof or?e=r.texture?Math.max(e,r.texture.updateTimestamp):1/0:r instanceof Be||(e=Math.max(e,r.buffer.updateTimestamp));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let r={...e.attributes};for(let[i]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(o=>o.name===i)&&i!=="positions"&&delete r[i];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,r=null;this.pipeline&&(x.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),o=null;this.source?o=i:this.fs&&(o=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,bindings:void 0,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindGroups:this._getBindGroups(),vs:i,fs:o}),this._attributeInfos=xs(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),r&&r!==e&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=x.level>3?0:xE;x.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,x.group(nr,`>>> DRAWING MODEL ${this.id}`,{collapsed:x.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=om(this.pipeline.shaderLayout,this.id);x.table(nr,e)();let r=this.shaderInputs.getDebugTable();x.table(nr,r)();let i=this._getAttributeDebugTable();x.table(nr,this._attributeInfos)(),x.table(nr,i)(),x.groupEnd(nr)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;let i=e.props.framebuffer;am(e,i,{id:i?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[r,i]of Object.entries(this._attributeInfos)){let o=this.vertexArray.attributes[i.location];e[i.location]={name:r,type:i.shaderType,values:o?this._getBufferOrConstantValues(o,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,i=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);e.indices={name:"indices",type:r.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,r){let i=ue.getTypedArrayConstructor(r);return(e instanceof I?new i(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let r={};for(let[i,o]of Object.entries(e))this.material.ownsBinding(i)||(r[i]=o);return r}},ve=bh;M(ve,"defaultProps",{...we.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:rr.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function AE(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}F();var qs=class{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,r=qs.defaultProps){if(!qs.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new ve(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||To(),topology:r.topology||"point-list",varyings:r.outputs||r.varyings,...r}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.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 r=this.device.beginRenderPass(e);this.model.draw(r),r.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let r=this.getBuffer(e);if(!r)throw new Error("BufferTransform#getBuffer");if(r instanceof I)return r.readAsync();let{buffer:i,byteOffset:o=0,byteLength:n=i.byteLength}=r;return i.readAsync(o,n)}},$e=qs;M($e,"defaultProps",{...ve.defaultProps,outputs:void 0,feedbackBuffers:void 0});var SE="transform_output",Mo=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,r){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new ve(this.device,{id:r.id||ne("texture-transform-model"),fs:r.fs||To({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:SE}),vertexCount:r.vertexCount,...r}),this._initialize(r),Object.seal(this)}destroy(){this.model.destroy();for(let e of this.bindings)e.framebuffer?.destroy()}delete(){this.destroy()}run(e){let{framebuffer:r}=this.bindings[this.currentIndex],i=this.device.beginRenderPass({framebuffer:r,...e});this.model.draw(i),i.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:r,sourceTextures:i,targetTexture:o}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,i),Object.assign(e.sourceBuffers,r),o){e.targetTexture=o;let{width:n,height:s}=o;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:n,height:s,colorAttachments:[o]}),e.framebuffer.resize({width:n,height:s})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:r}=this.bindings[e];for(let i in r)r[i].sampler=this.sampler}};var He=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:r={},indices:i=null,vertexCount:o=null}=e;this.id=e.id||ne("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[n,s]of Object.entries(r)){let a=ArrayBuffer.isView(s)?{value:s}:s;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(n)}: must be typed array or object with value as typed array`);if((n==="POSITION"||n==="positions")&&!a.size&&(a.size=3),n==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else this.attributes[n]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=o||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,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let i=1/0;for(let o of Object.values(e)){let{value:n,size:s,constant:a}=o;!a&&n&&s!==void 0&&s>=1&&(i=Math.min(i,n.length/s))}return i}};var EE=`struct VertexInputs {
|
|
1201
|
+
`;var rE=[38.25,38.25,38.25],wo={props:{},name:"gouraudMaterial",bindingLayout:[{name:"gouraudMaterial",group:3}],vs:Xs.replace("phongMaterial","gouraudMaterial"),fs:Hs.replace("phongMaterial","gouraudMaterial"),source:Ys.replaceAll("phongMaterial","gouraudMaterial"),defines:{LIGHTING_VERTEX:!0},dependencies:[$s,Vs],uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:rE},getUniforms(t){return{...wo.defaultUniforms,...t}}};var iE=[38.25,38.25,38.25],Ro={name:"phongMaterial",firstBindingSlot:0,bindingLayout:[{name:"phongMaterial",group:3}],dependencies:[$s,Vs],source:Ys,vs:Hs,fs:Xs,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{unlit:"i32",ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{unlit:!1,ambient:.35,diffuse:.6,shininess:32,specularColor:iE},getUniforms(t){return{...Ro.defaultUniforms,...t}}};L();var sh={};function oe(t="id"){sh[t]=sh[t]||1;let e=sh[t]++;return`${t}-${e}`}var Ks=class{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){if(this.id=e.id||oe("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&I.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 om(t,e){if(e instanceof Ks)return e;let r=oE(t,e),{attributes:i,bufferLayout:o}=nE(t,e);return new Ks({topology:e.topology||"triangle-list",bufferLayout:o,vertexCount:e.vertexCount,indices:r,attributes:i})}function oE(t,e){if(!e.indices)return;let r=e.indices.value;return t.createBuffer({usage:I.INDEX,data:r})}function nE(t,e){let r=[],i={};for(let[n,s]of Object.entries(e.attributes)){let a=n;switch(n){case"POSITION":a="positions";break;case"NORMAL":a="normals";break;case"TEXCOORD_0":a="texCoords";break;case"TEXCOORD_1":a="texCoords1";break;case"COLOR_0":a="colors";break}if(s){i[a]=t.createBuffer({data:s.value,id:`${n}-buffer`});let{value:c,size:l,normalized:f}=s;if(l===void 0)throw new Error(`Attribute ${n} is missing a size`);r.push({name:a,format:Pt.getVertexFormatFromAttribute(c,l,f)})}}let o=e._calculateVertexCount(e.attributes,e.indices);return{attributes:i,bufferLayout:r,vertexCount:o}}function nm(t,e){let r={},i="Values";if(t.attributes.length===0&&!t.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(let o of t.attributes)if(o){let n=`${o.location} ${o.name}: ${o.type}`;r[`in ${n}`]={[i]:o.stepMode||"vertex"}}for(let o of t.varyings||[]){let n=`${o.location} ${o.name}`;r[`out ${n}`]={[i]:JSON.stringify(o)}}return r}var sm="__debugFramebufferState";function cm(t,e,r){if(t.device.type!=="webgl")return;let i=cE(t.device);if(!i.flushing){if(fE(t)){sE(t,r,i);return}e&&lE(e)&&e.handle!==null&&(i.queuedFramebuffers.includes(e)||i.queuedFramebuffers.push(e))}}function sE(t,e,r){if(r.queuedFramebuffers.length===0)return;let i=t.device,{gl:o}=i,n=o.getParameter(36010),s=o.getParameter(36006),[a,c]=t.device.getDefaultCanvasContext().getDrawingBufferSize(),l=am(e.top,8),f=am(e.left,8);r.flushing=!0;try{for(let h of r.queuedFramebuffers){let[u,d,p,g,m]=aE({framebuffer:h,targetWidth:a,targetHeight:c,topPx:l,leftPx:f,minimap:e.minimap});o.bindFramebuffer(36008,h.handle),o.bindFramebuffer(36009,null),o.blitFramebuffer(0,0,h.width,h.height,u,d,p,g,16384,9728),l+=m+8}}finally{o.bindFramebuffer(36008,n),o.bindFramebuffer(36009,s),r.flushing=!1}}function aE(t){let{framebuffer:e,targetWidth:r,targetHeight:i,topPx:o,leftPx:n,minimap:s}=t,a=s?Math.max(Math.floor(r/4),1):r,c=s?Math.max(Math.floor(i/4),1):i,l=Math.min(a/e.width,c/e.height),f=Math.max(Math.floor(e.width*l),1),h=Math.max(Math.floor(e.height*l),1),u=n,d=Math.max(i-o-h,0),p=u+f,g=d+h;return[u,d,p,g,h]}function cE(t){return t.userData[sm]||={flushing:!1,queuedFramebuffers:[]},t.userData[sm]}function lE(t){return"colorAttachments"in t}function fE(t){let e=t.props.framebuffer;return!e||e.handle===null}function am(t,e){if(!t)return e;let r=Number.parseInt(t,10);return Number.isFinite(r)?r:e}function Zs(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!Zs(t[i],e[i],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(let n of i)if(!e.hasOwnProperty(n)||!Zs(t[n],e[n],r-1))return!1;return!0}return!1}L();var Ri=class{bufferLayouts;constructor(e){this.bufferLayouts=e}getBufferLayout(e){return this.bufferLayouts.find(r=>r.name===e)||null}getAttributeNamesForBuffer(e){return e.attributes?e.attributes?.map(r=>r.attribute):[e.name]}mergeBufferLayouts(e,r){let i=[...e];for(let o of r){let n=i.findIndex(s=>s.name===o.name);n<0?i.push(o):i[n]=o}return i}getBufferIndex(e){let r=this.bufferLayouts.findIndex(i=>i.name===e);return r===-1&&x.warn(`BufferLayout: Missing buffer for "${e}".`)(),r}};function lm(t,e){let r=1/0;for(let i of t){let o=e[i];o!==void 0&&(r=Math.min(r,o))}return r}function fm(t,e){let r=Object.fromEntries(t.attributes.map(o=>[o.name,o.location])),i=e.slice();return i.sort((o,n)=>{let s=o.attributes?o.attributes.map(f=>f.attribute):[o.name],a=n.attributes?n.attributes.map(f=>f.attribute):[n.name],c=lm(s,r),l=lm(a,r);return c-l}),i}function ah(t,e){if(!t||!e.some(i=>i.bindingLayout?.length))return t;let r={...t,bindings:t.bindings.map(i=>({...i}))};"attributes"in(t||{})&&(r.attributes=t?.attributes||[]);for(let i of e)for(let o of i.bindingLayout||[])for(let n of hE(o.name)){let s=r.bindings.find(a=>a.name===n);s?.group===0&&(s.group=o.group)}return r}function hm(t){return Boolean(t.uniformTypes&&!uE(t.uniformTypes))}function hE(t){let e=new Set([t,`${t}Uniforms`]);return t.endsWith("Uniforms")||e.add(`${t}Sampler`),[...e]}function uE(t){for(let e in t)return!1;return!0}L();function um(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function dm(t){return Array.isArray(t)?t.length===0||typeof t[0]=="number":!1}function ch(t){return um(t)||dm(t)}function dE(t){return ch(t)||typeof t=="number"||typeof t=="boolean"}function pm(t,e={}){let r={bindings:{},uniforms:{}};return Object.keys(t).forEach(i=>{let o=t[i];Object.prototype.hasOwnProperty.call(e,i)||dE(o)?r.uniforms[i]=o:r.bindings[i]=o}),r}var qs=class{options={disableWarnings:!1};modules;moduleUniforms;moduleBindings;constructor(e,r){Object.assign(this.options,r);let i=Ti(Object.values(e).filter(pE));for(let o of i)e[o.name]=o;x.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(let[o,n]of Object.entries(e))n&&(this._addModule(n),n.name&&o!==n.name&&!this.options.disableWarnings&&x.warn(`Module name: ${o} vs ${n.name}`)())}destroy(){}setProps(e){for(let r of Object.keys(e)){let i=r,o=e[i]||{},n=this.modules[i];if(!n)this.options.disableWarnings||x.warn(`Module ${r} not found`)();else{let s=this.moduleUniforms[i],a=this.moduleBindings[i],c=n.getUniforms?.(o,s)||o,{uniforms:l,bindings:f}=pm(c,n.uniformTypes);this.moduleUniforms[i]=gm(s,l,n.uniformTypes),this.moduleBindings[i]={...a,...f}}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindingValues(){let e={};for(let r of Object.values(this.moduleBindings))Object.assign(e,r);return e}getDebugTable(){let e={};for(let[r,i]of Object.entries(this.moduleUniforms))for(let[o,n]of Object.entries(i))e[`${r}.${o}`]={type:this.modules[r].uniformTypes?.[o],value:String(n)};return e}_addModule(e){let r=e.name;this.moduleUniforms[r]=gm({},e.defaultUniforms||{},e.uniformTypes),this.moduleBindings[r]={}}};function gm(t={},e={},r={}){let i={...t};for(let[o,n]of Object.entries(e))n!==void 0&&(i[o]=lh(t[o],n,r[o]));return i}function lh(t,e,r){if(!r||typeof r=="string")return Po(e);if(Array.isArray(r)){if(fh(e)||!Array.isArray(e))return Po(e);let s=Array.isArray(t)&&!fh(t)?[...t]:[],a=s.slice();for(let c=0;c<e.length;c++){let l=e[c];l!==void 0&&(a[c]=lh(s[c],l,r[0]))}return a}if(!hh(e))return Po(e);let i=r,o=hh(t)?t:{},n={...o};for(let[s,a]of Object.entries(e))a!==void 0&&(n[s]=lh(o[s],a,i[s]));return n}function Po(t){return ArrayBuffer.isView(t)?Array.prototype.slice.call(t):Array.isArray(t)?fh(t)?t.slice():t.map(r=>r===void 0?void 0:Po(r)):hh(t)?Object.fromEntries(Object.entries(t).map(([e,r])=>[e,r===void 0?void 0:Po(r)])):t}function fh(t){return ArrayBuffer.isView(t)||Array.isArray(t)&&(t.length===0||typeof t[0]=="number")}function hh(t){return Boolean(t)&&typeof t=="object"&&!Array.isArray(t)&&!ArrayBuffer.isView(t)}function pE(t){return Boolean(t?.dependencies)}L();L();var uh={"+X":0,"-X":1,"+Y":2,"-Y":3,"+Z":4,"-Z":5};function vo(t){return t?Array.isArray(t)?t[0]??null:t:null}function mm(t){let{dimension:e,data:r}=t;if(!r)return null;switch(e){case"1d":{let i=vo(r);if(!i)return null;let{width:o}=Mo(i);return{width:o,height:1}}case"2d":{let i=vo(r);return i?Mo(i):null}case"3d":case"2d-array":{if(!Array.isArray(r)||r.length===0)return null;let i=vo(r[0]);return i?Mo(i):null}case"cube":{let i=Object.keys(r)[0]??null;if(!i)return null;let o=r[i],n=vo(o);return n?Mo(n):null}case"cube-array":{if(!Array.isArray(r)||r.length===0)return null;let i=r[0],o=Object.keys(i)[0]??null;if(!o)return null;let n=vo(i[o]);return n?Mo(n):null}default:return null}}function Mo(t){if(si(t))return so(t);if(typeof t=="object"&&"width"in t&&"height"in t)return{width:t.width,height:t.height};throw new Error("Unsupported mip-level data")}function gE(t){return typeof t=="object"&&t!==null&&"data"in t&&"width"in t&&"height"in t}function mE(t){return ArrayBuffer.isView(t)}function dh(t){let{textureFormat:e,format:r}=t;if(e&&r&&e!==r)throw new Error(`Conflicting texture formats "${e}" and "${r}" provided for the same mip level`);return e??r}function _m(t){let e=uh[t];if(e===void 0)throw new Error(`Invalid cube face: ${t}`);return e}function _E(t,e){return 6*t+_m(e)}function ph(t){throw new Error("setTexture1DData not supported in WebGL.")}function yE(t){return Array.isArray(t)?t:[t]}function Nr(t,e,r,i){let o=yE(e),n=t,s=[];for(let a=0;a<o.length;a++){let c=o[a];if(si(c))s.push({type:"external-image",image:c,z:n,mipLevel:a});else if(gE(c))s.push({type:"texture-data",data:c,textureFormat:dh(c),z:n,mipLevel:a});else if(mE(c)&&r)s.push({type:"texture-data",data:{data:c,width:Math.max(1,r.width>>a),height:Math.max(1,r.height>>a),...i?{format:i}:{}},textureFormat:i,z:n,mipLevel:a});else throw new Error("Unsupported 2D mip-level payload")}return s}function gh(t){let e=[];for(let r=0;r<t.length;r++)e.push(...Nr(r,t[r]));return e}function mh(t){let e=[];for(let r=0;r<t.length;r++)e.push(...Nr(r,t[r]));return e}function _h(t){let e=[];for(let[r,i]of Object.entries(t)){let o=_m(r);e.push(...Nr(o,i))}return e}function yh(t){let e=[];return t.forEach((r,i)=>{for(let[o,n]of Object.entries(r)){let s=_E(i,o);e.push(...Nr(s,n))}}),e}var Th=class{device;id;props;_texture=null;_sampler=null;_view=null;ready;isReady=!1;destroyed=!1;resolveReady=()=>{};rejectReady=()=>{};get texture(){if(!this._texture)throw new Error("Texture not initialized yet");return this._texture}get sampler(){if(!this._sampler)throw new Error("Sampler not initialized yet");return this._sampler}get view(){if(!this._view)throw new Error("View not initialized yet");return this._view}get[Symbol.toStringTag](){return"DynamicTexture"}toString(){let e=this._texture?.width??this.props.width??"?",r=this._texture?.height??this.props.height??"?";return`DynamicTexture:"${this.id}":${e}x${r}px:(${this.isReady?"ready":"loading..."})`}constructor(e,r){this.device=e;let i=oe("dynamic-texture"),o=r;this.props={...Th.defaultProps,id:i,...r,data:null},this.id=this.props.id,this.ready=new Promise((n,s)=>{this.resolveReady=n,this.rejectReady=s}),this.initAsync(o)}async initAsync(e){try{let r=await this._loadAllData(e);this._checkNotDestroyed();let i=r.data?bE({...r,width:e.width,height:e.height,format:e.format}):[],o="format"in e&&e.format!==void 0,n="usage"in e&&e.usage!==void 0,a=(()=>{if(this.props.width&&this.props.height)return{width:this.props.width,height:this.props.height};let g=mm(r);return g||{width:this.props.width||1,height:this.props.height||1}})();if(!a||a.width<=0||a.height<=0)throw new Error(`${this} size could not be determined or was zero`);let c=TE(this.device,i,a,{format:o?e.format:void 0}),l=c.format??this.props.format,f={...this.props,...a,format:l,mipLevels:1,data:void 0};this.device.isTextureFormatCompressed(l)&&!n&&(f.usage=B.SAMPLE|B.COPY_DST);let h=this.props.mipmaps&&!c.hasExplicitMipChain&&!this.device.isTextureFormatCompressed(l);if(this.device.type==="webgpu"&&h){let g=this.props.dimension==="3d"?B.SAMPLE|B.STORAGE|B.COPY_DST|B.COPY_SRC:B.SAMPLE|B.RENDER|B.COPY_DST|B.COPY_SRC;f.usage|=g}let u=this.device.getMipLevelCount(f.width,f.height),d=c.hasExplicitMipChain?c.mipLevels:this.props.mipLevels==="auto"?u:Math.max(1,Math.min(u,this.props.mipLevels??1)),p={...f,mipLevels:d};this._texture=this.device.createTexture(p),this._sampler=this.texture.sampler,this._view=this.texture.view,c.subresources.length&&this._setTextureSubresources(c.subresources),this.props.mipmaps&&!c.hasExplicitMipChain&&!h&&x.warn(`${this} skipping auto-generated mipmaps for compressed texture format`)(),h&&this.generateMipmaps(),this.isReady=!0,this.resolveReady(this.texture),x.info(0,`${this} created`)()}catch(r){let i=r instanceof Error?r:new Error(String(r));this.rejectReady(i)}}destroy(){this._texture&&(this._texture.destroy(),this._texture=null,this._sampler=null,this._view=null),this.destroyed=!0}generateMipmaps(){this.device.type==="webgl"?this.texture.generateMipmapsWebGL():this.device.type==="webgpu"?this.device.generateMipmapsWebGPU(this.texture):x.warn(`${this} mipmaps not supported on ${this.device.type}`)}setSampler(e={}){this._checkReady();let r=e instanceof De?e:this.device.createSampler(e);this.texture.setSampler(r),this._sampler=r}async readBuffer(e={}){this.isReady||await this.ready;let r=e.width??this.texture.width,i=e.height??this.texture.height,o=e.depthOrArrayLayers??this.texture.depth,n=this.texture.computeMemoryLayout({width:r,height:i,depthOrArrayLayers:o}),s=this.device.createBuffer({byteLength:n.byteLength,usage:I.COPY_DST|I.MAP_READ});this.texture.readBuffer({...e,width:r,height:i,depthOrArrayLayers:o},s);let a=this.device.createFence();return await a.signaled,a.destroy(),s}async readAsync(e={}){this.isReady||await this.ready;let r=e.width??this.texture.width,i=e.height??this.texture.height,o=e.depthOrArrayLayers??this.texture.depth,n=this.texture.computeMemoryLayout({width:r,height:i,depthOrArrayLayers:o}),s=await this.readBuffer(e),a=await s.readAsync(0,n.byteLength);return s.destroy(),a.buffer}resize(e){if(this._checkReady(),e.width===this.texture.width&&e.height===this.texture.height)return!1;let r=this.texture;return this._texture=r.clone(e),this._sampler=this.texture.sampler,this._view=this.texture.view,r.destroy(),x.info(`${this} resized`),!0}getCubeFaceIndex(e){let r=uh[e];if(r===void 0)throw new Error(`Invalid cube face: ${e}`);return r}getCubeArrayFaceIndex(e,r){return 6*e+this.getCubeFaceIndex(r)}setTexture1DData(e){if(this._checkReady(),this.texture.props.dimension!=="1d")throw new Error(`${this} is not 1d`);let r=ph(e);this._setTextureSubresources(r)}setTexture2DData(e,r=0){if(this._checkReady(),this.texture.props.dimension!=="2d")throw new Error(`${this} is not 2d`);let i=Nr(r,e);this._setTextureSubresources(i)}setTexture3DData(e){if(this.texture.props.dimension!=="3d")throw new Error(`${this} is not 3d`);let r=gh(e);this._setTextureSubresources(r)}setTextureArrayData(e){if(this.texture.props.dimension!=="2d-array")throw new Error(`${this} is not 2d-array`);let r=mh(e);this._setTextureSubresources(r)}setTextureCubeData(e){if(this.texture.props.dimension!=="cube")throw new Error(`${this} is not cube`);let r=_h(e);this._setTextureSubresources(r)}setTextureCubeArrayData(e){if(this.texture.props.dimension!=="cube-array")throw new Error(`${this} is not cube-array`);let r=yh(e);this._setTextureSubresources(r)}_setTextureSubresources(e){for(let r of e){let{z:i,mipLevel:o}=r;switch(r.type){case"external-image":let{image:n,flipY:s}=r;this.texture.copyExternalImage({image:n,z:i,mipLevel:o,flipY:s});break;case"texture-data":let{data:a,textureFormat:c}=r;if(c&&c!==this.texture.format)throw new Error(`${this} mip level ${o} uses format "${c}" but texture format is "${this.texture.format}"`);this.texture.writeData(a.data,{x:0,y:0,z:i,width:a.width,height:a.height,depthOrArrayLayers:1,mipLevel:o});break;default:throw new Error("Unsupported 2D mip-level payload")}}}async _loadAllData(e){let r=await bh(e.data);return{dimension:e.dimension??"2d",data:r??null}}_checkNotDestroyed(){this.destroyed&&x.warn(`${this} already destroyed`)}_checkReady(){this.isReady||x.warn(`${this} Cannot perform this operation before ready`)}},ir=Th;M(ir,"defaultProps",{...B.defaultProps,dimension:"2d",data:null,mipmaps:!1});function bE(t){if(!t.data)return[];let e=t.width&&t.height?{width:t.width,height:t.height}:void 0,r="format"in t?t.format:void 0;switch(t.dimension){case"1d":return ph(t.data);case"2d":return Nr(0,t.data,e,r);case"3d":return gh(t.data);case"2d-array":return mh(t.data);case"cube":return _h(t.data);case"cube-array":return yh(t.data);default:throw new Error(`Unhandled dimension ${t.dimension}`)}}function TE(t,e,r,i){if(e.length===0)return{subresources:e,mipLevels:1,format:i.format,hasExplicitMipChain:!1};let o=new Map;for(let f of e){let h=o.get(f.z)??[];h.push(f),o.set(f.z,h)}let n=e.some(f=>f.mipLevel>0),s=i.format,a=Number.POSITIVE_INFINITY,c=[];for(let[f,h]of o){let u=[...h].sort((b,y)=>b.mipLevel-y.mipLevel),d=u[0];if(!d||d.mipLevel!==0)throw new Error(`DynamicTexture: slice ${f} is missing mip level 0`);let p=bm(t,d);if(p.width!==r.width||p.height!==r.height)throw new Error(`DynamicTexture: slice ${f} base level dimensions ${p.width}x${p.height} do not match expected ${r.width}x${r.height}`);let g=ym(d);if(g){if(s&&s!==g)throw new Error(`DynamicTexture: slice ${f} base level format "${g}" does not match texture format "${s}"`);s=g}let m=s&&t.isTextureFormatCompressed(s)?xE(t,p.width,p.height,s):t.getMipLevelCount(p.width,p.height),_=0;for(let b=0;b<u.length;b++){let y=u[b];if(!y||y.mipLevel!==b||b>=m)break;let T=bm(t,y),S=Math.max(1,p.width>>b),A=Math.max(1,p.height>>b);if(T.width!==S||T.height!==A)break;let w=ym(y);if(w&&(s||(s=w),w!==s))break;_++,c.push(y)}a=Math.min(a,_)}let l=Number.isFinite(a)?Math.max(1,a):1;return{subresources:c.filter(f=>f.mipLevel<l),mipLevels:l,format:s,hasExplicitMipChain:n}}function ym(t){if(t.type==="texture-data")return t.textureFormat??dh(t.data)}function bm(t,e){switch(e.type){case"external-image":return t.getExternalImageSize(e.image);case"texture-data":return{width:e.data.width,height:e.data.height};default:throw new Error("Unsupported texture subresource")}}function xE(t,e,r,i){let{blockWidth:o=1,blockHeight:n=1}=t.getTextureFormatInfo(i),s=1;for(let a=1;;a++){let c=Math.max(1,e>>a),l=Math.max(1,r>>a);if(c<o||l<n)break;s++}return s}async function bh(t){if(t=await t,Array.isArray(t))return await Promise.all(t.map(bh));if(t&&typeof t=="object"&&t.constructor===Object){let e=t,r=await Promise.all(Object.values(e).map(bh)),i=Object.keys(e),o={};for(let n=0;n<i.length;n++)o[i[n]]=r[n];return o}return t}var or=2,AE=1e4,Tm="render pipeline initialization failed",xh=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;material=null;_uniformStore;_attributeInfos={};_gpuGeometry=null;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;_bindingTable=[];get[Symbol.toStringTag](){return"Model"}toString(){return`Model(${this.id})`}constructor(e,r){this.props={...xh.defaultProps,...r},r=this.props,this.id=r.id||oe("model"),this.device=e,Object.assign(this.userData,r.userData),this.material=r.material||null;let i=Object.fromEntries(this.props.modules?.map(c=>[c.name,c])||[]),o=r.shaderInputs||new qs(i,{disableWarnings:this.props.disableWarnings});this.setShaderInputs(o);let n=SE(e),s=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if(this.props.shaderLayout=ah(this.props.shaderLayout,s)||null,this.device.type==="webgpu"&&this.props.source){let{source:c,getUniforms:l,bindingTable:f}=this.props.shaderAssembler.assembleWGSLShader({platformInfo:n,...this.props,modules:s});this.source=c,this._getModuleUniforms=l,this._bindingTable=f;let h=e.getShaderLayout?.(this.source);this.props.shaderLayout=ah(this.props.shaderLayout||h||null,s)||null}else{let{vs:c,fs:l,getUniforms:f}=this.props.shaderAssembler.assembleGLSLShaderPair({platformInfo:n,...this.props,modules:s});this.vs=c,this.fs=l,this._getModuleUniforms=f,this._bindingTable=[]}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,r.geometry&&this.setGeometry(r.geometry),this.pipelineFactory=r.pipelineFactory||li.getDefaultPipelineFactory(this.device),this.shaderFactory=r.shaderFactory||fi.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 r&&(this.isInstanced=r.isInstanced),r.instanceCount&&this.setInstanceCount(r.instanceCount),r.vertexCount&&this.setVertexCount(r.vertexCount),r.indexBuffer&&this.setIndexBuffer(r.indexBuffer),r.attributes&&this.setAttributes(r.attributes),r.constantAttributes&&this.setConstantAttributes(r.constantAttributes),r.bindings&&this.setBindings(r.bindings),r.transformFeedback&&(this.transformFeedback=r.transformFeedback)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.pipeline.fs!==this.pipeline.vs&&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}getBindingDebugTable(){return this._bindingTable}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let r=this._areBindingsLoading();if(r)return x.info(or,`>>> DRAWING ABORTED ${this.id}: ${r} not loaded`)(),!1;try{e.pushDebugGroup(`${this}.predraw(${e})`),this.predraw()}finally{e.popDebugGroup()}let i,o=this.pipeline.isErrored;try{if(e.pushDebugGroup(`${this}.draw(${e})`),this._logDrawCallStart(),this.pipeline=this._updatePipeline(),o=this.pipeline.isErrored,o)x.info(or,`>>> DRAWING ABORTED ${this.id}: ${Tm}`)(),i=!1;else{let n=this._getBindings(),s=this._getBindGroups(),{indexBuffer:a}=this.vertexArray,c=a?a.byteLength/(a.indexType==="uint32"?4:2):void 0;i=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:c,transformFeedback:this.transformFeedback||void 0,bindings:n,bindGroups:s,_bindGroupCacheKeys:this._getBindGroupCacheKeys(),uniforms:this.props.uniforms,parameters:this.parameters,topology:this.topology})}}finally{e.popDebugGroup(),this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):o?this._needsRedraw=Tm:this._needsRedraw="waiting for resource initialization",i}setGeometry(e){this._gpuGeometry?.destroy();let r=e&&om(this.device,e);if(r){this.setTopology(r.topology||"triangle-list");let i=new Ri(this.bufferLayout);this.bufferLayout=i.mergeBufferLayouts(r.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(r)}this._gpuGeometry=r}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){let r=new Ri(this.bufferLayout);this.bufferLayout=this._gpuGeometry?r.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){Zs(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 _o(this.device,this.shaderInputs.modules);for(let[r,i]of Object.entries(this.shaderInputs.modules))if(hm(i)&&!this.material?.ownsModule(r)){let o=this._uniformStore.getManagedUniformBuffer(r);this.bindings[`${r}Uniforms`]=o}this.setNeedsRedraw("shaderInputs")}setMaterial(e){this.material=e,this.setNeedsRedraw("material")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this._getNonMaterialBindings(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,r){let i=r?.disableWarnings??this.props.disableWarnings;e.indices&&x.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)(),this.bufferLayout=fm(this.pipeline.shaderLayout,this.bufferLayout);let o=new Ri(this.bufferLayout);for(let[n,s]of Object.entries(e)){let a=o.getBufferLayout(n);if(!a){i||x.warn(`Model(${this.id}): Missing layout for buffer "${n}".`)();continue}let c=o.getAttributeNamesForBuffer(a),l=!1;for(let f of c){let h=this._attributeInfos[f];if(h){let u=this.device.type==="webgpu"?o.getBufferIndex(h.bufferName):h.location;this.vertexArray.setBuffer(u,s),l=!0}}!l&&!i&&x.warn(`Model(${this.id}): Ignoring buffer "${s.id}" for unknown attribute "${n}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,r){for(let[i,o]of Object.entries(e)){let n=this._attributeInfos[i];n?this.vertexArray.setConstantWebGL(n.location,o):(r?.disableWarnings??this.props.disableWarnings)||x.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}_areBindingsLoading(){for(let e of Object.values(this.bindings))if(e instanceof ir&&!e.isReady)return e.id;for(let e of Object.values(this.material?.bindings||{}))if(e instanceof ir&&!e.isReady)return e.id;return!1}_getBindings(){let e={};for(let[r,i]of Object.entries(this.bindings))i instanceof ir?i.isReady&&(e[r]=i.texture):e[r]=i;return e}_getBindGroups(){let e=this.pipeline?.shaderLayout||this.props.shaderLayout||{bindings:[]},r=e.bindings.length?po(e,this._getBindings()):{0:this._getBindings()};if(!this.material)return r;for(let[i,o]of Object.entries(this.material.getBindingsByGroup())){let n=Number(i);r[n]={...r[n]||{},...o}}return r}_getBindGroupCacheKeys(){let e=this.material?.getBindGroupCacheKey(3);return e?{3:e}:{}}_getBindingsUpdateTimestamp(){let e=0;for(let r of Object.values(this.bindings))r instanceof Qt?e=Math.max(e,r.texture.updateTimestamp):r instanceof I||r instanceof B?e=Math.max(e,r.updateTimestamp):r instanceof ir?e=r.texture?Math.max(e,r.texture.updateTimestamp):1/0:r instanceof De||(e=Math.max(e,r.buffer.updateTimestamp));return Math.max(e,this.material?.getBindingsUpdateTimestamp()||0)}_setGeometryAttributes(e){let r={...e.attributes};for(let[i]of Object.entries(r))!this.pipeline.shaderLayout.attributes.find(o=>o.name===i)&&i!=="positions"&&delete r[i];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(r,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,r=null;this.pipeline&&(x.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,r=this.pipeline.fs),this._pipelineNeedsUpdate=!1;let i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debugShaders:this.props.debugShaders}),o=null;this.source?o=i:this.fs&&(o=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,bindings:void 0,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,bindGroups:this._getBindGroups(),vs:i,fs:o}),this._attributeInfos=As(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),r&&r!==e&&this.shaderFactory.release(r)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){let e=x.level>3?0:AE;x.level<2||Date.now()-this._lastLogTime<e||(this._lastLogTime=Date.now(),this._logOpen=!0,x.group(or,`>>> DRAWING MODEL ${this.id}`,{collapsed:x.level<=2})())}_logDrawCallEnd(){if(this._logOpen){let e=nm(this.pipeline.shaderLayout,this.id);x.table(or,e)();let r=this.shaderInputs.getDebugTable();x.table(or,r)();let i=this._getAttributeDebugTable();x.table(or,this._attributeInfos)(),x.table(or,i)(),x.groupEnd(or)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){let r=this.device.props.debugFramebuffers;if(this._drawCount++,!r)return;let i=e.props.framebuffer;cm(e,i,{id:i?.id||`${this.id}-framebuffer`,minimap:!0})}_getAttributeDebugTable(){let e={};for(let[r,i]of Object.entries(this._attributeInfos)){let o=this.vertexArray.attributes[i.location];e[i.location]={name:r,type:i.shaderType,values:o?this._getBufferOrConstantValues(o,i.bufferDataType):"null"}}if(this.vertexArray.indexBuffer){let{indexBuffer:r}=this.vertexArray,i=r.indexType==="uint32"?new Uint32Array(r.debugData):new Uint16Array(r.debugData);e.indices={name:"indices",type:r.indexType,values:i.toString()}}return e}_getBufferOrConstantValues(e,r){let i=he.getTypedArrayConstructor(r);return(e instanceof I?new i(e.debugData):e).toString()}_getNonMaterialBindings(e){if(!this.material)return e;let r={};for(let[i,o]of Object.entries(e))this.material.ownsBinding(i)||(r[i]=o);return r}},Pe=xh;M(Pe,"defaultProps",{...Ee.defaultProps,source:void 0,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},bindings:{},uniforms:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,material:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:tr.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});function SE(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}L();var Gs=class{device;model;transformFeedback;static isSupported(e){return e?.info?.type==="webgl"}constructor(e,r=Gs.defaultProps){if(!Gs.isSupported(e))throw new Error("BufferTransform not yet implemented on WebGPU");this.device=e,this.model=new Pe(this.device,{id:r.id||"buffer-transform-model",fs:r.fs||xo(),topology:r.topology||"point-list",varyings:r.outputs||r.varyings,...r}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:r.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 r=this.device.beginRenderPass(e);this.model.draw(r),r.end()}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){let r=this.getBuffer(e);if(!r)throw new Error("BufferTransform#getBuffer");if(r instanceof I)return r.readAsync();let{buffer:i,byteOffset:o=0,byteLength:n=i.byteLength}=r;return i.readAsync(o,n)}},je=Gs;M(je,"defaultProps",{...Pe.defaultProps,outputs:void 0,feedbackBuffers:void 0});var EE="transform_output",Co=class{device;model;sampler;currentIndex=0;samplerTextureMap=null;bindings=[];resources={};constructor(e,r){this.device=e,this.sampler=e.createSampler({addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",minFilter:"nearest",magFilter:"nearest",mipmapFilter:"nearest"}),this.model=new Pe(this.device,{id:r.id||oe("texture-transform-model"),fs:r.fs||xo({input:r.targetTextureVarying,inputChannels:r.targetTextureChannels,output:EE}),vertexCount:r.vertexCount,...r}),this._initialize(r),Object.seal(this)}destroy(){this.model.destroy();for(let e of this.bindings)e.framebuffer?.destroy()}delete(){this.destroy()}run(e){let{framebuffer:r}=this.bindings[this.currentIndex],i=this.device.beginRenderPass({framebuffer:r,...e});this.model.draw(i),i.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:r,sourceTextures:i,targetTexture:o}){if(e||(e={sourceBuffers:{},sourceTextures:{},targetTexture:null}),Object.assign(e.sourceTextures,i),Object.assign(e.sourceBuffers,r),o){e.targetTexture=o;let{width:n,height:s}=o;e.framebuffer&&e.framebuffer.destroy(),e.framebuffer=this.device.createFramebuffer({id:"transform-framebuffer",width:n,height:s,colorAttachments:[o]}),e.framebuffer.resize({width:n,height:s})}return e}_setSourceTextureParameters(){let e=this.currentIndex,{sourceTextures:r}=this.bindings[e];for(let i in r)r[i].sampler=this.sampler}};var $e=class{id;topology;vertexCount;indices;attributes;userData={};constructor(e){let{attributes:r={},indices:i=null,vertexCount:o=null}=e;this.id=e.id||oe("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(let[n,s]of Object.entries(r)){let a=ArrayBuffer.isView(s)?{value:s}:s;if(!ArrayBuffer.isView(a.value))throw new Error(`${this._print(n)}: must be typed array or object with value as typed array`);if((n==="POSITION"||n==="positions")&&!a.size&&(a.size=3),n==="indices"){if(this.indices)throw new Error("Multiple indices detected");this.indices=a}else this.attributes[n]=a}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=o||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,r){return this}_calculateVertexCount(e,r){if(r)return r.value.length;let i=1/0;for(let o of Object.values(e)){let{value:n,size:s,constant:a}=o;!a&&n&&s!==void 0&&s>=1&&(i=Math.min(i,n.length/s))}return i}};var wE=`struct VertexInputs {
|
|
1202
1202
|
@location(0) clipSpacePositions: vec2<f32>,
|
|
1203
1203
|
@location(1) texCoords: vec2<f32>,
|
|
1204
1204
|
@location(2) coordinates: vec2<f32>
|
|
@@ -1220,7 +1220,7 @@ fn vertexMain(inputs: VertexInputs) -> FragmentInputs {
|
|
|
1220
1220
|
outputs.uv = inputs.texCoords;
|
|
1221
1221
|
return outputs;
|
|
1222
1222
|
}
|
|
1223
|
-
`,
|
|
1223
|
+
`,RE=`#version 300 es
|
|
1224
1224
|
in vec2 clipSpacePositions;
|
|
1225
1225
|
in vec2 texCoords;
|
|
1226
1226
|
in vec2 coordinates;
|
|
@@ -1235,28 +1235,28 @@ void main(void) {
|
|
|
1235
1235
|
coordinate = coordinates;
|
|
1236
1236
|
uv = texCoords;
|
|
1237
1237
|
}
|
|
1238
|
-
`,
|
|
1239
|
-
${r.source}`}),super(e,{id:r.id||ne("clip-space"),...r,vs:wE,vertexCount:4,geometry:new He({topology:"triangle-strip",vertexCount:4,attributes:{clipSpacePositions:{size:2,value:new Float32Array(Tm)},texCoords:{size:2,value:new Float32Array(i)},coordinates:{size:2,value:new Float32Array(i)}}})})}};var Io=class extends He{constructor(e={}){let{id:r=ne("sphere-geometry")}=e,{indices:i,attributes:o}=RE(e);super({...e,id:r,topology:"triangle-list",indices:i,attributes:{...o,...e.attributes}})}};function RE(t){let{nlat:e=10,nlong:r=10}=t,n=Math.PI-0,s=0,c=2*Math.PI-s,l=(e+1)*(r+1),f=(_,b,y,T,S)=>t.radius||1,h=new Float32Array(l*3),u=new Float32Array(l*3),d=new Float32Array(l*2),p=l>65535?Uint32Array:Uint16Array,g=new p(e*r*6);for(let _=0;_<=e;_++)for(let b=0;b<=r;b++){let y=b/r,T=_/e,S=b+_*(r+1),A=S*2,w=S*3,P=c*y,R=n*T,v=Math.sin(P),O=Math.cos(P),C=Math.sin(R),W=Math.cos(R),V=O*C,J=W,wt=v*C,Rt=f(V,J,wt,y,T);h[w+0]=Rt*V,h[w+1]=Rt*J,h[w+2]=Rt*wt,u[w+0]=V,u[w+1]=J,u[w+2]=wt,d[A+0]=y,d[A+1]=1-T}let m=r+1;for(let _=0;_<r;_++)for(let b=0;b<e;b++){let y=(_*e+b)*6;g[y+0]=b*m+_,g[y+1]=b*m+_+1,g[y+2]=(b+1)*m+_,g[y+3]=(b+1)*m+_,g[y+4]=b*m+_+1,g[y+5]=(b+1)*m+_+1}return{indices:{size:1,value:g},attributes:{POSITION:{size:3,value:h},NORMAL:{size:3,value:u},TEXCOORD_0:{size:2,value:d}}}}function Th(t,e){if(!t)throw new Error(e)}var ft=class{id;matrix=new z;display=!0;position=new $;rotation=new $;scale=new $(1,1,1);userData={};props={};constructor(e={}){let{id:r}=e;this.id=r||ne(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 Th(e.length===3,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return Th(e.length===3||e.length===4,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return Th(e.length===3,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,r=!0){r?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){let{position:r,rotation:i,scale:o,update:n=!0}=e;return r&&this.setPosition(r),i&&this.setRotation(i),o&&this.setScale(o),n&&this.updateMatrix(),this}updateMatrix(){if(this.matrix.identity(),this.matrix.translate(this.position),this.rotation.length===4){let e=new z().fromQuaternion(this.rotation);this.matrix.multiplyRight(e)}else this.matrix.rotateXYZ(this.rotation);return this.matrix.scale(this.scale),this}update({position:e,rotation:r,scale:i}={}){return e&&this.setPosition(e),r&&this.setRotation(r),i&&this.setScale(i),this.updateMatrix(),this}getCoordinateUniforms(e,r){r=r||this.matrix;let i=new z(e).multiplyRight(r),o=i.invert(),n=o.transpose();return{viewMatrix:e,modelMatrix:r,objectMatrix:r,worldMatrix:i,worldInverseMatrix:o,worldInverseTransposeMatrix:n}}_setScenegraphNodeProps(e){e?.position&&this.setPosition(e.position),e?.rotation&&this.setRotation(e.rotation),e?.scale&&this.setScale(e.scale),this.updateMatrix(),e?.matrix&&this.setMatrix(e.matrix),Object.assign(this.props,e)}};F();var sr=class extends ft{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;let{children:r=[]}=e;x.assert(r.every(i=>i instanceof ft),"every child must an instance of ScenegraphNode"),super(e),this.children=r}getBounds(){let e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((r,{worldMatrix:i})=>{let o=r.getBounds();if(!o)return;let[n,s]=o,a=new $(n).add(s).divide([2,2,2]);i.transformAsPoint(a,a);let c=new $(s).subtract(n).divide([2,2,2]);i.transformAsVector(c,c);for(let l=0;l<8;l++){let f=new $(l&1?-1:1,l&2?-1:1,l&4?-1:1).multiply(c).add(a);for(let h=0;h<3;h++)e[0][h]=Math.min(e[0][h],f[h]),e[1][h]=Math.max(e[1][h],f[h])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(let r of e)Array.isArray(r)?this.add(...r):this.children.push(r);return this}remove(e){let r=this.children,i=r.indexOf(e);return i>-1&&r.splice(i,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:r=new z}={}){let i=new z(r).multiplyRight(this.matrix);for(let o of this.children)o instanceof sr?o.traverse(e,{worldMatrix:i}):e(o,{worldMatrix:i})}preorderTraversal(e,{worldMatrix:r=new z}={}){let i=new z(r).multiplyRight(this.matrix);e(this,{worldMatrix:i});for(let o of this.children)o instanceof sr?o.preorderTraversal(e,{worldMatrix:i}):e(o,{worldMatrix:i})}};var Oo=class extends ft{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 No=class extends He{constructor(e={}){let{id:r=ne("cube-geometry"),indices:i=!0}=e;super(i?{...e,id:r,topology:"triangle-list",indices:{size:1,value:PE},attributes:{...DE,...e.attributes}}:{...e,id:r,topology:"triangle-list",indices:void 0,attributes:{...BE,...e.attributes}})}},PE=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]),vE=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]),ME=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]),CE=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]),IE=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]),OE=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]),NE=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]),DE={POSITION:{size:3,value:vE},NORMAL:{size:3,value:ME},TEXCOORD_0:{size:2,value:CE}},BE={POSITION:{size:3,value:IE},TEXCOORD_0:{size:2,value:OE},COLOR_0:{size:3,value:NE}};var{stats:LE,getSupportedAdapters:FE,setDefaultDeviceProps:UE,attachDevice:kE,createDevice:VE,enforceWebGL2:zE}=Qt;var Zh={};Pt(Zh,{fetchFile:()=>Ci,load:()=>ur,parse:()=>hr,registerLoaders:()=>Wo});function ar(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var ht={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},WE=ht.self||ht.window||ht.global||{},jE=ht.window||ht.self||ht.global||{},$E=ht.global||ht.self||ht.window||{},HE=ht.document||{};var Br=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var xm=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),XE=xm&&parseFloat(xm[1])||0;ro();var Ah="4.4.1",YE=Ah[0]>="0"&&Ah[0]<="9"?`v${Ah}`:"";function KE(){let t=new he({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=YE,globalThis.probe||={},globalThis.probe.loaders=t,t}var Sh=KE();var ZE=t=>typeof t=="boolean",ut=t=>typeof t=="function",dt=t=>t!==null&&typeof t=="object",Gs=t=>dt(t)&&t.constructor==={}.constructor;var Eh=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer,Ri=t=>dt(t)&&typeof t.byteLength=="number"&&typeof t.slice=="function";var wh=t=>Boolean(t)&&ut(t[Symbol.iterator]),Rh=t=>Boolean(t)&&ut(t[Symbol.asyncIterator]);var Me=t=>typeof Response<"u"&&t instanceof Response||dt(t)&&ut(t.arrayBuffer)&&ut(t.text)&&ut(t.json);var Ce=t=>typeof Blob<"u"&&t instanceof Blob;var Am=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||dt(t)&&ut(t.tee)&&ut(t.cancel)&&ut(t.getReader);var Sm=t=>dt(t)&&ut(t.read)&&ut(t.pipe)&&ZE(t.readable),Do=t=>Am(t)||Sm(t);function Ph(t,e){return Em(t||{},e)}function Em(t,e,r=0){if(r>3)return e;let i={...t};for(let[o,n]of Object.entries(e))n&&typeof n=="object"&&!Array.isArray(n)?i[o]=Em(i[o]||{},e[o],r+1):i[o]=e[o];return i}var wm="latest";function qE(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.1"),globalThis._loadersgl_.version}var Rm=qE();function ge(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var pt={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},IF=pt.self||pt.window||pt.global||{},OF=pt.window||pt.self||pt.global||{},NF=pt.global||pt.self||pt.window||{},DF=pt.document||{};var Ue=typeof process!="object"||String(process)!=="[object process]"||process.browser;var vm=typeof window<"u"&&typeof window.orientation<"u",Pm=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),BF=Pm&&parseFloat(Pm[1])||0;var Bo=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,r){this.name=e,this.workerThread=r,this.result=new Promise((i,o)=>{this._resolve=i,this._reject=o})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){ge(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){ge(this.isRunning),this.isRunning=!1,this._reject(e)}};var Pi=class{terminate(){}};var vh=new Map;function Mm(t){ge(t.source&&!t.url||!t.source&&t.url);let e=vh.get(t.source||t.url);return e||(t.url&&(e=GE(t.url),vh.set(t.url,e)),t.source&&(e=Cm(t.source),vh.set(t.source,e))),ge(e),e}function GE(t){if(!t.startsWith("http"))return t;let e=QE(t);return Cm(e)}function Cm(t){let e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function QE(t){return`try {
|
|
1238
|
+
`,xm=[-1,-1,1,-1,-1,1,1,1],Io=class extends Pe{constructor(e,r){let i=xm.map(o=>o===-1?0:o);r.source&&(r={...r,source:`${wE}
|
|
1239
|
+
${r.source}`}),super(e,{id:r.id||oe("clip-space"),...r,vs:RE,vertexCount:4,geometry:new $e({topology:"triangle-strip",vertexCount:4,attributes:{clipSpacePositions:{size:2,value:new Float32Array(xm)},texCoords:{size:2,value:new Float32Array(i)},coordinates:{size:2,value:new Float32Array(i)}}})})}};var Oo=class extends $e{constructor(e={}){let{id:r=oe("sphere-geometry")}=e,{indices:i,attributes:o}=PE(e);super({...e,id:r,topology:"triangle-list",indices:i,attributes:{...o,...e.attributes}})}};function PE(t){let{nlat:e=10,nlong:r=10}=t,n=Math.PI-0,s=0,c=2*Math.PI-s,l=(e+1)*(r+1),f=(_,b,y,T,S)=>t.radius||1,h=new Float32Array(l*3),u=new Float32Array(l*3),d=new Float32Array(l*2),p=l>65535?Uint32Array:Uint16Array,g=new p(e*r*6);for(let _=0;_<=e;_++)for(let b=0;b<=r;b++){let y=b/r,T=_/e,S=b+_*(r+1),A=S*2,w=S*3,P=c*y,R=n*T,v=Math.sin(P),O=Math.cos(P),C=Math.sin(R),z=Math.cos(R),k=O*C,Q=z,Et=v*C,wt=f(k,Q,Et,y,T);h[w+0]=wt*k,h[w+1]=wt*Q,h[w+2]=wt*Et,u[w+0]=k,u[w+1]=Q,u[w+2]=Et,d[A+0]=y,d[A+1]=1-T}let m=r+1;for(let _=0;_<r;_++)for(let b=0;b<e;b++){let y=(_*e+b)*6;g[y+0]=b*m+_,g[y+1]=b*m+_+1,g[y+2]=(b+1)*m+_,g[y+3]=(b+1)*m+_,g[y+4]=b*m+_+1,g[y+5]=(b+1)*m+_+1}return{indices:{size:1,value:g},attributes:{POSITION:{size:3,value:h},NORMAL:{size:3,value:u},TEXCOORD_0:{size:2,value:d}}}}function Ah(t,e){if(!t)throw new Error(e)}var lt=class{id;matrix=new V;display=!0;position=new j;rotation=new j;scale=new j(1,1,1);userData={};props={};constructor(e={}){let{id:r}=e;this.id=r||oe(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 Ah(e.length===3,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return Ah(e.length===3||e.length===4,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return Ah(e.length===3,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,r=!0){r?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){let{position:r,rotation:i,scale:o,update:n=!0}=e;return r&&this.setPosition(r),i&&this.setRotation(i),o&&this.setScale(o),n&&this.updateMatrix(),this}updateMatrix(){if(this.matrix.identity(),this.matrix.translate(this.position),this.rotation.length===4){let e=new V().fromQuaternion(this.rotation);this.matrix.multiplyRight(e)}else this.matrix.rotateXYZ(this.rotation);return this.matrix.scale(this.scale),this}update({position:e,rotation:r,scale:i}={}){return e&&this.setPosition(e),r&&this.setRotation(r),i&&this.setScale(i),this.updateMatrix(),this}getCoordinateUniforms(e,r){r=r||this.matrix;let i=new V(e).multiplyRight(r),o=i.invert(),n=o.transpose();return{viewMatrix:e,modelMatrix:r,objectMatrix:r,worldMatrix:i,worldInverseMatrix:o,worldInverseTransposeMatrix:n}}_setScenegraphNodeProps(e){e?.position&&this.setPosition(e.position),e?.rotation&&this.setRotation(e.rotation),e?.scale&&this.setScale(e.scale),this.updateMatrix(),e?.matrix&&this.setMatrix(e.matrix),Object.assign(this.props,e)}};L();var nr=class extends lt{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;let{children:r=[]}=e;x.assert(r.every(i=>i instanceof lt),"every child must an instance of ScenegraphNode"),super(e),this.children=r}getBounds(){let e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((r,{worldMatrix:i})=>{let o=r.getBounds();if(!o)return;let[n,s]=o,a=new j(n).add(s).divide([2,2,2]);i.transformAsPoint(a,a);let c=new j(s).subtract(n).divide([2,2,2]);i.transformAsVector(c,c);for(let l=0;l<8;l++){let f=new j(l&1?-1:1,l&2?-1:1,l&4?-1:1).multiply(c).add(a);for(let h=0;h<3;h++)e[0][h]=Math.min(e[0][h],f[h]),e[1][h]=Math.max(e[1][h],f[h])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(let r of e)Array.isArray(r)?this.add(...r):this.children.push(r);return this}remove(e){let r=this.children,i=r.indexOf(e);return i>-1&&r.splice(i,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:r=new V}={}){let i=new V(r).multiplyRight(this.matrix);for(let o of this.children)o instanceof nr?o.traverse(e,{worldMatrix:i}):e(o,{worldMatrix:i})}preorderTraversal(e,{worldMatrix:r=new V}={}){let i=new V(r).multiplyRight(this.matrix);e(this,{worldMatrix:i});for(let o of this.children)o instanceof nr?o.preorderTraversal(e,{worldMatrix:i}):e(o,{worldMatrix:i})}};var No=class extends lt{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 Do=class extends $e{constructor(e={}){let{id:r=oe("cube-geometry"),indices:i=!0}=e;super(i?{...e,id:r,topology:"triangle-list",indices:{size:1,value:vE},attributes:{...BE,...e.attributes}}:{...e,id:r,topology:"triangle-list",indices:void 0,attributes:{...FE,...e.attributes}})}},vE=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]),ME=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]),CE=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]),IE=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]),OE=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]),NE=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]),DE=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]),BE={POSITION:{size:3,value:ME},NORMAL:{size:3,value:CE},TEXCOORD_0:{size:2,value:IE}},FE={POSITION:{size:3,value:OE},TEXCOORD_0:{size:2,value:NE},COLOR_0:{size:3,value:DE}};var{stats:LE,getSupportedAdapters:UE,setDefaultDeviceProps:kE,attachDevice:VE,createDevice:zE,enforceWebGL2:WE}=Gt;var Gh={};Rt(Gh,{fetchFile:()=>Ii,load:()=>hr,parse:()=>fr,registerLoaders:()=>jo});function sr(t,e){if(!t)throw new Error(e||"loader assertion failed.")}var ft={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},jE=ft.self||ft.window||ft.global||{},$E=ft.window||ft.self||ft.global||{},HE=ft.global||ft.self||ft.window||{},XE=ft.document||{};var Dr=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var Am=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),YE=Am&&parseFloat(Am[1])||0;io();var Eh="4.4.1",KE=Eh[0]>="0"&&Eh[0]<="9"?`v${Eh}`:"";function ZE(){let t=new fe({id:"loaders.gl"});return globalThis.loaders||={},globalThis.loaders.log=t,globalThis.loaders.version=KE,globalThis.probe||={},globalThis.probe.loaders=t,t}var wh=ZE();var qE=t=>typeof t=="boolean",ht=t=>typeof t=="function",ut=t=>t!==null&&typeof t=="object",Qs=t=>ut(t)&&t.constructor==={}.constructor;var Rh=t=>typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer,Pi=t=>ut(t)&&typeof t.byteLength=="number"&&typeof t.slice=="function";var Ph=t=>Boolean(t)&&ht(t[Symbol.iterator]),vh=t=>Boolean(t)&&ht(t[Symbol.asyncIterator]);var ve=t=>typeof Response<"u"&&t instanceof Response||ut(t)&&ht(t.arrayBuffer)&&ht(t.text)&&ht(t.json);var Me=t=>typeof Blob<"u"&&t instanceof Blob;var Sm=t=>typeof ReadableStream<"u"&&t instanceof ReadableStream||ut(t)&&ht(t.tee)&&ht(t.cancel)&&ht(t.getReader);var Em=t=>ut(t)&&ht(t.read)&&ht(t.pipe)&&qE(t.readable),Bo=t=>Sm(t)||Em(t);function Mh(t,e){return wm(t||{},e)}function wm(t,e,r=0){if(r>3)return e;let i={...t};for(let[o,n]of Object.entries(e))n&&typeof n=="object"&&!Array.isArray(n)?i[o]=wm(i[o]||{},e[o],r+1):i[o]=e[o];return i}var Rm="latest";function GE(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.4.1"),globalThis._loadersgl_.version}var Pm=GE();function pe(t,e){if(!t)throw new Error(e||"loaders.gl assertion failed.")}var dt={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},BL=dt.self||dt.window||dt.global||{},FL=dt.window||dt.self||dt.global||{},LL=dt.global||dt.self||dt.window||{},UL=dt.document||{};var Le=typeof process!="object"||String(process)!=="[object process]"||process.browser;var Mm=typeof window<"u"&&typeof window.orientation<"u",vm=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),kL=vm&&parseFloat(vm[1])||0;var Fo=class{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,r){this.name=e,this.workerThread=r,this.result=new Promise((i,o)=>{this._resolve=i,this._reject=o})}postMessage(e,r){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:r})}done(e){pe(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){pe(this.isRunning),this.isRunning=!1,this._reject(e)}};var vi=class{terminate(){}};var Ch=new Map;function Cm(t){pe(t.source&&!t.url||!t.source&&t.url);let e=Ch.get(t.source||t.url);return e||(t.url&&(e=QE(t.url),Ch.set(t.url,e)),t.source&&(e=Im(t.source),Ch.set(t.source,e))),pe(e),e}function QE(t){if(!t.startsWith("http"))return t;let e=JE(t);return Im(e)}function Im(t){let e=new Blob([t],{type:"application/javascript"});return URL.createObjectURL(e)}function JE(t){return`try {
|
|
1240
1240
|
importScripts('${t}');
|
|
1241
1241
|
} catch (error) {
|
|
1242
1242
|
console.error(error);
|
|
1243
1243
|
throw error;
|
|
1244
|
-
}`}function Mh(t,e=!0,r){let i=r||new Set;if(t){if(Im(t))i.add(t);else if(Im(t.buffer))i.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let o in t)Mh(t[o],e,i)}}return r===void 0?Array.from(i):[]}function Im(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}var Ch=()=>{},cr=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&Ue||typeof Pi<"u"&&!Ue}constructor(e){let{name:r,source:i,url:o}=e;ge(i||o),this.name=r,this.source=i,this.url=o,this.onMessage=Ch,this.onError=n=>console.log(n),this.worker=Ue?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Ch,this.onError=Ch,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,r){r=r||Mh(e),this.worker.postMessage(e,r)}_getErrorFromErrorEvent(e){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,e.message&&(r+=`${e.message} in `),e.lineno&&(r+=`:${e.lineno}:${e.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=Mm({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},e.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},e.onmessageerror=r=>console.error(r),e}_createNodeWorker(){let e;if(this.url){let i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,o=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new Pi(i,{eval:!1,type:o})}else if(this.source)e=new Pi(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",r=>{this.onMessage(r)}),e.on("error",r=>{this.onError(r)}),e.on("exit",r=>{}),e}};var Lo=class{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return cr.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,r=(o,n,s)=>o.done(s),i=(o,n)=>o.error(n)){let o=new Promise(n=>(this.jobQueue.push({name:e,onMessage:r,onError:i,onStart:n}),this));return this._startQueuedJob(),await o}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:e,backlog:this.jobQueue.length});let i=new Bo(r.name,e);e.onMessage=o=>r.onMessage(i,o.type,o.payload),e.onError=o=>r.onError(i,o),r.onStart(i);try{await i.result}catch(o){console.error(`Worker exception: ${o}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!Ue||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 cr({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return vm?this.maxMobileConcurrency:this.maxConcurrency}};var JE={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},Lr=class{props;workerPools=new Map;static isSupported(){return cr.isSupported()}static getWorkerFarm(e={}){return Lr._workerFarm=Lr._workerFarm||new Lr({}),Lr._workerFarm.setProps(e),Lr._workerFarm}constructor(e){this.props={...JE},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 r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:r,source:i,url:o}=e,n=this.workerPools.get(r);return n||(n=new Lo({name:r,source:i,url:o}),n.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,n)),n}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},lr=Lr;M(lr,"_workerFarm");function Ih(t,e={}){let r=e[t.id]||{},i=Ue?`${t.id}-worker.js`:`${t.id}-worker-node.js`,o=r.workerUrl;if(!o&&t.id==="compression"&&(o=e.workerUrl),(e._workerType||e?.core?._workerType)==="test"&&(Ue?o=`modules/${t.module}/dist/${i}`:o=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!o){let s=t.version;s==="latest"&&(s=wm);let a=s?`@${s}`:"";o=`https://unpkg.com/@loaders.gl/${t.module}${a}/dist/${i}`}return ge(o),o}function Oh(t,e=Rm){ge(t,"no worker provided");let r=t.version;return!(!e||!r)}function Nh(t,e){if(!lr.isSupported())return!1;let r=e?._nodeWorkers??e?.core?._nodeWorkers;if(!Ue&&!r)return!1;let i=e?.worker??e?.core?.worker;return Boolean(t.worker&&i)}async function Dh(t,e,r,i,o){let n=t.id,s=Ih(t,r),c=lr.getWorkerFarm(r?.core).getWorkerPool({name:n,url:s});r=JSON.parse(JSON.stringify(r)),i=JSON.parse(JSON.stringify(i||{}));let l=await c.startJob("process-on-worker",ew.bind(null,o));return l.postMessage("process",{input:e,options:r,context:i}),await(await l.result).result}async function ew(t,e,r,i){switch(r){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":let{id:o,input:n,options:s}=i;try{let a=await t(n,s);e.postMessage("done",{id:o,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:o,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function Bh(t,e,r){if(r=r||t.byteLength,t.byteLength<r||e.byteLength<r)return!1;let i=new Uint8Array(t),o=new Uint8Array(e);for(let n=0;n<i.length;++n)if(i[n]!==o[n])return!1;return!0}function Lh(...t){return Om(t)}function Om(t){let e=t.map(n=>n instanceof ArrayBuffer?new Uint8Array(n):n),r=e.reduce((n,s)=>n+s.byteLength,0),i=new Uint8Array(r),o=0;for(let n of e)i.set(n,o),o+=n.byteLength;return i.buffer}async function Fh(t){let e=[];for await(let r of t)e.push(tw(r));return Lh(...e)}function tw(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){let{buffer:e,byteOffset:r,byteLength:i}=t;return Nm(e,r,i)}return Nm(t)}function Nm(t,e=0,r=t.byteLength-e){let i=new Uint8Array(t,e,r),o=new Uint8Array(i.length);return o.set(i),o.buffer}var rw="",Dm={};function Uh(t){for(let e in Dm)if(t.startsWith(e)){let r=Dm[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${rw}${t}`),t}function Js(t){return t&&typeof t=="object"&&t.isBuffer}function vi(t){if(Js(t))return t;if(t instanceof ArrayBuffer)return t;if(Eh(t))return Qs(t);if(ArrayBuffer.isView(t)){let e=t.buffer;return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?e:e.slice(t.byteOffset,t.byteOffset+t.byteLength)}if(typeof t=="string"){let e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}function Fo(t){if(t instanceof ArrayBuffer)return t;if(Eh(t))return Qs(t);let{buffer:e,byteOffset:r,byteLength:i}=t;return e instanceof ArrayBuffer&&r===0&&i===e.byteLength?e:Qs(e,r,i)}function Qs(t,e=0,r=t.byteLength-e){let i=new Uint8Array(t,e,r),o=new Uint8Array(i.length);return o.set(i),o.buffer}function kh(t){return ArrayBuffer.isView(t)?t:new Uint8Array(t)}var Nt={};Pt(Nt,{dirname:()=>ow,filename:()=>iw,join:()=>nw,resolve:()=>sw});function Bm(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function iw(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function ow(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function nw(...t){let e="/";return t=t.map((r,i)=>(i&&(r=r.replace(new RegExp(`^${e}`),"")),i!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function sw(...t){let e=[];for(let n=0;n<t.length;n++)e[n]=t[n];let r="",i=!1,o;for(let n=e.length-1;n>=-1&&!i;n--){let s;n>=0?s=e[n]:(o===void 0&&(o=Bm()),s=o),s.length!==0&&(r=`${s}/${r}`,i=s.charCodeAt(0)===Uo)}return r=aw(r,!i),i?`/${r}`:r.length>0?r:"."}var Uo=47,Vh=46;function aw(t,e){let r="",i=-1,o=0,n,s=!1;for(let a=0;a<=t.length;++a){if(a<t.length)n=t.charCodeAt(a);else{if(n===Uo)break;n=Uo}if(n===Uo){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(r.length<2||!s||r.charCodeAt(r.length-1)!==Vh||r.charCodeAt(r.length-2)!==Vh){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==Uo;--l);if(l!==c){r=l===-1?"":r.slice(0,l),i=a,o=0,s=!1;continue}}else if(r.length===2||r.length===1){r="",i=a,o=0,s=!1;continue}}e&&(r.length>0?r+="/..":r="..",s=!0)}else{let c=t.slice(i+1,a);r.length>0?r+=`/${c}`:r=c,s=!1}i=a,o=0}else n===Vh&&o!==-1?++o:o=-1}return r}var ea=class extends Error{constructor(e,r){super(e),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var fw=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,hw=/^([-\w.]+\/[-\w.+]+)/;function zh(t,e){return t.toLowerCase()===e.toLowerCase()}function Lm(t){let e=hw.exec(t);return e?e[1]:t}function Wh(t){let e=fw.exec(t);return e?e[1]:""}var Fm=/\?.*/;function Um(t){let e=t.match(Fm);return e&&e[0]}function fr(t){return t.replace(Fm,"")}function km(t){if(t.length<50)return t;let e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function Fr(t){return Me(t)?t.url:Ce(t)?("name"in t?t.name:"")||"":typeof t=="string"?t:""}function Mi(t){if(Me(t)){let e=t.headers.get("content-type")||"",r=fr(t.url);return Lm(e)||Wh(r)}return Ce(t)?t.type||"":typeof t=="string"?Wh(t):""}function Vm(t){return Me(t)?t.headers["content-length"]||-1:Ce(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function ta(t){if(Me(t))return t;let e={},r=Vm(t);r>=0&&(e["content-length"]=String(r));let i=Fr(t),o=Mi(t);o&&(e["content-type"]=o);let n=await dw(t);n&&(e["x-first-bytes"]=n),typeof t=="string"&&(t=new TextEncoder().encode(t));let s=new Response(t,{headers:e});return Object.defineProperty(s,"url",{value:i}),s}async function zm(t){if(!t.ok)throw await uw(t)}async function uw(t){let e=km(t.url),r=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;r=r.length>100?`${r.slice(0,100)}...`:r;let i={reason:t.statusText,url:t.url,response:t};try{let o=t.headers.get("Content-Type");i.reason=!t.bodyUsed&&o?.includes("application/json")?await t.json():await t.text()}catch{}return new ea(r,i)}async function dw(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){let r=t.slice(0,5);return await new Promise(i=>{let o=new FileReader;o.onload=n=>i(n?.target?.result),o.readAsDataURL(r)})}if(t instanceof ArrayBuffer){let r=t.slice(0,5);return`data:base64,${pw(r)}`}return null}function pw(t){let e="",r=new Uint8Array(t);for(let i=0;i<r.byteLength;i++)e+=String.fromCharCode(r[i]);return btoa(e)}function gw(t){return!mw(t)&&!_w(t)}function mw(t){return t.startsWith("http:")||t.startsWith("https:")}function _w(t){return t.startsWith("data:")}async function Ci(t,e){if(typeof t=="string"){let r=Uh(t);return gw(r)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(r,e):await fetch(r,e)}return await ta(t)}ro();var ko=new he({id:"loaders.gl"}),ra=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},ia=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 oa={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new ia,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Br,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},Wm={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var jh=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function $h(){globalThis.loaders=globalThis.loaders||{};let{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function Hh(){let t=$h();return t.globalOptions=t.globalOptions||{...oa,core:{...oa.core}},Dt(t.globalOptions)}function Hm(t,e,r,i){return r=r||[],r=Array.isArray(r)?r:[r],yw(t,r),Dt(Tw(e,t,i))}function Dt(t){let e=Aw(t);Xm(e);for(let r of jh)e.core&&e.core[r]!==void 0&&delete e[r];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function yw(t,e){jm(t,null,oa,Wm,e);for(let r of e){let i=t&&t[r.id]||{},o=r.options&&r.options[r.id]||{},n=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};jm(i,r.id,o,n,e)}}function jm(t,e,r,i,o){let n=e||"Top level",s=e?`${e}.`:"";for(let a in t){let c=!e&&dt(t[a]),l=a==="baseUri"&&!e,f=a==="workerUrl"&&e;if(!(a in r)&&!l&&!f){if(a in i)ko.level>0&&ko.warn(`${n} loader option '${s}${a}' no longer supported, use '${i[a]}'`)();else if(!c&&ko.level>0){let h=bw(a,o);ko.warn(`${n} loader option '${s}${a}' not recognized. ${h}`)()}}}}function bw(t,e){let r=t.toLowerCase(),i="";for(let o of e)for(let n in o.options){if(t===n)return`Did you mean '${o.id}.${n}'?`;let s=n.toLowerCase();(r.startsWith(s)||s.startsWith(r))&&(i=i||`Did you mean '${o.id}.${n}'?`)}return i}function Tw(t,e,r){let i=t.options||{},o={...i};i.core&&(o.core={...i.core}),Xm(o),o.core?.log===null&&(o.core={...o.core,log:new ra}),$m(o,Dt(Hh()));let n=Dt(e);return $m(o,n),xw(o,r),Sw(o),o}function $m(t,e){for(let r in e)if(r in e){let i=e[r];Gs(i)&&Gs(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function xw(t,e){if(!e)return;t.core?.baseUrl!==void 0||(t.core||={},t.core.baseUrl=Nt.dirname(fr(e)))}function Aw(t){let e={...t};return t.core&&(e.core={...t.core}),e}function Xm(t){t.baseUri!==void 0&&(t.core||={},t.core.baseUrl===void 0&&(t.core.baseUrl=t.baseUri));for(let r of jh)if(t[r]!==void 0){let o=t.core=t.core||{};o[r]===void 0&&(o[r]=t[r])}let e=t._worker;e!==void 0&&(t.core||={},t.core._workerType===void 0&&(t.core._workerType=e))}function Sw(t){let e=t.core;if(e)for(let r of jh)e[r]!==void 0&&(t[r]=e[r])}function Vo(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t?.extensions)):!1}function zo(t){ar(t,"null loader"),ar(Vo(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t?.parseTextSync||t?.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}var Ym=()=>{let t=$h();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function Wo(t){let e=Ym();t=Array.isArray(t)?t:[t];for(let r of t){let i=zo(r);e.find(o=>i===o)||e.unshift(i)}}function Km(){return Ym()}var Ew=/\.([^.]+)$/;async function Gm(t,e=[],r,i){if(!Qm(t))return null;let o=Dt(r||{});if(o.core||={},t instanceof Response&&Zm(t)){let s=await t.clone().text(),a=na(s,e,{...o,core:{...o.core,nothrow:!0}},i);if(a)return a}let n=na(t,e,{...o,core:{...o.core,nothrow:!0}},i);if(n)return n;if(Ce(t)&&(t=await t.slice(0,10).arrayBuffer(),n=na(t,e,o,i)),!n&&t instanceof Response&&Zm(t)){let s=await t.clone().text();n=na(s,e,o,i)}if(!n&&!o.core.nothrow)throw new Error(Jm(t));return n}function Zm(t){let e=Mi(t);return Boolean(e&&(e.startsWith("text/")||e==="application/json"||e.endsWith("+json")))}function na(t,e=[],r,i){if(!Qm(t))return null;let o=Dt(r||{});if(o.core||={},e&&!Array.isArray(e))return zo(e);let n=[];e&&(n=n.concat(e)),o.core.ignoreRegisteredLoaders||n.push(...Km()),Rw(n);let s=ww(t,n,o,i);if(!s&&!o.core.nothrow)throw new Error(Jm(t));return s}function ww(t,e,r,i){let o=Fr(t),n=Mi(t),s=fr(o)||i?.url,a=null,c="";return r?.core?.mimeType&&(a=Xh(e,r?.core?.mimeType),c=`match forced by supplied MIME type ${r?.core?.mimeType}`),a=a||Pw(e,s),c=c||(a?`matched url ${s}`:""),a=a||Xh(e,n),c=c||(a?`matched MIME type ${n}`:""),a=a||Mw(e,t),c=c||(a?`matched initial data ${e_(t)}`:""),r?.core?.fallbackMimeType&&(a=a||Xh(e,r?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${n}`:"")),c&&Sh.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function Qm(t){return!(t instanceof Response&&t.status===204)}function Jm(t){let e=Fr(t),r=Mi(t),i="No valid loader found (";i+=e?`${Nt.filename(e)}, `:"no url provided, ",i+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let o=t?e_(t):"";return i+=o?` first bytes: "${o}"`:"first bytes: not available",i+=")",i}function Rw(t){for(let e of t)zo(e)}function Pw(t,e){let r=e&&Ew.exec(e),i=r&&r[1];return i?vw(t,i):null}function vw(t,e){e=e.toLowerCase();for(let r of t)for(let i of r.extensions)if(i.toLowerCase()===e)return r;return null}function Xh(t,e){for(let r of t)if(r.mimeTypes?.some(i=>zh(e,i))||zh(e,`application/x.${r.id}`))return r;return null}function Mw(t,e){if(!e)return null;for(let r of t)if(typeof e=="string"){if(Cw(e,r))return r}else if(ArrayBuffer.isView(e)){if(qm(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer&&qm(e,0,r))return r;return null}function Cw(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(i=>t.startsWith(i))}function qm(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(o=>Iw(t,e,r,o))}function Iw(t,e,r,i){if(Ri(i))return Bh(i,t,i.byteLength);switch(typeof i){case"function":return i(Fo(t));case"string":let o=Yh(t,e,i.length);return i===o;default:return!1}}function e_(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?Yh(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?Yh(t,0,e):""}function Yh(t,e,r){if(t.byteLength<e+r)return"";let i=new DataView(t),o="";for(let n=0;n<r;n++)o+=String.fromCharCode(i.getUint8(e+n));return o}var Ow=256*1024;function*t_(t,e){let r=e?.chunkSize||Ow,i=0,o=new TextEncoder;for(;i<t.length;){let n=Math.min(t.length-i,r),s=t.slice(i,i+n);i+=n,yield Fo(o.encode(s))}}function*r_(t,e={}){let{chunkSize:r=262144}=e,i=0;for(;i<t.byteLength;){let o=Math.min(t.byteLength-i,r),n=new ArrayBuffer(o),s=new Uint8Array(t,i,o);new Uint8Array(n).set(s),i+=o,yield n}}async function*i_(t,e){let r=e?.chunkSize||1048576,i=0;for(;i<t.size;){let o=i+r,n=await t.slice(i,o).arrayBuffer();i=o,yield n}}function Kh(t,e){return Br?Nw(t,e):Dw(t,e)}async function*Nw(t,e){let r=t.getReader(),i;try{for(;;){let o=i||r.read();e?._streamReadAhead&&(i=r.read());let{done:n,value:s}=await o;if(n)return;yield vi(s)}}catch{r.releaseLock()}}async function*Dw(t,e){for await(let r of t)yield vi(r)}function o_(t,e){if(typeof t=="string")return t_(t,e);if(t instanceof ArrayBuffer)return r_(t,e);if(Ce(t))return i_(t,e);if(Do(t))return Kh(t,e);if(Me(t)){let r=t.body;if(!r)throw new Error("Readable stream not available on Response");return Kh(r,e)}throw new Error("makeIterator")}var n_="Cannot convert supplied data type";function Bw(t,e,r){if(e.text&&typeof t=="string")return t;if(Js(t)&&(t=t.buffer),Ri(t)){let i=kh(t);return e.text&&!e.binary?new TextDecoder("utf8").decode(i):vi(i)}throw new Error(n_)}async function s_(t,e,r){if(typeof t=="string"||Ri(t))return Bw(t,e,r);if(Ce(t)&&(t=await ta(t)),Me(t))return await zm(t),e.binary?await t.arrayBuffer():await t.text();if(Do(t)&&(t=o_(t,r)),wh(t)||Rh(t))return Fh(t);throw new Error(n_)}function sa(t,e){let r=Hh(),i=t||r,o=i.fetch??i.core?.fetch;return typeof o=="function"?o:dt(o)?n=>Ci(n,o):e?.fetch?e?.fetch:Ci}function a_(t,e,r){if(r)return r;let i={fetch:sa(e,t),...t};if(i.url){let o=fr(i.url);i.baseUrl=o,i.queryString=Um(i.url),i.filename=Nt.filename(o),i.baseUrl=Nt.dirname(o)}return Array.isArray(i.loaders)||(i.loaders=null),i}function c_(t,e){if(t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){let i=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...i]:i}return r&&r.length?r:void 0}async function hr(t,e,r,i){e&&!Array.isArray(e)&&!Vo(e)&&(i=void 0,r=e,e=void 0),t=await t,r=r||{};let o=Fr(t),s=c_(e,i),a=await Gm(t,s,r);if(!a)return null;let c=Hm(r,a,s,o);return i=a_({url:o,_parse:hr,loaders:s},c,i||null),await Lw(a,t,c,i)}async function Lw(t,e,r,i){if(Oh(t),r=Ph(t.options,r),Me(e)){let{ok:n,redirected:s,status:a,statusText:c,type:l,url:f}=e,h=Object.fromEntries(e.headers.entries());i.response={headers:h,ok:n,redirected:s,status:a,statusText:c,type:l,url:f}}e=await s_(e,t,r);let o=t;if(o.parseTextSync&&typeof e=="string")return o.parseTextSync(e,r,i);if(Nh(t,r))return await Dh(t,e,r,i,hr);if(o.parseText&&typeof e=="string")return await o.parseText(e,r,i);if(o.parse)return await o.parse(e,r,i);throw ge(!o.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}async function ur(t,e,r,i){let o,n;!Array.isArray(e)&&!Vo(e)?(o=[],n=e,i=void 0):(o=e,n=r);let s=sa(n),a=t;return typeof t=="string"&&(a=await s(t)),Ce(t)&&(a=await s(t)),typeof t=="string"&&(Dt(n||{}).core?.baseUrl||(n={...n,core:{...n?.core,baseUrl:t}})),Array.isArray(o)?await hr(a,o,n):await hr(a,o,n)}var l_="4.4.1";var Fw=globalThis.loaders?.parseImageNode,qh=typeof Image<"u",Gh=typeof ImageBitmap<"u",Uw=Boolean(Fw),Qh=Br?!0:Uw;function f_(t){switch(t){case"auto":return Gh||qh||Qh;case"imagebitmap":return Gh;case"image":return qh;case"data":return Qh;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function h_(){if(Gh)return"imagebitmap";if(qh)return"image";if(Qh)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function kw(t){let e=Vw(t);if(!e)throw new Error("Not an image");return e}function u_(t){switch(kw(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function Vw(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var zw=/^data:image\/svg\+xml/,Ww=/\.svg((\?|#).*)?$/;function aa(t){return t&&(zw.test(t)||Ww.test(t))}function d_(t,e){if(aa(e)){let i=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(n){throw new Error(n.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return Jh(t,e)}function Jh(t,e){if(aa(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function ca(t,e,r){let i=d_(t,r),o=self.URL||self.webkitURL,n=typeof i!="string"&&o.createObjectURL(i);try{return await jw(n||i,e)}finally{n&&o.revokeObjectURL(n)}}async function jw(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((i,o)=>{try{r.onload=()=>i(r),r.onerror=n=>{let s=n instanceof Error?n.message:"error";o(new Error(s))}}catch(n){o(n)}})}var p_=!0;async function g_(t,e,r){let i;aa(r)?i=await ca(t,e,r):i=Jh(t,r);let o=e&&e.imagebitmap;return await $w(i,o)}async function $w(t,e=null){if((Hw(e)||!p_)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),p_=!1}return await createImageBitmap(t)}function Hw(t){if(!t)return!0;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function m_(t){return!Zw(t,"ftyp",4)||!(t[8]&96)?null:Xw(t)}function Xw(t){switch(Yw(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function Yw(t,e,r){return String.fromCharCode(...t.slice(e,r))}function Kw(t){return[...t].map(e=>e.charCodeAt(0))}function Zw(t,e,r=0){let i=Kw(e);for(let o=0;o<i.length;++o)if(i[o]!==t[o+r])return!1;return!0}var gt=!1,jo=!0;function la(t){let e=$o(t);return Gw(e)||eR(e)||Qw(e)||Jw(e)||qw(e)}function qw(t){let e=new Uint8Array(t instanceof DataView?t.buffer:t),r=m_(e);return r?{mimeType:r.mimeType,width:0,height:0}:null}function Gw(t){let e=$o(t);return e.byteLength>=24&&e.getUint32(0,gt)===2303741511?{mimeType:"image/png",width:e.getUint32(16,gt),height:e.getUint32(20,gt)}:null}function Qw(t){let e=$o(t);return e.byteLength>=10&&e.getUint32(0,gt)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,jo),height:e.getUint16(8,jo)}:null}function Jw(t){let e=$o(t);return e.byteLength>=14&&e.getUint16(0,gt)===16973&&e.getUint32(2,jo)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,jo),height:e.getUint32(22,jo)}:null}function eR(t){let e=$o(t);if(!(e.byteLength>=3&&e.getUint16(0,gt)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:o}=tR(),n=2;for(;n+9<e.byteLength;){let s=e.getUint16(n,gt);if(o.has(s))return{mimeType:"image/jpeg",height:e.getUint16(n+5,gt),width:e.getUint16(n+7,gt)};if(!i.has(s))return null;n+=2,n+=e.getUint16(n,gt)}return null}function tR(){let t=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)t.add(r);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function $o(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function __(t,e){let{mimeType:r}=la(t)||{},i=globalThis.loaders?.parseImageNode;return ar(i),await i(t,r)}async function y_(t,e,r){e=e||{};let o=(e.image||{}).type||"auto",{url:n}=r||{},s=rR(o),a;switch(s){case"imagebitmap":a=await g_(t,e,n);break;case"image":a=await ca(t,e,n);break;case"data":a=await __(t,e);break;default:ar(!1)}return o==="data"&&(a=u_(a)),a}function rR(t){switch(t){case"auto":case"data":return h_();default:return f_(t),t}}var iR=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],oR=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],nR={image:{type:"auto",decode:!0}},eu={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:l_,mimeTypes:oR,extensions:iR,parse:y_,tests:[t=>Boolean(la(new DataView(t)))],options:nR};ro();var sR=new he({id:"deck"}),L=sR;var tu={};function fa(t){tu=t}function G(t,e,r,i){L.level>0&&tu[t]&&tu[t].call(null,e,r,i)}function aR(t){let e=t[0],r=t[t.length-1];return e==="{"&&r==="}"||e==="["&&r==="]"}var b_={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:aR,parseTextSync:JSON.parse};function cR(){let t="9.3.0-alpha.6",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${t}`);return e||(L.log(1,`deck.gl ${t}`)(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:L,_registerLoggers:fa},Wo([b_,[eu,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}var ha=cR();var lR=`struct LayerUniforms {
|
|
1244
|
+
}`}function Ih(t,e=!0,r){let i=r||new Set;if(t){if(Om(t))i.add(t);else if(Om(t.buffer))i.add(t.buffer);else if(!ArrayBuffer.isView(t)){if(e&&typeof t=="object")for(let o in t)Ih(t[o],e,i)}}return r===void 0?Array.from(i):[]}function Om(t){return t?t instanceof ArrayBuffer||typeof MessagePort<"u"&&t instanceof MessagePort||typeof ImageBitmap<"u"&&t instanceof ImageBitmap||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas:!1}var Oh=()=>{},ar=class{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return typeof Worker<"u"&&Le||typeof vi<"u"&&!Le}constructor(e){let{name:r,source:i,url:o}=e;pe(i||o),this.name=r,this.source=i,this.url=o,this.onMessage=Oh,this.onError=n=>console.log(n),this.worker=Le?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Oh,this.onError=Oh,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,r){r=r||Ih(e),this.worker.postMessage(e,r)}_getErrorFromErrorEvent(e){let r="Failed to load ";return r+=`worker ${this.name} from ${this.url}. `,e.message&&(r+=`${e.message} in `),e.lineno&&(r+=`:${e.lineno}:${e.colno}`),new Error(r)}_createBrowserWorker(){this._loadableURL=Cm({source:this.source,url:this.url});let e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=r=>{r.data?this.onMessage(r.data):this.onError(new Error("No data received"))},e.onerror=r=>{this.onError(this._getErrorFromErrorEvent(r)),this.terminated=!0},e.onmessageerror=r=>console.error(r),e}_createNodeWorker(){let e;if(this.url){let i=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`,o=this.url.endsWith(".ts")||this.url.endsWith(".mjs")?"module":"commonjs";e=new vi(i,{eval:!1,type:o})}else if(this.source)e=new vi(this.source,{eval:!0});else throw new Error("no worker");return e.on("message",r=>{this.onMessage(r)}),e.on("error",r=>{this.onError(r)}),e.on("exit",r=>{}),e}};var Lo=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,r=(o,n,s)=>o.done(s),i=(o,n)=>o.error(n)){let o=new Promise(n=>(this.jobQueue.push({name:e,onMessage:r,onError:i,onStart:n}),this));return this._startQueuedJob(),await o}async _startQueuedJob(){if(!this.jobQueue.length)return;let e=this._getAvailableWorker();if(!e)return;let r=this.jobQueue.shift();if(r){this.onDebug({message:"Starting job",name:r.name,workerThread:e,backlog:this.jobQueue.length});let i=new Fo(r.name,e);e.onMessage=o=>r.onMessage(i,o.type,o.payload),e.onError=o=>r.onError(i,o),r.onStart(i);try{await i.result}catch(o){console.error(`Worker exception: ${o}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!Le||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 Mm?this.maxMobileConcurrency:this.maxConcurrency}};var ew={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}},Br=class{props;workerPools=new Map;static isSupported(){return ar.isSupported()}static getWorkerFarm(e={}){return Br._workerFarm=Br._workerFarm||new Br({}),Br._workerFarm.setProps(e),Br._workerFarm}constructor(e){this.props={...ew},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 r of this.workerPools.values())r.setProps(this._getWorkerPoolProps())}getWorkerPool(e){let{name:r,source:i,url:o}=e,n=this.workerPools.get(r);return n||(n=new Lo({name:r,source:i,url:o}),n.setProps(this._getWorkerPoolProps()),this.workerPools.set(r,n)),n}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}},cr=Br;M(cr,"_workerFarm");function Nh(t,e={}){let r=e[t.id]||{},i=Le?`${t.id}-worker.js`:`${t.id}-worker-node.js`,o=r.workerUrl;if(!o&&t.id==="compression"&&(o=e.workerUrl),(e._workerType||e?.core?._workerType)==="test"&&(Le?o=`modules/${t.module}/dist/${i}`:o=`modules/${t.module}/src/workers/${t.id}-worker-node.ts`),!o){let s=t.version;s==="latest"&&(s=Rm);let a=s?`@${s}`:"";o=`https://unpkg.com/@loaders.gl/${t.module}${a}/dist/${i}`}return pe(o),o}function Dh(t,e=Pm){pe(t,"no worker provided");let r=t.version;return!(!e||!r)}function Bh(t,e){if(!cr.isSupported())return!1;let r=e?._nodeWorkers??e?.core?._nodeWorkers;if(!Le&&!r)return!1;let i=e?.worker??e?.core?.worker;return Boolean(t.worker&&i)}async function Fh(t,e,r,i,o){let n=t.id,s=Nh(t,r),c=cr.getWorkerFarm(r?.core).getWorkerPool({name:n,url:s});r=JSON.parse(JSON.stringify(r)),i=JSON.parse(JSON.stringify(i||{}));let l=await c.startJob("process-on-worker",tw.bind(null,o));return l.postMessage("process",{input:e,options:r,context:i}),await(await l.result).result}async function tw(t,e,r,i){switch(r){case"done":e.done(i);break;case"error":e.error(new Error(i.error));break;case"process":let{id:o,input:n,options:s}=i;try{let a=await t(n,s);e.postMessage("done",{id:o,result:a})}catch(a){let c=a instanceof Error?a.message:"unknown error";e.postMessage("error",{id:o,error:c})}break;default:console.warn(`parse-with-worker unknown message ${r}`)}}function Lh(t,e,r){if(r=r||t.byteLength,t.byteLength<r||e.byteLength<r)return!1;let i=new Uint8Array(t),o=new Uint8Array(e);for(let n=0;n<i.length;++n)if(i[n]!==o[n])return!1;return!0}function Uh(...t){return Nm(t)}function Nm(t){let e=t.map(n=>n instanceof ArrayBuffer?new Uint8Array(n):n),r=e.reduce((n,s)=>n+s.byteLength,0),i=new Uint8Array(r),o=0;for(let n of e)i.set(n,o),o+=n.byteLength;return i.buffer}async function kh(t){let e=[];for await(let r of t)e.push(rw(r));return Uh(...e)}function rw(t){if(t instanceof ArrayBuffer)return t;if(ArrayBuffer.isView(t)){let{buffer:e,byteOffset:r,byteLength:i}=t;return Dm(e,r,i)}return Dm(t)}function Dm(t,e=0,r=t.byteLength-e){let i=new Uint8Array(t,e,r),o=new Uint8Array(i.length);return o.set(i),o.buffer}var iw="",Bm={};function Vh(t){for(let e in Bm)if(t.startsWith(e)){let r=Bm[e];t=t.replace(e,r)}return!t.startsWith("http://")&&!t.startsWith("https://")&&(t=`${iw}${t}`),t}function ea(t){return t&&typeof t=="object"&&t.isBuffer}function Mi(t){if(ea(t))return t;if(t instanceof ArrayBuffer)return t;if(Rh(t))return Js(t);if(ArrayBuffer.isView(t)){let e=t.buffer;return t.byteOffset===0&&t.byteLength===t.buffer.byteLength?e:e.slice(t.byteOffset,t.byteOffset+t.byteLength)}if(typeof t=="string"){let e=t;return new TextEncoder().encode(e).buffer}if(t&&typeof t=="object"&&t._toArrayBuffer)return t._toArrayBuffer();throw new Error("toArrayBuffer")}function Uo(t){if(t instanceof ArrayBuffer)return t;if(Rh(t))return Js(t);let{buffer:e,byteOffset:r,byteLength:i}=t;return e instanceof ArrayBuffer&&r===0&&i===e.byteLength?e:Js(e,r,i)}function Js(t,e=0,r=t.byteLength-e){let i=new Uint8Array(t,e,r),o=new Uint8Array(i.length);return o.set(i),o.buffer}function zh(t){return ArrayBuffer.isView(t)?t:new Uint8Array(t)}var Ot={};Rt(Ot,{dirname:()=>nw,filename:()=>ow,join:()=>sw,resolve:()=>aw});function Fm(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let t=window.location?.pathname;return t?.slice(0,t.lastIndexOf("/")+1)||""}function ow(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(e+1):t}function nw(t){let e=t?t.lastIndexOf("/"):-1;return e>=0?t.substr(0,e):""}function sw(...t){let e="/";return t=t.map((r,i)=>(i&&(r=r.replace(new RegExp(`^${e}`),"")),i!==t.length-1&&(r=r.replace(new RegExp(`${e}$`),"")),r)),t.join(e)}function aw(...t){let e=[];for(let n=0;n<t.length;n++)e[n]=t[n];let r="",i=!1,o;for(let n=e.length-1;n>=-1&&!i;n--){let s;n>=0?s=e[n]:(o===void 0&&(o=Fm()),s=o),s.length!==0&&(r=`${s}/${r}`,i=s.charCodeAt(0)===ko)}return r=cw(r,!i),i?`/${r}`:r.length>0?r:"."}var ko=47,Wh=46;function cw(t,e){let r="",i=-1,o=0,n,s=!1;for(let a=0;a<=t.length;++a){if(a<t.length)n=t.charCodeAt(a);else{if(n===ko)break;n=ko}if(n===ko){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(r.length<2||!s||r.charCodeAt(r.length-1)!==Wh||r.charCodeAt(r.length-2)!==Wh){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==ko;--l);if(l!==c){r=l===-1?"":r.slice(0,l),i=a,o=0,s=!1;continue}}else if(r.length===2||r.length===1){r="",i=a,o=0,s=!1;continue}}e&&(r.length>0?r+="/..":r="..",s=!0)}else{let c=t.slice(i+1,a);r.length>0?r+=`/${c}`:r=c,s=!1}i=a,o=0}else n===Wh&&o!==-1?++o:o=-1}return r}var ta=class extends Error{constructor(e,r){super(e),this.reason=r.reason,this.url=r.url,this.response=r.response}reason;url;response};var hw=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,uw=/^([-\w.]+\/[-\w.+]+)/;function jh(t,e){return t.toLowerCase()===e.toLowerCase()}function Lm(t){let e=uw.exec(t);return e?e[1]:t}function $h(t){let e=hw.exec(t);return e?e[1]:""}var Um=/\?.*/;function km(t){let e=t.match(Um);return e&&e[0]}function lr(t){return t.replace(Um,"")}function Vm(t){if(t.length<50)return t;let e=t.slice(t.length-15);return`${t.substr(0,32)}...${e}`}function Fr(t){return ve(t)?t.url:Me(t)?("name"in t?t.name:"")||"":typeof t=="string"?t:""}function Ci(t){if(ve(t)){let e=t.headers.get("content-type")||"",r=lr(t.url);return Lm(e)||$h(r)}return Me(t)?t.type||"":typeof t=="string"?$h(t):""}function zm(t){return ve(t)?t.headers["content-length"]||-1:Me(t)?t.size:typeof t=="string"?t.length:t instanceof ArrayBuffer||ArrayBuffer.isView(t)?t.byteLength:-1}async function ra(t){if(ve(t))return t;let e={},r=zm(t);r>=0&&(e["content-length"]=String(r));let i=Fr(t),o=Ci(t);o&&(e["content-type"]=o);let n=await pw(t);n&&(e["x-first-bytes"]=n),typeof t=="string"&&(t=new TextEncoder().encode(t));let s=new Response(t,{headers:e});return Object.defineProperty(s,"url",{value:i}),s}async function Wm(t){if(!t.ok)throw await dw(t)}async function dw(t){let e=Vm(t.url),r=`Failed to fetch resource (${t.status}) ${t.statusText}: ${e}`;r=r.length>100?`${r.slice(0,100)}...`:r;let i={reason:t.statusText,url:t.url,response:t};try{let o=t.headers.get("Content-Type");i.reason=!t.bodyUsed&&o?.includes("application/json")?await t.json():await t.text()}catch{}return new ta(r,i)}async function pw(t){if(typeof t=="string")return`data:,${t.slice(0,5)}`;if(t instanceof Blob){let r=t.slice(0,5);return await new Promise(i=>{let o=new FileReader;o.onload=n=>i(n?.target?.result),o.readAsDataURL(r)})}if(t instanceof ArrayBuffer){let r=t.slice(0,5);return`data:base64,${gw(r)}`}return null}function gw(t){let e="",r=new Uint8Array(t);for(let i=0;i<r.byteLength;i++)e+=String.fromCharCode(r[i]);return btoa(e)}function mw(t){return!_w(t)&&!yw(t)}function _w(t){return t.startsWith("http:")||t.startsWith("https:")}function yw(t){return t.startsWith("data:")}async function Ii(t,e){if(typeof t=="string"){let r=Vh(t);return mw(r)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(r,e):await fetch(r,e)}return await ra(t)}io();var Vo=new fe({id:"loaders.gl"}),ia=class{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}},oa=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 na={core:{baseUrl:void 0,fetch:null,mimeType:void 0,fallbackMimeType:void 0,ignoreRegisteredLoaders:void 0,nothrow:!1,log:new oa,useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Dr,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]}},jm={baseUri:"core.baseUrl",fetch:"core.fetch",mimeType:"core.mimeType",fallbackMimeType:"core.fallbackMimeType",ignoreRegisteredLoaders:"core.ignoreRegisteredLoaders",nothrow:"core.nothrow",log:"core.log",useLocalLibraries:"core.useLocalLibraries",CDN:"core.CDN",worker:"core.worker",maxConcurrency:"core.maxConcurrency",maxMobileConcurrency:"core.maxMobileConcurrency",reuseWorkers:"core.reuseWorkers",_nodeWorkers:"core.nodeWorkers",_workerType:"core._workerType",_worker:"core._workerType",limit:"core.limit",_limitMB:"core._limitMB",batchSize:"core.batchSize",batchDebounceMs:"core.batchDebounceMs",metadata:"core.metadata",transforms:"core.transforms",throws:"nothrow",dataType:"(no longer used)",uri:"core.baseUrl",method:"core.fetch.method",headers:"core.fetch.headers",body:"core.fetch.body",mode:"core.fetch.mode",credentials:"core.fetch.credentials",cache:"core.fetch.cache",redirect:"core.fetch.redirect",referrer:"core.fetch.referrer",referrerPolicy:"core.fetch.referrerPolicy",integrity:"core.fetch.integrity",keepalive:"core.fetch.keepalive",signal:"core.fetch.signal"};var Hh=["baseUrl","fetch","mimeType","fallbackMimeType","ignoreRegisteredLoaders","nothrow","log","useLocalLibraries","CDN","worker","maxConcurrency","maxMobileConcurrency","reuseWorkers","_nodeWorkers","_workerType","limit","_limitMB","batchSize","batchDebounceMs","metadata","transforms"];function Xh(){globalThis.loaders=globalThis.loaders||{};let{loaders:t}=globalThis;return t._state||(t._state={}),t._state}function Yh(){let t=Xh();return t.globalOptions=t.globalOptions||{...na,core:{...na.core}},Nt(t.globalOptions)}function Xm(t,e,r,i){return r=r||[],r=Array.isArray(r)?r:[r],bw(t,r),Nt(xw(e,t,i))}function Nt(t){let e=Sw(t);Ym(e);for(let r of Hh)e.core&&e.core[r]!==void 0&&delete e[r];return e.core&&e.core._workerType!==void 0&&delete e._worker,e}function bw(t,e){$m(t,null,na,jm,e);for(let r of e){let i=t&&t[r.id]||{},o=r.options&&r.options[r.id]||{},n=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};$m(i,r.id,o,n,e)}}function $m(t,e,r,i,o){let n=e||"Top level",s=e?`${e}.`:"";for(let a in t){let c=!e&&ut(t[a]),l=a==="baseUri"&&!e,f=a==="workerUrl"&&e;if(!(a in r)&&!l&&!f){if(a in i)Vo.level>0&&Vo.warn(`${n} loader option '${s}${a}' no longer supported, use '${i[a]}'`)();else if(!c&&Vo.level>0){let h=Tw(a,o);Vo.warn(`${n} loader option '${s}${a}' not recognized. ${h}`)()}}}}function Tw(t,e){let r=t.toLowerCase(),i="";for(let o of e)for(let n in o.options){if(t===n)return`Did you mean '${o.id}.${n}'?`;let s=n.toLowerCase();(r.startsWith(s)||s.startsWith(r))&&(i=i||`Did you mean '${o.id}.${n}'?`)}return i}function xw(t,e,r){let i=t.options||{},o={...i};i.core&&(o.core={...i.core}),Ym(o),o.core?.log===null&&(o.core={...o.core,log:new ia}),Hm(o,Nt(Yh()));let n=Nt(e);return Hm(o,n),Aw(o,r),Ew(o),o}function Hm(t,e){for(let r in e)if(r in e){let i=e[r];Qs(i)&&Qs(t[r])?t[r]={...t[r],...e[r]}:t[r]=e[r]}}function Aw(t,e){if(!e)return;t.core?.baseUrl!==void 0||(t.core||={},t.core.baseUrl=Ot.dirname(lr(e)))}function Sw(t){let e={...t};return t.core&&(e.core={...t.core}),e}function Ym(t){t.baseUri!==void 0&&(t.core||={},t.core.baseUrl===void 0&&(t.core.baseUrl=t.baseUri));for(let r of Hh)if(t[r]!==void 0){let o=t.core=t.core||{};o[r]===void 0&&(o[r]=t[r])}let e=t._worker;e!==void 0&&(t.core||={},t.core._workerType===void 0&&(t.core._workerType=e))}function Ew(t){let e=t.core;if(e)for(let r of Hh)e[r]!==void 0&&(t[r]=e[r])}function zo(t){return t?(Array.isArray(t)&&(t=t[0]),Array.isArray(t?.extensions)):!1}function Wo(t){sr(t,"null loader"),sr(zo(t),"invalid loader");let e;return Array.isArray(t)&&(e=t[1],t=t[0],t={...t,options:{...t.options,...e}}),(t?.parseTextSync||t?.parseText)&&(t.text=!0),t.text||(t.binary=!0),t}var Km=()=>{let t=Xh();return t.loaderRegistry=t.loaderRegistry||[],t.loaderRegistry};function jo(t){let e=Km();t=Array.isArray(t)?t:[t];for(let r of t){let i=Wo(r);e.find(o=>i===o)||e.unshift(i)}}function Zm(){return Km()}var ww=/\.([^.]+)$/;async function Qm(t,e=[],r,i){if(!Jm(t))return null;let o=Nt(r||{});if(o.core||={},t instanceof Response&&qm(t)){let s=await t.clone().text(),a=sa(s,e,{...o,core:{...o.core,nothrow:!0}},i);if(a)return a}let n=sa(t,e,{...o,core:{...o.core,nothrow:!0}},i);if(n)return n;if(Me(t)&&(t=await t.slice(0,10).arrayBuffer(),n=sa(t,e,o,i)),!n&&t instanceof Response&&qm(t)){let s=await t.clone().text();n=sa(s,e,o,i)}if(!n&&!o.core.nothrow)throw new Error(e_(t));return n}function qm(t){let e=Ci(t);return Boolean(e&&(e.startsWith("text/")||e==="application/json"||e.endsWith("+json")))}function sa(t,e=[],r,i){if(!Jm(t))return null;let o=Nt(r||{});if(o.core||={},e&&!Array.isArray(e))return Wo(e);let n=[];e&&(n=n.concat(e)),o.core.ignoreRegisteredLoaders||n.push(...Zm()),Pw(n);let s=Rw(t,n,o,i);if(!s&&!o.core.nothrow)throw new Error(e_(t));return s}function Rw(t,e,r,i){let o=Fr(t),n=Ci(t),s=lr(o)||i?.url,a=null,c="";return r?.core?.mimeType&&(a=Kh(e,r?.core?.mimeType),c=`match forced by supplied MIME type ${r?.core?.mimeType}`),a=a||vw(e,s),c=c||(a?`matched url ${s}`:""),a=a||Kh(e,n),c=c||(a?`matched MIME type ${n}`:""),a=a||Cw(e,t),c=c||(a?`matched initial data ${t_(t)}`:""),r?.core?.fallbackMimeType&&(a=a||Kh(e,r?.core?.fallbackMimeType),c=c||(a?`matched fallback MIME type ${n}`:"")),c&&wh.log(1,`selectLoader selected ${a?.name}: ${c}.`),a}function Jm(t){return!(t instanceof Response&&t.status===204)}function e_(t){let e=Fr(t),r=Ci(t),i="No valid loader found (";i+=e?`${Ot.filename(e)}, `:"no url provided, ",i+=`MIME type: ${r?`"${r}"`:"not provided"}, `;let o=t?t_(t):"";return i+=o?` first bytes: "${o}"`:"first bytes: not available",i+=")",i}function Pw(t){for(let e of t)Wo(e)}function vw(t,e){let r=e&&ww.exec(e),i=r&&r[1];return i?Mw(t,i):null}function Mw(t,e){e=e.toLowerCase();for(let r of t)for(let i of r.extensions)if(i.toLowerCase()===e)return r;return null}function Kh(t,e){for(let r of t)if(r.mimeTypes?.some(i=>jh(e,i))||jh(e,`application/x.${r.id}`))return r;return null}function Cw(t,e){if(!e)return null;for(let r of t)if(typeof e=="string"){if(Iw(e,r))return r}else if(ArrayBuffer.isView(e)){if(Gm(e.buffer,e.byteOffset,r))return r}else if(e instanceof ArrayBuffer&&Gm(e,0,r))return r;return null}function Iw(t,e){return e.testText?e.testText(t):(Array.isArray(e.tests)?e.tests:[e.tests]).some(i=>t.startsWith(i))}function Gm(t,e,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(o=>Ow(t,e,r,o))}function Ow(t,e,r,i){if(Pi(i))return Lh(i,t,i.byteLength);switch(typeof i){case"function":return i(Uo(t));case"string":let o=Zh(t,e,i.length);return i===o;default:return!1}}function t_(t,e=5){return typeof t=="string"?t.slice(0,e):ArrayBuffer.isView(t)?Zh(t.buffer,t.byteOffset,e):t instanceof ArrayBuffer?Zh(t,0,e):""}function Zh(t,e,r){if(t.byteLength<e+r)return"";let i=new DataView(t),o="";for(let n=0;n<r;n++)o+=String.fromCharCode(i.getUint8(e+n));return o}var Nw=256*1024;function*r_(t,e){let r=e?.chunkSize||Nw,i=0,o=new TextEncoder;for(;i<t.length;){let n=Math.min(t.length-i,r),s=t.slice(i,i+n);i+=n,yield Uo(o.encode(s))}}function*i_(t,e={}){let{chunkSize:r=262144}=e,i=0;for(;i<t.byteLength;){let o=Math.min(t.byteLength-i,r),n=new ArrayBuffer(o),s=new Uint8Array(t,i,o);new Uint8Array(n).set(s),i+=o,yield n}}async function*o_(t,e){let r=e?.chunkSize||1048576,i=0;for(;i<t.size;){let o=i+r,n=await t.slice(i,o).arrayBuffer();i=o,yield n}}function qh(t,e){return Dr?Dw(t,e):Bw(t,e)}async function*Dw(t,e){let r=t.getReader(),i;try{for(;;){let o=i||r.read();e?._streamReadAhead&&(i=r.read());let{done:n,value:s}=await o;if(n)return;yield Mi(s)}}catch{r.releaseLock()}}async function*Bw(t,e){for await(let r of t)yield Mi(r)}function n_(t,e){if(typeof t=="string")return r_(t,e);if(t instanceof ArrayBuffer)return i_(t,e);if(Me(t))return o_(t,e);if(Bo(t))return qh(t,e);if(ve(t)){let r=t.body;if(!r)throw new Error("Readable stream not available on Response");return qh(r,e)}throw new Error("makeIterator")}var s_="Cannot convert supplied data type";function Fw(t,e,r){if(e.text&&typeof t=="string")return t;if(ea(t)&&(t=t.buffer),Pi(t)){let i=zh(t);return e.text&&!e.binary?new TextDecoder("utf8").decode(i):Mi(i)}throw new Error(s_)}async function a_(t,e,r){if(typeof t=="string"||Pi(t))return Fw(t,e,r);if(Me(t)&&(t=await ra(t)),ve(t))return await Wm(t),e.binary?await t.arrayBuffer():await t.text();if(Bo(t)&&(t=n_(t,r)),Ph(t)||vh(t))return kh(t);throw new Error(s_)}function aa(t,e){let r=Yh(),i=t||r,o=i.fetch??i.core?.fetch;return typeof o=="function"?o:ut(o)?n=>Ii(n,o):e?.fetch?e?.fetch:Ii}function c_(t,e,r){if(r)return r;let i={fetch:aa(e,t),...t};if(i.url){let o=lr(i.url);i.baseUrl=o,i.queryString=km(i.url),i.filename=Ot.filename(o),i.baseUrl=Ot.dirname(o)}return Array.isArray(i.loaders)||(i.loaders=null),i}function l_(t,e){if(t&&!Array.isArray(t))return t;let r;if(t&&(r=Array.isArray(t)?t:[t]),e&&e.loaders){let i=Array.isArray(e.loaders)?e.loaders:[e.loaders];r=r?[...r,...i]:i}return r&&r.length?r:void 0}async function fr(t,e,r,i){e&&!Array.isArray(e)&&!zo(e)&&(i=void 0,r=e,e=void 0),t=await t,r=r||{};let o=Fr(t),s=l_(e,i),a=await Qm(t,s,r);if(!a)return null;let c=Xm(r,a,s,o);return i=c_({url:o,_parse:fr,loaders:s},c,i||null),await Lw(a,t,c,i)}async function Lw(t,e,r,i){if(Dh(t),r=Mh(t.options,r),ve(e)){let{ok:n,redirected:s,status:a,statusText:c,type:l,url:f}=e,h=Object.fromEntries(e.headers.entries());i.response={headers:h,ok:n,redirected:s,status:a,statusText:c,type:l,url:f}}e=await a_(e,t,r);let o=t;if(o.parseTextSync&&typeof e=="string")return o.parseTextSync(e,r,i);if(Bh(t,r))return await Fh(t,e,r,i,fr);if(o.parseText&&typeof e=="string")return await o.parseText(e,r,i);if(o.parse)return await o.parse(e,r,i);throw pe(!o.parseSync),new Error(`${t.id} loader - no parser found and worker is disabled`)}async function hr(t,e,r,i){let o,n;!Array.isArray(e)&&!zo(e)?(o=[],n=e,i=void 0):(o=e,n=r);let s=aa(n),a=t;return typeof t=="string"&&(a=await s(t)),Me(t)&&(a=await s(t)),typeof t=="string"&&(Nt(n||{}).core?.baseUrl||(n={...n,core:{...n?.core,baseUrl:t}})),Array.isArray(o)?await fr(a,o,n):await fr(a,o,n)}var f_="4.4.1";var Uw=globalThis.loaders?.parseImageNode,Qh=typeof Image<"u",Jh=typeof ImageBitmap<"u",kw=Boolean(Uw),eu=Dr?!0:kw;function h_(t){switch(t){case"auto":return Jh||Qh||eu;case"imagebitmap":return Jh;case"image":return Qh;case"data":return eu;default:throw new Error(`@loaders.gl/images: image ${t} not supported in this environment`)}}function u_(){if(Jh)return"imagebitmap";if(Qh)return"image";if(eu)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function Vw(t){let e=zw(t);if(!e)throw new Error("Not an image");return e}function d_(t){switch(Vw(t)){case"data":return t;case"image":case"imagebitmap":let e=document.createElement("canvas"),r=e.getContext("2d");if(!r)throw new Error("getImageData");return e.width=t.width,e.height=t.height,r.drawImage(t,0,0),r.getImageData(0,0,t.width,t.height);default:throw new Error("getImageData")}}function zw(t){return typeof ImageBitmap<"u"&&t instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&t instanceof Image?"image":t&&typeof t=="object"&&t.data&&t.width&&t.height?"data":null}var Ww=/^data:image\/svg\+xml/,jw=/\.svg((\?|#).*)?$/;function ca(t){return t&&(Ww.test(t)||jw.test(t))}function p_(t,e){if(ca(e)){let i=new TextDecoder().decode(t);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(i=unescape(encodeURIComponent(i)))}catch(n){throw new Error(n.message)}return`data:image/svg+xml;base64,${btoa(i)}`}return tu(t,e)}function tu(t,e){if(ca(e))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(t)])}async function la(t,e,r){let i=p_(t,r),o=self.URL||self.webkitURL,n=typeof i!="string"&&o.createObjectURL(i);try{return await $w(n||i,e)}finally{n&&o.revokeObjectURL(n)}}async function $w(t,e){let r=new Image;return r.src=t,e.image&&e.image.decode&&r.decode?(await r.decode(),r):await new Promise((i,o)=>{try{r.onload=()=>i(r),r.onerror=n=>{let s=n instanceof Error?n.message:"error";o(new Error(s))}}catch(n){o(n)}})}var g_=!0;async function m_(t,e,r){let i;ca(r)?i=await la(t,e,r):i=tu(t,r);let o=e&&e.imagebitmap;return await Hw(i,o)}async function Hw(t,e=null){if((Xw(e)||!g_)&&(e=null),e)try{return await createImageBitmap(t,e)}catch(r){console.warn(r),g_=!1}return await createImageBitmap(t)}function Xw(t){if(!t)return!0;for(let e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function __(t){return!qw(t,"ftyp",4)||!(t[8]&96)?null:Yw(t)}function Yw(t){switch(Kw(t,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function Kw(t,e,r){return String.fromCharCode(...t.slice(e,r))}function Zw(t){return[...t].map(e=>e.charCodeAt(0))}function qw(t,e,r=0){let i=Zw(e);for(let o=0;o<i.length;++o)if(i[o]!==t[o+r])return!1;return!0}var pt=!1,$o=!0;function fa(t){let e=Ho(t);return Qw(e)||tR(e)||Jw(e)||eR(e)||Gw(e)}function Gw(t){let e=new Uint8Array(t instanceof DataView?t.buffer:t),r=__(e);return r?{mimeType:r.mimeType,width:0,height:0}:null}function Qw(t){let e=Ho(t);return e.byteLength>=24&&e.getUint32(0,pt)===2303741511?{mimeType:"image/png",width:e.getUint32(16,pt),height:e.getUint32(20,pt)}:null}function Jw(t){let e=Ho(t);return e.byteLength>=10&&e.getUint32(0,pt)===1195984440?{mimeType:"image/gif",width:e.getUint16(6,$o),height:e.getUint16(8,$o)}:null}function eR(t){let e=Ho(t);return e.byteLength>=14&&e.getUint16(0,pt)===16973&&e.getUint32(2,$o)===e.byteLength?{mimeType:"image/bmp",width:e.getUint32(18,$o),height:e.getUint32(22,$o)}:null}function tR(t){let e=Ho(t);if(!(e.byteLength>=3&&e.getUint16(0,pt)===65496&&e.getUint8(2)===255))return null;let{tableMarkers:i,sofMarkers:o}=rR(),n=2;for(;n+9<e.byteLength;){let s=e.getUint16(n,pt);if(o.has(s))return{mimeType:"image/jpeg",height:e.getUint16(n+5,pt),width:e.getUint16(n+7,pt)};if(!i.has(s))return null;n+=2,n+=e.getUint16(n,pt)}return null}function rR(){let t=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)t.add(r);return{tableMarkers:t,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function Ho(t){if(t instanceof DataView)return t;if(ArrayBuffer.isView(t))return new DataView(t.buffer);if(t instanceof ArrayBuffer)return new DataView(t);throw new Error("toDataView")}async function y_(t,e){let{mimeType:r}=fa(t)||{},i=globalThis.loaders?.parseImageNode;return sr(i),await i(t,r)}async function b_(t,e,r){e=e||{};let o=(e.image||{}).type||"auto",{url:n}=r||{},s=iR(o),a;switch(s){case"imagebitmap":a=await m_(t,e,n);break;case"image":a=await la(t,e,n);break;case"data":a=await y_(t,e);break;default:sr(!1)}return o==="data"&&(a=d_(a)),a}function iR(t){switch(t){case"auto":case"data":return u_();default:return h_(t),t}}var oR=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],nR=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],sR={image:{type:"auto",decode:!0}},ru={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:f_,mimeTypes:nR,extensions:oR,parse:b_,tests:[t=>Boolean(fa(new DataView(t)))],options:sR};io();var aR=new fe({id:"deck"}),F=aR;var iu={};function ha(t){iu=t}function q(t,e,r,i){F.level>0&&iu[t]&&iu[t].call(null,e,r,i)}function cR(t){let e=t[0],r=t[t.length-1];return e==="{"&&r==="}"||e==="["&&r==="]"}var T_={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:cR,parseTextSync:JSON.parse};function lR(){let t="9.3.0-beta.1",e=globalThis.deck&&globalThis.deck.VERSION;if(e&&e!==t)throw new Error(`deck.gl - multiple versions detected: ${e} vs ${t}`);return e||(F.log(1,`deck.gl ${t}`)(),globalThis.deck={...globalThis.deck,VERSION:t,version:t,log:F,_registerLoggers:ha},jo([T_,[ru,{imagebitmap:{premultiplyAlpha:"none"}}]])),t}var ua=lR();var fR=`struct LayerUniforms {
|
|
1245
1245
|
opacity: f32,
|
|
1246
1246
|
};
|
|
1247
1247
|
|
|
1248
1248
|
@group(0) @binding(auto)
|
|
1249
1249
|
var<uniform> layer: LayerUniforms;
|
|
1250
|
-
`,
|
|
1250
|
+
`,x_=`layout(std140) uniform layerUniforms {
|
|
1251
1251
|
uniform float opacity;
|
|
1252
1252
|
} layer;
|
|
1253
|
-
`,
|
|
1253
|
+
`,ou={name:"layer",source:fR,vs:x_,fs:x_,getUniforms:t=>({opacity:Math.pow(t.opacity,.45454545454545453)}),uniformTypes:{opacity:"f32"}};var hR=`
|
|
1254
1254
|
|
|
1255
1255
|
@must_use
|
|
1256
1256
|
fn deckgl_premultiplied_alpha(fragColor: vec4<f32>) -> vec4<f32> {
|
|
1257
1257
|
return vec4(fragColor.rgb * fragColor.a, fragColor.a);
|
|
1258
1258
|
};
|
|
1259
|
-
`,
|
|
1259
|
+
`,nu={name:"color",dependencies:[],source:hR,getUniforms:t=>({})};var uR=`const SMOOTH_EDGE_RADIUS: f32 = 0.5;
|
|
1260
1260
|
|
|
1261
1261
|
struct VertexGeometry {
|
|
1262
1262
|
position: vec4<f32>,
|
|
@@ -1285,7 +1285,7 @@ var<private> fragmentGeometry: FragmentGeometry;
|
|
|
1285
1285
|
fn smoothedge(edge: f32, x: f32) -> f32 {
|
|
1286
1286
|
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
|
|
1287
1287
|
}
|
|
1288
|
-
`,
|
|
1288
|
+
`,A_="#define SMOOTH_EDGE_RADIUS 0.5",dR=`${A_}
|
|
1289
1289
|
|
|
1290
1290
|
struct VertexGeometry {
|
|
1291
1291
|
vec4 position;
|
|
@@ -1302,7 +1302,7 @@ struct VertexGeometry {
|
|
|
1302
1302
|
vec2(0.0),
|
|
1303
1303
|
vec3(0.0)
|
|
1304
1304
|
);
|
|
1305
|
-
`,
|
|
1305
|
+
`,pR=`${A_}
|
|
1306
1306
|
|
|
1307
1307
|
struct FragmentGeometry {
|
|
1308
1308
|
vec2 uv;
|
|
@@ -1311,9 +1311,9 @@ struct FragmentGeometry {
|
|
|
1311
1311
|
float smoothedge(float edge, float x) {
|
|
1312
1312
|
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
|
|
1313
1313
|
}
|
|
1314
|
-
`,ua={name:"geometry",source:hR,vs:uR,fs:dR};var H;(function(t){t[t.Start=1]="Start",t[t.Move=2]="Move",t[t.End=4]="End",t[t.Cancel=8]="Cancel"})(H||(H={}));var K;(function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Right=2]="Right",t[t.Up=4]="Up",t[t.Down=8]="Down",t[t.Horizontal=3]="Horizontal",t[t.Vertical=12]="Vertical",t[t.All=15]="All"})(K||(K={}));var N;(function(t){t[t.Possible=1]="Possible",t[t.Began=2]="Began",t[t.Changed=4]="Changed",t[t.Ended=8]="Ended",t[t.Recognized=8]="Recognized",t[t.Cancelled=16]="Cancelled",t[t.Failed=32]="Failed"})(N||(N={}));var A_="compute",ou="auto",Ho="manipulation",Ur="none",Xo="pan-x",Yo="pan-y";function nu(t){if(t.includes(Ur))return Ur;let e=t.includes(Xo),r=t.includes(Yo);return e&&r?Ur:e||r?e?Xo:Yo:t.includes(Ho)?Ho:ou}var Ko=class{constructor(e,r){this.actions="",this.manager=e,this.set(r)}set(e){e===A_&&(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 r of this.manager.recognizers)r.options.enable&&(e=e.concat(r.getTouchAction()));return nu(e.join(" "))}};function Ii(t){return t.trim().split(/\s+/g)}function da(t,e,r){if(t)for(let i of Ii(e))t.addEventListener(i,r,!1)}function pa(t,e,r){if(t)for(let i of Ii(e))t.removeEventListener(i,r,!1)}function su(t){return(t.ownerDocument||t).defaultView}function au(t,e){let r=t;for(;r;){if(r===e)return!0;r=r.parentNode}return!1}function ga(t){let e=t.length;if(e===1)return{x:Math.round(t[0].clientX),y:Math.round(t[0].clientY)};let r=0,i=0,o=0;for(;o<e;)r+=t[o].clientX,i+=t[o].clientY,o++;return{x:Math.round(r/e),y:Math.round(i/e)}}function cu(t){let e=[],r=0;for(;r<t.pointers.length;)e[r]={clientX:Math.round(t.pointers[r].clientX),clientY:Math.round(t.pointers[r].clientY)},r++;return{timeStamp:Date.now(),pointers:e,center:ga(e),deltaX:t.deltaX,deltaY:t.deltaY}}function ma(t,e){let r=e.x-t.x,i=e.y-t.y;return Math.sqrt(r*r+i*i)}function lu(t,e){let r=e.clientX-t.clientX,i=e.clientY-t.clientY;return Math.sqrt(r*r+i*i)}function S_(t,e){let r=e.x-t.x,i=e.y-t.y;return Math.atan2(i,r)*180/Math.PI}function fu(t,e){let r=e.clientX-t.clientX,i=e.clientY-t.clientY;return Math.atan2(i,r)*180/Math.PI}function _a(t,e){return t===e?K.None:Math.abs(t)>=Math.abs(e)?t<0?K.Left:K.Right:e<0?K.Up:K.Down}function E_(t,e){let r=e.center,i=t.offsetDelta,o=t.prevDelta,n=t.prevInput;return(e.eventType===H.Start||n?.eventType===H.End)&&(o=t.prevDelta={x:n?.deltaX||0,y:n?.deltaY||0},i=t.offsetDelta={x:r.x,y:r.y}),{deltaX:o.x+(r.x-i.x),deltaY:o.y+(r.y-i.y)}}function ya(t,e,r){return{x:e/t||0,y:r/t||0}}function w_(t,e){return lu(e[0],e[1])/lu(t[0],t[1])}function R_(t,e){return fu(e[1],e[0])-fu(t[1],t[0])}function P_(t,e){let r=t.lastInterval||e,i=e.timeStamp-r.timeStamp,o,n,s,a;if(e.eventType!==H.Cancel&&(i>25||r.velocity===void 0)){let c=e.deltaX-r.deltaX,l=e.deltaY-r.deltaY,f=ya(i,c,l);n=f.x,s=f.y,o=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,a=_a(c,l),t.lastInterval=e}else o=r.velocity,n=r.velocityX,s=r.velocityY,a=r.direction;e.velocity=o,e.velocityX=n,e.velocityY=s,e.direction=a}function v_(t,e){let{session:r}=t,{pointers:i}=e,{length:o}=i;r.firstInput||(r.firstInput=cu(e)),o>1&&!r.firstMultiple?r.firstMultiple=cu(e):o===1&&(r.firstMultiple=!1);let{firstInput:n,firstMultiple:s}=r,a=s?s.center:n.center,c=e.center=ga(i);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-n.timeStamp,e.angle=S_(a,c),e.distance=ma(a,c);let{deltaX:l,deltaY:f}=E_(r,e);e.deltaX=l,e.deltaY=f,e.offsetDirection=_a(e.deltaX,e.deltaY);let h=ya(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=h.x,e.overallVelocityY=h.y,e.overallVelocity=Math.abs(h.x)>Math.abs(h.y)?h.x:h.y,e.scale=s?w_(s.pointers,i):1,e.rotation=s?R_(s.pointers,i):0,e.maxPointers=r.prevInput?e.pointers.length>r.prevInput.maxPointers?e.pointers.length:r.prevInput.maxPointers:e.pointers.length;let u=t.element;return au(e.srcEvent.target,u)&&(u=e.srcEvent.target),e.target=u,P_(r,e),e}function M_(t,e,r){let i=r.pointers.length,o=r.changedPointers.length,n=e&H.Start&&i-o===0,s=e&(H.End|H.Cancel)&&i-o===0;r.isFirst=Boolean(n),r.isFinal=Boolean(s),n&&(t.session={}),r.eventType=e;let a=v_(t,r);t.emit("hammer.input",a),t.recognize(a),t.session.prevInput=a}var Zo=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=r=>{this.manager.options.enable&&this.handler(r)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,r){M_(this.manager,e,r)}init(){da(this.element,this.evEl,this.domHandler),da(this.target,this.evTarget,this.domHandler),da(su(this.element),this.evWin,this.domHandler)}destroy(){pa(this.element,this.evEl,this.domHandler),pa(this.target,this.evTarget,this.domHandler),pa(su(this.element),this.evWin,this.domHandler)}};var gR={pointerdown:H.Start,pointermove:H.Move,pointerup:H.End,pointercancel:H.Cancel,pointerout:H.Cancel},mR="pointerdown",_R="pointermove pointerup pointercancel",qo=class extends Zo{constructor(e){super(e),this.evEl=mR,this.evWin=_R,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:r}=this,i=!1,o=gR[e.type],n=e.pointerType,s=n==="touch",a=r.findIndex(c=>c.pointerId===e.pointerId);o&H.Start&&(e.buttons||s)?a<0&&(r.push(e),a=r.length-1):o&(H.End|H.Cancel)&&(i=!0),!(a<0)&&(r[a]=e,this.callback(o,{pointers:r,changedPointers:[e],eventType:o,pointerType:n,srcEvent:e}),i&&r.splice(a,1))}};var yR=["","webkit","Moz","MS","ms","o"];function C_(t,e){let r=e[0].toUpperCase()+e.slice(1);for(let i of yR){let o=i?i+r:e;if(o in t)return o}}var bR=1,I_=2,O_={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},Go=class{constructor(e,r){this.options={...O_,...r,cssProps:{...O_.cssProps,...r.cssProps},inputTarget:r.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new qo(this),this.touchAction=new Ko(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?I_:bR}recognize(e){let{session:r}=this;if(r.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let i,{recognizers:o}=this,{curRecognizer:n}=r;(!n||n&&n.state&N.Recognized)&&(n=r.curRecognizer=null);let s=0;for(;s<o.length;)i=o[s],r.stopped!==I_&&(!n||i===n||i.canRecognizeWith(n))?i.recognize(e):i.reset(),!n&&i.state&(N.Began|N.Changed|N.Ended)&&(n=r.curRecognizer=i),s++}get(e){let{recognizers:r}=this;for(let i=0;i<r.length;i++)if(r[i].options.event===e)return r[i];return null}add(e){if(Array.isArray(e)){for(let i of e)this.add(i);return this}let r=this.get(e.options.event);return r&&this.remove(r),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(let i of e)this.remove(i);return this}let r=typeof e=="string"?this.get(e):e;if(r){let{recognizers:i}=this,o=i.indexOf(r);o!==-1&&(i.splice(o,1),this.touchAction.update())}return this}on(e,r){if(!e||!r)return;let{handlers:i}=this;for(let o of Ii(e))i[o]=i[o]||[],i[o].push(r)}off(e,r){if(!e)return;let{handlers:i}=this;for(let o of Ii(e))r?i[o]&&i[o].splice(i[o].indexOf(r),1):delete i[o]}emit(e,r){let i=this.handlers[e]&&this.handlers[e].slice();if(!i||!i.length)return;let o=r;o.type=e,o.preventDefault=function(){r.srcEvent.preventDefault()};let n=0;for(;n<i.length;)i[n](o),n++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){let{element:r}=this;if(r){for(let[i,o]of Object.entries(this.options.cssProps)){let n=C_(r.style,i);e?(this.oldCssProps[n]=r.style[n],r.style[n]=o):r.style[n]=this.oldCssProps[n]||""}e||(this.oldCssProps={})}}};var TR=1;function N_(){return TR++}function hu(t){return t&N.Cancelled?"cancel":t&N.Ended?"end":t&N.Changed?"move":t&N.Began?"start":""}var Bt=class{constructor(e){this.options=e,this.id=N_(),this.state=N.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 o of e)this.recognizeWith(o);return this}let r;if(typeof e=="string"){if(r=this.manager.get(e),!r)throw new Error(`Cannot find recognizer ${e}`)}else r=e;let{simultaneous:i}=this;return i[r.id]||(i[r.id]=r,r.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(let i of e)this.dropRecognizeWith(i);return this}let r;return typeof e=="string"?r=this.manager.get(e):r=e,r&&delete this.simultaneous[r.id],this}requireFailure(e){if(Array.isArray(e)){for(let o of e)this.requireFailure(o);return this}let r;if(typeof e=="string"){if(r=this.manager.get(e),!r)throw new Error(`Cannot find recognizer ${e}`)}else r=e;let{requireFail:i}=this;return i.indexOf(r)===-1&&(i.push(r),r.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(let i of e)this.dropRequireFailure(i);return this}let r;if(typeof e=="string"?r=this.manager.get(e):r=e,r){let i=this.requireFail.indexOf(r);i>-1&&this.requireFail.splice(i,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:r}=this;r<N.Ended&&this.manager.emit(this.options.event+hu(r),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),r>=N.Ended&&this.manager.emit(this.options.event+hu(r),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=N.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&(N.Failed|N.Possible)))return!1;e++}return!0}recognize(e){let r={...e};if(!this.options.enable){this.reset(),this.state=N.Failed;return}this.state&(N.Recognized|N.Cancelled|N.Failed)&&(this.state=N.Possible),this.state=this.process(r),this.state&(N.Began|N.Changed|N.Ended|N.Cancelled)&&this.tryEmit(r)}getEventNames(){return[this.options.event]}reset(){}};var Lt=class extends Bt{attrTest(e){let r=this.options.pointers;return r===0||e.pointers.length===r}process(e){let{state:r}=this,{eventType:i}=e,o=r&(N.Began|N.Changed),n=this.attrTest(e);return o&&(i&H.Cancel||!n)?r|N.Cancelled:o||n?i&H.End?r|N.Ended:r&N.Began?r|N.Changed:N.Began:N.Failed}};var kr=class extends Bt{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[Ho]}process(e){let{options:r}=this,i=e.pointers.length===r.pointers,o=e.distance<r.threshold,n=e.deltaTime<r.time;if(this.reset(),e.eventType&H.Start&&this.count===0)return this.failTimeout();if(o&&n&&i){if(e.eventType!==H.End)return this.failTimeout();let s=this.pTime?e.timeStamp-this.pTime<r.interval:!0,a=!this.pCenter||ma(this.pCenter,e.center)<r.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!a||!s?this.count=1:this.count+=1,this._input=e,this.count%r.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=N.Recognized,this.tryEmit(this._input)},r.interval),N.Began):N.Recognized}return N.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=N.Failed},this.options.interval),N.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===N.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}};var xR=["","start","move","end","cancel","up","down","left","right"],dr=class extends Lt{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:K.All,...e}),this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,r=[];return e&K.Horizontal&&r.push(Yo),e&K.Vertical&&r.push(Xo),r}getEventNames(){return xR.map(e=>this.options.event+e)}directionTest(e){let{options:r}=this,i=!0,{distance:o}=e,{direction:n}=e,s=e.deltaX,a=e.deltaY;return n&r.direction||(r.direction&K.Horizontal?(n=s===0?K.None:s<0?K.Left:K.Right,i=s!==this.pX,o=Math.abs(e.deltaX)):(n=a===0?K.None:a<0?K.Up:K.Down,i=a!==this.pY,o=Math.abs(e.deltaY))),e.direction=n,i&&o>r.threshold&&Boolean(n&r.direction)}attrTest(e){return super.attrTest(e)&&(Boolean(this.state&N.Began)||!(this.state&N.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let r=K[e.direction].toLowerCase();r&&(e.additionalEvent=this.options.event+r),super.emit(e)}};var AR=["","start","move","end","cancel","in","out"],Oi=class extends Lt{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,...e})}getTouchAction(){return[Ur]}getEventNames(){return AR.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||Boolean(this.state&N.Began))}emit(e){if(e.scale!==1){let r=e.scale<1?"in":"out";e.additionalEvent=this.options.event+r}super.emit(e)}};var mt=class{constructor(e,r,i){this.element=e,this.callback=r,this.options=i}};var D_=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",wV=typeof window<"u"?window:global;var RR=D_.indexOf("firefox")!==-1,B_=4.000244140625,PR=40,vR=.25,ba=class extends mt{constructor(e,r,i){super(e,r,{enable:!0,...i}),this.handleEvent=o=>{if(!this.options.enable)return;let n=o.deltaY;globalThis.WheelEvent&&(RR&&o.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(n/=globalThis.devicePixelRatio),o.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(n*=PR)),n!==0&&n%B_===0&&(n=Math.floor(n/B_)),o.shiftKey&&n&&(n=n*vR),this.callback({type:"wheel",center:{x:o.clientX,y:o.clientY},delta:-n,srcEvent:o,pointerType:"mouse",target:o.target})},e.addEventListener("wheel",this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener("wheel",this.handleEvent)}enableEventType(e,r){e==="wheel"&&(this.options.enable=r)}};var L_=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],Ta=class extends mt{constructor(e,r,i){super(e,r,{enable:!0,...i}),this.handleEvent=n=>{this.handleOverEvent(n),this.handleOutEvent(n),this.handleEnterEvent(n),this.handleLeaveEvent(n),this.handleMoveEvent(n)},this.pressed=!1;let{enable:o}=this.options;this.enableMoveEvent=o,this.enableLeaveEvent=o,this.enableEnterEvent=o,this.enableOutEvent=o,this.enableOverEvent=o,L_.forEach(n=>e.addEventListener(n,this.handleEvent))}destroy(){L_.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){switch(e){case"pointermove":this.enableMoveEvent=r;break;case"pointerover":this.enableOverEvent=r;break;case"pointerout":this.enableOutEvent=r;break;case"pointerenter":this.enableEnterEvent=r;break;case"pointerleave":this.enableLeaveEvent=r;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,r){this.callback({type:e,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var F_=["keydown","keyup"],xa=class extends mt{constructor(e,r,i){super(e,r,{enable:!0,tabIndex:0,...i}),this.handleEvent=o=>{let n=o.target||o.srcElement;n.tagName==="INPUT"&&n.type==="text"||n.tagName==="TEXTAREA"||(this.enableDownEvent&&o.type==="keydown"&&this.callback({type:"keydown",srcEvent:o,key:o.key,target:o.target}),this.enableUpEvent&&o.type==="keyup"&&this.callback({type:"keyup",srcEvent:o,key:o.key,target:o.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,e.tabIndex=this.options.tabIndex,e.style.outline="none",F_.forEach(o=>e.addEventListener(o,this.handleEvent))}destroy(){F_.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e==="keydown"&&(this.enableDownEvent=r),e==="keyup"&&(this.enableUpEvent=r)}};var Aa=class extends mt{constructor(e,r,i){super(e,r,i),this.handleEvent=o=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:o.clientX,y:o.clientY},srcEvent:o,pointerType:"mouse",target:o.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,r){e==="contextmenu"&&(this.options.enable=r)}};var MR={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},CR=0,IR=1,OR=2,NR=1,DR=2,BR=4;function U_(t){let e=MR[t.srcEvent.type];if(!e)return null;let{buttons:r,button:i}=t.srcEvent,o=!1,n=!1,s=!1;return e===2?(o=Boolean(r&NR),n=Boolean(r&BR),s=Boolean(r&DR)):(o=i===CR,n=i===IR,s=i===OR),{leftButton:o,middleButton:n,rightButton:s}}function k_(t,e){let r=t.center;if(!r)return null;let i=e.getBoundingClientRect(),o=i.width/e.offsetWidth||1,n=i.height/e.offsetHeight||1,s={x:(r.x-i.left-e.clientLeft)/o,y:(r.y-i.top-e.clientTop)/n};return{center:r,offsetCenter:s}}var LR={srcElement:"root",priority:0},Sa=class{constructor(e,r){this.handleEvent=i=>{if(this.isEmpty())return;let o=this._normalizeEvent(i),n=i.srcEvent.target;for(;n&&n!==o.rootElement;){if(this._emit(o,n),o.handled)return;n=n.parentNode}this._emit(o,"root")},this.eventManager=e,this.recognizerName=r,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,r,i,o=!1,n=!1){let{handlers:s,handlersByElement:a}=this,c={...LR,...i},l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let f={type:e,handler:r,srcElement:c.srcElement,priority:c.priority};o&&(f.once=!0),n&&(f.passive=!0),s.push(f),this._active=this._active||!f.passive;let h=l.length-1;for(;h>=0&&!(l[h].priority>=f.priority);)h--;l.splice(h+1,0,f)}remove(e,r){let{handlers:i,handlersByElement:o}=this;for(let n=i.length-1;n>=0;n--){let s=i[n];if(s.type===e&&s.handler===r){i.splice(n,1);let a=o.get(s.srcElement);a.splice(a.indexOf(s),1),a.length===0&&o.delete(s.srcElement)}}this._active=i.some(n=>!n.passive)}_emit(e,r){let i=this.handlersByElement.get(r);if(i){let o=!1,n=()=>{e.handled=!0},s=()=>{e.handled=!0,o=!0},a=[];for(let c=0;c<i.length;c++){let{type:l,handler:f,once:h}=i[c];if(f({...e,type:l,stopPropagation:n,stopImmediatePropagation:s}),h&&a.push(i[c]),o)break}for(let c=0;c<a.length;c++){let{type:l,handler:f}=a[c];this.remove(l,f)}}}_normalizeEvent(e){let r=this.eventManager.getElement();return{...e,...U_(e),...k_(e,r),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};function FR(t){if("recognizer"in t)return t;let e,r=Array.isArray(t)?[...t]:[t];if(typeof r[0]=="function"){let i=r.shift(),o=r.shift()||{};e=new i(o)}else e=r.shift();return{recognizer:e,recognizeWith:typeof r[0]=="string"?[r[0]]:r[0],requireFailure:typeof r[1]=="string"?[r[1]]:r[1]}}var Qo=class{constructor(e=null,r={}){if(this._onBasicInput=i=>{this.manager.emit(i.srcEvent.type,i)},this._onOtherEvent=i=>{this.manager.emit(i.type,i)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...r},this.events=new Map,this.element=e,!!e){this.manager=new Go(e,this.options);for(let i of this.options.recognizers){let{recognizer:o,recognizeWith:n,requireFailure:s}=FR(i);this.manager.add(o),n&&o.recognizeWith(n),s&&o.requireFailure(s)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new ba(e,this._onOtherEvent,{enable:!1}),this.moveInput=new Ta(e,this._onOtherEvent,{enable:!1}),this.keyInput=new xa(e,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new Aa(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,r,i){this._addEventHandler(e,r,i,!1)}once(e,r,i){this._addEventHandler(e,r,i,!0)}watch(e,r,i){this._addEventHandler(e,r,i,!1,!0)}off(e,r){this._removeEventHandler(e,r)}_toggleRecognizer(e,r){let{manager:i}=this;if(!i)return;let o=i.get(e);o&&(o.set({enable:r}),i.touchAction.update()),this.wheelInput?.enableEventType(e,r),this.moveInput?.enableEventType(e,r),this.keyInput?.enableEventType(e,r),this.contextmenuInput?.enableEventType(e,r)}_addEventHandler(e,r,i,o,n){if(typeof e!="string"){i=r;for(let[l,f]of Object.entries(e))this._addEventHandler(l,f,i,o,n);return}let{manager:s,events:a}=this;if(!s)return;let c=a.get(e);if(!c){let l=this._getRecognizerName(e)||e;c=new Sa(this,l),a.set(e,c),s&&s.on(e,c.handleEvent)}c.add(e,r,i,o,n),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,r){if(typeof e!="string"){for(let[n,s]of Object.entries(e))this._removeEventHandler(n,s);return}let{events:i}=this,o=i.get(e);if(o&&(o.remove(e,r),o.isEmpty())){let{recognizerName:n}=o,s=!1;for(let a of i.values())if(a.recognizerName===n&&!a.isEmpty()){s=!0;break}s||this._toggleRecognizer(n,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(r=>r.getEventNames().includes(e))?.options.event}};var k={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(k,"IDENTITY",{get:()=>(L.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});var oe={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},pr={common:0,meters:1,pixels:2},Ni={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},uu={multipan:[dr,{threshold:10,direction:K.Vertical,pointers:2}],pinch:[Oi,{},null,["multipan"]],pan:[dr,{threshold:1},["pinch"],["multipan"]],dblclick:[kr,{event:"dblclick",taps:2}],click:[kr,{event:"click"},null,["dblclick"]]},V_={DRAW:"draw",MASK:"mask",TERRAIN:"terrain"};function UR(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let i=0;i<r;i++)if(t[i]!==e[i])return!1;return!0}return!1}function ke(t){let e={},r;return i=>{for(let o in i)if(!UR(i[o],e[o])){r=t(i),e=i;break}return r}}var z_=[0,0,0,0],kR=[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],VR=[0,0,0],j_=[0,0,0],zR=ke(jR);function du(t,e,r=j_){r.length<3&&(r=[r[0],r[1],0]);let i=r,o,n=!0;switch(e===k.LNGLAT_OFFSETS||e===k.METER_OFFSETS?o=r:o=t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case oe.WEB_MERCATOR:(e===k.LNGLAT||e===k.CARTESIAN)&&(o=[0,0,0],n=!1);break;case oe.WEB_MERCATOR_AUTO_OFFSET:e===k.LNGLAT?i=o:e===k.CARTESIAN&&(i=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],o=t.unprojectPosition(i),i[0]-=r[0],i[1]-=r[1],i[2]-=r[2]);break;case oe.IDENTITY:i=t.position.map(Math.fround),i[2]=i[2]||0;break;case oe.GLOBE:n=!1,o=null;break;default:n=!1}return{geospatialOrigin:o,shaderCoordinateOrigin:i,offsetMode:n}}function WR(t,e,r){let{viewMatrixUncentered:i,projectionMatrix:o}=t,{viewMatrix:n,viewProjectionMatrix:s}=t,a=z_,c=z_,l=t.cameraPosition,{geospatialOrigin:f,shaderCoordinateOrigin:h,offsetMode:u}=du(t,e,r);return u&&(c=t.projectPosition(f||h),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=xe.transformMat4([],c,s),n=i||n,s=re.multiply([],o,n),s=re.multiply([],s,kR)),{viewMatrix:n,viewProjectionMatrix:s,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:h,geospatialOrigin:f}}function Ea({viewport:t,devicePixelRatio:e=1,modelMatrix:r=null,coordinateSystem:i=k.DEFAULT,coordinateOrigin:o=j_,autoWrapLongitude:n=!1}){i===k.DEFAULT&&(i=t.isGeospatial?k.LNGLAT:k.CARTESIAN);let s=zR({viewport:t,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:o});return s.wrapLongitude=n,s.modelMatrix=r||W_,s}function jR({viewport:t,devicePixelRatio:e,coordinateSystem:r,coordinateOrigin:i}){let{projectionCenter:o,viewProjectionMatrix:n,originCommon:s,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=WR(t,r,i),f=t.getDistanceScales(),h=[t.width*e,t.height*e],u=xe.transformMat4([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,d={coordinateSystem:r,projectionMode:t.projectionMode,coordinateOrigin:c,commonOrigin:s.slice(0,3),center:o,pseudoMeters:Boolean(t._pseudoMeters),viewportSize:h,devicePixelRatio:e,focalDistance:u,commonUnitsPerMeter:f.unitsPerMeter,commonUnitsPerWorldUnit:f.unitsPerMeter,commonUnitsPerWorldUnit2:VR,scale:t.scale,wrapLongitude:!1,viewProjectionMatrix:n,modelMatrix:W_,cameraPosition:a};if(l){let p=t.getDistanceScales(l);switch(r){case k.METER_OFFSETS:d.commonUnitsPerWorldUnit=p.unitsPerMeter,d.commonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case k.LNGLAT:case k.LNGLAT_OFFSETS:t._pseudoMeters||(d.commonUnitsPerMeter=p.unitsPerMeter),d.commonUnitsPerWorldUnit=p.unitsPerDegree,d.commonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case k.CARTESIAN:d.commonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],d.commonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}return d}var $R=Object.keys(k).map(t=>`const COORDINATE_SYSTEM_${t}: i32 = ${k[t]};`).join(""),HR=Object.keys(oe).map(t=>`const PROJECTION_MODE_${t}: i32 = ${oe[t]};`).join(""),XR=Object.keys(pr).map(t=>`const UNIT_${t.toUpperCase()}: i32 = ${pr[t]};`).join(""),YR=`${$R}
|
|
1315
|
-
${
|
|
1316
|
-
${
|
|
1314
|
+
`,da={name:"geometry",source:uR,vs:dR,fs:pR};var $;(function(t){t[t.Start=1]="Start",t[t.Move=2]="Move",t[t.End=4]="End",t[t.Cancel=8]="Cancel"})($||($={}));var Y;(function(t){t[t.None=0]="None",t[t.Left=1]="Left",t[t.Right=2]="Right",t[t.Up=4]="Up",t[t.Down=8]="Down",t[t.Horizontal=3]="Horizontal",t[t.Vertical=12]="Vertical",t[t.All=15]="All"})(Y||(Y={}));var N;(function(t){t[t.Possible=1]="Possible",t[t.Began=2]="Began",t[t.Changed=4]="Changed",t[t.Ended=8]="Ended",t[t.Recognized=8]="Recognized",t[t.Cancelled=16]="Cancelled",t[t.Failed=32]="Failed"})(N||(N={}));var S_="compute",su="auto",Xo="manipulation",Lr="none",Yo="pan-x",Ko="pan-y";function au(t){if(t.includes(Lr))return Lr;let e=t.includes(Yo),r=t.includes(Ko);return e&&r?Lr:e||r?e?Yo:Ko:t.includes(Xo)?Xo:su}var Zo=class{constructor(e,r){this.actions="",this.manager=e,this.set(r)}set(e){e===S_&&(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 r of this.manager.recognizers)r.options.enable&&(e=e.concat(r.getTouchAction()));return au(e.join(" "))}};function Oi(t){return t.trim().split(/\s+/g)}function pa(t,e,r){if(t)for(let i of Oi(e))t.addEventListener(i,r,!1)}function ga(t,e,r){if(t)for(let i of Oi(e))t.removeEventListener(i,r,!1)}function cu(t){return(t.ownerDocument||t).defaultView}function lu(t,e){let r=t;for(;r;){if(r===e)return!0;r=r.parentNode}return!1}function ma(t){let e=t.length;if(e===1)return{x:Math.round(t[0].clientX),y:Math.round(t[0].clientY)};let r=0,i=0,o=0;for(;o<e;)r+=t[o].clientX,i+=t[o].clientY,o++;return{x:Math.round(r/e),y:Math.round(i/e)}}function fu(t){let e=[],r=0;for(;r<t.pointers.length;)e[r]={clientX:Math.round(t.pointers[r].clientX),clientY:Math.round(t.pointers[r].clientY)},r++;return{timeStamp:Date.now(),pointers:e,center:ma(e),deltaX:t.deltaX,deltaY:t.deltaY}}function _a(t,e){let r=e.x-t.x,i=e.y-t.y;return Math.sqrt(r*r+i*i)}function hu(t,e){let r=e.clientX-t.clientX,i=e.clientY-t.clientY;return Math.sqrt(r*r+i*i)}function E_(t,e){let r=e.x-t.x,i=e.y-t.y;return Math.atan2(i,r)*180/Math.PI}function uu(t,e){let r=e.clientX-t.clientX,i=e.clientY-t.clientY;return Math.atan2(i,r)*180/Math.PI}function ya(t,e){return t===e?Y.None:Math.abs(t)>=Math.abs(e)?t<0?Y.Left:Y.Right:e<0?Y.Up:Y.Down}function w_(t,e){let r=e.center,i=t.offsetDelta,o=t.prevDelta,n=t.prevInput;return(e.eventType===$.Start||n?.eventType===$.End)&&(o=t.prevDelta={x:n?.deltaX||0,y:n?.deltaY||0},i=t.offsetDelta={x:r.x,y:r.y}),{deltaX:o.x+(r.x-i.x),deltaY:o.y+(r.y-i.y)}}function ba(t,e,r){return{x:e/t||0,y:r/t||0}}function R_(t,e){return hu(e[0],e[1])/hu(t[0],t[1])}function P_(t,e){return uu(e[1],e[0])-uu(t[1],t[0])}function v_(t,e){let r=t.lastInterval||e,i=e.timeStamp-r.timeStamp,o,n,s,a;if(e.eventType!==$.Cancel&&(i>25||r.velocity===void 0)){let c=e.deltaX-r.deltaX,l=e.deltaY-r.deltaY,f=ba(i,c,l);n=f.x,s=f.y,o=Math.abs(f.x)>Math.abs(f.y)?f.x:f.y,a=ya(c,l),t.lastInterval=e}else o=r.velocity,n=r.velocityX,s=r.velocityY,a=r.direction;e.velocity=o,e.velocityX=n,e.velocityY=s,e.direction=a}function M_(t,e){let{session:r}=t,{pointers:i}=e,{length:o}=i;r.firstInput||(r.firstInput=fu(e)),o>1&&!r.firstMultiple?r.firstMultiple=fu(e):o===1&&(r.firstMultiple=!1);let{firstInput:n,firstMultiple:s}=r,a=s?s.center:n.center,c=e.center=ma(i);e.timeStamp=Date.now(),e.deltaTime=e.timeStamp-n.timeStamp,e.angle=E_(a,c),e.distance=_a(a,c);let{deltaX:l,deltaY:f}=w_(r,e);e.deltaX=l,e.deltaY=f,e.offsetDirection=ya(e.deltaX,e.deltaY);let h=ba(e.deltaTime,e.deltaX,e.deltaY);e.overallVelocityX=h.x,e.overallVelocityY=h.y,e.overallVelocity=Math.abs(h.x)>Math.abs(h.y)?h.x:h.y,e.scale=s?R_(s.pointers,i):1,e.rotation=s?P_(s.pointers,i):0,e.maxPointers=r.prevInput?e.pointers.length>r.prevInput.maxPointers?e.pointers.length:r.prevInput.maxPointers:e.pointers.length;let u=t.element;return lu(e.srcEvent.target,u)&&(u=e.srcEvent.target),e.target=u,v_(r,e),e}function C_(t,e,r){let i=r.pointers.length,o=r.changedPointers.length,n=e&$.Start&&i-o===0,s=e&($.End|$.Cancel)&&i-o===0;r.isFirst=Boolean(n),r.isFinal=Boolean(s),n&&(t.session={}),r.eventType=e;let a=M_(t,r);t.emit("hammer.input",a),t.recognize(a),t.session.prevInput=a}var qo=class{constructor(e){this.evEl="",this.evWin="",this.evTarget="",this.domHandler=r=>{this.manager.options.enable&&this.handler(r)},this.manager=e,this.element=e.element,this.target=e.options.inputTarget||e.element}callback(e,r){C_(this.manager,e,r)}init(){pa(this.element,this.evEl,this.domHandler),pa(this.target,this.evTarget,this.domHandler),pa(cu(this.element),this.evWin,this.domHandler)}destroy(){ga(this.element,this.evEl,this.domHandler),ga(this.target,this.evTarget,this.domHandler),ga(cu(this.element),this.evWin,this.domHandler)}};var mR={pointerdown:$.Start,pointermove:$.Move,pointerup:$.End,pointercancel:$.Cancel,pointerout:$.Cancel},_R="pointerdown",yR="pointermove pointerup pointercancel",Go=class extends qo{constructor(e){super(e),this.evEl=_R,this.evWin=yR,this.store=this.manager.session.pointerEvents=[],this.init()}handler(e){let{store:r}=this,i=!1,o=mR[e.type],n=e.pointerType,s=n==="touch",a=r.findIndex(c=>c.pointerId===e.pointerId);o&$.Start&&(e.buttons||s)?a<0&&(r.push(e),a=r.length-1):o&($.End|$.Cancel)&&(i=!0),!(a<0)&&(r[a]=e,this.callback(o,{pointers:r,changedPointers:[e],eventType:o,pointerType:n,srcEvent:e}),i&&r.splice(a,1))}};var bR=["","webkit","Moz","MS","ms","o"];function I_(t,e){let r=e[0].toUpperCase()+e.slice(1);for(let i of bR){let o=i?i+r:e;if(o in t)return o}}var TR=1,O_=2,N_={touchAction:"compute",enable:!0,inputTarget:null,cssProps:{userSelect:"none",userDrag:"none",touchCallout:"none",tapHighlightColor:"rgba(0,0,0,0)"}},Qo=class{constructor(e,r){this.options={...N_,...r,cssProps:{...N_.cssProps,...r.cssProps},inputTarget:r.inputTarget||e},this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=e,this.input=new Go(this),this.touchAction=new Zo(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?O_:TR}recognize(e){let{session:r}=this;if(r.stopped)return;this.session.prevented&&e.srcEvent.preventDefault();let i,{recognizers:o}=this,{curRecognizer:n}=r;(!n||n&&n.state&N.Recognized)&&(n=r.curRecognizer=null);let s=0;for(;s<o.length;)i=o[s],r.stopped!==O_&&(!n||i===n||i.canRecognizeWith(n))?i.recognize(e):i.reset(),!n&&i.state&(N.Began|N.Changed|N.Ended)&&(n=r.curRecognizer=i),s++}get(e){let{recognizers:r}=this;for(let i=0;i<r.length;i++)if(r[i].options.event===e)return r[i];return null}add(e){if(Array.isArray(e)){for(let i of e)this.add(i);return this}let r=this.get(e.options.event);return r&&this.remove(r),this.recognizers.push(e),e.manager=this,this.touchAction.update(),e}remove(e){if(Array.isArray(e)){for(let i of e)this.remove(i);return this}let r=typeof e=="string"?this.get(e):e;if(r){let{recognizers:i}=this,o=i.indexOf(r);o!==-1&&(i.splice(o,1),this.touchAction.update())}return this}on(e,r){if(!e||!r)return;let{handlers:i}=this;for(let o of Oi(e))i[o]=i[o]||[],i[o].push(r)}off(e,r){if(!e)return;let{handlers:i}=this;for(let o of Oi(e))r?i[o]&&i[o].splice(i[o].indexOf(r),1):delete i[o]}emit(e,r){let i=this.handlers[e]&&this.handlers[e].slice();if(!i||!i.length)return;let o=r;o.type=e,o.preventDefault=function(){r.srcEvent.preventDefault()};let n=0;for(;n<i.length;)i[n](o),n++}destroy(){this.toggleCssProps(!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}toggleCssProps(e){let{element:r}=this;if(r){for(let[i,o]of Object.entries(this.options.cssProps)){let n=I_(r.style,i);e?(this.oldCssProps[n]=r.style[n],r.style[n]=o):r.style[n]=this.oldCssProps[n]||""}e||(this.oldCssProps={})}}};var xR=1;function D_(){return xR++}function du(t){return t&N.Cancelled?"cancel":t&N.Ended?"end":t&N.Changed?"move":t&N.Began?"start":""}var Dt=class{constructor(e){this.options=e,this.id=D_(),this.state=N.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 o of e)this.recognizeWith(o);return this}let r;if(typeof e=="string"){if(r=this.manager.get(e),!r)throw new Error(`Cannot find recognizer ${e}`)}else r=e;let{simultaneous:i}=this;return i[r.id]||(i[r.id]=r,r.recognizeWith(this)),this}dropRecognizeWith(e){if(Array.isArray(e)){for(let i of e)this.dropRecognizeWith(i);return this}let r;return typeof e=="string"?r=this.manager.get(e):r=e,r&&delete this.simultaneous[r.id],this}requireFailure(e){if(Array.isArray(e)){for(let o of e)this.requireFailure(o);return this}let r;if(typeof e=="string"){if(r=this.manager.get(e),!r)throw new Error(`Cannot find recognizer ${e}`)}else r=e;let{requireFail:i}=this;return i.indexOf(r)===-1&&(i.push(r),r.requireFailure(this)),this}dropRequireFailure(e){if(Array.isArray(e)){for(let i of e)this.dropRequireFailure(i);return this}let r;if(typeof e=="string"?r=this.manager.get(e):r=e,r){let i=this.requireFail.indexOf(r);i>-1&&this.requireFail.splice(i,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:r}=this;r<N.Ended&&this.manager.emit(this.options.event+du(r),e),this.manager.emit(this.options.event,e),e.additionalEvent&&this.manager.emit(e.additionalEvent,e),r>=N.Ended&&this.manager.emit(this.options.event+du(r),e)}tryEmit(e){this.canEmit()?this.emit(e):this.state=N.Failed}canEmit(){let e=0;for(;e<this.requireFail.length;){if(!(this.requireFail[e].state&(N.Failed|N.Possible)))return!1;e++}return!0}recognize(e){let r={...e};if(!this.options.enable){this.reset(),this.state=N.Failed;return}this.state&(N.Recognized|N.Cancelled|N.Failed)&&(this.state=N.Possible),this.state=this.process(r),this.state&(N.Began|N.Changed|N.Ended|N.Cancelled)&&this.tryEmit(r)}getEventNames(){return[this.options.event]}reset(){}};var Bt=class extends Dt{attrTest(e){let r=this.options.pointers;return r===0||e.pointers.length===r}process(e){let{state:r}=this,{eventType:i}=e,o=r&(N.Began|N.Changed),n=this.attrTest(e);return o&&(i&$.Cancel||!n)?r|N.Cancelled:o||n?i&$.End?r|N.Ended:r&N.Began?r|N.Changed:N.Began:N.Failed}};var Ur=class extends Dt{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[Xo]}process(e){let{options:r}=this,i=e.pointers.length===r.pointers,o=e.distance<r.threshold,n=e.deltaTime<r.time;if(this.reset(),e.eventType&$.Start&&this.count===0)return this.failTimeout();if(o&&n&&i){if(e.eventType!==$.End)return this.failTimeout();let s=this.pTime?e.timeStamp-this.pTime<r.interval:!0,a=!this.pCenter||_a(this.pCenter,e.center)<r.posThreshold;if(this.pTime=e.timeStamp,this.pCenter=e.center,!a||!s?this.count=1:this.count+=1,this._input=e,this.count%r.taps===0)return this.hasRequireFailures()?(this._timer=setTimeout(()=>{this.state=N.Recognized,this.tryEmit(this._input)},r.interval),N.Began):N.Recognized}return N.Failed}failTimeout(){return this._timer=setTimeout(()=>{this.state=N.Failed},this.options.interval),N.Failed}reset(){clearTimeout(this._timer)}emit(e){this.state===N.Recognized&&(e.tapCount=this.count,this.manager.emit(this.options.event,e))}};var AR=["","start","move","end","cancel","up","down","left","right"],ur=class extends Bt{constructor(e={}){super({enable:!0,pointers:1,event:"pan",threshold:10,direction:Y.All,...e}),this.pX=null,this.pY=null}getTouchAction(){let{options:{direction:e}}=this,r=[];return e&Y.Horizontal&&r.push(Ko),e&Y.Vertical&&r.push(Yo),r}getEventNames(){return AR.map(e=>this.options.event+e)}directionTest(e){let{options:r}=this,i=!0,{distance:o}=e,{direction:n}=e,s=e.deltaX,a=e.deltaY;return n&r.direction||(r.direction&Y.Horizontal?(n=s===0?Y.None:s<0?Y.Left:Y.Right,i=s!==this.pX,o=Math.abs(e.deltaX)):(n=a===0?Y.None:a<0?Y.Up:Y.Down,i=a!==this.pY,o=Math.abs(e.deltaY))),e.direction=n,i&&o>r.threshold&&Boolean(n&r.direction)}attrTest(e){return super.attrTest(e)&&(Boolean(this.state&N.Began)||!(this.state&N.Began)&&this.directionTest(e))}emit(e){this.pX=e.deltaX,this.pY=e.deltaY;let r=Y[e.direction].toLowerCase();r&&(e.additionalEvent=this.options.event+r),super.emit(e)}};var SR=["","start","move","end","cancel","in","out"],Ni=class extends Bt{constructor(e={}){super({enable:!0,event:"pinch",threshold:0,pointers:2,...e})}getTouchAction(){return[Lr]}getEventNames(){return SR.map(e=>this.options.event+e)}attrTest(e){return super.attrTest(e)&&(Math.abs(e.scale-1)>this.options.threshold||Boolean(this.state&N.Began))}emit(e){if(e.scale!==1){let r=e.scale<1?"in":"out";e.additionalEvent=this.options.event+r}super.emit(e)}};var gt=class{constructor(e,r,i){this.element=e,this.callback=r,this.options=i}};var B_=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"",M5=typeof window<"u"?window:global;var PR=B_.indexOf("firefox")!==-1,F_=4.000244140625,vR=40,MR=.25,Ta=class extends gt{constructor(e,r,i){super(e,r,{enable:!0,...i}),this.handleEvent=o=>{if(!this.options.enable)return;let n=o.deltaY;globalThis.WheelEvent&&(PR&&o.deltaMode===globalThis.WheelEvent.DOM_DELTA_PIXEL&&(n/=globalThis.devicePixelRatio),o.deltaMode===globalThis.WheelEvent.DOM_DELTA_LINE&&(n*=vR)),n!==0&&n%F_===0&&(n=Math.floor(n/F_)),o.shiftKey&&n&&(n=n*MR),this.callback({type:"wheel",center:{x:o.clientX,y:o.clientY},delta:-n,srcEvent:o,pointerType:"mouse",target:o.target})},e.addEventListener("wheel",this.handleEvent,{passive:!1})}destroy(){this.element.removeEventListener("wheel",this.handleEvent)}enableEventType(e,r){e==="wheel"&&(this.options.enable=r)}};var L_=["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],xa=class extends gt{constructor(e,r,i){super(e,r,{enable:!0,...i}),this.handleEvent=n=>{this.handleOverEvent(n),this.handleOutEvent(n),this.handleEnterEvent(n),this.handleLeaveEvent(n),this.handleMoveEvent(n)},this.pressed=!1;let{enable:o}=this.options;this.enableMoveEvent=o,this.enableLeaveEvent=o,this.enableEnterEvent=o,this.enableOutEvent=o,this.enableOverEvent=o,L_.forEach(n=>e.addEventListener(n,this.handleEvent))}destroy(){L_.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){switch(e){case"pointermove":this.enableMoveEvent=r;break;case"pointerover":this.enableOverEvent=r;break;case"pointerout":this.enableOutEvent=r;break;case"pointerenter":this.enableEnterEvent=r;break;case"pointerleave":this.enableLeaveEvent=r;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,r){this.callback({type:e,center:{x:r.clientX,y:r.clientY},srcEvent:r,pointerType:"mouse",target:r.target})}};var U_=["keydown","keyup"],Aa=class extends gt{constructor(e,r,i){super(e,r,{enable:!0,tabIndex:0,...i}),this.handleEvent=o=>{let n=o.target||o.srcElement;n.tagName==="INPUT"&&n.type==="text"||n.tagName==="TEXTAREA"||(this.enableDownEvent&&o.type==="keydown"&&this.callback({type:"keydown",srcEvent:o,key:o.key,target:o.target}),this.enableUpEvent&&o.type==="keyup"&&this.callback({type:"keyup",srcEvent:o,key:o.key,target:o.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,e.tabIndex=this.options.tabIndex,e.style.outline="none",U_.forEach(o=>e.addEventListener(o,this.handleEvent))}destroy(){U_.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,r){e==="keydown"&&(this.enableDownEvent=r),e==="keyup"&&(this.enableUpEvent=r)}};var Sa=class extends gt{constructor(e,r,i){super(e,r,i),this.handleEvent=o=>{this.options.enable&&this.callback({type:"contextmenu",center:{x:o.clientX,y:o.clientY},srcEvent:o,pointerType:"mouse",target:o.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,r){e==="contextmenu"&&(this.options.enable=r)}};var CR={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4},IR=0,OR=1,NR=2,DR=1,BR=2,FR=4;function k_(t){let e=CR[t.srcEvent.type];if(!e)return null;let{buttons:r,button:i}=t.srcEvent,o=!1,n=!1,s=!1;return e===2?(o=Boolean(r&DR),n=Boolean(r&FR),s=Boolean(r&BR)):(o=i===IR,n=i===OR,s=i===NR),{leftButton:o,middleButton:n,rightButton:s}}function V_(t,e){let r=t.center;if(!r)return null;let i=e.getBoundingClientRect(),o=i.width/e.offsetWidth||1,n=i.height/e.offsetHeight||1,s={x:(r.x-i.left-e.clientLeft)/o,y:(r.y-i.top-e.clientTop)/n};return{center:r,offsetCenter:s}}var LR={srcElement:"root",priority:0},Ea=class{constructor(e,r){this.handleEvent=i=>{if(this.isEmpty())return;let o=this._normalizeEvent(i),n=i.srcEvent.target;for(;n&&n!==o.rootElement;){if(this._emit(o,n),o.handled)return;n=n.parentNode}this._emit(o,"root")},this.eventManager=e,this.recognizerName=r,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,r,i,o=!1,n=!1){let{handlers:s,handlersByElement:a}=this,c={...LR,...i},l=a.get(c.srcElement);l||(l=[],a.set(c.srcElement,l));let f={type:e,handler:r,srcElement:c.srcElement,priority:c.priority};o&&(f.once=!0),n&&(f.passive=!0),s.push(f),this._active=this._active||!f.passive;let h=l.length-1;for(;h>=0&&!(l[h].priority>=f.priority);)h--;l.splice(h+1,0,f)}remove(e,r){let{handlers:i,handlersByElement:o}=this;for(let n=i.length-1;n>=0;n--){let s=i[n];if(s.type===e&&s.handler===r){i.splice(n,1);let a=o.get(s.srcElement);a.splice(a.indexOf(s),1),a.length===0&&o.delete(s.srcElement)}}this._active=i.some(n=>!n.passive)}_emit(e,r){let i=this.handlersByElement.get(r);if(i){let o=!1,n=()=>{e.handled=!0},s=()=>{e.handled=!0,o=!0},a=[];for(let c=0;c<i.length;c++){let{type:l,handler:f,once:h}=i[c];if(f({...e,type:l,stopPropagation:n,stopImmediatePropagation:s}),h&&a.push(i[c]),o)break}for(let c=0;c<a.length;c++){let{type:l,handler:f}=a[c];this.remove(l,f)}}}_normalizeEvent(e){let r=this.eventManager.getElement();return{...e,...k_(e),...V_(e,r),preventDefault:()=>{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:r}}};function UR(t){if("recognizer"in t)return t;let e,r=Array.isArray(t)?[...t]:[t];if(typeof r[0]=="function"){let i=r.shift(),o=r.shift()||{};e=new i(o)}else e=r.shift();return{recognizer:e,recognizeWith:typeof r[0]=="string"?[r[0]]:r[0],requireFailure:typeof r[1]=="string"?[r[1]]:r[1]}}var Jo=class{constructor(e=null,r={}){if(this._onBasicInput=i=>{this.manager.emit(i.srcEvent.type,i)},this._onOtherEvent=i=>{this.manager.emit(i.type,i)},this.options={recognizers:[],events:{},touchAction:"compute",tabIndex:0,cssProps:{},...r},this.events=new Map,this.element=e,!!e){this.manager=new Qo(e,this.options);for(let i of this.options.recognizers){let{recognizer:o,recognizeWith:n,requireFailure:s}=UR(i);this.manager.add(o),n&&o.recognizeWith(n),s&&o.requireFailure(s)}this.manager.on("hammer.input",this._onBasicInput),this.wheelInput=new Ta(e,this._onOtherEvent,{enable:!1}),this.moveInput=new xa(e,this._onOtherEvent,{enable:!1}),this.keyInput=new Aa(e,this._onOtherEvent,{enable:!1,tabIndex:r.tabIndex}),this.contextmenuInput=new Sa(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,r,i){this._addEventHandler(e,r,i,!1)}once(e,r,i){this._addEventHandler(e,r,i,!0)}watch(e,r,i){this._addEventHandler(e,r,i,!1,!0)}off(e,r){this._removeEventHandler(e,r)}_toggleRecognizer(e,r){let{manager:i}=this;if(!i)return;let o=i.get(e);o&&(o.set({enable:r}),i.touchAction.update()),this.wheelInput?.enableEventType(e,r),this.moveInput?.enableEventType(e,r),this.keyInput?.enableEventType(e,r),this.contextmenuInput?.enableEventType(e,r)}_addEventHandler(e,r,i,o,n){if(typeof e!="string"){i=r;for(let[l,f]of Object.entries(e))this._addEventHandler(l,f,i,o,n);return}let{manager:s,events:a}=this;if(!s)return;let c=a.get(e);if(!c){let l=this._getRecognizerName(e)||e;c=new Ea(this,l),a.set(e,c),s&&s.on(e,c.handleEvent)}c.add(e,r,i,o,n),c.isEmpty()||this._toggleRecognizer(c.recognizerName,!0)}_removeEventHandler(e,r){if(typeof e!="string"){for(let[n,s]of Object.entries(e))this._removeEventHandler(n,s);return}let{events:i}=this,o=i.get(e);if(o&&(o.remove(e,r),o.isEmpty())){let{recognizerName:n}=o,s=!1;for(let a of i.values())if(a.recognizerName===n&&!a.isEmpty()){s=!0;break}s||this._toggleRecognizer(n,!1)}}_getRecognizerName(e){return this.manager.recognizers.find(r=>r.getEventNames().includes(e))?.options.event}};var kr={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(kr,"IDENTITY",{get:()=>(F.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),kr.CARTESIAN)});var ie={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},dr={common:0,meters:1,pixels:2},Di={click:"onClick",dblclick:"onClick",panstart:"onDragStart",panmove:"onDrag",panend:"onDragEnd"},pu={multipan:[ur,{threshold:10,direction:Y.Vertical,pointers:2}],pinch:[Ni,{},null,["multipan"]],pan:[ur,{threshold:1},["pinch"],["multipan"]],dblclick:[Ur,{event:"dblclick",taps:2}],click:[Ur,{event:"click"},null,["dblclick"]]},z_={DRAW:"draw",MASK:"mask",TERRAIN:"terrain"};function kR(t,e){if(t===e)return!0;if(Array.isArray(t)){let r=t.length;if(!e||e.length!==r)return!1;for(let i=0;i<r;i++)if(t[i]!==e[i])return!1;return!0}return!1}function Ue(t){let e={},r;return i=>{for(let o in i)if(!kR(i[o],e[o])){r=t(i),e=i;break}return r}}var W_=[0,0,0,0],VR=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],j_=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],zR=[0,0,0],$_=[0,0,0],WR={default:-1,cartesian:0,lnglat:1,"meter-offsets":2,"lnglat-offsets":3};function Vr(t){let e=WR[t];if(e===void 0)throw new Error(`Invalid coordinateSystem: ${t}`);return e}var jR=Ue(HR);function gu(t,e,r=$_){r.length<3&&(r=[r[0],r[1],0]);let i=r,o,n=!0;switch(e==="lnglat-offsets"||e==="meter-offsets"?o=r:o=t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case ie.WEB_MERCATOR:(e==="lnglat"||e==="cartesian")&&(o=[0,0,0],n=!1);break;case ie.WEB_MERCATOR_AUTO_OFFSET:e==="lnglat"?i=o:e==="cartesian"&&(i=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],o=t.unprojectPosition(i),i[0]-=r[0],i[1]-=r[1],i[2]-=r[2]);break;case ie.IDENTITY:i=t.position.map(Math.fround),i[2]=i[2]||0;break;case ie.GLOBE:n=!1,o=null;break;default:n=!1}return{geospatialOrigin:o,shaderCoordinateOrigin:i,offsetMode:n}}function $R(t,e,r){let{viewMatrixUncentered:i,projectionMatrix:o}=t,{viewMatrix:n,viewProjectionMatrix:s}=t,a=W_,c=W_,l=t.cameraPosition,{geospatialOrigin:f,shaderCoordinateOrigin:h,offsetMode:u}=gu(t,e,r);return u&&(c=t.projectPosition(f||h),l=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],c[3]=1,a=Te.transformMat4([],c,s),n=i||n,s=te.multiply([],o,n),s=te.multiply([],s,VR)),{viewMatrix:n,viewProjectionMatrix:s,projectionCenter:a,originCommon:c,cameraPosCommon:l,shaderCoordinateOrigin:h,geospatialOrigin:f}}function wa({viewport:t,devicePixelRatio:e=1,modelMatrix:r=null,coordinateSystem:i="default",coordinateOrigin:o=$_,autoWrapLongitude:n=!1}){i==="default"&&(i=t.isGeospatial?"lnglat":"cartesian");let s=jR({viewport:t,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:o});return s.wrapLongitude=n,s.modelMatrix=r||j_,s}function HR({viewport:t,devicePixelRatio:e,coordinateSystem:r,coordinateOrigin:i}){let{projectionCenter:o,viewProjectionMatrix:n,originCommon:s,cameraPosCommon:a,shaderCoordinateOrigin:c,geospatialOrigin:l}=$R(t,r,i),f=t.getDistanceScales(),h=[t.width*e,t.height*e],u=Te.transformMat4([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,d={coordinateSystem:Vr(r),projectionMode:t.projectionMode,coordinateOrigin:c,commonOrigin:s.slice(0,3),center:o,pseudoMeters:Boolean(t._pseudoMeters),viewportSize:h,devicePixelRatio:e,focalDistance:u,commonUnitsPerMeter:f.unitsPerMeter,commonUnitsPerWorldUnit:f.unitsPerMeter,commonUnitsPerWorldUnit2:zR,scale:t.scale,wrapLongitude:!1,viewProjectionMatrix:n,modelMatrix:j_,cameraPosition:a};if(l){let p=t.getDistanceScales(l);switch(r){case"meter-offsets":d.commonUnitsPerWorldUnit=p.unitsPerMeter,d.commonUnitsPerWorldUnit2=p.unitsPerMeter2;break;case"lnglat":case"lnglat-offsets":t._pseudoMeters||(d.commonUnitsPerMeter=p.unitsPerMeter),d.commonUnitsPerWorldUnit=p.unitsPerDegree,d.commonUnitsPerWorldUnit2=p.unitsPerDegree2;break;case"cartesian":d.commonUnitsPerWorldUnit=[1,1,p.unitsPerMeter[2]],d.commonUnitsPerWorldUnit2=[0,0,p.unitsPerMeter2[2]];break;default:break}}return d}var XR=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],YR=XR.map(t=>`const COORDINATE_SYSTEM_${t.toUpperCase().replaceAll("-","_")}: i32 = ${Vr(t)};`).join(""),KR=Object.keys(ie).map(t=>`const PROJECTION_MODE_${t}: i32 = ${ie[t]};`).join(""),ZR=Object.keys(dr).map(t=>`const UNIT_${t.toUpperCase()}: i32 = ${dr[t]};`).join(""),qR=`${YR}
|
|
1315
|
+
${KR}
|
|
1316
|
+
${ZR}
|
|
1317
1317
|
|
|
1318
1318
|
const TILE_SIZE: f32 = 512.0;
|
|
1319
1319
|
const PI: f32 = 3.1415926536;
|
|
@@ -1365,7 +1365,7 @@ struct Geometry {
|
|
|
1365
1365
|
};
|
|
1366
1366
|
|
|
1367
1367
|
var<private> geometry: Geometry;
|
|
1368
|
-
|
|
1368
|
+
`,H_=`${qR}
|
|
1369
1369
|
|
|
1370
1370
|
// -----------------------------------------------------------------------------
|
|
1371
1371
|
// Functions
|
|
@@ -1592,9 +1592,9 @@ fn project_pixel_size_float(pixels: f32) -> f32 {
|
|
|
1592
1592
|
fn project_pixel_size_vec2(pixels: vec2<f32>) -> vec2<f32> {
|
|
1593
1593
|
return pixels / project.scale;
|
|
1594
1594
|
}
|
|
1595
|
-
`;var
|
|
1596
|
-
${
|
|
1597
|
-
${
|
|
1595
|
+
`;var GR=["default","lnglat","meter-offsets","lnglat-offsets","cartesian"],QR=GR.map(t=>`const int COORDINATE_SYSTEM_${t.toUpperCase().replaceAll("-","_")} = ${Vr(t)};`).join(""),JR=Object.keys(ie).map(t=>`const int PROJECTION_MODE_${t} = ${ie[t]};`).join(""),e3=Object.keys(dr).map(t=>`const int UNIT_${t.toUpperCase()} = ${dr[t]};`).join(""),X_=`${QR}
|
|
1596
|
+
${JR}
|
|
1597
|
+
${e3}
|
|
1598
1598
|
layout(std140) uniform projectUniforms {
|
|
1599
1599
|
bool wrapLongitude;
|
|
1600
1600
|
int coordinateSystem;
|
|
@@ -1786,7 +1786,7 @@ return pixels / project.scale;
|
|
|
1786
1786
|
vec2 project_pixel_size(vec2 pixels) {
|
|
1787
1787
|
return pixels / project.scale;
|
|
1788
1788
|
}
|
|
1789
|
-
`;var
|
|
1789
|
+
`;var t3={};function r3(t=t3){return"viewport"in t?wa(t):{}}var pr={name:"project",dependencies:[rh,da],source:H_,vs:X_,getUniforms:r3,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 i3=`// Define a structure to hold both the clip-space position and the common position.
|
|
1790
1790
|
struct ProjectResult {
|
|
1791
1791
|
clipPosition: vec4<f32>,
|
|
1792
1792
|
commonPosition: vec4<f32>,
|
|
@@ -1829,7 +1829,7 @@ fn project_position_to_clipspace(
|
|
|
1829
1829
|
) -> vec4<f32> {
|
|
1830
1830
|
return project_position_to_clipspace_and_commonspace(position, position64Low, offset).clipPosition;
|
|
1831
1831
|
}
|
|
1832
|
-
`,
|
|
1832
|
+
`,o3=`vec4 project_position_to_clipspace(
|
|
1833
1833
|
vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition
|
|
1834
1834
|
) {
|
|
1835
1835
|
vec3 projectedPosition = project_position(position, position64Low);
|
|
@@ -1849,7 +1849,7 @@ vec4 project_position_to_clipspace(
|
|
|
1849
1849
|
vec4 commonPosition;
|
|
1850
1850
|
return project_position_to_clipspace(position, position64Low, offset, commonPosition);
|
|
1851
1851
|
}
|
|
1852
|
-
`,
|
|
1852
|
+
`,mu={name:"project32",dependencies:[pr],source:i3,vs:o3};function _u(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function gr(t,e){let r=Te.transformMat4([],e,t);return Te.scale(r,r,1/r[3]),r}function Y_(t,e,r){return r*e+(1-r)*t}function en(t,e,r){return t<e?e:t>r?r:t}function n3(t){return Math.log(t)*Math.LOG2E}var tn=Math.log2||n3;function He(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}var Xe=Math.PI,K_=Xe/4,ke=Xe/180,yu=180/Xe,Bi=512,Ra=4003e4,ge=85.051129,Z_=1.5;function rn(t){return Math.pow(2,t)}function Pa(t){return tn(t)}function xe(t){let[e,r]=t;He(Number.isFinite(e)),He(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let i=e*ke,o=r*ke,n=Bi*(i+Xe)/(2*Xe),s=Bi*(Xe+Math.log(Math.tan(K_+o*.5)))/(2*Xe);return[n,s]}function me(t){let[e,r]=t,i=e/Bi*(2*Xe)-Xe,o=2*(Math.atan(Math.exp(r/Bi*(2*Xe)-Xe))-K_);return[i*yu,o*yu]}function on(t){let{latitude:e}=t;He(Number.isFinite(e));let r=Math.cos(e*ke);return Pa(Ra*r)-9}function nn(t){let e=Math.cos(t*ke);return Bi/Ra/e}function Fi(t){let{latitude:e,longitude:r,highPrecision:i=!1}=t;He(Number.isFinite(e)&&Number.isFinite(r));let o=Bi,n=Math.cos(e*ke),s=o/360,a=s/n,c=o/Ra/n,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[s,a,c],degreesPerUnit:[1/s,1/a,1/c]};if(i){let f=ke*Math.tan(e*ke)/n,h=s*f/2,u=o/Ra*f,d=u/a*c;l.unitsPerDegree2=[0,h,u],l.unitsPerMeter2=[d,0,d]}return l}function sn(t,e){let[r,i,o]=t,[n,s,a]=e,{unitsPerMeter:c,unitsPerMeter2:l}=Fi({longitude:r,latitude:i,highPrecision:!0}),f=xe(t);f[0]+=n*(c[0]+l[0]*s),f[1]+=s*(c[1]+l[1]*s);let h=me(f),u=(o||0)+(a||0);return Number.isFinite(o)||Number.isFinite(a)?[h[0],h[1],u]:h}function va(t){let{height:e,pitch:r,bearing:i,altitude:o,scale:n,center:s}=t,a=_u();te.translate(a,a,[0,0,-o]),te.rotateX(a,a,-r*ke),te.rotateZ(a,a,i*ke);let c=n/e;return te.scale(a,a,[c,c,c]),s&&te.translate(a,a,de.negate([],s)),a}function bu(t){let{width:e,height:r,altitude:i,pitch:o=0,offset:n,center:s,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=t,{fovy:f=Ft(Z_)}=t;i!==void 0&&(f=Ft(i));let h=f*ke,u=o*ke,d=Lt(f),p=d;s&&(p+=s[2]*a/Math.cos(u)/r);let g=h*(.5+(n?n[1]:0)/r),m=Math.sin(g)*p/Math.sin(en(Math.PI/2-u-g,.01,Math.PI-.01)),_=Math.sin(u)*m+p,b=p*10,y=Math.min(_*l,b);return{fov:h,aspect:e/r,focalDistance:d,near:c,far:y}}function Ft(t){return 2*Math.atan(.5/t)*yu}function Lt(t){return .5/Math.tan(.5*t*ke)}function Li(t,e){let[r,i,o=0]=t;return He(Number.isFinite(r)&&Number.isFinite(i)&&Number.isFinite(o)),gr(e,[r,i,o,1])}function Ve(t,e,r=0){let[i,o,n]=t;if(He(Number.isFinite(i)&&Number.isFinite(o),"invalid pixel coordinate"),Number.isFinite(n))return gr(e,[i,o,n,1]);let s=gr(e,[i,o,0,1]),a=gr(e,[i,o,1,1]),c=s[2],l=a[2],f=c===l?0:((r||0)-c)/(l-c);return J.lerp([],s,a,f)}function Ma(t){let{width:e,height:r,bounds:i,minExtent:o=0,maxZoom:n=24,offset:s=[0,0]}=t,[[a,c],[l,f]]=i,h=s3(t.padding),u=xe([a,en(f,-ge,ge)]),d=xe([l,en(c,-ge,ge)]),p=[Math.max(Math.abs(d[0]-u[0]),o),Math.max(Math.abs(d[1]-u[1]),o)],g=[e-h.left-h.right-Math.abs(s[0])*2,r-h.top-h.bottom-Math.abs(s[1])*2];He(g[0]>0&&g[1]>0);let m=g[0]/p[0],_=g[1]/p[1],b=(h.right-h.left)/2/m,y=(h.top-h.bottom)/2/_,T=[(d[0]+u[0])/2+b,(d[1]+u[1])/2+y],S=me(T),A=Math.min(n,tn(Math.abs(Math.min(m,_))));return He(Number.isFinite(A)),{longitude:S[0],latitude:S[1],zoom:A}}function s3(t=0){return typeof t=="number"?{top:t,bottom:t,left:t,right:t}:(He(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t)}var q_=Math.PI/180;function Ca(t,e=0){let{width:r,height:i,unproject:o}=t,n={targetZ:e},s=o([0,i],n),a=o([r,i],n),c,l,f=t.fovy?.5*t.fovy*q_:Math.atan(.5/t.altitude),h=(90-t.pitch)*q_;return f>h-.01?(c=G_(t,0,e),l=G_(t,r,e)):(c=o([0,0],n),l=o([r,0],n)),[s,a,l,c]}function G_(t,e,r){let{pixelUnprojectionMatrix:i}=t,o=gr(i,[e,0,1,1]),n=gr(i,[e,t.height,1,1]),a=(r*t.distanceScales.unitsPerMeter[2]-o[2])/(n[2]-o[2]),c=J.lerp([],o,n,a),l=me(c);return l.push(r),l}var Q_=.01,c3=["longitude","latitude","zoom"],J_={curve:1.414,speed:1.2};function Tu(t,e,r,i){let{startZoom:o,startCenterXY:n,uDelta:s,w0:a,u1:c,S:l,rho:f,rho2:h,r0:u}=ey(t,e,i);if(c<Q_){let T={};for(let S of c3){let A=t[S],w=e[S];T[S]=Y_(A,w,r)}return T}let d=r*l,p=Math.cosh(u)/Math.cosh(u+f*d),g=a*((Math.cosh(u)*Math.tanh(u+f*d)-Math.sinh(u))/h)/c,m=1/p,_=o+Pa(m),b=J.scale([],s,g);J.add(b,b,n);let y=me(b);return{longitude:y[0],latitude:y[1],zoom:_}}function xu(t,e,r){let i={...J_,...r},{screenSpeed:o,speed:n,maxDuration:s}=i,{S:a,rho:c}=ey(t,e,i),l=1e3*a,f;return Number.isFinite(o)?f=l/(o/c):f=l/n,Number.isFinite(s)&&f>s?0:f}function ey(t,e,r){r=Object.assign({},J_,r);let i=r.curve,o=t.zoom,n=[t.longitude,t.latitude],s=rn(o),a=e.zoom,c=[e.longitude,e.latitude],l=rn(a-o),f=xe(n),h=xe(c),u=J.sub([],h,f),d=Math.max(t.width,t.height),p=d/l,g=J.length(u)*s,m=Math.max(g,Q_),_=i*i,b=(p*p-d*d+_*_*m*m)/(2*d*_*m),y=(p*p-d*d-_*_*m*m)/(2*p*_*m),T=Math.log(Math.sqrt(b*b+1)-b),S=Math.log(Math.sqrt(y*y+1)-y),A=(S-T)/i;return{startZoom:o,startCenterXY:f,uDelta:u,w0:d,u1:g,S:A,rho:i,rho2:_,r0:T,r1:S}}var ty=`
|
|
1853
1853
|
layout(std140) uniform shadowUniforms {
|
|
1854
1854
|
bool drawShadowMap;
|
|
1855
1855
|
bool useShadowMap;
|
|
@@ -1861,7 +1861,7 @@ layout(std140) uniform shadowUniforms {
|
|
|
1861
1861
|
vec4 projectCenter0;
|
|
1862
1862
|
vec4 projectCenter1;
|
|
1863
1863
|
} shadow;
|
|
1864
|
-
`,
|
|
1864
|
+
`,f3=`
|
|
1865
1865
|
const int max_lights = 2;
|
|
1866
1866
|
|
|
1867
1867
|
out vec3 shadow_vPosition[max_lights];
|
|
@@ -1887,10 +1887,10 @@ vec4 shadow_setVertexPosition(vec4 position_commonspace) {
|
|
|
1887
1887
|
}
|
|
1888
1888
|
return gl_Position;
|
|
1889
1889
|
}
|
|
1890
|
-
`,
|
|
1891
|
-
${
|
|
1892
|
-
${
|
|
1893
|
-
`,
|
|
1890
|
+
`,h3=`
|
|
1891
|
+
${ty}
|
|
1892
|
+
${f3}
|
|
1893
|
+
`,u3=`
|
|
1894
1894
|
const int max_lights = 2;
|
|
1895
1895
|
uniform sampler2D shadow_uShadowMap0;
|
|
1896
1896
|
uniform sampler2D shadow_uShadowMap1;
|
|
@@ -1930,18 +1930,18 @@ vec4 shadow_filterShadowColor(vec4 color) {
|
|
|
1930
1930
|
}
|
|
1931
1931
|
return color;
|
|
1932
1932
|
}
|
|
1933
|
-
`,
|
|
1934
|
-
${
|
|
1935
|
-
${
|
|
1936
|
-
`,
|
|
1933
|
+
`,d3=`
|
|
1934
|
+
${ty}
|
|
1935
|
+
${u3}
|
|
1936
|
+
`,p3=Ue(b3),g3=Ue(T3),m3=[0,0,0,1],_3=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];function y3(t,e){let[r,i,o]=t,n=Ve([r,i,o],e);return Number.isFinite(o)?n:[n[0],n[1],0]}function b3({viewport:t,center:e}){return new V(t.viewProjectionMatrix).invert().transform(e)}function T3({viewport:t,shadowMatrices:e}){let r=[],i=t.pixelUnprojectionMatrix,o=t.isGeospatial?void 0:1,n=[[0,0,o],[t.width,0,o],[0,t.height,o],[t.width,t.height,o],[0,0,-1],[t.width,0,-1],[0,t.height,-1],[t.width,t.height,-1]].map(s=>y3(s,i));for(let s of e){let a=s.clone().translate(new j(t.center).negate()),c=n.map(f=>a.transform(f)),l=new V().ortho({left:Math.min(...c.map(f=>f[0])),right:Math.max(...c.map(f=>f[0])),bottom:Math.min(...c.map(f=>f[1])),top:Math.max(...c.map(f=>f[1])),near:Math.min(...c.map(f=>-f[2])),far:Math.max(...c.map(f=>-f[2]))});r.push(l.multiplyRight(s))}return r}function x3(t){let{shadowEnabled:e=!0,project:r}=t;if(!e||!r||!t.shadowMatrices||!t.shadowMatrices.length)return{drawShadowMap:!1,useShadowMap:!1,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};let i=pr.getUniforms(r),o=p3({viewport:r.viewport,center:i.center}),n=[],s=g3({shadowMatrices:t.shadowMatrices,viewport:r.viewport}).slice();for(let c=0;c<t.shadowMatrices.length;c++){let l=s[c],f=l.clone().translate(new j(r.viewport.center).negate());i.coordinateSystem===Vr("lnglat")&&i.projectionMode===ie.WEB_MERCATOR?(s[c]=f,n[c]=o):(s[c]=l.clone().multiplyRight(_3),n[c]=f.transform(o))}let a={drawShadowMap:Boolean(t.drawToShadowMap),useShadowMap:t.shadowMaps?t.shadowMaps.length>0:!1,color:t.shadowColor||m3,lightId:t.shadowLightId||0,lightCount:t.shadowMatrices.length,shadow_uShadowMap0:t.dummyShadowMap,shadow_uShadowMap1:t.dummyShadowMap};for(let c=0;c<s.length;c++)a[`viewProjectionMatrix${c}`]=s[c],a[`projectCenter${c}`]=n[c];for(let c=0;c<2;c++)a[`shadow_uShadowMap${c}`]=t.shadowMaps&&t.shadowMaps[c]||t.dummyShadowMap;return a}var Ui={name:"shadow",dependencies:[pr],vs:h3,fs:d3,inject:{"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1937
1937
|
position = shadow_setVertexPosition(geometry.position);
|
|
1938
1938
|
`,"fs:DECKGL_FILTER_COLOR":`
|
|
1939
1939
|
color = shadow_filterShadowColor(color);
|
|
1940
|
-
`},getUniforms:
|
|
1940
|
+
`},getUniforms:x3,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 A3=`struct pickingUniforms {
|
|
1941
1941
|
isActive: f32,
|
|
1942
1942
|
isAttribute: f32,
|
|
1943
1943
|
isHighlightActive: f32,
|
|
1944
|
-
|
|
1944
|
+
useByteColors: f32,
|
|
1945
1945
|
highlightedObjectColor: vec3<f32>,
|
|
1946
1946
|
highlightColor: vec4<f32>,
|
|
1947
1947
|
};
|
|
@@ -1949,11 +1949,11 @@ ${c3}
|
|
|
1949
1949
|
@group(0) @binding(auto) var<uniform> picking: pickingUniforms;
|
|
1950
1950
|
|
|
1951
1951
|
fn picking_normalizeColor(color: vec3<f32>) -> vec3<f32> {
|
|
1952
|
-
return select(color / 255.0,
|
|
1952
|
+
return select(color, color / 255.0, picking.useByteColors > 0.5);
|
|
1953
1953
|
}
|
|
1954
1954
|
|
|
1955
1955
|
fn picking_normalizeColor4(color: vec4<f32>) -> vec4<f32> {
|
|
1956
|
-
return select(color / 255.0,
|
|
1956
|
+
return select(color, color / 255.0, picking.useByteColors > 0.5);
|
|
1957
1957
|
}
|
|
1958
1958
|
|
|
1959
1959
|
fn picking_isColorZero(color: vec3<f32>) -> bool {
|
|
@@ -1963,7 +1963,7 @@ fn picking_isColorZero(color: vec3<f32>) -> bool {
|
|
|
1963
1963
|
fn picking_isColorValid(color: vec3<f32>) -> bool {
|
|
1964
1964
|
return dot(color, vec3<f32>(1.0)) > 0.00001;
|
|
1965
1965
|
}
|
|
1966
|
-
`,
|
|
1966
|
+
`,Au={...zs,source:A3,defaultUniforms:{...zs.defaultUniforms,useByteColors:!0},inject:{"vs:DECKGL_FILTER_GL_POSITION":`
|
|
1967
1967
|
// for picking depth values
|
|
1968
1968
|
picking_setPickingAttribute(position.z / position.w);
|
|
1969
1969
|
`,"vs:DECKGL_FILTER_COLOR":`
|
|
@@ -1974,10 +1974,10 @@ fn picking_isColorValid(color: vec3<f32>) -> bool {
|
|
|
1974
1974
|
|
|
1975
1975
|
// use picking color if rendering to picking FBO.
|
|
1976
1976
|
color = picking_filterPickingColor(color);
|
|
1977
|
-
`}}};var b3=[ua],T3=["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)"],x3=[];function Ca(t){let e=rr.getDefaultShaderAssembler();for(let i of b3)e.addDefaultModule(i);e._hookFunctions.length=0;let r=t==="glsl"?T3:x3;for(let i of r)e.addShaderHook(i);return e}var A3=[255,255,255],S3=1,E3=0,Ui=class{constructor(e={}){this.type="ambient";let{color:r=A3}=e,{intensity:i=S3}=e;this.id=e.id||`ambient-${E3++}`,this.color=r,this.intensity=i}};var w3=[255,255,255],R3=1,P3=[0,0,-1],v3=0,kt=class{constructor(e={}){this.type="directional";let{color:r=w3}=e,{intensity:i=R3}=e,{direction:o=P3}=e,{_shadow:n=!1}=e;this.id=e.id||`directional-${v3++}`,this.color=r,this.intensity=i,this.type="directional",this.direction=new $(o).normalize().toArray(),this.shadow=n}getProjectedLight(e){return this}};var Vr=class{constructor(e,r={id:"pass"}){let{id:i}=r;this.id=i,this.device=e,this.props={...r}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var M3={depthWriteEnabled:!0,depthCompare:"less-equal",blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one-minus-dst-alpha",blendAlphaDstFactor:"one"},Ke=class extends Vr{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){this._render(e)}_render(e){let r=this.device.canvasContext,i=e.target??r.getCurrentFramebuffer(),[o,n]=r.getDrawingBufferSize(),s=e.clearCanvas??!0,a=e.clearColor??(s?[0,0,0,0]:!1),c=s?1:!1,l=s?0:!1,f=e.colorMask??15,h={viewport:[0,0,o,n]};e.colorMask&&(h.colorMask=f),e.scissorRect&&(h.scissorRect=e.scissorRect);let u=this.device.beginRenderPass({framebuffer:i,parameters:h,clearColor:a,clearDepth:c,clearStencil:l});try{return this._drawLayers(u,e)}finally{u.end(),this.device.submit()}}_drawLayers(e,r){let{target:i,shaderModuleProps:o,viewports:n,views:s,onViewportActive:a,clearStack:c=!0}=r;r.pass=r.pass||"unknown",c&&(this._lastRenderIndex=-1);let l=[];for(let f of n){let h=s&&s[f.id];a?.(f);let u=this._getDrawLayerParams(f,r),d=f.subViewports||[f];for(let p of d){let g=this._drawLayersInViewport(e,{target:i,shaderModuleProps:o,viewport:p,view:h,pass:r.pass,layers:r.layers},u);l.push(g)}}return l}_getDrawLayerParams(e,{layers:r,pass:i,isPicking:o=!1,layerFilter:n,cullRect:s,effects:a,shaderModuleProps:c},l=!1){let f=[],h=ry(this._lastRenderIndex+1),u={layer:r[0],viewport:e,isPicking:o,renderPass:i,cullRect:s},d={};for(let p=0;p<r.length;p++){let g=r[p],m=this._shouldDrawLayer(g,u,n,d),_={shouldDrawLayer:m};if(m&&!l){_.shouldDrawLayer=!0,_.layerRenderIndex=h(g,m),_.shaderModuleProps=this._getShaderModuleProps(g,a,i,c);let b=g.context.device.type==="webgpu"?M3:null;_.layerParameters={...b,...g.context.deck?.props.parameters,...this.getLayerParameters(g,p,e)}}f[p]=_}return f}_drawLayersInViewport(e,{layers:r,shaderModuleProps:i,pass:o,target:n,viewport:s,view:a},c){let l=C3(this.device,{shaderModuleProps:i,target:n,viewport:s});if(a){let{clear:h,clearColor:u,clearDepth:d,clearStencil:p}=a.props;if(h){let g=[0,0,0,0],m=1,_=0;Array.isArray(u)?g=[...u.slice(0,3),u[3]||255].map(y=>y/255):u===!1&&(g=!1),d!==void 0&&(m=d),p!==void 0&&(_=p),this.device.beginRenderPass({framebuffer:n,parameters:{viewport:l,scissorRect:l},clearColor:g,clearDepth:m,clearStencil:_}).end()}}let f={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let h=0;h<r.length;h++){let u=r[h],d=c[h],{shouldDrawLayer:p}=d;if(p&&u.props.pickable&&f.pickableCount++,u.isComposite&&f.compositeCount++,u.isDrawable&&d.shouldDrawLayer){let{layerRenderIndex:g,shaderModuleProps:m,layerParameters:_}=d;f.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,g),m.project&&(m.project.viewport=s),u.context.renderPass=e;try{u._drawLayer({renderPass:e,shaderModuleProps:m,uniforms:{layerIndex:g},parameters:_})}catch(b){u.raiseError(b,`drawing ${u} to ${o}`)}}}return f}shouldDrawLayer(e){return!0}getShaderModuleProps(e,r,i){return null}getLayerParameters(e,r,i){return e.props.parameters}_shouldDrawLayer(e,r,i,o){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;r.layer=e;let s=e.parent;for(;s;){if(!s.props.visible||!s.filterSubLayer(r))return!1;r.layer=s,s=s.parent}if(i){let a=r.layer.id;if(a in o||(o[a]=i(r)),!o[a])return!1}return e.activateViewport(r.viewport),!0}_getShaderModuleProps(e,r,i,o){let n=this.device.canvasContext.cssToDeviceRatio(),s=e.internalState?.propsInTransition||e.props,a={layer:s,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:n,modelMatrix:s.modelMatrix,coordinateSystem:s.coordinateSystem,coordinateOrigin:s.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(r)for(let c of r)ty(a,c.getShaderModuleProps?.(e,a));return ty(a,this.getShaderModuleProps(e,r,a),o)}};function ry(t=0,e={}){let r={},i=(o,n)=>{let s=o.props._offset,a=o.id,c=o.parent&&o.parent.id,l;if(c&&!(c in e)&&i(o.parent,!1),c in r){let f=r[c]=r[c]||ry(e[c],e);l=f(o,n),r[a]=f}else Number.isFinite(s)?(l=s+(e[c]||0),r[a]=null):l=t;return n&&l>=t&&(t=l+1),e[a]=l,l};return i}function C3(t,{shaderModuleProps:e,target:r,viewport:i}){let o=e?.project?.devicePixelRatio??t.canvasContext.cssToDeviceRatio(),[,n]=t.canvasContext.getDrawingBufferSize(),s=r?r.height:n,a=i;return[a.x*o,s-(a.y+a.height)*o,a.width*o,a.height*o]}function ty(t,...e){for(let r of e)if(r)for(let i in r)t[i]?Object.assign(t[i],r[i]):t[i]=r[i];return t}var sn=class extends Ke{constructor(e,r){super(e,r);let i=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),o=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[i],depthStencilAttachment:o})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let r=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),o=e.viewports[0],n=o.width*i,s=o.height*i,a=[1,1,1,1];(n!==r.width||s!==r.height)&&r.resize({width:n,height:s}),super.render({...e,clearColor:a,target:r,pass:"shadow"})}getLayerParameters(e,r,i){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,r,i){return{shadow:{project:i.project,drawToShadowMap:!0}}}};var I3={color:[255,255,255],intensity:1},iy=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],O3=[0,0,0,200/255],_r=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=O3,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:r,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),i._addDefaultShaderModule(Fi),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let r in e){let i=e[r];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:r,viewports:i,onViewportActive:o,views:n}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let s=0;s<this.shadowPasses.length;s++)this.shadowPasses[s].render({layers:e,layerFilter:r,viewports:i,onViewportActive:o,views:n,shaderModuleProps:{shadow:{shadowLightId:s,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,r){let i=this.shadow?{project:r.project,shadowMaps:this.shadowPasses.map(s=>s.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},o={enabled:!0,lights:this._getLights(e)},n=e.props.material;return{shadow:i,lighting:o,phongMaterial:n,gouraudMaterial:n}}cleanup(e){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(Fi))}_calculateMatrices(){let e=[];for(let r of this.directionalLights){let i=new z().lookAt({eye:new $(r.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let r=0;r<this.directionalLights.length;r++){let i=new sn(e);this.shadowPasses[r]=i}}_applyDefaultLights(){let{ambientLight:e,pointLights:r,directionalLights:i}=this;!e&&r.length===0&&i.length===0&&(this.ambientLight=new Ui(I3),this.directionalLights.push(new kt(iy[0]),new kt(iy[1])))}_getLights(e){let r=[];this.ambientLight&&r.push(this.ambientLight);for(let i of this.pointLights)r.push(i.getProjectedLight({layer:e}));for(let i of this.directionalLights)r.push(i.getProjectedLight({layer:e}));return r}};var xu=class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,r,{size:i=1,type:o,padding:n=0,copy:s=!1,initialize:a=!1,maxCount:c}){let l=o||e&&e.constructor||Float32Array,f=r*i+n;if(ArrayBuffer.isView(e)){if(f<=e.length)return e;if(f*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new l(e.buffer,0,f)}let h=1/0;c&&(h=c*i+n);let u=this._allocate(l,f,a,h);return e&&s?u.set(e):a||u.fill(0,0,4),this._release(e),u}release(e){this._release(e)}_allocate(e,r,i,o){let n=Math.max(Math.ceil(r*this.opts.overAlloc),1);n>o&&(n=o);let s=this._pool,a=e.BYTES_PER_ELEMENT*n,c=s.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(s.splice(c,1)[0],0,n);return i&&l.fill(0),l}return new e(n)}_release(e){if(!ArrayBuffer.isView(e))return;let r=this._pool,{buffer:i}=e,{byteLength:o}=i,n=r.findIndex(s=>s.byteLength>=o);n<0?r.push(i):(n>0||r.length<this.opts.poolSize)&&r.splice(n,0,i),r.length>this.opts.poolSize&&r.shift()}},Ze=new xu;function Vi(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function _t(t,e){let r=t%e;return r<0?e+r:r}function ny(t){return[t[12],t[13],t[14]]}function sy(t){let e=t[10],r=t[14];return{near:r/(e-1),far:r/(e+1)}}function ay(t){return{left:ki(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:ki(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:ki(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:ki(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:ki(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:ki(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}var oy=new $;function ki(t,e,r,i){oy.set(t,e,r);let o=oy.len();return{distance:i/o,normal:new $(-t/o,-e/o,-r/o)}}function Au(t){return t-Math.fround(t)}var an;function Ia(t,e){let{size:r=1,startIndex:i=0}=e,o=e.endIndex!==void 0?e.endIndex:t.length,n=(o-i)/r;an=Ze.allocate(an,n,{type:Float32Array,size:r*2});let s=i,a=0;for(;s<o;){for(let c=0;c<r;c++){let l=t[s++];an[a+c]=l,an[a+c+r]=Au(l)}a+=r*2}return an.subarray(0,n*r*2)}function cy(t){let e=null,r=!1;for(let i of t)i&&(e?(r||(e=[[e[0][0],e[0][1]],[e[1][0],e[1][1]]],r=!0),e[0][0]=Math.min(e[0][0],i[0][0]),e[0][1]=Math.min(e[0][1],i[0][1]),e[1][0]=Math.max(e[1][0],i[1][0]),e[1][1]=Math.max(e[1][1],i[1][1])):e=i);return e}var N3=Math.PI/180,D3=Vi(),ly=[0,0,0],B3={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function L3({width:t,height:e,orthographic:r,fovyRadians:i,focalDistance:o,padding:n,near:s,far:a}){let c=t/e,l=r?new z().orthographic({fovy:i,aspect:c,focalDistance:o,near:s,far:a}):new z().perspective({fovy:i,aspect:c,near:s,far:a});if(n){let{left:f=0,right:h=0,top:u=0,bottom:d=0}=n,p=U((f+t-h)/2,0,t)-t/2,g=U((u+e-d)/2,0,e)-e/2;l[8]-=p*2/t,l[9]+=g*2/e}return l}var zi=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||B3,this.focalDistance=e.focalDistance||1,this.position=e.position||ly,this.modelMatrix=e.modelMatrix||null;let{longitude:r,latitude:i}=e;this.isGeospatial=Number.isFinite(i)&&Number.isFinite(r),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?oe.WEB_MERCATOR:oe.WEB_MERCATOR_AUTO_OFFSET:oe.IDENTITY}equals(e){return e instanceof zi?this===e?!0:e.width===this.width&&e.height===this.height&&e.scale===this.scale&&Pe(e.projectionMatrix,this.projectionMatrix)&&Pe(e.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:r=!0}={}){let i=this.projectPosition(e),o=Li(i,this.pixelProjectionMatrix),[n,s]=o,a=r?s:this.height-s;return e.length===2?[n,a]:[n,a,o[2]]}unproject(e,{topLeft:r=!0,targetZ:i}={}){let[o,n,s]=e,a=r?n:this.height-n,c=i&&i*this.distanceScales.unitsPerMeter[2],l=ze([o,a,s],this.pixelUnprojectionMatrix,c),[f,h,u]=this.unprojectPosition(l);return Number.isFinite(s)?[f,h,u]:Number.isFinite(i)?[f,h,i]:[f,h]}projectPosition(e){let[r,i]=this.projectFlat(e),o=(e[2]||0)*this.distanceScales.unitsPerMeter[2];return[r,i,o]}unprojectPosition(e){let[r,i]=this.unprojectFlat(e),o=(e[2]||0)*this.distanceScales.metersPerUnit[2];return[r,i,o]}projectFlat(e){if(this.isGeospatial){let r=Ae(e);return r[1]=U(r[1],-318,830),r}return e}unprojectFlat(e){return this.isGeospatial?_e(e):e}getBounds(e={}){let r={targetZ:e.z||0},i=this.unproject([0,0],r),o=this.unproject([this.width,0],r),n=this.unproject([0,this.height],r),s=this.unproject([this.width,this.height],r);return[Math.min(i[0],o[0],n[0],s[0]),Math.min(i[1],o[1],n[1],s[1]),Math.max(i[0],o[0],n[0],s[0]),Math.max(i[1],o[1],n[1],s[1])]}getDistanceScales(e){return e&&this.isGeospatial?Bi({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:r,width:i=1,height:o=1}){return e<this.x+this.width&&this.x<e+i&&r<this.y+this.height&&this.y<r+o}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,ay(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(e,r,i){return null}_initProps(e){let r=e.longitude,i=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=rn({latitude:i})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||Bi({latitude:i,longitude:r}));let o=Math.pow(2,this.zoom);this.scale=o;let{position:n,modelMatrix:s}=e,a=ly;if(n&&(a=s?new z(s).transformAsVector(n,[]):n),this.isGeospatial){let c=this.projectPosition([r,i,0]);this.center=new $(a).scale(this.distanceScales.unitsPerMeter).add(c)}else this.center=this.projectPosition(a)}_initMatrices(e){let{viewMatrix:r=D3,projectionMatrix:i=null,orthographic:o=!1,fovyRadians:n,fovy:s=75,near:a=.1,far:c=1e3,padding:l=null,focalDistance:f=1}=e;this.viewMatrixUncentered=r,this.viewMatrix=new z().multiplyRight(r).translate(new $(this.center).negate()),this.projectionMatrix=i||L3({width:this.width,height:this.height,orthographic:o,fovyRadians:n||s*N3,focalDistance:f,padding:l,near:a,far:c});let h=Vi();re.multiply(h,h,this.projectionMatrix),re.multiply(h,h,this.viewMatrix),this.viewProjectionMatrix=h,this.viewMatrixInverse=re.invert([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=ny(this.viewMatrixInverse);let u=Vi(),d=Vi();re.scale(u,u,[this.width/2,-this.height/2,1]),re.translate(u,u,[1,-1,0]),re.multiply(d,u,this.viewProjectionMatrix),this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=re.invert(Vi(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||L.warn("Pixel project matrix not invertible")()}};zi.displayName="Viewport";var Se=zi;var zr=class extends Se{constructor(e={}){let{latitude:r=0,longitude:i=0,zoom:o=0,pitch:n=0,bearing:s=0,nearZMultiplier:a=.1,farZMultiplier:c=1.01,nearZ:l,farZ:f,orthographic:h=!1,projectionMatrix:u,repeat:d=!1,worldOffset:p=0,position:g,padding:m,legacyMeterSizes:_=!1}=e,{width:b,height:y,altitude:T=1.5}=e,S=Math.pow(2,o);b=b||1,y=y||1;let A,w=null;if(u)T=u[5]/2,A=Ft(T);else{e.fovy?(A=e.fovy,T=Ut(A)):A=Ft(T);let R;if(m){let{top:v=0,bottom:O=0}=m;R=[0,U((v+y-O)/2,0,y)-y/2]}w=_u({width:b,height:y,scale:S,center:g&&[0,0,g[2]*on(r)],offset:R,pitch:n,fovy:A,nearZMultiplier:a,farZMultiplier:c}),Number.isFinite(l)&&(w.near=l),Number.isFinite(f)&&(w.far=f)}let P=Pa({height:y,pitch:n,bearing:s,scale:S,altitude:T});p&&(P=new z().translate([512*p,0,0]).multiplyLeft(P)),super({...e,width:b,height:y,viewMatrix:P,longitude:i,latitude:r,zoom:o,...w,fovy:A,focalDistance:T}),this.latitude=r,this.longitude=i,this.zoom=o,this.pitch=n,this.bearing=s,this.altitude=T,this.fovy=A,this.orthographic=h,this._subViewports=d?[]:null,this._pseudoMeters=_,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let e=this.getBounds(),r=Math.floor((e[0]+180)/360),i=Math.ceil((e[2]-180)/360);for(let o=r;o<=i;o++){let n=o?new zr({...this,worldOffset:o}):this;this._subViewports.push(n)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);let[r,i]=this.projectFlat(e),o=(e[2]||0)*on(e[1]);return[r,i,o]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);let[r,i]=this.unprojectFlat(e),o=(e[2]||0)/on(i);return[r,i,o]}addMetersToLngLat(e,r){return nn(e,r)}panByPosition(e,r,i){let o=ze(r,this.pixelUnprojectionMatrix),n=this.projectFlat(e),s=ee.add([],n,ee.negate([],o)),a=ee.add([],this.center,s),[c,l]=this.unprojectFlat(a);return{longitude:c,latitude:l}}panByPosition3D(e,r){let i=e[2]||0,o=ee.sub([],e,this.unproject(r,{targetZ:i}));return{longitude:this.longitude+o[0],latitude:this.latitude+o[1]}}getBounds(e={}){let r=Ma(this,e.z||0);return[Math.min(r[0][0],r[1][0],r[2][0],r[3][0]),Math.min(r[0][1],r[1][1],r[2][1],r[3][1]),Math.max(r[0][0],r[1][0],r[2][0],r[3][0]),Math.max(r[0][1],r[1][1],r[2][1],r[3][1])]}fitBounds(e,r={}){let{width:i,height:o}=this,{longitude:n,latitude:s,zoom:a}=va({width:i,height:o,bounds:e,...r});return new zr({width:i,height:o,longitude:n,latitude:s,zoom:a})}};zr.displayName="WebMercatorViewport";var yr=zr;var fy=[0,0,0];function Su(t,e,r=!1){let i=e.projectPosition(t);if(r&&e instanceof yr){let[o,n,s=0]=t,a=e.getDistanceScales([o,n]);i[2]=s*a.unitsPerMeter[2]}return i}function F3(t){let{viewport:e,modelMatrix:r,coordinateOrigin:i}=t,{coordinateSystem:o,fromCoordinateSystem:n,fromCoordinateOrigin:s}=t;return o===k.DEFAULT&&(o=e.isGeospatial?k.LNGLAT:k.CARTESIAN),n===void 0&&(n=o),s===void 0&&(s=i),{viewport:e,coordinateSystem:o,coordinateOrigin:i,modelMatrix:r,fromCoordinateSystem:n,fromCoordinateOrigin:s}}function Eu(t,{viewport:e,modelMatrix:r,coordinateSystem:i,coordinateOrigin:o,offsetMode:n}){let[s,a,c=0]=t;switch(r&&([s,a,c]=xe.transformMat4([],[s,a,c,1],r)),i){case k.LNGLAT:return Su([s,a,c],e,n);case k.LNGLAT_OFFSETS:return Su([s+o[0],a+o[1],c+(o[2]||0)],e,n);case k.METER_OFFSETS:return Su(nn(o,[s,a,c]),e,n);case k.CARTESIAN:default:return e.isGeospatial?[s+o[0],a+o[1],c+o[2]]:e.projectPosition([s,a,c])}}function Oa(t,e){let{viewport:r,coordinateSystem:i,coordinateOrigin:o,modelMatrix:n,fromCoordinateSystem:s,fromCoordinateOrigin:a}=F3(e),{autoOffset:c=!0}=e,{geospatialOrigin:l=fy,shaderCoordinateOrigin:f=fy,offsetMode:h=!1}=c?du(r,i,o):{},u=Eu(t,{viewport:r,modelMatrix:n,coordinateSystem:s,coordinateOrigin:a,offsetMode:h});if(h){let d=r.projectPosition(l||f);pe.sub(u,u,d)}return u}var U3=[255,255,255],k3=1,V3=[1,0,0],z3=[0,0,1],W3=0,Wi=class{constructor(e={}){this.type="point";let{color:r=U3}=e,{intensity:i=k3}=e,{position:o=z3}=e;this.id=e.id||`point-${W3++}`,this.color=r,this.intensity=i,this.type="point",this.position=o,this.attenuation=j3(e),this.projectedLight={...this}}getProjectedLight({layer:e}){let{projectedLight:r}=this,i=e.context.viewport,{coordinateSystem:o,coordinateOrigin:n}=e.props,s=Oa(this.position,{viewport:i,coordinateSystem:o,coordinateOrigin:n,fromCoordinateSystem:i.isGeospatial?k.LNGLAT:k.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return r.color=this.color,r.intensity=this.intensity,r.position=s,r}};function j3(t){return t.attenuation?t.attenuation:V3}var cn=class extends Wi{getProjectedLight({layer:e}){let{projectedLight:r}=this,i=e.context.viewport,{coordinateSystem:o,coordinateOrigin:n,modelMatrix:s}=e.props,{cameraPosition:a}=Ea({viewport:i,modelMatrix:s,coordinateSystem:o,coordinateOrigin:n});return r.color=this.color,r.intensity=this.intensity,r.position=a,r}};var Wr=Math.PI/180,$3=1e3*60*60*24,H3=2440588,X3=2451545,Na=Wr*23.4397,Y3=357.5291,K3=.98560028,Z3=280.147,q3=360.9856235;function hy(t,e,r){let i=Wr*-r,o=Wr*e,n=Q3(t),s=sP(n),a=iP(n,i)-s.rightAscension;return{azimuth:tP(a,o,s.declination),altitude:rP(a,o,s.declination)}}function Da(t,e,r){let{azimuth:i,altitude:o}=hy(t,e,r);return[Math.sin(i)*Math.cos(o),Math.cos(i)*Math.cos(o),-Math.sin(o)]}function G3(t){return(typeof t=="number"?t:t.getTime())/$3-.5+H3}function Q3(t){return G3(t)-X3}function J3(t,e){let r=t;return Math.atan2(Math.sin(r)*Math.cos(Na)-Math.tan(e)*Math.sin(Na),Math.cos(r))}function eP(t,e){let r=t;return Math.asin(Math.sin(e)*Math.cos(Na)+Math.cos(e)*Math.sin(Na)*Math.sin(r))}function tP(t,e,r){let i=t,o=e,n=r;return Math.atan2(Math.sin(i),Math.cos(i)*Math.sin(o)-Math.tan(n)*Math.cos(o))}function rP(t,e,r){let i=t,o=e,n=r;return Math.asin(Math.sin(o)*Math.sin(n)+Math.cos(o)*Math.cos(n)*Math.cos(i))}function iP(t,e){return Wr*(Z3+q3*t)-e}function oP(t){return Wr*(Y3+K3*t)}function nP(t){let e=t,r=Wr*(1.9148*Math.sin(e)+.02*Math.sin(2*e)+3e-4*Math.sin(3*e)),i=Wr*102.9372;return e+r+i+Math.PI}function sP(t){let e=oP(t),r=nP(e);return{declination:eP(r,0),rightAscension:J3(r,0)}}var ln=class extends kt{constructor(e){super(e),this.timestamp=e.timestamp}getProjectedLight({layer:e}){let{viewport:r}=e.context;if(r.resolution&&r.resolution>0){let[o,n,s]=Da(this.timestamp,0,0);this.direction=[o,-s,n]}else{let{latitude:o,longitude:n}=r;this.direction=Da(this.timestamp,o,n)}return this}};var aP=`layout(std140) uniform screenUniforms {
|
|
1977
|
+
`}}};var S3=[da],E3=["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)"],w3=[];function Ia(t){let e=tr.getDefaultShaderAssembler();for(let i of S3)e.addDefaultModule(i);e._hookFunctions.length=0;let r=t==="glsl"?E3:w3;for(let i of r)e.addShaderHook(i);return e}var R3=[255,255,255],P3=1,v3=0,ki=class{constructor(e={}){this.type="ambient";let{color:r=R3}=e,{intensity:i=P3}=e;this.id=e.id||`ambient-${v3++}`,this.color=r,this.intensity=i}};var M3=[255,255,255],C3=1,I3=[0,0,-1],O3=0,Ut=class{constructor(e={}){this.type="directional";let{color:r=M3}=e,{intensity:i=C3}=e,{direction:o=I3}=e,{_shadow:n=!1}=e;this.id=e.id||`directional-${O3++}`,this.color=r,this.intensity=i,this.type="directional",this.direction=new j(o).normalize().toArray(),this.shadow=n}getProjectedLight(e){return this}};var zr=class{constructor(e,r={id:"pass"}){let{id:i}=r;this.id=i,this.device=e,this.props={...r}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}};var N3={depthWriteEnabled:!0,depthCompare:"less-equal",blendColorOperation:"add",blendColorSrcFactor:"src-alpha",blendColorDstFactor:"one",blendAlphaOperation:"add",blendAlphaSrcFactor:"one-minus-dst-alpha",blendAlphaDstFactor:"one"},Ye=class extends zr{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){this._render(e)}_render(e){let r=this.device.canvasContext,i=e.target??r.getCurrentFramebuffer(),[o,n]=r.getDrawingBufferSize(),s=e.clearCanvas??!0,a=e.clearColor??(s?[0,0,0,0]:!1),c=s?1:!1,l=s?0:!1,f=e.colorMask??15,h={viewport:[0,0,o,n]};e.colorMask&&(h.colorMask=f),e.scissorRect&&(h.scissorRect=e.scissorRect);let u=this.device.beginRenderPass({framebuffer:i,parameters:h,clearColor:a,clearDepth:c,clearStencil:l});try{return this._drawLayers(u,e)}finally{u.end(),this.device.submit()}}_drawLayers(e,r){let{target:i,shaderModuleProps:o,viewports:n,views:s,onViewportActive:a,clearStack:c=!0}=r;r.pass=r.pass||"unknown",c&&(this._lastRenderIndex=-1);let l=[];for(let f of n){let h=s&&s[f.id];a?.(f);let u=this._getDrawLayerParams(f,r),d=f.subViewports||[f];for(let p of d){let g=this._drawLayersInViewport(e,{target:i,shaderModuleProps:o,viewport:p,view:h,pass:r.pass,layers:r.layers},u);l.push(g)}}return l}_getDrawLayerParams(e,{layers:r,pass:i,isPicking:o=!1,layerFilter:n,cullRect:s,effects:a,shaderModuleProps:c},l=!1){let f=[],h=iy(this._lastRenderIndex+1),u={layer:r[0],viewport:e,isPicking:o,renderPass:i,cullRect:s},d={};for(let p=0;p<r.length;p++){let g=r[p],m=this._shouldDrawLayer(g,u,n,d),_={shouldDrawLayer:m};if(m&&!l){_.shouldDrawLayer=!0,_.layerRenderIndex=h(g,m),_.shaderModuleProps=this._getShaderModuleProps(g,a,i,c);let b=g.context.device.type==="webgpu"?N3:null;_.layerParameters={...b,...g.context.deck?.props.parameters,...this.getLayerParameters(g,p,e)}}f[p]=_}return f}_drawLayersInViewport(e,{layers:r,shaderModuleProps:i,pass:o,target:n,viewport:s,view:a},c){let l=D3(this.device,{shaderModuleProps:i,target:n,viewport:s});if(a){let{clear:h,clearColor:u,clearDepth:d,clearStencil:p}=a.props;if(h){let g=[0,0,0,0],m=1,_=0;Array.isArray(u)?g=[...u.slice(0,3),u[3]||255].map(y=>y/255):u===!1&&(g=!1),d!==void 0&&(m=d),p!==void 0&&(_=p),this.device.beginRenderPass({framebuffer:n,parameters:{viewport:l,scissorRect:l},clearColor:g,clearDepth:m,clearStencil:_}).end()}}let f={totalCount:r.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let h=0;h<r.length;h++){let u=r[h],d=c[h],{shouldDrawLayer:p}=d;if(p&&u.props.pickable&&f.pickableCount++,u.isComposite&&f.compositeCount++,u.isDrawable&&d.shouldDrawLayer){let{layerRenderIndex:g,shaderModuleProps:m,layerParameters:_}=d;f.visibleCount++,this._lastRenderIndex=Math.max(this._lastRenderIndex,g),m.project&&(m.project.viewport=s),u.context.renderPass=e;try{u._drawLayer({renderPass:e,shaderModuleProps:m,uniforms:{layerIndex:g},parameters:_})}catch(b){u.raiseError(b,`drawing ${u} to ${o}`)}}}return f}shouldDrawLayer(e){return!0}getShaderModuleProps(e,r,i){return null}getLayerParameters(e,r,i){return e.props.parameters}_shouldDrawLayer(e,r,i,o){if(!(e.props.visible&&this.shouldDrawLayer(e)))return!1;r.layer=e;let s=e.parent;for(;s;){if(!s.props.visible||!s.filterSubLayer(r))return!1;r.layer=s,s=s.parent}if(i){let a=r.layer.id;if(a in o||(o[a]=i(r)),!o[a])return!1}return e.activateViewport(r.viewport),!0}_getShaderModuleProps(e,r,i,o){let n=this.device.canvasContext.cssToDeviceRatio(),s=e.internalState?.propsInTransition||e.props,a={layer:s,picking:{isActive:!1},project:{viewport:e.context.viewport,devicePixelRatio:n,modelMatrix:s.modelMatrix,coordinateSystem:s.coordinateSystem,coordinateOrigin:s.coordinateOrigin,autoWrapLongitude:e.wrapLongitude}};if(r)for(let c of r)ry(a,c.getShaderModuleProps?.(e,a));return ry(a,this.getShaderModuleProps(e,r,a),o)}};function iy(t=0,e={}){let r={},i=(o,n)=>{let s=o.props._offset,a=o.id,c=o.parent&&o.parent.id,l;if(c&&!(c in e)&&i(o.parent,!1),c in r){let f=r[c]=r[c]||iy(e[c],e);l=f(o,n),r[a]=f}else Number.isFinite(s)?(l=s+(e[c]||0),r[a]=null):l=t;return n&&l>=t&&(t=l+1),e[a]=l,l};return i}function D3(t,{shaderModuleProps:e,target:r,viewport:i}){let o=e?.project?.devicePixelRatio??t.canvasContext.cssToDeviceRatio(),[,n]=t.canvasContext.getDrawingBufferSize(),s=r?r.height:n,a=i;return[a.x*o,s-(a.y+a.height)*o,a.width*o,a.height*o]}function ry(t,...e){for(let r of e)if(r)for(let i in r)t[i]?Object.assign(t[i],r[i]):t[i]=r[i];return t}var an=class extends Ye{constructor(e,r){super(e,r);let i=e.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),o=e.createTexture({format:"depth16unorm",width:1,height:1});this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[i],depthStencilAttachment:o})}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null)}getShadowMap(){return this.fbo.colorAttachments[0].texture}render(e){let r=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),o=e.viewports[0],n=o.width*i,s=o.height*i,a=[1,1,1,1];(n!==r.width||s!==r.height)&&r.resize({width:n,height:s}),super.render({...e,clearColor:a,target:r,pass:"shadow"})}getLayerParameters(e,r,i){return{...e.props.parameters,blend:!1,depthWriteEnabled:!0,depthCompare:"less-equal"}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getShaderModuleProps(e,r,i){return{shadow:{project:i.project,drawToShadowMap:!0}}}};var B3={color:[255,255,255],intensity:1},oy=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],F3=[0,0,0,200/255],mr=class{constructor(e={}){this.id="lighting-effect",this.shadowColor=F3,this.shadow=!1,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;let{device:r,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(r),i._addDefaultShaderModule(Ui),this.dummyShadowMap=r.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=void 0,this.directionalLights=[],this.pointLights=[];for(let r in e){let i=e[r];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i);break;default:}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(r=>r.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:r,viewports:i,onViewportActive:o,views:n}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let s=0;s<this.shadowPasses.length;s++)this.shadowPasses[s].render({layers:e,layerFilter:r,viewports:i,onViewportActive:o,views:n,shaderModuleProps:{shadow:{shadowLightId:s,dummyShadowMap:this.dummyShadowMap,shadowMatrices:this.shadowMatrices}}})}}getShaderModuleProps(e,r){let i=this.shadow?{project:r.project,shadowMaps:this.shadowPasses.map(s=>s.getShadowMap()),dummyShadowMap:this.dummyShadowMap,shadowColor:this.shadowColor,shadowMatrices:this.shadowMatrices}:{},o={enabled:!0,lights:this._getLights(e)},n=e.props.material;return{shadow:i,lighting:o,phongMaterial:n,gouraudMaterial:n}}cleanup(e){for(let r of this.shadowPasses)r.delete();this.shadowPasses.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(Ui))}_calculateMatrices(){let e=[];for(let r of this.directionalLights){let i=new V().lookAt({eye:new j(r.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let r=0;r<this.directionalLights.length;r++){let i=new an(e);this.shadowPasses[r]=i}}_applyDefaultLights(){let{ambientLight:e,pointLights:r,directionalLights:i}=this;!e&&r.length===0&&i.length===0&&(this.ambientLight=new ki(B3),this.directionalLights.push(new Ut(oy[0]),new Ut(oy[1])))}_getLights(e){let r=[];this.ambientLight&&r.push(this.ambientLight);for(let i of this.pointLights)r.push(i.getProjectedLight({layer:e}));for(let i of this.directionalLights)r.push(i.getProjectedLight({layer:e}));return r}};var Su=class{constructor(e={}){this._pool=[],this.opts={overAlloc:2,poolSize:100},this.setOptions(e)}setOptions(e){Object.assign(this.opts,e)}allocate(e,r,{size:i=1,type:o,padding:n=0,copy:s=!1,initialize:a=!1,maxCount:c}){let l=o||e&&e.constructor||Float32Array,f=r*i+n;if(ArrayBuffer.isView(e)){if(f<=e.length)return e;if(f*e.BYTES_PER_ELEMENT<=e.buffer.byteLength)return new l(e.buffer,0,f)}let h=1/0;c&&(h=c*i+n);let u=this._allocate(l,f,a,h);return e&&s?u.set(e):a||u.fill(0,0,4),this._release(e),u}release(e){this._release(e)}_allocate(e,r,i,o){let n=Math.max(Math.ceil(r*this.opts.overAlloc),1);n>o&&(n=o);let s=this._pool,a=e.BYTES_PER_ELEMENT*n,c=s.findIndex(l=>l.byteLength>=a);if(c>=0){let l=new e(s.splice(c,1)[0],0,n);return i&&l.fill(0),l}return new e(n)}_release(e){if(!ArrayBuffer.isView(e))return;let r=this._pool,{buffer:i}=e,{byteLength:o}=i,n=r.findIndex(s=>s.byteLength>=o);n<0?r.push(i):(n>0||r.length<this.opts.poolSize)&&r.splice(n,0,i),r.length>this.opts.poolSize&&r.shift()}},Ke=new Su;function zi(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function mt(t,e){let r=t%e;return r<0?e+r:r}function sy(t){return[t[12],t[13],t[14]]}function ay(t){let e=t[10],r=t[14];return{near:r/(e-1),far:r/(e+1)}}function cy(t){return{left:Vi(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:Vi(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:Vi(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:Vi(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:Vi(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:Vi(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}var ny=new j;function Vi(t,e,r,i){ny.set(t,e,r);let o=ny.len();return{distance:i/o,normal:new j(-t/o,-e/o,-r/o)}}function Eu(t){return t-Math.fround(t)}var cn;function Oa(t,e){let{size:r=1,startIndex:i=0}=e,o=e.endIndex!==void 0?e.endIndex:t.length,n=(o-i)/r;cn=Ke.allocate(cn,n,{type:Float32Array,size:r*2});let s=i,a=0;for(;s<o;){for(let c=0;c<r;c++){let l=t[s++];cn[a+c]=l,cn[a+c+r]=Eu(l)}a+=r*2}return cn.subarray(0,n*r*2)}function ly(t){let e=null,r=!1;for(let i of t)i&&(e?(r||(e=[[e[0][0],e[0][1]],[e[1][0],e[1][1]]],r=!0),e[0][0]=Math.min(e[0][0],i[0][0]),e[0][1]=Math.min(e[0][1],i[0][1]),e[1][0]=Math.max(e[1][0],i[1][0]),e[1][1]=Math.max(e[1][1],i[1][1])):e=i);return e}var L3=Math.PI/180,U3=zi(),fy=[0,0,0],k3={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function V3({width:t,height:e,orthographic:r,fovyRadians:i,focalDistance:o,padding:n,near:s,far:a}){let c=t/e,l=r?new V().orthographic({fovy:i,aspect:c,focalDistance:o,near:s,far:a}):new V().perspective({fovy:i,aspect:c,near:s,far:a});if(n){let{left:f=0,right:h=0,top:u=0,bottom:d=0}=n,p=U((f+t-h)/2,0,t)-t/2,g=U((u+e-d)/2,0,e)-e/2;l[8]-=p*2/t,l[9]+=g*2/e}return l}var Wi=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||k3,this.focalDistance=e.focalDistance||1,this.position=e.position||fy,this.modelMatrix=e.modelMatrix||null;let{longitude:r,latitude:i}=e;this.isGeospatial=Number.isFinite(i)&&Number.isFinite(r),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?ie.WEB_MERCATOR:ie.WEB_MERCATOR_AUTO_OFFSET:ie.IDENTITY}equals(e){return e instanceof Wi?this===e?!0:e.width===this.width&&e.height===this.height&&e.scale===this.scale&&Re(e.projectionMatrix,this.projectionMatrix)&&Re(e.viewMatrix,this.viewMatrix):!1}project(e,{topLeft:r=!0}={}){let i=this.projectPosition(e),o=Li(i,this.pixelProjectionMatrix),[n,s]=o,a=r?s:this.height-s;return e.length===2?[n,a]:[n,a,o[2]]}unproject(e,{topLeft:r=!0,targetZ:i}={}){let[o,n,s]=e,a=r?n:this.height-n,c=i&&i*this.distanceScales.unitsPerMeter[2],l=Ve([o,a,s],this.pixelUnprojectionMatrix,c),[f,h,u]=this.unprojectPosition(l);return Number.isFinite(s)?[f,h,u]:Number.isFinite(i)?[f,h,i]:[f,h]}projectPosition(e){let[r,i]=this.projectFlat(e),o=(e[2]||0)*this.distanceScales.unitsPerMeter[2];return[r,i,o]}unprojectPosition(e){let[r,i]=this.unprojectFlat(e),o=(e[2]||0)*this.distanceScales.metersPerUnit[2];return[r,i,o]}projectFlat(e){if(this.isGeospatial){let r=xe(e);return r[1]=U(r[1],-318,830),r}return e}unprojectFlat(e){return this.isGeospatial?me(e):e}getBounds(e={}){let r={targetZ:e.z||0},i=this.unproject([0,0],r),o=this.unproject([this.width,0],r),n=this.unproject([0,this.height],r),s=this.unproject([this.width,this.height],r);return[Math.min(i[0],o[0],n[0],s[0]),Math.min(i[1],o[1],n[1],s[1]),Math.max(i[0],o[0],n[0],s[0]),Math.max(i[1],o[1],n[1],s[1])]}getDistanceScales(e){return e&&this.isGeospatial?Fi({longitude:e[0],latitude:e[1],highPrecision:!0}):this.distanceScales}containsPixel({x:e,y:r,width:i=1,height:o=1}){return e<this.x+this.width&&this.x<e+i&&r<this.y+this.height&&this.y<r+o}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,cy(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(e,r,i){return null}_initProps(e){let r=e.longitude,i=e.latitude;this.isGeospatial&&(Number.isFinite(e.zoom)||(this.zoom=on({latitude:i})+Math.log2(this.focalDistance)),this.distanceScales=e.distanceScales||Fi({latitude:i,longitude:r}));let o=Math.pow(2,this.zoom);this.scale=o;let{position:n,modelMatrix:s}=e,a=fy;if(n&&(a=s?new V(s).transformAsVector(n,[]):n),this.isGeospatial){let c=this.projectPosition([r,i,0]);this.center=new j(a).scale(this.distanceScales.unitsPerMeter).add(c)}else this.center=this.projectPosition(a)}_initMatrices(e){let{viewMatrix:r=U3,projectionMatrix:i=null,orthographic:o=!1,fovyRadians:n,fovy:s=75,near:a=.1,far:c=1e3,padding:l=null,focalDistance:f=1}=e;this.viewMatrixUncentered=r,this.viewMatrix=new V().multiplyRight(r).translate(new j(this.center).negate()),this.projectionMatrix=i||V3({width:this.width,height:this.height,orthographic:o,fovyRadians:n||s*L3,focalDistance:f,padding:l,near:a,far:c});let h=zi();te.multiply(h,h,this.projectionMatrix),te.multiply(h,h,this.viewMatrix),this.viewProjectionMatrix=h,this.viewMatrixInverse=te.invert([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=sy(this.viewMatrixInverse);let u=zi(),d=zi();te.scale(u,u,[this.width/2,-this.height/2,1]),te.translate(u,u,[1,-1,0]),te.multiply(d,u,this.viewProjectionMatrix),this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=te.invert(zi(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||F.warn("Pixel project matrix not invertible")()}};Wi.displayName="Viewport";var Ae=Wi;var Wr=class extends Ae{constructor(e={}){let{latitude:r=0,longitude:i=0,zoom:o=0,pitch:n=0,bearing:s=0,nearZMultiplier:a=.1,farZMultiplier:c=1.01,nearZ:l,farZ:f,orthographic:h=!1,projectionMatrix:u,repeat:d=!1,worldOffset:p=0,position:g,padding:m,legacyMeterSizes:_=!1}=e,{width:b,height:y,altitude:T=1.5}=e,S=Math.pow(2,o);b=b||1,y=y||1;let A,w=null;if(u)T=u[5]/2,A=Ft(T);else{e.fovy?(A=e.fovy,T=Lt(A)):A=Ft(T);let R;if(m){let{top:v=0,bottom:O=0}=m;R=[0,U((v+y-O)/2,0,y)-y/2]}w=bu({width:b,height:y,scale:S,center:g&&[0,0,g[2]*nn(r)],offset:R,pitch:n,fovy:A,nearZMultiplier:a,farZMultiplier:c}),Number.isFinite(l)&&(w.near=l),Number.isFinite(f)&&(w.far=f)}let P=va({height:y,pitch:n,bearing:s,scale:S,altitude:T});p&&(P=new V().translate([512*p,0,0]).multiplyLeft(P)),super({...e,width:b,height:y,viewMatrix:P,longitude:i,latitude:r,zoom:o,...w,fovy:A,focalDistance:T}),this.latitude=r,this.longitude=i,this.zoom=o,this.pitch=n,this.bearing=s,this.altitude=T,this.fovy=A,this.orthographic=h,this._subViewports=d?[]:null,this._pseudoMeters=_,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let e=this.getBounds(),r=Math.floor((e[0]+180)/360),i=Math.ceil((e[2]-180)/360);for(let o=r;o<=i;o++){let n=o?new Wr({...this,worldOffset:o}):this;this._subViewports.push(n)}}return this._subViewports}projectPosition(e){if(this._pseudoMeters)return super.projectPosition(e);let[r,i]=this.projectFlat(e),o=(e[2]||0)*nn(e[1]);return[r,i,o]}unprojectPosition(e){if(this._pseudoMeters)return super.unprojectPosition(e);let[r,i]=this.unprojectFlat(e),o=(e[2]||0)/nn(i);return[r,i,o]}addMetersToLngLat(e,r){return sn(e,r)}panByPosition(e,r,i){let o=Ve(r,this.pixelUnprojectionMatrix),n=this.projectFlat(e),s=J.add([],n,J.negate([],o)),a=J.add([],this.center,s),[c,l]=this.unprojectFlat(a);return{longitude:c,latitude:l}}panByPosition3D(e,r){let i=e[2]||0,o=J.sub([],e,this.unproject(r,{targetZ:i}));return{longitude:this.longitude+o[0],latitude:this.latitude+o[1]}}getBounds(e={}){let r=Ca(this,e.z||0);return[Math.min(r[0][0],r[1][0],r[2][0],r[3][0]),Math.min(r[0][1],r[1][1],r[2][1],r[3][1]),Math.max(r[0][0],r[1][0],r[2][0],r[3][0]),Math.max(r[0][1],r[1][1],r[2][1],r[3][1])]}fitBounds(e,r={}){let{width:i,height:o}=this,{longitude:n,latitude:s,zoom:a}=Ma({width:i,height:o,bounds:e,...r});return new Wr({width:i,height:o,longitude:n,latitude:s,zoom:a})}};Wr.displayName="WebMercatorViewport";var _r=Wr;var hy=[0,0,0];function wu(t,e,r=!1){let i=e.projectPosition(t);if(r&&e instanceof _r){let[o,n,s=0]=t,a=e.getDistanceScales([o,n]);i[2]=s*a.unitsPerMeter[2]}return i}function z3(t){let{viewport:e,modelMatrix:r,coordinateOrigin:i}=t,{coordinateSystem:o,fromCoordinateSystem:n,fromCoordinateOrigin:s}=t;return o==="default"&&(o=e.isGeospatial?"lnglat":"cartesian"),n===void 0?n=o:n==="default"&&(n=e.isGeospatial?"lnglat":"cartesian"),s===void 0&&(s=i),{viewport:e,coordinateSystem:o,coordinateOrigin:i,modelMatrix:r,fromCoordinateSystem:n,fromCoordinateOrigin:s}}function Na(t,{viewport:e,modelMatrix:r,coordinateSystem:i,coordinateOrigin:o,offsetMode:n}){let[s,a,c=0]=t;switch(r&&([s,a,c]=Te.transformMat4([],[s,a,c,1],r)),i){case"default":return Na(t,{viewport:e,modelMatrix:r,coordinateSystem:e.isGeospatial?"lnglat":"cartesian",coordinateOrigin:o,offsetMode:n});case"lnglat":return wu([s,a,c],e,n);case"lnglat-offsets":return wu([s+o[0],a+o[1],c+(o[2]||0)],e,n);case"meter-offsets":return wu(sn(o,[s,a,c]),e,n);case"cartesian":return e.isGeospatial?[s+o[0],a+o[1],c+o[2]]:e.projectPosition([s,a,c]);default:throw new Error(`Invalid coordinateSystem: ${i}`)}}function Da(t,e){let{viewport:r,coordinateSystem:i,coordinateOrigin:o,modelMatrix:n,fromCoordinateSystem:s,fromCoordinateOrigin:a}=z3(e),{autoOffset:c=!0}=e,{geospatialOrigin:l=hy,shaderCoordinateOrigin:f=hy,offsetMode:h=!1}=c?gu(r,i,o):{},u=Na(t,{viewport:r,modelMatrix:n,coordinateSystem:s,coordinateOrigin:a,offsetMode:h});if(h){let d=r.projectPosition(l||f);de.sub(u,u,d)}return u}var W3=[255,255,255],j3=1,$3=[1,0,0],H3=[0,0,1],X3=0,ji=class{constructor(e={}){this.type="point";let{color:r=W3}=e,{intensity:i=j3}=e,{position:o=H3}=e;this.id=e.id||`point-${X3++}`,this.color=r,this.intensity=i,this.type="point",this.position=o,this.attenuation=Y3(e),this.projectedLight={...this}}getProjectedLight({layer:e}){let{projectedLight:r}=this,i=e.context.viewport,{coordinateSystem:o,coordinateOrigin:n}=e.props,s=Da(this.position,{viewport:i,coordinateSystem:o,coordinateOrigin:n,fromCoordinateSystem:i.isGeospatial?kr.LNGLAT:kr.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return r.color=this.color,r.intensity=this.intensity,r.position=s,r}};function Y3(t){return t.attenuation?t.attenuation:$3}var ln=class extends ji{getProjectedLight({layer:e}){let{projectedLight:r}=this,i=e.context.viewport,{coordinateSystem:o,coordinateOrigin:n,modelMatrix:s}=e.props,{cameraPosition:a}=wa({viewport:i,modelMatrix:s,coordinateSystem:o,coordinateOrigin:n});return r.color=this.color,r.intensity=this.intensity,r.position=a,r}};var jr=Math.PI/180,K3=1e3*60*60*24,Z3=2440588,q3=2451545,Ba=jr*23.4397,G3=357.5291,Q3=.98560028,J3=280.147,eP=360.9856235;function uy(t,e,r){let i=jr*-r,o=jr*e,n=rP(t),s=fP(n),a=aP(n,i)-s.rightAscension;return{azimuth:nP(a,o,s.declination),altitude:sP(a,o,s.declination)}}function Fa(t,e,r){let{azimuth:i,altitude:o}=uy(t,e,r);return[Math.sin(i)*Math.cos(o),Math.cos(i)*Math.cos(o),-Math.sin(o)]}function tP(t){return(typeof t=="number"?t:t.getTime())/K3-.5+Z3}function rP(t){return tP(t)-q3}function iP(t,e){let r=t;return Math.atan2(Math.sin(r)*Math.cos(Ba)-Math.tan(e)*Math.sin(Ba),Math.cos(r))}function oP(t,e){let r=t;return Math.asin(Math.sin(e)*Math.cos(Ba)+Math.cos(e)*Math.sin(Ba)*Math.sin(r))}function nP(t,e,r){let i=t,o=e,n=r;return Math.atan2(Math.sin(i),Math.cos(i)*Math.sin(o)-Math.tan(n)*Math.cos(o))}function sP(t,e,r){let i=t,o=e,n=r;return Math.asin(Math.sin(o)*Math.sin(n)+Math.cos(o)*Math.cos(n)*Math.cos(i))}function aP(t,e){return jr*(J3+eP*t)-e}function cP(t){return jr*(G3+Q3*t)}function lP(t){let e=t,r=jr*(1.9148*Math.sin(e)+.02*Math.sin(2*e)+3e-4*Math.sin(3*e)),i=jr*102.9372;return e+r+i+Math.PI}function fP(t){let e=cP(t),r=lP(e);return{declination:oP(r,0),rightAscension:iP(r,0)}}var fn=class extends Ut{constructor(e){super(e),this.timestamp=e.timestamp}getProjectedLight({layer:e}){let{viewport:r}=e.context;if(r.resolution&&r.resolution>0){let[o,n,s]=Fa(this.timestamp,0,0);this.direction=[o,-s,n]}else{let{latitude:o,longitude:n}=r;this.direction=Fa(this.timestamp,o,n)}return this}};var hP=`layout(std140) uniform screenUniforms {
|
|
1978
1978
|
vec2 texSize;
|
|
1979
1979
|
} screen;
|
|
1980
|
-
`,
|
|
1980
|
+
`,dy={name:"screen",fs:hP,uniformTypes:{texSize:"vec2<f32>"}};var hn=class extends zr{constructor(e,r){super(e,r);let{module:i,fs:o,id:n}=r,s={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 Io(e,{id:n,fs:o,modules:[i,dy],parameters:s})}render(e){this._renderPass(this.device,e)}delete(){this.model.destroy(),this.model=null}_renderPass(e,r){let{clearCanvas:i,inputBuffer:o,outputBuffer:n}=r,s=[o.width,o.height],a={texSrc:o.colorAttachments[0],texSize:s};this.model.shaderInputs.setProps({screen:a,...r.moduleProps});let c=this.device.beginRenderPass({framebuffer:n,parameters:{viewport:[0,0,...s]},clearColor:i?[0,0,0,0]:!1,clearDepth:1,clearStencil:!1});this.model.draw(c),c.end()}};var un=class{constructor(e,r){this.id=`${e.name}-pass`,this.props=r,Rs(e),this.module=e}setup({device:e}){this.passes=uP(e,this.module,this.id)}setProps(e){this.props=e}preRender(){}postRender(e){let r=this.passes,{target:i}=e,o=e.inputBuffer,n=e.swapBuffer;for(let s=0;s<r.length;s++){let a=s===r.length-1,c=i!==void 0&&a;c&&(n=i);let l=!c||Boolean(e.clearCanvas),f={},h=this.module.passes[s].uniforms;f[this.module.name]={...this.props,...h},r[s].render({clearCanvas:l,inputBuffer:o,outputBuffer:n,moduleProps:f});let u=n;n=o,o=u}return o}cleanup(){if(this.passes){for(let e of this.passes)e.delete();this.passes=void 0}}};function uP(t,e,r){return e.passes.map((i,o)=>{let n=gP(e,i),s=`${r}-${o}`;return new hn(t,{id:s,module:e,fs:n})})}var py=`#version 300 es
|
|
1981
1981
|
uniform sampler2D texSrc;
|
|
1982
1982
|
|
|
1983
1983
|
in vec2 position;
|
|
@@ -1985,19 +1985,19 @@ in vec2 coordinate;
|
|
|
1985
1985
|
in vec2 uv;
|
|
1986
1986
|
|
|
1987
1987
|
out vec4 fragColor;
|
|
1988
|
-
`,
|
|
1988
|
+
`,dP=t=>`${py}
|
|
1989
1989
|
void main() {
|
|
1990
1990
|
fragColor = texture(texSrc, coordinate);
|
|
1991
1991
|
fragColor = ${t}(fragColor, screen.texSize, coordinate);
|
|
1992
1992
|
}
|
|
1993
|
-
`,
|
|
1993
|
+
`,pP=t=>`${py}
|
|
1994
1994
|
void main() {
|
|
1995
1995
|
fragColor = ${t}(texSrc, screen.texSize, coordinate);
|
|
1996
1996
|
}
|
|
1997
|
-
`;function hP(t,e){if(e.filter){let r=typeof e.filter=="string"?e.filter:`${t.name}_filterColor_ext`;return lP(r)}if(e.sampler){let r=typeof e.sampler=="string"?e.sampler:`${t.name}_sampleColor`;return fP(r)}return""}var uP={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant",blendAlphaDstFactor:"zero"},Vt=class extends Ke{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):{decodePickingColor:null,stats:super._render(e)}}_drawPickingBuffer({layers:e,layerFilter:r,views:i,viewports:o,onViewportActive:n,pickingFBO:s,deviceRect:{x:a,y:c,width:l,height:f},cullRect:h,effects:u,pass:d="picking",pickZ:p,shaderModuleProps:g,clearColor:m}){this.pickZ=p;let _=this._resetColorEncoder(p),b=[a,c,l,f],y=super._render({target:s,layers:e,layerFilter:r,views:i,viewports:o,onViewportActive:n,cullRect:h,effects:u?.filter(S=>S.useInPicking),pass:d,isPicking:!0,shaderModuleProps:g,clearColor:m??[0,0,0,0],colorMask:15,scissorRect:b});return this._colorEncoderState=null,{decodePickingColor:_&&dP.bind(null,_),stats:y}}shouldDrawLayer(e){let{pickable:r,operation:i}=e.props;return r&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getShaderModuleProps(e,r,i){return{picking:{isActive:1,isAttribute:this.pickZ},lighting:{enabled:!1}}}getLayerParameters(e,r,i){let o={...e.props.parameters},{pickable:n,operation:s}=e.props;return this._colorEncoderState?n&&s.includes("draw")?(Object.assign(o,uP),o.blend=!0,this.device.type==="webgpu"?o.blendConstant=py(this._colorEncoderState,e,i):o.blendColor=py(this._colorEncoderState,e,i),s.includes("terrain")&&e.state?._hasPickingCover&&(o.blendAlphaSrcFactor="one")):s.includes("terrain")&&(o.blend=!1):o.blend=!1,o}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function py(t,e,r){let{byLayer:i,byAlpha:o}=t,n,s=i.get(e);return s?(s.viewports.push(r),n=s.a):(n=i.size+1,n<=255?(s={a:n,layer:e,viewports:[r]},i.set(e,s),o[n]=s):(L.warn("Too many pickable layers, only picking the first 255")(),n=0)),[0,0,0,n/255]}function dP(t,e){let r=t.byAlpha[e[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(e)}}var br={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"},ji=Symbol.for("component"),We=Symbol.for("propTypes"),Ba=Symbol.for("deprecatedProps"),zt=Symbol.for("asyncPropDefaults"),yt=Symbol.for("asyncPropOriginal"),qe=Symbol.for("asyncPropResolved");function Tr(t,e=()=>!0){return Array.isArray(t)?gy(t,e,[]):e(t)?[t]:[]}function gy(t,e,r){let i=-1;for(;++i<t.length;){let o=t[i];Array.isArray(o)?gy(o,e,r):e(o)&&r.push(o)}return r}function La({target:t,source:e,start:r=0,count:i=1}){let o=e.length,n=i*o,s=0;for(let a=r;s<o;s++)t[a++]=e[s];for(;s<n;)s<n-s?(t.copyWithin(r+s,r,r+s),s*=2):(t.copyWithin(r+s,r,r+n-s),s=n);return t}to();var un=class{constructor(e,r,i){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=i,this.setData(r)}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,r){if(e===this._data&&!r)return;this._data=e;let i=++this._loadCount,o=e;typeof e=="string"&&(o=ur(e)),o instanceof Promise?(this.isLoaded=!1,this._loader=o.then(n=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=n)}).catch(n=>{this._loadCount===i&&(this.isLoaded=!0,this._error=n||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let n of this._subscribers)n.onChange(this.getData())}};var dn=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:r,forceUpdate:i=!1,persistent:o=!0}){let n=this._resources[e];n?n.setData(r,i):(n=new un(e,r,this._context),this._resources[e]=n),n.persistent=o}remove(e){let r=this._resources[e];r&&(r.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let r=this._consumers[e];if(r){for(let i in r){let o=r[i],n=this._resources[o.resourceId];n&&n.unsubscribe(o)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:r,consumerId:i,requestId:o="default"}){let{_resources:n,protocol:s}=this;e.startsWith(s)&&(e=e.replace(s,""),n[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=n[e];if(this._track(i,o,a,r),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,r,i,o){let n=this._consumers,s=n[e]=n[e]||{},a=s[r],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),i&&(a?(a.onChange=o,a.resourceId=i.id):a={onChange:o,resourceId:i.id},s[r]=a,i.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let r=this._resources[e];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[e])}}};var pP="layerManager.setLayers",gP="layerManager.activateViewport",jr=class{constructor(e,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{G(gP,this,a),a&&(this.context.viewport=a)};let{deck:i,stats:o,viewport:n,timeline:s}=r||{};this.layers=[],this.resourceManager=new dn({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:Ca(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[ru],renderPass:void 0,stats:o||new Ne({id:"deck.gl"}),viewport:n||new Se({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:s||new Mr,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 r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let i of this.layers){let o=i.getNeedsRedraw(e);r=r||o}return r}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(r=>e.find(i=>r.id.indexOf(i)===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,r){G(pP,this,r,e),this._lastRenderedLayers=e;let i=Tr(e,Boolean);for(let o of i)o.context=this.context;this._updateLayers(this.layers,i)}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:r}=this.context;r.find(i=>i.name===e.name)||(r.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:r}=this.context,i=r.findIndex(o=>o.name===e.name);i>=0&&(r.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,r,i){i.raiseError(r,`${e} of ${i}`)}_updateLayers(e,r){let i={};for(let s of e)i[s.id]?L.warn(`Multiple old layers with same id ${s.id}`)():i[s.id]=s;if(this._defaultShaderModulesChanged){for(let s of e)s.setNeedsUpdate(),s.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let o=[];this._updateSublayersRecursively(r,i,o),this._finalizeOldLayers(i);let n=!1;for(let s of o)if(s.hasUniformTransition()){n=`Uniform transition in ${s}`;break}this._needsUpdate=n,this.layers=o}_updateSublayersRecursively(e,r,i){for(let o of e){o.context=this.context;let n=r[o.id];n===null&&L.warn(`Multiple new layers with same id ${o.id}`)(),r[o.id]=null;let s=null;try{this._debug&&n!==o&&o.validateProps(),n?(this._transferLayerState(n,o),this._updateLayer(o)):this._initializeLayer(o),i.push(o),s=o.isComposite?o.getSubLayers():null}catch(a){this._handleError("matching",a,o)}s&&this._updateSublayersRecursively(s,r,i)}}_finalizeOldLayers(e){for(let r in e){let i=e[r];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=br.INITIALIZED}catch(r){this._handleError("initialization",r,e)}}_transferLayerState(e,r){r._transferState(e),r.lifecycle=br.MATCHED,r!==e&&(e.lifecycle=br.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(r){this._handleError("update",r,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=br.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=br.FINALIZED}catch(r){this._handleError("finalization",r,e)}}};function Z(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!Z(t[i],e[i],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(let n of i)if(!e.hasOwnProperty(n)||!Z(t[n],e[n],r-1))return!1;return!0}return!1}var pn=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},this._pickPosition=e.pickPosition,Object.seal(this),this.setProps(e)}finalize(){for(let e in this.controllers){let r=this.controllers[e];r&&r.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(let e in this.controllers){let r=this.controllers[e];r&&r.updateTransition()}}getViewports(e){return e?this._viewports.filter(r=>r.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(r=>{e[r.id]=r}),e}getView(e){return this.views.find(r=>r.id===e)}getViewState(e){let r=typeof e=="string"?this.getView(e):e,i=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}unproject(e,r){let i=this.getViewports(),o={x:e[0],y:e[1]};for(let n=i.length-1;n>=0;--n){let s=i[n];if(s.containsPixel(o)){let a=e.slice();return a[0]-=s.x,a[1]-=s.y,s.unproject(a,r)}}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),"pickPosition"in e&&(this._pickPosition=e.pickPosition),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,r){(e!==this.width||r!==this.height)&&(this.width=e,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Tr(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!Z(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):L.warn("missing `viewState` or `initialViewState`")()}_createController(e,r){let i=r.type;return new i({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:n=>this.getView(e.id)?.makeViewport({viewState:n,width:this.width,height:this.height}),pickPosition:this._pickPosition})}_updateController(e,r,i,o){let n=e.controller;if(n&&i){let s={...r,...n,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return(!o||o.constructor!==n.type)&&(o=this._createController(e,s)),o&&o.setProps(s),o}return null}_rebuildViewports(){let{views:e}=this,r=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let o=e.length;o--;){let n=e[o],s=this.getViewState(n),a=n.makeViewport({viewState:s,width:this.width,height:this.height}),c=r[n.id],l=Boolean(n.controller);l&&!c&&(i=!0),(i||!l)&&c&&(c.finalize(),c=null),this.controllers[n.id]=this._updateController(n,s,a,c),a&&this._viewports.unshift(a)}for(let o in r){let n=r[o];n&&!this.controllers[o]&&n.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,r){return e.length!==r.length?!0:e.some((i,o)=>!e[o].equals(r[o]))}};var mP=/^(?:\d+\.?\d*|\.\d+)$/;function Wt(t){switch(typeof t){case"number":if(!Number.isFinite(t))throw new Error(`Could not parse position string ${t}`);return{type:"literal",value:t};case"string":try{let e=_P(t);return new Ru(e).parseExpression()}catch(e){let r=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${t}: ${r}`)}default:throw new Error(`Could not parse position string ${t}`)}}function wu(t,e){switch(t.type){case"literal":return t.value;case"percentage":return Math.round(t.value*e);case"binary":let r=wu(t.left,e),i=wu(t.right,e);return t.operator==="+"?r+i:r-i;default:throw new Error("Unknown layout expression type")}}function jt(t,e){return wu(t,e)}function _P(t){let e=[],r=0;for(;r<t.length;){let i=t[r];if(/\s/.test(i)){r++;continue}if(i==="+"||i==="-"||i==="("||i===")"||i==="%"){e.push({type:"symbol",value:i}),r++;continue}if(my(i)||i==="."){let o=r,n=i===".";for(r++;r<t.length;){let a=t[r];if(my(a)){r++;continue}if(a==="."&&!n){n=!0,r++;continue}break}let s=t.slice(o,r);if(!mP.test(s))throw new Error("Invalid number token");e.push({type:"number",value:parseFloat(s)});continue}if(_y(i)){let o=r;for(;r<t.length&&_y(t[r]);)r++;let n=t.slice(o,r).toLowerCase();e.push({type:"word",value:n});continue}throw new Error("Invalid token in position string")}return e}var Ru=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(),r=this.peek();for(;yP(r);){this.index++;let i=this.parseFactor();e={type:"binary",operator:r.value,left:e,right:i},r=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 r=this.parseFactor();return{type:"binary",operator:"-",left:{type:"literal",value:0},right:r}}if(e.type==="symbol"&&e.value==="("){this.index++;let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(e.type==="word"&&e.value==="calc"){if(this.index++,!this.consumeSymbol("("))throw new Error("Missing opening parenthesis after calc");let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(e.type==="number"){this.index++;let r=e.value,i=this.peek();return i&&i.type==="symbol"&&i.value==="%"?(this.index++,{type:"percentage",value:r/100}):i&&i.type==="word"&&i.value==="px"?(this.index++,{type:"literal",value:r}):{type:"literal",value:r}}throw new Error("Unexpected token in expression")}consumeSymbol(e){let r=this.peek();return r&&r.type==="symbol"&&r.value===e?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}};function my(t){return t>="0"&&t<="9"}function _y(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}function yP(t){return Boolean(t&&t.type==="symbol"&&(t.value==="+"||t.value==="-"))}function yy(t,e){let r={...t};for(let i in e)i!=="id"&&(Array.isArray(r[i])&&Array.isArray(e[i])?r[i]=bP(r[i],e[i]):r[i]=e[i]);return r}function bP(t,e){t=t.slice();for(let r=0;r<e.length;r++){let i=e[r];Number.isFinite(i)&&(t[r]=i)}return t}var ye=class{constructor(e){let{id:r,x:i=0,y:o=0,width:n="100%",height:s="100%",padding:a=null}=e;this.id=r||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=Wt(i),this._y=Wt(o),this._width=Wt(n),this._height=Wt(s),this._padding=a&&{left:Wt(a.left||0),right:Wt(a.right||0),top:Wt(a.top||0),bottom:Wt(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.constructor===e.constructor&&Z(this.props,e.props,2)}clone(e){let r=this.constructor;return new r({...this.props,...e})}makeViewport({width:e,height:r,viewState:i}){i=this.filterViewState(i);let o=this.getDimensions({width:e,height:r});if(!o.height||!o.width)return null;let n=this.getViewportType(i);return new n({...i,...this.props,...o})}getViewStateId(){let{viewState:e}=this.props;return typeof e=="string"?e:e?.id||this.id}filterViewState(e){return this.props.viewState&&typeof this.props.viewState=="object"?this.props.viewState.id?yy(e,this.props.viewState):this.props.viewState:e}getDimensions({width:e,height:r}){let i={x:jt(this._x,e),y:jt(this._y,r),width:jt(this._width,e),height:jt(this._height,r)};return this._padding&&(i.padding={left:jt(this._padding.left,e),top:jt(this._padding.top,r),right:jt(this._padding.right,e),bottom:jt(this._padding.bottom,r)}),i}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 Ge=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:r}=this;this._handle=e.addChannel({delay:e.getTime(),duration:r.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 by=()=>{},gn={BREAK:1,SNAP_TO_END:2,IGNORE:3},TP=t=>t,xP=gn.BREAK,mn=class{constructor(e){this._onTransitionUpdate=r=>{let{time:i,settings:{interpolator:o,startProps:n,endProps:s,duration:a,easing:c}}=r,l=c(i/a),f=o.interpolateProps(n,s,l);this.propsInTransition=this.getControllerState({...this.props,...f}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new Ge(e.timeline),this.onViewStateChange=e.onViewStateChange||by,this.onStateChange=e.onStateChange||by}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let r=!1,i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let o=i;if(this.transition.inProgress){let{interruption:n,endProps:s}=this.transition.settings;o={...i,...n===gn.SNAP_TO_END?s:this.propsInTransition||i}}this._triggerTransition(o,e),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:r,transitionInterpolator:i}=e;return(r>0||r==="auto")&&Boolean(i)}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,r){return this.transition.inProgress?this.transition.settings.interruption===gn.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(e,r):!0}_triggerTransition(e,r){let i=this.getControllerState(e),o=this.getControllerState(r).shortestPathFrom(i),n=r.transitionInterpolator,s=n.getDuration?n.getDuration(e,r):r.transitionDuration;if(s===0)return;let a=n.initializeProps(e,o);this.propsInTransition={};let c={duration:s,easing:r.transitionEasing||TP,interpolator:n,interruption:r.transitionInterruption||xP,startProps:a.start,endProps:a.end,onStart:r.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(r.onTransitionInterrupt),onEnd:this._onTransitionEnd(r.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(r)}}};function Y(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}var $t=class{constructor(e){let{compare:r,extract:i,required:o}=e;this._propsToCompare=r,this._propsToExtract=i||r,this._requiredProps=o}arePropsEqual(e,r){for(let i of this._propsToCompare)if(!(i in e)||!(i in r)||!Pe(e[i],r[i]))return!1;return!0}initializeProps(e,r){let i={},o={};for(let n of this._propsToExtract)(n in e||n in r)&&(i[n]=e[n],o[n]=r[n]);return this._checkRequiredProps(i),this._checkRequiredProps(o),{start:i,end:o}}getDuration(e,r){return r.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(r=>{let i=e[r];Y(Number.isFinite(i)||Array.isArray(i),`${r} is required for transition`)})}};var Fa=Math.PI/180,Ty=180/Math.PI,Ua=6370972,Ht=256;function AP(){let t=Ht/Ua,e=Math.PI/180*Ht;return{unitsPerMeter:[t,t,t],unitsPerMeter2:[0,0,0],metersPerUnit:[1/t,1/t,1/t],unitsPerDegree:[e,e,t],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/e,1/e,1/t]}}var ka=class extends Se{constructor(e={}){let{longitude:r=0,zoom:i=0,nearZMultiplier:o=.5,farZMultiplier:n=1,resolution:s=10}=e,{latitude:a=0,height:c,altitude:l=1.5,fovy:f}=e;a=Math.max(Math.min(a,me),-me),c=c||1,f?l=Ut(f):f=Ft(l);let h=Math.pow(2,i-bt(a)),u=e.nearZ??o,d=e.farZ??(l+Ht*2*h/c)*n,p=new z().lookAt({eye:[0,-l,0],up:[0,0,1]});p.rotateX(a*Fa),p.rotateZ(-r*Fa),p.scale(h/c),super({...e,height:c,viewMatrix:p,longitude:r,latitude:a,zoom:i,distanceScales:AP(),fovy:f,focalDistance:l,near:u,far:d}),this.scale=h,this.latitude=a,this.longitude=r,this.fovy=f,this.resolution=s}get projectionMode(){return oe.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){let r={targetZ:e.z||0},i=this.unproject([0,this.height/2],r),o=this.unproject([this.width/2,0],r),n=this.unproject([this.width,this.height/2],r),s=this.unproject([this.width/2,this.height],r);return n[0]<this.longitude&&(n[0]+=360),i[0]>this.longitude&&(i[0]-=360),[Math.min(i[0],n[0],o[0],s[0]),Math.min(i[1],n[1],o[1],s[1]),Math.max(i[0],n[0],o[0],s[0]),Math.max(i[1],n[1],o[1],s[1])]}unproject(e,{topLeft:r=!0,targetZ:i}={}){let[o,n,s]=e,a=r?n:this.height-n,{pixelUnprojectionMatrix:c}=this,l;if(Number.isFinite(s))l=Pu(c,[o,a,s,1]);else{let d=Pu(c,[o,a,-1,1]),p=Pu(c,[o,a,1,1]),g=((i||0)/Ua+1)*Ht,m=pe.sqrLen(pe.sub([],d,p)),_=pe.sqrLen(d),b=pe.sqrLen(p),T=4*((4*_*b-(m-_-b)**2)/16)/m,S=Math.sqrt(_-T),A=Math.sqrt(Math.max(0,g*g-T)),w=(S-A)/Math.sqrt(m);l=pe.lerp([],d,p,w)}let[f,h,u]=this.unprojectPosition(l);return Number.isFinite(s)?[f,h,u]:Number.isFinite(i)?[f,h,i]:[f,h]}projectPosition(e){let[r,i,o=0]=e,n=r*Fa,s=i*Fa,a=Math.cos(s),c=(o/Ua+1)*Ht;return[Math.sin(n)*a*c,-Math.cos(n)*a*c,Math.sin(s)*c]}unprojectPosition(e){let[r,i,o]=e,n=pe.len(e),s=Math.asin(o/n),c=Math.atan2(r,-i)*Ty,l=s*Ty,f=(n/Ht-1)*Ua;return[c,l,f]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition([e,r,i],o,n){let a=.25/Math.pow(2,this.zoom-bt(this.latitude)),c=e+a*(n[0]-o[0]),l=r-a*(n[1]-o[1]);l=Math.max(Math.min(l,me),-me);let f={longitude:c,latitude:l,zoom:i-bt(r)};return f.zoom+=bt(f.latitude),f}};ka.displayName="GlobeViewport";var $i=ka;function bt(t){let e=Math.PI*Math.cos(t*Math.PI/180);return Math.log2(e)}function Pu(t,e){let r=xe.transformMat4([],e,t);return xe.scale(r,r,1/r[3]),r}var SP=["longitude","latitude","zoom","bearing","pitch"],EP=["longitude","latitude","zoom"],ae=class extends $t{constructor(e={}){let r=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:SP,required:EP},super(i.transitionProps),this.opts=i}initializeProps(e,r){let i=super.initializeProps(e,r),{makeViewport:o,around:n}=this.opts;if(o&&n)if(o(e)instanceof $i)L.warn("around not supported in GlobeView")();else{let a=o(e),c=o(r),l=a.unproject(n);i.start.around=n,Object.assign(i.end,{around:c.project(l),aroundPosition:l,width:r.width,height:r.height})}return i}interpolateProps(e,r,i){let o={};for(let n of this._propsToExtract)o[n]=Ot(e[n]||0,r[n]||0,i);if(r.aroundPosition&&this.opts.makeViewport){let n=this.opts.makeViewport({...r,...o});Object.assign(o,n.panByPosition(r.aroundPosition,Ot(e.around,r.around,i)))}return o}};var Xt={transitionDuration:0},wP=300,Va=t=>1-(1-t)*(1-t),Hi={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],KEYBOARD:["keydown"]},$r={},be=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 mn({...e,getControllerState:r=>new this.ControllerState(r),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,this.pickPosition=e.pickPosition}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 r=this._eventStartBlocked;switch(e.type){case"panstart":return r?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return r?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"multipanstart":return r?!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:r,y:i}=this.props,{offsetCenter:o}=e;return[o.x-r,o.y-i]}isPointInBounds(e,r){let{width:i,height:o}=this.props;if(r&&r.handled)return!1;let n=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=o;return n&&r&&r.stopPropagation(),n}isFunctionKeyPressed(e){let{srcEvent:r}=e;return Boolean(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=r}setProps(e){e.dragMode&&(this.dragMode=e.dragMode);let r=this.props;this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:i}=e;this.inertia=Number.isFinite(i)?i:i===!0?wP:0;let{scrollZoom:o=!0,dragPan:n=!0,dragRotate:s=!0,doubleClickZoom:a=!0,touchZoom:c=!0,touchRotate:l=!1,keyboard:f=!0}=e,h=Boolean(this.onViewStateChange);if(this.toggleEvents(Hi.WHEEL,h&&o),this.toggleEvents(Hi.PAN,h),this.toggleEvents(Hi.PINCH,h&&(c||l)),this.toggleEvents(Hi.MULTI_PAN,h&&l),this.toggleEvents(Hi.DOUBLE_CLICK,h&&a),this.toggleEvents(Hi.KEYBOARD,h&&f),this.scrollZoom=o,this.dragPan=n,this.dragRotate=s,this.doubleClickZoom=a,this.touchZoom=c,this.touchRotate=l,this.keyboard=f,(!r||r.height!==e.height||r.width!==e.width||r.maxBounds!==e.maxBounds)&&e.maxBounds){let d=new this.ControllerState({...e,makeViewport:this.makeViewport}),p=d.getViewportProps();Object.keys(p).some(m=>!Z(p[m],e[m],1))&&this.updateViewport(d)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,r){this.eventManager&&e.forEach(i=>{this._events[i]!==r&&(this._events[i]=r,r?this.eventManager.on(i,this.handleEvent):this.eventManager.off(i,this.handleEvent))})}updateViewport(e,r=null,i={}){let o={...e.getViewportProps(),...r},n=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),n){let s=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:o,interactionState:this._interactionState,oldViewState:s,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 r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(i=!i);let o=this.controllerState[i?"panStart":"rotateStart"]({pos:r});return this._panMove=i,this.updateViewport(o,Xt,{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 r=this.getCenter(e),i=this.controllerState.pan({pos:r});return this.updateViewport(i,Xt,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:r}=this;if(this.dragPan&&r&&e.velocity){let i=this.getCenter(e),o=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],n=this.controllerState.pan({pos:o}).panEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Va},{isDragging:!1,isPanning:!0})}else{let i=this.controllerState.panEnd();this.updateViewport(i,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let r=this.getCenter(e),i=this.controllerState.rotate({pos:r});return this.updateViewport(i,Xt,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:r}=this;if(this.dragRotate&&r&&e.velocity){let i=this.getCenter(e),o=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],n=this.controllerState.rotate({pos:o}).rotateEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Va},{isDragging:!1,isRotating:!0})}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;e.srcEvent.preventDefault();let{speed:i=.01,smooth:o=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:n}=e,s=2/(1+Math.exp(-Math.abs(n*i)));n<0&&s!==0&&(s=1/s);let a=o?{...this._getTransitionProps({around:r}),transitionDuration:250}:Xt,c=this.controllerState.zoom({pos:r,scale:s});return this.updateViewport(c,a,{isZooming:!0,isPanning:!0}),o||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.rotateStart({pos:r});return this.updateViewport(i,Xt,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate||!this.isDragging())return!1;let r=this.getCenter(e);r[0]-=e.deltaX;let i=this.controllerState.rotate({pos:r});return this.updateViewport(i,Xt,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this;if(this.touchRotate&&r&&e.velocityY){let i=this.getCenter(e),o=[i[0],i[1]+=e.velocityY*r/2],n=this.controllerState.rotate({pos:o});this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Va},{isDragging:!1,isRotating:!0}),this.blockEvents(r)}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.zoomStart({pos:r}).rotateStart({pos:r});return $r._startPinchRotation=e.rotation,$r._lastPinchEvent=e,this.updateViewport(i,Xt,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:i}=e,o=this.getCenter(e);r=r.zoom({pos:o,scale:i})}if(this.touchRotate){let{rotation:i}=e;r=r.rotate({deltaAngleX:$r._startPinchRotation-i})}return this.updateViewport(r,Xt,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),$r._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:i}=$r;if(this.touchZoom&&r&&i&&e.scale!==i.scale){let o=this.getCenter(e),n=this.controllerState.rotateEnd(),s=Math.log2(e.scale),a=(s-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),c=Math.pow(2,s+a*r/2);n=n.zoom({pos:o,scale:c}).zoomEnd(),this.updateViewport(n,{...this._getTransitionProps({around:o}),transitionDuration:r,transitionEasing:Va},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let o=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(o,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return $r._startPinchRotation=null,$r._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e),o=this.controllerState.zoom({pos:r,scale:i?.5:2});return this.updateViewport(o,this._getTransitionProps({around:r}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(e),{zoomSpeed:i,moveSpeed:o,rotateSpeedX:n,rotateSpeedY:s}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(e.srcEvent.code){case"Minus":c=r?a.zoomOut(i).zoomOut(i):a.zoomOut(i),l.isZooming=!0;break;case"Equal":c=r?a.zoomIn(i).zoomIn(i):a.zoomIn(i),l.isZooming=!0;break;case"ArrowLeft":r?(c=a.rotateLeft(n),l.isRotating=!0):(c=a.moveLeft(o),l.isPanning=!0);break;case"ArrowRight":r?(c=a.rotateRight(n),l.isRotating=!0):(c=a.moveRight(o),l.isPanning=!0);break;case"ArrowUp":r?(c=a.rotateUp(s),l.isRotating=!0):(c=a.moveUp(o),l.isPanning=!0);break;case"ArrowDown":r?(c=a.rotateDown(s),l.isRotating=!0):(c=a.moveDown(o),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(e){let{transition:r}=this;return!r||!r.transitionInterpolator?Xt:e?{...r,transitionInterpolator:new ae({...e,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var Qe=class{constructor(e,r,i){this.makeViewport=i,this._viewportProps=this.applyConstraints(e),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};var xy=5,RP=1.2,Ay=512,Sy=[[-1/0,-90],[1/0,90]];function za([t,e]){if(Math.abs(e)>90&&(e=Math.sign(e)*90),Number.isFinite(t)){let[i,o]=Ae([t,e]);return[i,U(o,0,Ay)]}let[,r]=Ae([0,e]);return[t,U(r,0,Ay)]}var _n=class extends Qe{constructor(e){let{width:r,height:i,latitude:o,longitude:n,zoom:s,bearing:a=0,pitch:c=0,altitude:l=1.5,position:f=[0,0,0],maxZoom:h=20,minZoom:u=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:g,startZoomLngLat:m,startRotatePos:_,startRotateLngLat:b,startBearing:y,startPitch:T,startZoom:S,normalize:A=!0}=e;Y(Number.isFinite(n)),Y(Number.isFinite(o)),Y(Number.isFinite(s));let w=e.maxBounds||(A?Sy:null);super({width:r,height:i,latitude:o,longitude:n,zoom:s,bearing:a,pitch:c,altitude:l,maxZoom:h,minZoom:u,maxPitch:d,minPitch:p,normalize:A,position:f,maxBounds:w},{startPanLngLat:g,startZoomLngLat:m,startRotatePos:_,startRotateLngLat:b,startBearing:y,startPitch:T,startZoom:S},e.makeViewport),this.getAltitude=e.getAltitude}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:r}){let i=this.getState().startPanLngLat||this._unproject(r);if(!i)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){let r=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:r!==void 0?this._unproject3D(e,r):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:o,startRotateLngLat:n,startBearing:s,startPitch:a}=this.getState();if(!o||s===void 0||a===void 0)return this;let c;if(e?c=this._getNewRotation(e,o,a,s):c={bearing:s+r,pitch:a+i},n){let l=this.makeViewport({...this.getViewportProps(),...c}),f="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[f](n,o)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:o,startZoomLngLat:n}=this.getState();if(n||(o=this.getViewportProps().zoom,n=this._unproject(r)||this._unproject(e)),!n)return this;let s=this._constrainZoom(o+Math.log2(i)),a=this.makeViewport({...this.getViewportProps(),zoom:s});return this._getUpdatedState({zoom:s,...a.panByPosition(n,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 r=e.getViewportProps(),i={...this.getViewportProps()},{bearing:o,longitude:n}=i;return Math.abs(o-r.bearing)>180&&(i.bearing=o<0?o+360:o-360),Math.abs(n-r.longitude)>180&&(i.longitude=n<0?n+360:n-360),i}applyConstraints(e){let{maxPitch:r,minPitch:i,pitch:o,longitude:n,bearing:s,normalize:a,maxBounds:c}=e;if(a&&((n<-180||n>180)&&(e.longitude=_t(n+180,360)-180),(s<-180||s>180)&&(e.bearing=_t(s+180,360)-180)),e.pitch=U(o,i,r),e.zoom=this._constrainZoom(e.zoom,e),c){let l=za(c[0]),f=za(c[1]),h=2**e.zoom,u=e.width/2/h,d=e.height/2/h,[p,g]=_e([l[0]+u,l[1]+d]),[m,_]=_e([f[0]-u,f[1]-d]);e.longitude=U(e.longitude,p,m),e.latitude=U(e.latitude,g,_)}return e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{maxZoom:i,maxBounds:o}=r,n=o!==null&&r.width>0&&r.height>0,{minZoom:s}=r;if(n){let a=za(o[0]),c=za(o[1]),l=c[0]-a[0],f=c[1]-a[1];Number.isFinite(l)&&l>0&&(s=Math.max(s,Math.log2(r.width/l))),Number.isFinite(f)&&f>0&&(s=Math.max(s,Math.log2(r.height/f))),s>i&&(s=i)}return U(e,s,i)}_zoomFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.zoom({pos:[r/2,i/2],scale:e})}_panFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.pan({startPos:[r/2,i/2],pos:[r/2+e[0],i/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let r=this.makeViewport(this.getViewportProps());return e&&r.unproject(e)}_unproject3D(e,r){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:r})}_getNewRotation(e,r,i,o){let n=e[0]-r[0],s=e[1]-r[1],a=e[1],c=r[1],{width:l,height:f}=this.getViewportProps(),h=n/l,u=0;s>0?Math.abs(f-c)>xy&&(u=s/(c-f)*RP):s<0&&c>xy&&(u=1-a/c),u=U(u,-1,1);let{minPitch:d,maxPitch:p}=this.getViewportProps(),g=o+180*h,m=i;return u>0?m=i+u*(p-i):u<0&&(m=i-u*(d-i)),{pitch:m,bearing:g}}},Yt=class extends be{constructor(){super(...arguments),this.ControllerState=_n,this.transition={transitionDuration:300,transitionInterpolator:new ae({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=e=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:r,y:i}=this.props,o=this.pickPosition(r+e[0],i+e[1]);if(o&&o.coordinate&&o.coordinate.length>=3)return o.coordinate[2]}}}setProps(e){"rotationPivot"in e&&(this.rotationPivot=e.rotationPivot||"center"),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:Sy),super.setProps(e)}updateViewport(e,r=null,i={}){let o=e.getState();i.isDragging&&o.startRotateLngLat?i={...i,rotationPivotPosition:o.startRotateLngLat}:i.isDragging===!1&&(i={...i,rotationPivotPosition:void 0}),super.updateViewport(e,r,i)}};var Wa=class extends ye{constructor(e={}){super(e)}getViewportType(){return yr}get ControllerType(){return Yt}};Wa.displayName="MapView";var ja=Wa;var PP=new _r;function vP(t,e){let r=t.order??1/0,i=e.order??1/0;return r-i}var yn=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let r=this._defaultEffects;if(!r.find(i=>i.id===e.id)){let i=r.findIndex(o=>vP(o,e)>0);i<0?r.push(e):r.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(Z(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(e){let r={};for(let o of this.effects)r[o.id]=o;let i=[];for(let o of e){let n=r[o.id],s=o;n&&n!==o?n.setProps?(n.setProps(o.props),s=n):n.cleanup(this._context):n||o.setup(this._context),i.push(s),delete r[o.id]}for(let o in r)r[o].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(o=>o instanceof _r)||this._resolvedEffects.push(PP),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 bn=class extends Ke{shouldDrawLayer(e){let{operation:r}=e.props;return r.includes("draw")||r.includes("terrain")}render(e){return this._render(e)}};var MP="deckRenderer.renderLayers",Hr=class{constructor(e,r={}){this.device=e,this.stats=r.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new bn(e),this.pickLayersPass=new Vt(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 r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};i.effects&&this._preRender(i.effects,i);let o=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);let n=r.render({...i,target:o}),s="stats"in n?n.stats:n;i.effects&&(this.lastPostProcessEffect&&(i.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(i.effects,i)),this.renderCount++,G(MP,this,s,e),this._updateStats(s)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:e}=this;for(let r of e)r.delete();e.length=0}_updateStats(e){if(!this.stats)return;let r=0;for(let{visibleCount:i}of e)r+=i;this.stats.get("Layers rendered").addCount(r)}_preRender(e,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let i of e)r.preRenderStats[i.id]=i.preRender(r),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,r=this.device.canvasContext.getDrawingBufferSize(),[i,o]=r;e.length===0&&[0,1].map(n=>{let s=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:i,height:o});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${n}`,colorAttachments:[s]}))});for(let n of e)n.resize(r)}_postRender(e,r){let{renderBuffers:i}=this,o={...r,inputBuffer:i[0],swapBuffer:i[1]};for(let n of e)if(n.postRender){o.target=n.id===this.lastPostProcessEffect?r.target:void 0;let s=n.postRender(o);o.inputBuffer=s,o.swapBuffer=s===i[0]?i[1]:i[0]}}};F();var CP={pickedColor:null,pickedObjectIndex:-1};function vu({pickedColors:t,decodePickingColor:e,deviceX:r,deviceY:i,deviceRadius:o,deviceRect:n}){let{x:s,y:a,width:c,height:l}=n,f=o*o,h=-1,u=0;for(let d=0;d<l;d++){let p=d+a-i,g=p*p;if(g>f)u+=4*c;else for(let m=0;m<c;m++){if(t[u+3]-1>=0){let b=m+s-r,y=b*b+g;y<=f&&(f=y,h=u)}u+=4}}if(h>=0){let d=t.slice(h,h+4),p=e(d);if(p){let g=Math.floor(h/4/c),m=h/4-g*c;return{...p,pickedColor:d,pickedX:s+m,pickedY:a+g}}L.error("Picked non-existent layer. Is picking buffer corrupt?")()}return CP}function Mu({pickedColors:t,decodePickingColor:e}){let r=new Map;if(t){for(let i=0;i<t.length;i+=4)if(t[i+3]-1>=0){let n=t.slice(i,i+4),s=n.join(",");if(!r.has(s)){let a=e(n);a?r.set(s,{...a,color:n}):L.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function $a({pickInfo:t,viewports:e,pixelRatio:r,x:i,y:o,z:n}){let s=e[0];e.length>1&&(s=IP(t?.pickedViewports||e,{x:i,y:o}));let a;if(s){let c=[i-s.x,o-s.y];n!==void 0&&(c[2]=n),a=s.unproject(c)}return{color:null,layer:null,viewport:s,index:-1,picked:!1,x:i,y:o,pixel:[i,o],coordinate:a,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:r}}function Cu(t){let{pickInfo:e,lastPickedInfo:r,mode:i,layers:o}=t,{pickedColor:n,pickedLayer:s,pickedObjectIndex:a}=e,c=s?[s]:[];if(i==="hover"){let h=r.index,u=r.layerId,d=s?s.props.id:null;if(d!==u||a!==h){if(d!==u){let p=o.find(g=>g.props.id===u);p&&c.unshift(p)}r.layerId=d,r.index=a,r.info=null}}let l=$a(t),f=new Map;return f.set(null,l),c.forEach(h=>{let u={...l};h===s&&(u.color=n,u.index=a,u.picked=!0),u=Ha({layer:h,info:u,mode:i});let d=u.layer;h===s&&i==="hover"&&(r.info=u),f.set(d.id,u),i==="hover"&&d.updateAutoHighlight(u)}),f}function Ha({layer:t,info:e,mode:r}){for(;t&&e;){let i=e.layer||null;e.sourceLayer=i,e.layer=t,e=t.getPickingInfo({info:e,mode:r,sourceLayer:i}),t=t.parent}return e}function IP(t,e){for(let r=t.length-1;r>=0;r--){let i=t[r];if(i.containsPixel(e))return i}return t[0]}var Tn=class{constructor(e,r={}){this._pickable=!0,this.device=e,this.stats=r.stats,this.pickLayersPass=new Vt(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:r,layers:i,viewports:o},n=this.lastPickedInfo.info){let s=n&&n.layer&&n.layer.id,a=n&&n.viewport&&n.viewport.id,c=s?i.find(u=>u.id===s):null,l=a&&o.find(u=>u.id===a)||o[0],f=l&&l.unproject([e-l.x,r-l.y]);return{...n,...{x:e,y:r,viewport:l,coordinate:f,layer:c}}}_resizeBuffer(){if(!this.pickingFBO){let r=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:B.RENDER_ATTACHMENT|B.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[r],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){let i=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:B.RENDER_ATTACHMENT|B.COPY_SRC}),o=this.device.createFramebuffer({colorAttachments:[i],depthStencilAttachment:"depth16unorm"});this.depthFBO=o}}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 r=e.filter(i=>this.pickLayersPass.shouldDrawLayer(i)&&!i.isComposite);return r.length?r:null}async _pickClosestObjectAsync({layers:e,views:r,viewports:i,x:o,y:n,radius:s=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:f,effects:h}){let u=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||i.length===0)return{result:[],emptyInfo:$a({viewports:i,x:o,y:n,pixelRatio:u})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([o,n],!0),g=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(s*u),{width:_,height:b}=this.pickingFBO,y=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceWidth:_,deviceHeight:b}),T={x:o-s,y:n-s,width:s*2+1,height:s*2+1},S,A=[],w=new Set;for(let P=0;P<a;P++){let R;if(y){let C=await this._drawAndSampleAsync({layers:d,views:r,viewports:i,onViewportActive:f,deviceRect:y,cullRect:T,effects:h,pass:`picking:${c}`});R=vu({...C,deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceRect:y})}else R={pickedColor:null,pickedObjectIndex:-1};let v,O=this._getDepthLayers(R,d,l);if(O.length>0){let{pickedColors:C}=await this._drawAndSampleAsync({layers:O,views:r,viewports:i,onViewportActive:f,deviceRect:{x:R.pickedX??g[0],y:R.pickedY??g[1],width:1,height:1},cullRect:T,effects:h,pass:`picking:${c}:z`},!0);C[3]&&(v=C[0])}R.pickedLayer&&P+1<a&&(w.add(R.pickedLayer),R.pickedLayer.disablePickingIndex(R.pickedObjectIndex)),S=Cu({pickInfo:R,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:i,x:o,y:n,z:v,pixelRatio:u});for(let C of S.values())C.layer&&A.push(C);if(!R.pickedColor)break}for(let P of w)P.restorePickingColors();return{result:A,emptyInfo:S.get(null)}}_pickClosestObject({layers:e,views:r,viewports:i,x:o,y:n,radius:s=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:f,effects:h}){let u=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||i.length===0)return{result:[],emptyInfo:$a({viewports:i,x:o,y:n,pixelRatio:u})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([o,n],!0),g=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(s*u),{width:_,height:b}=this.pickingFBO,y=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceWidth:_,deviceHeight:b}),T={x:o-s,y:n-s,width:s*2+1,height:s*2+1},S,A=[],w=new Set;for(let P=0;P<a;P++){let R;if(y){let C=this._drawAndSample({layers:d,views:r,viewports:i,onViewportActive:f,deviceRect:y,cullRect:T,effects:h,pass:`picking:${c}`});R=vu({...C,deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceRect:y})}else R={pickedColor:null,pickedObjectIndex:-1};let v,O=this._getDepthLayers(R,d,l);if(O.length>0){let{pickedColors:C}=this._drawAndSample({layers:O,views:r,viewports:i,onViewportActive:f,deviceRect:{x:R.pickedX??g[0],y:R.pickedY??g[1],width:1,height:1},cullRect:T,effects:h,pass:`picking:${c}:z`},!0);C[3]&&(v=C[0])}R.pickedLayer&&P+1<a&&(w.add(R.pickedLayer),R.pickedLayer.disablePickingIndex(R.pickedObjectIndex)),S=Cu({pickInfo:R,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:i,x:o,y:n,z:v,pixelRatio:u});for(let C of S.values())C.layer&&A.push(C);if(!R.pickedColor)break}for(let P of w)P.restorePickingColors();return{result:A,emptyInfo:S.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:r,viewports:i,x:o,y:n,width:s=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:f,effects:h}){let u=this._getPickable(e);if(!u||i.length===0)return[];this._resizeBuffer();let d=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([o,n],!0),g=p.x,m=p.y+p.height,_=this.device.canvasContext.cssToDevicePixels([o+s,n+a],!0),b=_.x+_.width,y=_.y,T={x:g,y,width:b-g,height:m-y},S=await this._drawAndSampleAsync({layers:u,views:r,viewports:i,onViewportActive:f,deviceRect:T,cullRect:{x:o,y:n,width:s,height:a},effects:h,pass:`picking:${c}`}),A=Mu(S),w=new Map,P=[],R=Number.isFinite(l);for(let v=0;v<A.length&&!(R&&P.length>=l);v++){let O=A[v],C={color:O.pickedColor,layer:null,index:O.pickedObjectIndex,picked:!0,x:o,y:n,pixelRatio:d};C=Ha({layer:O.pickedLayer,info:C,mode:c});let W=C.layer.id;w.has(W)||w.set(W,new Set);let V=w.get(W),J=C.object??C.index;V.has(J)||(V.add(J),P.push(C))}return P}_pickVisibleObjects({layers:e,views:r,viewports:i,x:o,y:n,width:s=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:f,effects:h}){let u=this._getPickable(e);if(!u||i.length===0)return[];this._resizeBuffer();let d=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([o,n],!0),g=p.x,m=p.y+p.height,_=this.device.canvasContext.cssToDevicePixels([o+s,n+a],!0),b=_.x+_.width,y=_.y,T={x:g,y,width:b-g,height:m-y},S=this._drawAndSample({layers:u,views:r,viewports:i,onViewportActive:f,deviceRect:T,cullRect:{x:o,y:n,width:s,height:a},effects:h,pass:`picking:${c}`}),A=Mu(S),w=new Map,P=[],R=Number.isFinite(l);for(let v=0;v<A.length&&!(R&&P.length>=l);v++){let O=A[v],C={color:O.pickedColor,layer:null,index:O.pickedObjectIndex,picked:!0,x:o,y:n,pixelRatio:d};C=Ha({layer:O.pickedLayer,info:C,mode:c});let W=C.layer.id;w.has(W)||w.set(W,new Set);let V=w.get(W),J=C.object??C.index;V.has(J)||(V.add(J),P.push(C))}return P}async _drawAndSampleAsync({layers:e,views:r,viewports:i,onViewportActive:o,deviceRect:n,cullRect:s,effects:a,pass:c},l=!1){let f=l?this.depthFBO:this.pickingFBO,h={layers:e,layerFilter:this.layerFilter,views:r,viewports:i,onViewportActive:o,pickingFBO:f,deviceRect:n,cullRect:s,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let T of a)T.useInPicking&&(h.preRenderStats[T.id]=T.preRender(h));let{decodePickingColor:u,stats:d}=this.pickLayersPass.render(h);this._updateStats(d);let{x:p,y:g,width:m,height:_}=n,b=f.colorAttachments[0]?.texture;if(!b)throw new Error("Picking framebuffer color attachment is missing");let y=await this._readTextureDataAsync(b,{x:p,y:g,width:m,height:_},l?Float32Array:Uint8Array);if(!l){let T=!1;for(let S=3;S<y.length;S+=4)if(y[S]!==0){T=!0;break}!T&&y.length>0&&L.warn("Async pick readback returned only zero alpha values",{deviceRect:n,bytes:Array.from(y.subarray(0,Math.min(y.length,16)))})()}return{pickedColors:y,decodePickingColor:u}}async _readTextureDataAsync(e,r,i){let{width:o,height:n}=r,s=e.computeMemoryLayout(r),a=this.device.createBuffer({byteLength:s.byteLength,usage:I.COPY_DST|I.MAP_READ});try{e.readBuffer(r,a);let c=await a.readAsync(0,s.byteLength),l=i.BYTES_PER_ELEMENT;if(s.bytesPerRow%l!==0)throw new Error(`Texture readback row stride ${s.bytesPerRow} is not aligned to ${l}-byte elements.`);let f=new i(c.buffer,c.byteOffset,s.byteLength/l),h=o*4,u=s.bytesPerRow/l;if(u<h)throw new Error(`Texture readback row stride ${u} is smaller than packed row length ${h}.`);let d=new i(o*n*4);for(let p=0;p<n;p++){let g=p*u;d.set(f.subarray(g,g+h),p*h)}return d}finally{a.destroy()}}_drawAndSample({layers:e,views:r,viewports:i,onViewportActive:o,deviceRect:n,cullRect:s,effects:a,pass:c},l=!1){let f=l?this.depthFBO:this.pickingFBO,h={layers:e,layerFilter:this.layerFilter,views:r,viewports:i,onViewportActive:o,pickingFBO:f,deviceRect:n,cullRect:s,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let y of a)y.useInPicking&&(h.preRenderStats[y.id]=y.preRender(h));let{decodePickingColor:u,stats:d}=this.pickLayersPass.render(h);this._updateStats(d);let{x:p,y:g,width:m,height:_}=n,b=new(l?Float32Array:Uint8Array)(m*_*4);return this.device.readPixelsToArrayWebGL(f,{sourceX:p,sourceY:g,sourceWidth:m,sourceHeight:_,target:b}),{pickedColors:b,decodePickingColor:u}}_updateStats(e){if(!this.stats)return;let r=0;for(let{visibleCount:i}of e)r+=i;this.stats.get("Layers picked").addCount(r)}_getDepthLayers(e,r,i){if(!i||!this.depthFBO)return[];let{pickedLayer:o}=e,n=o?.state?.terrainDrawMode==="drape";return o&&!n?[o]:r.filter(s=>s.props.operation.includes("terrain"))}_getPickingRect({deviceX:e,deviceY:r,deviceRadius:i,deviceWidth:o,deviceHeight:n}){let s=Math.max(0,e-i),a=Math.max(0,r-i),c=Math.min(o,e+i+1)-s,l=Math.min(n,r+i+1)-a;return c<=0||l<=0?null:{x:s,y:a,width:c,height:l}}};var OP={"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}},NP="top-left",Ey="root",Xa=class{constructor({deck:e,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,r?.classList.add("deck-widget-container"),this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!Z(e.widgets,this.widgets,1)){let r=e.widgets.filter(Boolean);this._setWidgets(r)}}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(r=>r.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:r}){let i=e.reduce((o,n)=>(o[n.id]=n,o),{});for(let o of this.getWidgets()){let{viewId:n}=o;if(n){let s=i[n];s&&(o.onViewportChange&&o.onViewportChange(s),o.onRedraw?.({viewports:[s],layers:r}))}else{if(o.onViewportChange)for(let s of e)o.onViewportChange(s);o.onRedraw?.({viewports:e,layers:r})}}this.lastViewports=i,this._updateContainers()}onHover(e,r){for(let i of this.getWidgets()){let{viewId:o}=i;(!o||o===e.viewport?.id)&&i.onHover?.(e,r)}}onEvent(e,r){let i=Ni[r.type];if(i)for(let o of this.getWidgets()){let{viewId:n}=o;(!n||n===e.viewport?.id)&&o[i]?.(e,r)}}_setWidgets(e){let r={};for(let i of this.resolvedWidgets)r[i.id]=i;this.resolvedWidgets.length=0;for(let i of this.defaultWidgets)r[i.id]=null,this.resolvedWidgets.push(i);for(let i of e){let o=r[i.id];o?o.viewId!==i.viewId||o.placement!==i.placement?(this._removeWidget(o),this._addWidget(i)):i!==o&&(o.setProps(i.props),i=o):this._addWidget(i),r[i.id]=null,this.resolvedWidgets.push(i)}for(let i in r){let o=r[i];o&&this._removeWidget(o)}this.widgets=e}_addWidget(e){let{viewId:r=null,placement:i=NP}=e,o=e.props._container??r;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:r}),e.rootElement&&this._getContainer(o,i).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,r){if(e&&typeof e!="string")return e;let i=e||Ey,o=this.containers[i];o||(o=document.createElement("div"),o.style.pointerEvents="none",o.style.position="absolute",o.style.overflow="hidden",this.parentElement?.append(o),this.containers[i]=o);let n=o.querySelector(`.${r}`);return n||(n=globalThis.document.createElement("div"),n.className=r,n.style.position="absolute",n.style.zIndex="2",Object.assign(n.style,OP[r]),o.append(n)),n}_updateContainers(){let e=this.deck.width,r=this.deck.height;for(let i in this.containers){let o=this.lastViewports[i]||null,n=i===Ey||o,s=this.containers[i];n?(s.style.display="block",s.style.left=`${o?o.x:0}px`,s.style.top=`${o?o.y:0}px`,s.style.width=`${o?o.width:e}px`,s.style.height=`${o?o.height:r}px`):s.style.display="none"}}};function xn(t,e){e&&Object.entries(e).map(([r,i])=>{r.startsWith("--")?t.style.setProperty(r,i):t.style[r]=i})}function Ya(t,e){e&&Object.keys(e).map(r=>{r.startsWith("--")?t.style.removeProperty(r):t.style[r]=""})}var xr=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let r=this.props,i=this.rootElement;i&&r.className!==e.className&&(r.className&&i.classList.remove(r.className),e.className&&i.classList.add(e.className)),i&&!Z(r.style,e.style,1)&&(Ya(i,r.style),xn(i,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,r){this.deck?._onViewStateChange({viewId:e,viewState:r,interactionState:{}})}onCreateRootElement(){let e=["deck-widget",this.className,this.props.className],r=document.createElement("div");return e.filter(i=>typeof i=="string"&&i.length>0).forEach(i=>r.classList.add(i)),xn(r,this.props.style),r}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,r){}onClick(e,r){}onDrag(e,r){}onDragStart(e,r){}onDragEnd(e,r){}};xr.defaultProps={id:"widget",style:{},_container:null,className:""};var DP={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},An=class extends xr{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,DP),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:r}=this,i=r&&r.props.getTooltip;if(!i)return;let o=i(e);this.setTooltip(o,e.x,e.y)}setTooltip(e,r,i){let o=this.rootElement;if(o){if(typeof e=="string")o.innerText=e;else if(e)e.text&&(o.innerText=e.text),e.html&&(o.innerHTML=e.html),e.className&&(o.className=e.className);else{this.isVisible=!1,o.style.display="none";return}this.isVisible=!0,o.style.display="block",o.style.transform=`translate(${r}px, ${i}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(o.style,e.style)}}};An.defaultProps={...xr.defaultProps};F();Pc();to();function Sr(){}var $v=({isDragging:t})=>t?"grabbing":"grab",Kb={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",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:Sr,onWebGLInitialized:Sr,onResize:Sr,onViewStateChange:Sr,onInteractionStateChange:Sr,onBeforeRender:Sr,onAfterRender:Sr,onLoad:Sr,onError:t=>L.error(t.message,t.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:$v,getTooltip:null,debug:!1,drawPickingColors:!1},In=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 Ne({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=i=>{let{_pickRequest:o}=this;if(i.type==="pointerleave")o.x=-1,o.y=-1,o.radius=0;else{if(i.leftButton||i.rightButton)return;{let n=i.offsetCenter;if(!n)return;o.x=n.x,o.y=n.y,o.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:o.x,y:o.y}),o.event=i},this._onEvent=i=>{let o=Ni[i.type],n=i.offsetCenter;if(!o||!n||!this.layerManager)return;let s=this.layerManager.getLayers(),a=this._getInternalPickingMode();if(!a)return;if(a==="sync"){let l=i.type==="click"&&this._shouldUnproject3D(s)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(n.x,n.y,{unproject3D:!0},s))):this._getLastPointerDownPickingInfo(n.x,n.y,s);this._dispatchPickingEvent(l,i);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(n.x,n.y,s))).then(l=>{this._dispatchPickingEvent(l,i)}).catch(l=>this.props.onError?.(l))},this._onPointerDown=i=>{let o=i.offsetCenter;if(!o)return;let n=this._getInternalPickingMode();if(!n)return;let s=this.layerManager?.getLayers()||[],a=++this._pointerDownPickSequence;if(n==="sync"){let l=this._pickPointSync({x:o.x,y:o.y,radius:this.props.pickingRadius}),f=this._getFirstPickedInfo(l);this._lastPointerDownInfo=f,this._lastPointerDownInfoPromise=Promise.resolve(f);return}let c=this._pickPointAsync(this._getPointPickOptions(o.x,o.y,{},s)).then(l=>this._getFirstPickedInfo(l)).then(l=>(a===this._pointerDownPickSequence&&(this._lastPointerDownInfo=l),l)).catch(l=>{this.props.onError?.(l);let f=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(o.x,o.y,s):{};return a===this._pointerDownPickSequence&&(this._lastPointerDownInfo=f),f});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=c},this.props={...Kb,...e},e=this.props,e.viewState&&e.initialViewState&&L.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 r=this.device;if(!r&&e.gl){e.gl instanceof WebGLRenderingContext&&L.error("WebGL1 context not supported.")();let i=this.props.deviceProps?.onResize;r=Cn.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps,onResize:(o,n)=>{let{width:s,height:a}=o.canvas;o.setDrawingBufferSize(s,a),this._needsRedraw="Canvas resized",i?.(o,n)}})}r||(r=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(r,e),this.setProps(e),e._typedArrayManagerProps&&Ze.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=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&&L.removed("onLayerHover","onHover")(),"onLayerClick"in e&&L.removed("onLayerClick","onClick")(),e.initialViewState&&!Z(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._validateInternalPickingMode(),this._setCanvasSize(this.props);let r=Object.create(this.props);Object.assign(r,{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),L.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()),this.animationLoop?.setProps(r),e.useDevicePixels!==void 0&&this.device?.canvasContext?.setProps&&this.device.canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(r),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(r),this.effectManager.setProps(r),this.deckRenderer.setProps(r),this.deckPicker.setProps(r),this.widgetManager.setProps(r)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let i=this.viewManager.needsRedraw(e),o=this.layerManager.needsRedraw(e),n=this.effectManager.needsRedraw(e),s=this.deckRenderer.needsRedraw(e);return r=r||i||o||n||s,r}redraw(e){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=e||r,r&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(r):this._drawLayers(r))}get isInitialized(){return this.viewManager!==null}getViews(){return Y(this.viewManager),this.viewManager.views}getView(e){return Y(this.viewManager),this.viewManager.getView(e)}getViewports(e){return Y(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}async pickObjectAsync(e){let r=(await this._pickAsync("pickObjectAsync","pickObject Time",e)).result;return r.length?r[0]:null}async pickObjectsAsync(e){return await this._pickAsync("pickObjectsAsync","pickObjects Time",e)}pickObject(e){let r=this._pick("pickObject","pickObject Time",e).result;return r.length?r[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)}_pickPositionForController(e,r){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:e,y:r,radius:0,unproject3D:!0})}_addResources(e,r=!1){for(let i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:r})}_removeResources(e){for(let r of e)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){let{pickAsync:e}=this.props,r=this.device?.type||this.props.deviceProps?.type;if(e==="auto")return r==="webgpu"?"async":"sync";if(e==="sync"&&r==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:r}){return e[0]||r}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(r=>r.props.pickable==="3d")}_getPointPickOptions(e,r,i={},o=this.layerManager?.getLayers()||[]){return{x:e,y:r,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(o),...i}}_pickPointSync(e){return this._pick("pickObject","pickObject Time",e)}_pickPointAsync(e){return this._pickAsync("pickObjectAsync","pickObject Time",e)}_getLastPointerDownPickingInfo(e,r,i=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:r,layers:i,viewports:this.getViewports({x:e,y:r})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:r},i){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let o=r,n=!1;for(let s of e)o=s,n=s.layer?.onHover(s,i)||n;n||(this.props.onHover?.(o,i),this.widgetManager.onHover(o,i))}_dispatchPickingEvent(e,r){if(!this.layerManager||!this.widgetManager)return;let i=Ni[r.type];if(!i)return;let{layer:o}=e,n=o&&(o[i]||o.props[i]),s=this.props[i],a=!1;n&&(a=n.call(o,e,r)),a||(s?.(e,r),this.widgetManager.onEvent(e,r))}_pickAsync(e,r,i){Y(this.deckPicker);let{stats:o}=this;o.get("Pick Count").incrementCount(),o.get(r).timeStart();let n=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return o.get(r).timeEnd(),n}_pick(e,r,i){Y(this.deckPicker);let{stats:o}=this;o.get("Pick Count").incrementCount(),o.get(r).timeStart();let n=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return o.get(r).timeEnd(),n}_createCanvas(e){let r=e.canvas;return typeof r=="string"&&(r=document.getElementById(r),Y(r)),r||(r=document.createElement("canvas"),r.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(r.width=e.width),e.height&&typeof e.height=="number"&&(r.height=e.height),(e.parent||document.body).appendChild(r)),Object.assign(r.style,e.style),r}_setCanvasSize(e){if(!this.canvas)return;let{width:r,height:i}=e;if(r||r===0){let o=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=o}if(i||i===0){let o=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=o}}_updateCanvasSize(){let{canvas:e}=this;if(!e)return;let r=e.clientWidth??e.width,i=e.clientHeight??e.height;(r!==this.width||i!==this.height)&&(this.width=r,this.height=i,this.viewManager?.setProps({width:r,height:i}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:r,height:i}))}_createAnimationLoop(e,r){let{gl:i,onError:o}=r;return new yi({device:e,autoResizeDrawingBuffer:!i,autoResizeViewport:!1,onInitialize:n=>this._setDevice(n.device),onRender:this._onRenderFrame.bind(this),onError:o})}_createDevice(e){let r=this.props.deviceProps?.createCanvasContext,i=typeof r=="object"?r:void 0,o={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};o.adapters.includes(Cn)||o.adapters.push(Cn);let n={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0},s=this.props.deviceProps?.onResize;return Qt.createDevice({_reuseDevices:!0,type:"webgl",...o,createCanvasContext:{...n,...i,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0},onResize:(a,c)=>{this._needsRedraw="Canvas resized",s?.(a,c)}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,r=Array.isArray(e)?e:e?[e]:[new ja({id:"default-view"})];return r.length&&this.props.controller&&(r[0].props.controller=this.props.controller),r}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let r=e.event,i=this.layerManager?.getLayers()||[],o=this._getPointPickOptions(e.x,e.y,{radius:e.radius,mode:e.mode},i),n=this._getInternalPickingMode(),s=++this._hoverPickSequence;if(e.event=null,!n)return;if(n==="sync"){this._applyHoverCallbacks(this._pickPointSync(o),r);return}this._pickPointAsync(o).then(({result:a,emptyInfo:c})=>{s===this._hoverPickSequence&&this._applyHoverCallbacks({result:a,emptyInfo:c},r)}).catch(a=>this.props.onError?.(a))}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!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 r=new Mr;r.play(),this.animationLoop.attachTimeline(r);let i=this.props.parent?.querySelector(".deck-events-root")||this.canvas;this.eventManager=new Qo(i,{touchAction:this.props.touchAction,recognizers:Object.keys(uu).map(s=>{let[a,c,l,f]=uu[s],h=this.props.eventRecognizerOptions?.[s],u={...c,...h,event:s};return{recognizer:new a(u),recognizeWith:l,requestFailure:f}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let s in Ni)this.eventManager.on(s,this._onEvent);this.viewManager=new pn({timeline:r,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let o=this.viewManager.getViewports()[0];this.layerManager=new jr(this.device,{deck:this,stats:this.stats,viewport:o,timeline:r}),this.effectManager=new yn({deck:this,device:this.device}),this.deckRenderer=new Hr(this.device,{stats:this.stats}),this.deckPicker=new Tn(this.device,{stats:this.stats});let n=this.props.parent?.querySelector(".deck-widgets-root")||this.canvas?.parentElement;this.widgetManager=new Xa({deck:this,parentElement:n}),this.widgetManager.addDefault(new An),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,r){let{device:i,gl:o}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:o});let n={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(),...r};this.deckRenderer?.renderLayers(n),n.pass==="screen"&&this.widgetManager.onRedraw({viewports:n.viewports,layers:n.layers}),this.props.onAfterRender({device:i,gl:o})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),L.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let r=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:r},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 r=this.animationLoop.stats;e.get("GPU Time").addTime(r.get("GPU Time").lastTiming),e.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:r}=this;e.fps=r.get("frameRate").getHz(),e.setPropsTime=r.get("setProps Time").time,e.updateAttributesTime=r.get("Update Attributes").time,e.framesRedrawn=r.get("Redraw Count").count,e.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,e.pickCount=r.get("Pick Count").count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=r.get("Layers rendered").lastSampleCount,e.pickLayersCount=r.get("Layers picked").lastSampleCount,e.updateAttributesCount=r.get("Layers updated").count,e.updateAttributesCount=r.get("Attributes updated").count,e.gpuTime=r.get("GPU Time").time,e.cpuTime=r.get("CPU Time").time,e.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let i=Qt.stats.get("GPU Time and Memory");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}};In.defaultProps=Kb;In.VERSION=ha;var Ic=In;F();F();function Zb(t){switch(t){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return po(t)}}var qb=ue.getDataType.bind(ue);function On(t,e,r){if(e.size>4)return null;let i=r==="webgpu"&&e.type==="uint8"?"unorm8":e.type;return{attribute:t,format:e.size>1?`${i}x${e.size}`:e.type,byteOffset:e.offset||0}}function Er(t){return t.stride||t.size*t.bytesPerElement}function Gb(t,e){return t.type===e.type&&t.size===e.size&&Er(t)===Er(e)&&(t.offset||0)===(e.offset||0)}function id(t,e){e.offset&&L.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=Er(t),i=e.vertexOffset!==void 0?e.vertexOffset:t.vertexOffset||0,o=e.elementOffset||0,n=i*r+o*t.bytesPerElement+(t.offset||0);return{...e,offset:n,stride:r}}function Hv(t,e){let r=id(t,e);return{high:r,low:{...r,offset:r.offset+t.size*4}}}var Nn=class{constructor(e,r,i){this._buffer=null,this.device=e,this.id=r.id||"",this.size=r.size||1;let o=r.logicalType||r.type,n=o==="float64",{defaultValue:s}=r;s=Number.isFinite(s)?[s]:s||new Array(this.size).fill(0);let a;n?a="float32":!o&&r.isIndexed?a="uint32":a=o||"float32";let c=Zb(o||a);this.doublePrecision=n,n&&r.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...r,defaultType:c,defaultValue:s,logicalType:o,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...i,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*Er(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),Ze.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,r=null){let i={};if(this.state.constant){let o=this.value;if(r){let n=id(this.getAccessor(),r),s=n.offset/o.BYTES_PER_ELEMENT,a=n.size||this.size;i[e]=o.subarray(s,s+a)}else i[e]=o}else i[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,r=null){let i=this.getAccessor(),o=[],n={name:this.id,byteStride:Er(i)};if(this.doublePrecision){let s=Hv(i,r||{});o.push(On(e,{...i,...s.high},this.device.type),On(`${e}64Low`,{...i,...s.low},this.device.type))}else if(r){let s=id(i,r);o.push(On(e,{...i,...s},this.device.type))}else o.push(On(e,i,this.device.type));return n.attributes=o.filter(Boolean),n}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 r=Array.from(this.value);e=[r,r]}else{let{value:r,numInstances:i,size:o}=this,n=i*o;if(r&&n&&r.length>=n){let s=new Array(o).fill(1/0),a=new Array(o).fill(-1/0);for(let c=0;c<n;)for(let l=0;l<o;l++){let f=r[c++];f<s[l]&&(s[l]=f),f>a[l]&&(a[l]=f)}e=[s,a]}}return this.state.bounds=e,e}setData(e){let{state:r}=this,i;ArrayBuffer.isView(e)?i={value:e}:e instanceof I?i={buffer:e}:i=e;let o={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)o.type="float32";else{let s=qb(i.value);o.type=o.normalized?s.replace("int","norm"):s}o.bytesPerElement=i.value.BYTES_PER_ELEMENT,o.stride=Er(o)}if(r.bounds=null,i.constant){let n=i.value;if(n=this._normalizeValue(n,[],0),this.settings.normalized&&(n=this.normalizeConstant(n)),!(!r.constant||!this._areValuesEqual(n,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(n)?n:new Float32Array(n)}else if(i.buffer){let n=i.buffer;r.externalBuffer=n,r.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let n=i.value;r.externalBuffer=null,r.constant=!1,this.value=n;let{buffer:s}=this,a=Er(o),c=(o.vertexOffset||0)*a;if(this.doublePrecision&&n instanceof Float64Array&&(n=Ia(n,o)),this.settings.isIndexed){let f=this.settings.defaultType;n.constructor!==f&&(n=new f(n))}let l=n.byteLength+c+a*2;(!s||s.byteLength<l)&&(s=this._createBuffer(l)),s.write(n,c)}return this.setAccessor(o),!0}updateSubBuffer(e={}){this.state.bounds=null;let r=this.value,{startOffset:i=0,endOffset:o}=e;this.buffer.write(this.doublePrecision&&r instanceof Float64Array?Ia(r,{size:this.size,startIndex:i,endIndex:o}):r.subarray(i,o),i*r.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,r=!1){let{state:i}=this,o=i.allocatedValue,n=Ze.allocate(o,e+1,{size:this.size,type:this.settings.defaultType,copy:r});this.value=n;let{byteOffset:s}=this,{buffer:a}=this;return(!a||a.byteLength<n.byteLength+s)&&(a=this._createBuffer(n.byteLength+s),r&&o&&a.write(o instanceof Float64Array?Ia(o,this):o,s)),i.allocatedValue=n,i.constant=!1,i.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){let{value:r}=e;if(!ArrayBuffer.isView(r))throw new Error(`Attribute ${this.id} value is not TypedArray`);let i=this.settings.defaultType,o=!1;if(this.doublePrecision&&(o=r.BYTES_PER_ELEMENT<4),o)throw new Error(`Attribute ${this.id} does not support ${r.constructor.name}`);!(r instanceof i)&&this.settings.normalized&&!("normalized"in e)&&L.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case"snorm8":return new Float32Array(e).map(r=>(r+128)/255*2-1);case"snorm16":return new Float32Array(e).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(r=>r/255);case"unorm16":return new Float32Array(e).map(r=>r/65535);default:return e}}_normalizeValue(e,r,i){let{defaultValue:o,size:n}=this.settings;if(Number.isFinite(e))return r[i]=e,r;if(!e){let s=n;for(;--s>=0;)r[i+s]=o[s];return r}switch(n){case 4:r[i+3]=Number.isFinite(e[3])?e[3]:o[3];case 3:r[i+2]=Number.isFinite(e[2])?e[2]:o[2];case 2:r[i+1]=Number.isFinite(e[1])?e[1]:o[1];case 1:r[i+0]=Number.isFinite(e[0])?e[0]:o[0];break;default:let s=n;for(;--s>=0;)r[i+s]=Number.isFinite(e[s])?e[s]:o[s]}return r}_areValuesEqual(e,r){if(!e||!r)return!1;let{size:i}=this;for(let o=0;o<i;o++)if(e[o]!==r[o])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();let{isIndexed:r,type:i}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(r?I.INDEX:I.VERTEX)|I.COPY_DST,indexType:r?i:void 0,byteLength:e}),this._buffer}};var Qb=[],Jb=[];function Gi(t,e=0,r=1/0){let i=Qb,o={index:-1,data:t,target:[]};return t?typeof t[Symbol.iterator]=="function"?i=t:t.length>0&&(Jb.length=t.length,i=Jb):i=Qb,(e>0||Number.isFinite(r))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,r),o.index=e-1),{iterable:i,objectInfo:o}}function Oc(t){return t&&t[Symbol.asyncIterator]}function Nc(t,e){let{size:r,stride:i,offset:o,startIndices:n,nested:s}=e,a=t.BYTES_PER_ELEMENT,c=i?i/a:r,l=o?o/a:0,f=Math.floor((t.length-l)/c);return(h,{index:u,target:d})=>{if(!n){let _=u*c+l;for(let b=0;b<r;b++)d[b]=t[_+b];return d}let p=n[u],g=n[u+1]||f,m;if(s){m=new Array(g-p);for(let _=p;_<g;_++){let b=_*c+l;d=new Array(r);for(let y=0;y<r;y++)d[y]=t[b+y];m[_-p]=d}}else if(c===r)m=t.subarray(p*r+l,g*r+l);else{m=new t.constructor((g-p)*r);let _=0;for(let b=p;b<g;b++){let y=b*c+l;for(let T=0;T<r;T++)m[_++]=t[y+T]}}return m}}var e0=[],Dn=[[0,1/0]];function t0(t,e){if(t===Dn||(e[0]<0&&(e[0]=0),e[0]>=e[1]))return t;let r=[],i=t.length,o=0;for(let n=0;n<i;n++){let s=t[n];s[1]<e[0]?(r.push(s),o=n+1):s[0]>e[1]?r.push(s):e=[Math.min(s[0],e[0]),Math.max(s[1],e[1])]}return r.splice(o,0,e),r}var Yv={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function Dc(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});let r=t.type||"interpolation";return{...Yv[r],...e,...t,type:r}}var Kt=class extends Nn{constructor(e,r){super(e,r,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:Dn}),this.constant=!1,this.settings.update=r.update||(r.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 r=this.state.needsRedraw;return this.state.needsRedraw=r&&!e,r}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var r;(r=this.state).layoutChanged||(r.layoutChanged=!Gb(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:r}=this.settings,i=this.settings.transition,o=Array.isArray(r)?e[r.find(n=>e[n])]:e[r];return Dc(o,i)}setNeedsUpdate(e=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),r){let{startRow:i=0,endRow:o=1/0}=r;this.state.updateRanges=t0(this.state.updateRanges,[i,o])}else this.state.updateRanges=Dn}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=e0}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:r,settings:i}=this;return i.noAlloc?!1:i.update?(super.allocate(e,r.updateRanges!==Dn),!0):!1}updateBuffer({numInstances:e,data:r,props:i,context:o}){if(!this.needsUpdate())return!1;let{state:{updateRanges:n},settings:{update:s,noAlloc:a}}=this,c=!0;if(s){for(let[l,f]of n)s.call(o,this,{data:r,startRow:l,endRow:f,props:i,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,f]of n){let h=Number.isFinite(l)?this.getVertexOffset(l):0,u=Number.isFinite(f)?this.getVertexOffset(f):a||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:h,endOffset:u})}this._checkAttributeArray()}else c=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),c}setConstantValue(e,r){let i=this.device.type==="webgpu";if(i||r===void 0||typeof r=="function"){if(i&&typeof r!="function"){let s=this._normalizeValue(r,[],0);this._areValuesEqual(s,this.value)||this.setNeedsUpdate("WebGPU constant updated")}return!1}let o=this.settings.transform&&e?this.settings.transform.call(e,r):r;return this.setData({constant:!0,value:o})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0}setExternalBuffer(e){let{state:r}=this;return e?(this.clearNeedsUpdate(),r.lastExternalBuffer===e||(r.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e)),!0):(r.lastExternalBuffer=null,!1)}setBinaryValue(e,r=null){let{state:i,settings:o}=this;if(!e)return i.binaryValue=null,i.binaryAccessor=null,!1;if(o.noAlloc)return!1;if(i.binaryValue===e)return this.clearNeedsUpdate(),!0;if(i.binaryValue=e,this.setNeedsRedraw(),o.transform||r!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});let s=e;Y(ArrayBuffer.isView(s.value),`invalid ${o.accessor}`);let a=Boolean(s.size)&&s.size!==this.size;return i.binaryAccessor=Nc(s.value,{size:s.size||this.size,stride:s.stride,offset:s.offset,startIndices:r,nested:a}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){let{startIndices:r}=this;return(r?e<r.length?r[e]:this.numInstances:e)*this.size}getValue(){let e=this.settings.shaderAttributes,r=super.getValue();if(!e)return r;for(let i in e)Object.assign(r,super.getValue(i,e[i]));return r}getBufferLayout(e){this.state.layoutChanged=!1;let r=this.settings.shaderAttributes,i=super._getBufferLayout(),{stepMode:o}=this.settings;if(o==="dynamic"?i.stepMode=e?e.isInstanced?"instance":"vertex":"instance":i.stepMode=o??"vertex",!r)return i;for(let n in r){let s=super._getBufferLayout(n,r[n]);i.attributes.push(...s.attributes)}return i}_autoUpdater(e,{data:r,startRow:i,endRow:o,props:n,numInstances:s}){if(e.constant&&this.context.device.type!=="webgpu")return;let{settings:a,state:c,value:l,size:f,startIndices:h}=e,{accessor:u,transform:d}=a,p=c.binaryAccessor||(typeof u=="function"?u:n[u]);typeof p!="function"&&typeof u=="string"&&(p=()=>n[u]),Y(typeof p=="function",`accessor "${u}" is not a function`);let g=e.getVertexOffset(i),{iterable:m,objectInfo:_}=Gi(r,i,o);for(let b of m){_.index++;let y=p(b,_);if(d&&(y=d.call(this,y)),h){let T=(_.index<h.length-1?h[_.index+1]:s)-h[_.index];if(y&&Array.isArray(y[0])){let S=g;for(let A of y)e._normalizeValue(A,l,S),S+=f}else y&&y.length>f?l.set(y,g):(e._normalizeValue(y,_.target,0),La({target:l,source:_.target,start:g,count:T}));g+=T*f}else e._normalizeValue(y,l,g),g+=f}}_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,r=Math.min(4,this.size);if(e&&e.length>=r){let i=!0;switch(r){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function od(t){let{source:e,target:r,start:i=0,size:o,getData:n}=t,s=t.end||r.length,a=e.length,c=s-i;if(a>c){r.set(e.subarray(0,c),i);return}if(r.set(e,i),!n)return;let l=a;for(;l<c;){let f=n(l,e);for(let h=0;h<o;h++)r[i+l]=f[h]||0,l++}}function r0({source:t,target:e,size:r,getData:i,sourceStartIndices:o,targetStartIndices:n}){if(!o||!n)return od({source:t,target:e,size:r,getData:i}),e;let s=0,a=0,c=i&&((f,h)=>i(f+a,h)),l=Math.min(o.length,n.length);for(let f=1;f<l;f++){let h=o[f]*r,u=n[f]*r;od({source:t.subarray(s,h),target:e,start:a,end:u,size:r,getData:c}),s=h,a=u}return a<e.length&&od({source:[],target:e,start:a,size:r,getData:c}),e}function i0(t){let{device:e,settings:r,value:i}=t,o=new Kt(e,r);return o.setData({value:i instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:r.normalized}),o}function Bc(t){switch(t){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 "${t}"`)}}function Lc(t){switch(t){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function Fc(t){t.push(t.shift())}function o0(t,e){let{doublePrecision:r,settings:i,value:o,size:n}=t,s=r&&o instanceof Float64Array?2:1,a=0,{shaderAttributes:c}=t.settings;if(c)for(let l of Object.values(c))a=Math.max(a,l.vertexOffset??0);return(i.noAlloc?o.length:(e+a)*n)*s}function Uc({device:t,source:e,target:r}){return(!r||r.byteLength<e.byteLength)&&(r?.destroy(),r=t.createBuffer({byteLength:e.byteLength,usage:e.usage})),r}function kc({device:t,buffer:e,attribute:r,fromLength:i,toLength:o,fromStartIndices:n,getData:s=a=>a}){let a=r.doublePrecision&&r.value instanceof Float64Array?2:1,c=r.size*a,l=r.byteOffset,f=r.settings.bytesPerElement<4?l/r.settings.bytesPerElement*4:l,h=r.startIndices,u=n&&h,d=r.isConstant;if(!u&&e&&i>=o)return e;let p=r.value instanceof Float64Array?Float32Array:r.value.constructor,g=d?r.value:new p(r.getBuffer().readSyncWebGL(l,o*p.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!d){let y=s;s=(T,S)=>r.normalizeConstant(y(T,S))}let m=d?(y,T)=>s(g,T):(y,T)=>s(g.subarray(y+l,y+l+c),T),_=e?new Float32Array(e.readSyncWebGL(f,i*4).buffer):new Float32Array(0),b=new Float32Array(o);return r0({source:_,target:b,sourceStartIndices:n,targetStartIndices:h,size:c,getData:m}),(!e||e.byteLength<b.byteLength+f)&&(e?.destroy(),e=t.createBuffer({byteLength:b.byteLength+f,usage:35050})),e.write(b,f),e}var Qi=class{constructor({device:e,attribute:r,timeline:i}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new Ge(i),this.attribute=r,this.attributeInTransition=i0(r),this.currentStartIndices=r.startIndices}get inProgress(){return this.transition.inProgress}start(e,r,i=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=o0(this.attribute,r),this.transition.start({...e,duration:i})}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 Bn=class extends Qi{constructor({device:e,attribute:r,timeline:i}){super({device:e,attribute:r,timeline:i}),this.type="interpolation",this.transform=Gv(e,r)}start(e,r){let i=this.currentLength,o=this.currentStartIndices;if(super.start(e,r,e.duration),e.duration<=0){this.transition.cancel();return}let{buffers:n,attribute:s}=this;Fc(n),n[0]=kc({device:this.device,buffer:n[0],attribute:s,fromLength:i,toLength:this.currentLength,fromStartIndices:o,getData:e.enter}),n[1]=Uc({device:this.device,source:n[0],target:n[1]}),this.setBuffer(n[1]);let{transform:a}=this,c=a.model,l=Math.floor(this.currentLength/s.size);s0(s)&&(l/=2),c.setVertexCount(l),s.isConstant?(c.setAttributes({aFrom:n[0]}),c.setConstantAttributes({aTo:s.value})):c.setAttributes({aFrom:n[0],aTo:s.getBuffer()}),a.transformFeedback.setBuffers({vCurrent:n[1]})}onUpdate(){let{duration:e,easing:r}=this.settings,{time:i}=this.transition,o=i/e;r&&(o=r(o));let{model:n}=this.transform,s={time:o};n.shaderInputs.setProps({interpolation:s}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},Kv=`layout(std140) uniform interpolationUniforms {
|
|
1997
|
+
`;function gP(t,e){if(e.filter){let r=typeof e.filter=="string"?e.filter:`${t.name}_filterColor_ext`;return dP(r)}if(e.sampler){let r=typeof e.sampler=="string"?e.sampler:`${t.name}_sampleColor`;return pP(r)}return""}var mP={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant",blendAlphaDstFactor:"zero"},kt=class extends Ye{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):{decodePickingColor:null,stats:super._render(e)}}_drawPickingBuffer({layers:e,layerFilter:r,views:i,viewports:o,onViewportActive:n,pickingFBO:s,deviceRect:{x:a,y:c,width:l,height:f},cullRect:h,effects:u,pass:d="picking",pickZ:p,shaderModuleProps:g,clearColor:m}){this.pickZ=p;let _=this._resetColorEncoder(p),b=[a,c,l,f],y=super._render({target:s,layers:e,layerFilter:r,views:i,viewports:o,onViewportActive:n,cullRect:h,effects:u?.filter(S=>S.useInPicking),pass:d,isPicking:!0,shaderModuleProps:g,clearColor:m??[0,0,0,0],colorMask:15,scissorRect:b});return this._colorEncoderState=null,{decodePickingColor:_&&_P.bind(null,_),stats:y}}shouldDrawLayer(e){let{pickable:r,operation:i}=e.props;return r&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getShaderModuleProps(e,r,i){return{picking:{isActive:1,isAttribute:this.pickZ},lighting:{enabled:!1}}}getLayerParameters(e,r,i){let o={...e.props.parameters},{pickable:n,operation:s}=e.props;return this._colorEncoderState?n&&s.includes("draw")?(Object.assign(o,mP),o.blend=!0,this.device.type==="webgpu"?o.blendConstant=gy(this._colorEncoderState,e,i):o.blendColor=gy(this._colorEncoderState,e,i),s.includes("terrain")&&e.state?._hasPickingCover&&(o.blendAlphaSrcFactor="one")):s.includes("terrain")&&(o.blend=!1):o.blend=!1,o}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}};function gy(t,e,r){let{byLayer:i,byAlpha:o}=t,n,s=i.get(e);return s?(s.viewports.push(r),n=s.a):(n=i.size+1,n<=255?(s={a:n,layer:e,viewports:[r]},i.set(e,s),o[n]=s):(F.warn("Too many pickable layers, only picking the first 255")(),n=0)),[0,0,0,n/255]}function _P(t,e){let r=t.byAlpha[e[3]];return r&&{pickedLayer:r.layer,pickedViewports:r.viewports,pickedObjectIndex:r.layer.decodePickingColor(e)}}var yr={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"},$i=Symbol.for("component"),ze=Symbol.for("propTypes"),La=Symbol.for("deprecatedProps"),Vt=Symbol.for("asyncPropDefaults"),_t=Symbol.for("asyncPropOriginal"),Ze=Symbol.for("asyncPropResolved");function br(t,e=()=>!0){return Array.isArray(t)?my(t,e,[]):e(t)?[t]:[]}function my(t,e,r){let i=-1;for(;++i<t.length;){let o=t[i];Array.isArray(o)?my(o,e,r):e(o)&&r.push(o)}return r}function Ua({target:t,source:e,start:r=0,count:i=1}){let o=e.length,n=i*o,s=0;for(let a=r;s<o;s++)t[a++]=e[s];for(;s<n;)s<n-s?(t.copyWithin(r+s,r,r+s),s*=2):(t.copyWithin(r+s,r,r+n-s),s=n);return t}ro();var dn=class{constructor(e,r,i){this._loadCount=0,this._subscribers=new Set,this.id=e,this.context=i,this.setData(r)}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,r){if(e===this._data&&!r)return;this._data=e;let i=++this._loadCount,o=e;typeof e=="string"&&(o=hr(e)),o instanceof Promise?(this.isLoaded=!1,this._loader=o.then(n=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=n)}).catch(n=>{this._loadCount===i&&(this.isLoaded=!0,this._error=n||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(let n of this._subscribers)n.onChange(this.getData())}};var pn=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:r,forceUpdate:i=!1,persistent:o=!0}){let n=this._resources[e];n?n.setData(r,i):(n=new dn(e,r,this._context),this._resources[e]=n),n.persistent=o}remove(e){let r=this._resources[e];r&&(r.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){let r=this._consumers[e];if(r){for(let i in r){let o=r[i],n=this._resources[o.resourceId];n&&n.unsubscribe(o)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:r,consumerId:i,requestId:o="default"}){let{_resources:n,protocol:s}=this;e.startsWith(s)&&(e=e.replace(s,""),n[e]||this.add({resourceId:e,data:null,persistent:!1}));let a=n[e];if(this._track(i,o,a,r),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,r,i,o){let n=this._consumers,s=n[e]=n[e]||{},a=s[r],c=a&&a.resourceId&&this._resources[a.resourceId];c&&(c.unsubscribe(a),this.prune()),i&&(a?(a.onChange=o,a.resourceId=i.id):a={onChange:o,resourceId:i.id},s[r]=a,i.subscribe(a))}_prune(){this._pruneRequest=null;for(let e of Object.keys(this._resources)){let r=this._resources[e];!r.persistent&&!r.inUse()&&(r.delete(),delete this._resources[e])}}};var yP="layerManager.setLayers",bP="layerManager.activateViewport",$r=class{constructor(e,r){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=a=>{q(bP,this,a),a&&(this.context.viewport=a)};let{deck:i,stats:o,viewport:n,timeline:s}=r||{};this.layers=[],this.resourceManager=new pn({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:Ia(e?.info?.shadingLanguage||"glsl"),defaultShaderModules:[ou],renderPass:void 0,stats:o||new Oe({id:"deck.gl"}),viewport:n||new Ae({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:s||new vr,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 r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(let i of this.layers){let o=i.getNeedsRedraw(e);r=r||o}return r}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(r=>e.find(i=>r.id.indexOf(i)===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,r){q(yP,this,r,e),this._lastRenderedLayers=e;let i=br(e,Boolean);for(let o of i)o.context=this.context;this._updateLayers(this.layers,i)}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:r}=this.context;r.find(i=>i.name===e.name)||(r.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){let{defaultShaderModules:r}=this.context,i=r.findIndex(o=>o.name===e.name);i>=0&&(r.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,r,i){i.raiseError(r,`${e} of ${i}`)}_updateLayers(e,r){let i={};for(let s of e)i[s.id]?F.warn(`Multiple old layers with same id ${s.id}`)():i[s.id]=s;if(this._defaultShaderModulesChanged){for(let s of e)s.setNeedsUpdate(),s.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}let o=[];this._updateSublayersRecursively(r,i,o),this._finalizeOldLayers(i);let n=!1;for(let s of o)if(s.hasUniformTransition()){n=`Uniform transition in ${s}`;break}this._needsUpdate=n,this.layers=o}_updateSublayersRecursively(e,r,i){for(let o of e){o.context=this.context;let n=r[o.id];n===null&&F.warn(`Multiple new layers with same id ${o.id}`)(),r[o.id]=null;let s=null;try{this._debug&&n!==o&&o.validateProps(),n?(this._transferLayerState(n,o),this._updateLayer(o)):this._initializeLayer(o),i.push(o),s=o.isComposite?o.getSubLayers():null}catch(a){this._handleError("matching",a,o)}s&&this._updateSublayersRecursively(s,r,i)}}_finalizeOldLayers(e){for(let r in e){let i=e[r];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=yr.INITIALIZED}catch(r){this._handleError("initialization",r,e)}}_transferLayerState(e,r){r._transferState(e),r.lifecycle=yr.MATCHED,r!==e&&(e.lifecycle=yr.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(r){this._handleError("update",r,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=yr.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=yr.FINALIZED}catch(r){this._handleError("finalization",r,e)}}};function K(t,e,r){if(t===e)return!0;if(!r||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let i=0;i<t.length;i++)if(!K(t[i],e[i],r-1))return!1;return!0}if(Array.isArray(e))return!1;if(typeof t=="object"&&typeof e=="object"){let i=Object.keys(t),o=Object.keys(e);if(i.length!==o.length)return!1;for(let n of i)if(!e.hasOwnProperty(n)||!K(t[n],e[n],r-1))return!1;return!0}return!1}var gn=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},this._pickPosition=e.pickPosition,Object.seal(this),this.setProps(e)}finalize(){for(let e in this.controllers){let r=this.controllers[e];r&&r.finalize()}this.controllers={}}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e,this._needsRedraw=this._needsRedraw||e}updateViewStates(){for(let e in this.controllers){let r=this.controllers[e];r&&r.updateTransition()}}getViewports(e){return e?this._viewports.filter(r=>r.containsPixel(e)):this._viewports}getViews(){let e={};return this.views.forEach(r=>{e[r.id]=r}),e}getView(e){return this.views.find(r=>r.id===e)}getViewState(e){let r=typeof e=="string"?this.getView(e):e,i=r&&this.viewState[r.getViewStateId()]||this.viewState;return r?r.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}unproject(e,r){let i=this.getViewports(),o={x:e[0],y:e[1]};for(let n=i.length-1;n>=0;--n){let s=i[n];if(s.containsPixel(o)){let a=e.slice();return a[0]-=s.x,a[1]-=s.y,s.unproject(a,r)}}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),"pickPosition"in e&&(this._pickPosition=e.pickPosition),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,r){(e!==this.width||r!==this.height)&&(this.width=e,this.height=r,this.setNeedsUpdate("Size changed"))}_setViews(e){e=br(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!K(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):F.warn("missing `viewState` or `initialViewState`")()}_createController(e,r){let i=r.type;return new i({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:n=>this.getView(e.id)?.makeViewport({viewState:n,width:this.width,height:this.height}),pickPosition:this._pickPosition})}_updateController(e,r,i,o){let n=e.controller;if(n&&i){let s={...r,...n,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return(!o||o.constructor!==n.type)&&(o=this._createController(e,s)),o&&o.setProps(s),o}return null}_rebuildViewports(){let{views:e}=this,r=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let o=e.length;o--;){let n=e[o],s=this.getViewState(n),a=n.makeViewport({viewState:s,width:this.width,height:this.height}),c=r[n.id],l=Boolean(n.controller);l&&!c&&(i=!0),(i||!l)&&c&&(c.finalize(),c=null),this.controllers[n.id]=this._updateController(n,s,a,c),a&&this._viewports.unshift(a)}for(let o in r){let n=r[o];n&&!this.controllers[o]&&n.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,r){return e.length!==r.length?!0:e.some((i,o)=>!e[o].equals(r[o]))}};var TP=/^(?:\d+\.?\d*|\.\d+)$/;function zt(t){switch(typeof t){case"number":if(!Number.isFinite(t))throw new Error(`Could not parse position string ${t}`);return{type:"literal",value:t};case"string":try{let e=xP(t);return new Pu(e).parseExpression()}catch(e){let r=e instanceof Error?e.message:String(e);throw new Error(`Could not parse position string ${t}: ${r}`)}default:throw new Error(`Could not parse position string ${t}`)}}function Ru(t,e){switch(t.type){case"literal":return t.value;case"percentage":return Math.round(t.value*e);case"binary":let r=Ru(t.left,e),i=Ru(t.right,e);return t.operator==="+"?r+i:r-i;default:throw new Error("Unknown layout expression type")}}function Wt(t,e){return Ru(t,e)}function xP(t){let e=[],r=0;for(;r<t.length;){let i=t[r];if(/\s/.test(i)){r++;continue}if(i==="+"||i==="-"||i==="("||i===")"||i==="%"){e.push({type:"symbol",value:i}),r++;continue}if(_y(i)||i==="."){let o=r,n=i===".";for(r++;r<t.length;){let a=t[r];if(_y(a)){r++;continue}if(a==="."&&!n){n=!0,r++;continue}break}let s=t.slice(o,r);if(!TP.test(s))throw new Error("Invalid number token");e.push({type:"number",value:parseFloat(s)});continue}if(yy(i)){let o=r;for(;r<t.length&&yy(t[r]);)r++;let n=t.slice(o,r).toLowerCase();e.push({type:"word",value:n});continue}throw new Error("Invalid token in position string")}return e}var Pu=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(),r=this.peek();for(;AP(r);){this.index++;let i=this.parseFactor();e={type:"binary",operator:r.value,left:e,right:i},r=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 r=this.parseFactor();return{type:"binary",operator:"-",left:{type:"literal",value:0},right:r}}if(e.type==="symbol"&&e.value==="("){this.index++;let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(e.type==="word"&&e.value==="calc"){if(this.index++,!this.consumeSymbol("("))throw new Error("Missing opening parenthesis after calc");let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(e.type==="number"){this.index++;let r=e.value,i=this.peek();return i&&i.type==="symbol"&&i.value==="%"?(this.index++,{type:"percentage",value:r/100}):i&&i.type==="word"&&i.value==="px"?(this.index++,{type:"literal",value:r}):{type:"literal",value:r}}throw new Error("Unexpected token in expression")}consumeSymbol(e){let r=this.peek();return r&&r.type==="symbol"&&r.value===e?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}};function _y(t){return t>="0"&&t<="9"}function yy(t){return t>="a"&&t<="z"||t>="A"&&t<="Z"}function AP(t){return Boolean(t&&t.type==="symbol"&&(t.value==="+"||t.value==="-"))}function by(t,e){let r={...t};for(let i in e)i!=="id"&&(Array.isArray(r[i])&&Array.isArray(e[i])?r[i]=SP(r[i],e[i]):r[i]=e[i]);return r}function SP(t,e){t=t.slice();for(let r=0;r<e.length;r++){let i=e[r];Number.isFinite(i)&&(t[r]=i)}return t}var _e=class{constructor(e){let{id:r,x:i=0,y:o=0,width:n="100%",height:s="100%",padding:a=null}=e;this.id=r||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=zt(i),this._y=zt(o),this._width=zt(n),this._height=zt(s),this._padding=a&&{left:zt(a.left||0),right:zt(a.right||0),top:zt(a.top||0),bottom:zt(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.constructor===e.constructor&&K(this.props,e.props,2)}clone(e){let r=this.constructor;return new r({...this.props,...e})}makeViewport({width:e,height:r,viewState:i}){i=this.filterViewState(i);let o=this.getDimensions({width:e,height:r});if(!o.height||!o.width)return null;let n=this.getViewportType(i);return new n({...i,...this.props,...o})}getViewStateId(){let{viewState:e}=this.props;return typeof e=="string"?e:e?.id||this.id}filterViewState(e){return this.props.viewState&&typeof this.props.viewState=="object"?this.props.viewState.id?by(e,this.props.viewState):this.props.viewState:e}getDimensions({width:e,height:r}){let i={x:Wt(this._x,e),y:Wt(this._y,r),width:Wt(this._width,e),height:Wt(this._height,r)};return this._padding&&(i.padding={left:Wt(this._padding.left,e),top:Wt(this._padding.top,r),right:Wt(this._padding.right,e),bottom:Wt(this._padding.bottom,r)}),i}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 qe=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:r}=this;this._handle=e.addChannel({delay:e.getTime(),duration:r.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 Ty=()=>{},mn={BREAK:1,SNAP_TO_END:2,IGNORE:3},EP=t=>t,wP=mn.BREAK,_n=class{constructor(e){this._onTransitionUpdate=r=>{let{time:i,settings:{interpolator:o,startProps:n,endProps:s,duration:a,easing:c}}=r,l=c(i/a),f=o.interpolateProps(n,s,l);this.propsInTransition=this.getControllerState({...this.props,...f}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new qe(e.timeline),this.onViewStateChange=e.onViewStateChange||Ty,this.onStateChange=e.onStateChange||Ty}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let r=!1,i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let o=i;if(this.transition.inProgress){let{interruption:n,endProps:s}=this.transition.settings;o={...i,...n===mn.SNAP_TO_END?s:this.propsInTransition||i}}this._triggerTransition(o,e),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(e){let{transitionDuration:r,transitionInterpolator:i}=e;return(r>0||r==="auto")&&Boolean(i)}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,r){return this.transition.inProgress?this.transition.settings.interruption===mn.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(e,r):!0}_triggerTransition(e,r){let i=this.getControllerState(e),o=this.getControllerState(r).shortestPathFrom(i),n=r.transitionInterpolator,s=n.getDuration?n.getDuration(e,r):r.transitionDuration;if(s===0)return;let a=n.initializeProps(e,o);this.propsInTransition={};let c={duration:s,easing:r.transitionEasing||EP,interpolator:n,interruption:r.transitionInterruption||wP,startProps:a.start,endProps:a.end,onStart:r.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(r.onTransitionInterrupt),onEnd:this._onTransitionEnd(r.onTransitionEnd)};this.transition.start(c),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(r)}}};function X(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}var jt=class{constructor(e){let{compare:r,extract:i,required:o}=e;this._propsToCompare=r,this._propsToExtract=i||r,this._requiredProps=o}arePropsEqual(e,r){for(let i of this._propsToCompare)if(!(i in e)||!(i in r)||!Re(e[i],r[i]))return!1;return!0}initializeProps(e,r){let i={},o={};for(let n of this._propsToExtract)(n in e||n in r)&&(i[n]=e[n],o[n]=r[n]);return this._checkRequiredProps(i),this._checkRequiredProps(o),{start:i,end:o}}getDuration(e,r){return r.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(r=>{let i=e[r];X(Number.isFinite(i)||Array.isArray(i),`${r} is required for transition`)})}};var ka=Math.PI/180,xy=180/Math.PI,Va=6370972,$t=256;function RP(){let t=$t/Va,e=Math.PI/180*$t;return{unitsPerMeter:[t,t,t],unitsPerMeter2:[0,0,0],metersPerUnit:[1/t,1/t,1/t],unitsPerDegree:[e,e,t],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/e,1/e,1/t]}}var za=class extends Ae{constructor(e={}){let{longitude:r=0,zoom:i=0,nearZMultiplier:o=.5,farZMultiplier:n=1,resolution:s=10}=e,{latitude:a=0,height:c,altitude:l=1.5,fovy:f}=e;a=Math.max(Math.min(a,ge),-ge),c=c||1,f?l=Lt(f):f=Ft(l);let h=Math.pow(2,i-yt(a)),u=e.nearZ??o,d=e.farZ??(l+$t*2*h/c)*n,p=new V().lookAt({eye:[0,-l,0],up:[0,0,1]});p.rotateX(a*ka),p.rotateZ(-r*ka),p.scale(h/c),super({...e,height:c,viewMatrix:p,longitude:r,latitude:a,zoom:i,distanceScales:RP(),fovy:f,focalDistance:l,near:u,far:d}),this.scale=h,this.latitude=a,this.longitude=r,this.fovy=f,this.resolution=s}get projectionMode(){return ie.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){let r={targetZ:e.z||0},i=this.unproject([0,this.height/2],r),o=this.unproject([this.width/2,0],r),n=this.unproject([this.width,this.height/2],r),s=this.unproject([this.width/2,this.height],r);return n[0]<this.longitude&&(n[0]+=360),i[0]>this.longitude&&(i[0]-=360),[Math.min(i[0],n[0],o[0],s[0]),Math.min(i[1],n[1],o[1],s[1]),Math.max(i[0],n[0],o[0],s[0]),Math.max(i[1],n[1],o[1],s[1])]}unproject(e,{topLeft:r=!0,targetZ:i}={}){let[o,n,s]=e,a=r?n:this.height-n,{pixelUnprojectionMatrix:c}=this,l;if(Number.isFinite(s))l=vu(c,[o,a,s,1]);else{let d=vu(c,[o,a,-1,1]),p=vu(c,[o,a,1,1]),g=((i||0)/Va+1)*$t,m=de.sqrLen(de.sub([],d,p)),_=de.sqrLen(d),b=de.sqrLen(p),T=4*((4*_*b-(m-_-b)**2)/16)/m,S=Math.sqrt(_-T),A=Math.sqrt(Math.max(0,g*g-T)),w=(S-A)/Math.sqrt(m);l=de.lerp([],d,p,w)}let[f,h,u]=this.unprojectPosition(l);return Number.isFinite(s)?[f,h,u]:Number.isFinite(i)?[f,h,i]:[f,h]}projectPosition(e){let[r,i,o=0]=e,n=r*ka,s=i*ka,a=Math.cos(s),c=(o/Va+1)*$t;return[Math.sin(n)*a*c,-Math.cos(n)*a*c,Math.sin(s)*c]}unprojectPosition(e){let[r,i,o]=e,n=de.len(e),s=Math.asin(o/n),c=Math.atan2(r,-i)*xy,l=s*xy,f=(n/$t-1)*Va;return[c,l,f]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition([e,r,i],o,n){let a=.25/Math.pow(2,this.zoom-yt(this.latitude)),c=e+a*(n[0]-o[0]),l=r-a*(n[1]-o[1]);l=Math.max(Math.min(l,ge),-ge);let f={longitude:c,latitude:l,zoom:i-yt(r)};return f.zoom+=yt(f.latitude),f}};za.displayName="GlobeViewport";var Hi=za;function yt(t){let e=Math.PI*Math.cos(t*Math.PI/180);return Math.log2(e)}function vu(t,e){let r=Te.transformMat4([],e,t);return Te.scale(r,r,1/r[3]),r}var PP=["longitude","latitude","zoom","bearing","pitch"],vP=["longitude","latitude","zoom"],se=class extends jt{constructor(e={}){let r=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:PP,required:vP},super(i.transitionProps),this.opts=i}initializeProps(e,r){let i=super.initializeProps(e,r),{makeViewport:o,around:n}=this.opts;if(o&&n)if(o(e)instanceof Hi)F.warn("around not supported in GlobeView")();else{let a=o(e),c=o(r),l=a.unproject(n);i.start.around=n,Object.assign(i.end,{around:c.project(l),aroundPosition:l,width:r.width,height:r.height})}return i}interpolateProps(e,r,i){let o={};for(let n of this._propsToExtract)o[n]=It(e[n]||0,r[n]||0,i);if(r.aroundPosition&&this.opts.makeViewport){let n=this.opts.makeViewport({...r,...o});Object.assign(o,n.panByPosition(r.aroundPosition,It(e.around,r.around,i)))}return o}};var Ht={transitionDuration:0},MP=300,Wa=t=>1-(1-t)*(1-t),Xi={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],KEYBOARD:["keydown"]},Hr={},ye=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 _n({...e,getControllerState:r=>new this.ControllerState(r),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,this.pickPosition=e.pickPosition}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 r=this._eventStartBlocked;switch(e.type){case"panstart":return r?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return r?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"multipanstart":return r?!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:r,y:i}=this.props,{offsetCenter:o}=e;return[o.x-r,o.y-i]}isPointInBounds(e,r){let{width:i,height:o}=this.props;if(r&&r.handled)return!1;let n=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=o;return n&&r&&r.stopPropagation(),n}isFunctionKeyPressed(e){let{srcEvent:r}=e;return Boolean(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=r}setProps(e){e.dragMode&&(this.dragMode=e.dragMode);let r=this.props;this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);let{inertia:i}=e;this.inertia=Number.isFinite(i)?i:i===!0?MP:0;let{scrollZoom:o=!0,dragPan:n=!0,dragRotate:s=!0,doubleClickZoom:a=!0,touchZoom:c=!0,touchRotate:l=!1,keyboard:f=!0}=e,h=Boolean(this.onViewStateChange);if(this.toggleEvents(Xi.WHEEL,h&&o),this.toggleEvents(Xi.PAN,h),this.toggleEvents(Xi.PINCH,h&&(c||l)),this.toggleEvents(Xi.MULTI_PAN,h&&l),this.toggleEvents(Xi.DOUBLE_CLICK,h&&a),this.toggleEvents(Xi.KEYBOARD,h&&f),this.scrollZoom=o,this.dragPan=n,this.dragRotate=s,this.doubleClickZoom=a,this.touchZoom=c,this.touchRotate=l,this.keyboard=f,(!r||r.height!==e.height||r.width!==e.width||r.maxBounds!==e.maxBounds)&&e.maxBounds){let d=new this.ControllerState({...e,makeViewport:this.makeViewport}),p=d.getViewportProps();Object.keys(p).some(m=>!K(p[m],e[m],1))&&this.updateViewport(d)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,r){this.eventManager&&e.forEach(i=>{this._events[i]!==r&&(this._events[i]=r,r?this.eventManager.on(i,this.handleEvent):this.eventManager.off(i,this.handleEvent))})}updateViewport(e,r=null,i={}){let o={...e.getViewportProps(),...r},n=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),n){let s=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:o,interactionState:this._interactionState,oldViewState:s,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 r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(i=!i);let o=this.controllerState[i?"panStart":"rotateStart"]({pos:r});return this._panMove=i,this.updateViewport(o,Ht,{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 r=this.getCenter(e),i=this.controllerState.pan({pos:r});return this.updateViewport(i,Ht,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){let{inertia:r}=this;if(this.dragPan&&r&&e.velocity){let i=this.getCenter(e),o=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],n=this.controllerState.pan({pos:o}).panEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Wa},{isDragging:!1,isPanning:!0})}else{let i=this.controllerState.panEnd();this.updateViewport(i,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;let r=this.getCenter(e),i=this.controllerState.rotate({pos:r});return this.updateViewport(i,Ht,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){let{inertia:r}=this;if(this.dragRotate&&r&&e.velocity){let i=this.getCenter(e),o=[i[0]+e.velocityX*r/2,i[1]+e.velocityY*r/2],n=this.controllerState.rotate({pos:o}).rotateEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Wa},{isDragging:!1,isRotating:!0})}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;e.srcEvent.preventDefault();let{speed:i=.01,smooth:o=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:n}=e,s=2/(1+Math.exp(-Math.abs(n*i)));n<0&&s!==0&&(s=1/s);let a=o?{...this._getTransitionProps({around:r}),transitionDuration:250}:Ht,c=this.controllerState.zoom({pos:r,scale:s});return this.updateViewport(c,a,{isZooming:!0,isPanning:!0}),o||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.rotateStart({pos:r});return this.updateViewport(i,Ht,{isDragging:!0}),!0}_onMultiPan(e){if(!this.touchRotate||!this.isDragging())return!1;let r=this.getCenter(e);r[0]-=e.deltaX;let i=this.controllerState.rotate({pos:r});return this.updateViewport(i,Ht,{isDragging:!0,isRotating:!0}),!0}_onMultiPanEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this;if(this.touchRotate&&r&&e.velocityY){let i=this.getCenter(e),o=[i[0],i[1]+=e.velocityY*r/2],n=this.controllerState.rotate({pos:o});this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Wa},{isDragging:!1,isRotating:!0}),this.blockEvents(r)}else{let i=this.controllerState.rotateEnd();this.updateViewport(i,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.controllerState.zoomStart({pos:r}).rotateStart({pos:r});return Hr._startPinchRotation=e.rotation,Hr._lastPinchEvent=e,this.updateViewport(i,Ht,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:i}=e,o=this.getCenter(e);r=r.zoom({pos:o,scale:i})}if(this.touchRotate){let{rotation:i}=e;r=r.rotate({deltaAngleX:Hr._startPinchRotation-i})}return this.updateViewport(r,Ht,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),Hr._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:i}=Hr;if(this.touchZoom&&r&&i&&e.scale!==i.scale){let o=this.getCenter(e),n=this.controllerState.rotateEnd(),s=Math.log2(e.scale),a=(s-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),c=Math.pow(2,s+a*r/2);n=n.zoom({pos:o,scale:c}).zoomEnd(),this.updateViewport(n,{...this._getTransitionProps({around:o}),transitionDuration:r,transitionEasing:Wa},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let o=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(o,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return Hr._startPinchRotation=null,Hr._lastPinchEvent=null,!0}_onDoubleClick(e){if(!this.doubleClickZoom)return!1;let r=this.getCenter(e);if(!this.isPointInBounds(r,e))return!1;let i=this.isFunctionKeyPressed(e),o=this.controllerState.zoom({pos:r,scale:i?.5:2});return this.updateViewport(o,this._getTransitionProps({around:r}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(e),{zoomSpeed:i,moveSpeed:o,rotateSpeedX:n,rotateSpeedY:s}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(e.srcEvent.code){case"Minus":c=r?a.zoomOut(i).zoomOut(i):a.zoomOut(i),l.isZooming=!0;break;case"Equal":c=r?a.zoomIn(i).zoomIn(i):a.zoomIn(i),l.isZooming=!0;break;case"ArrowLeft":r?(c=a.rotateLeft(n),l.isRotating=!0):(c=a.moveLeft(o),l.isPanning=!0);break;case"ArrowRight":r?(c=a.rotateRight(n),l.isRotating=!0):(c=a.moveRight(o),l.isPanning=!0);break;case"ArrowUp":r?(c=a.rotateUp(s),l.isRotating=!0):(c=a.moveUp(o),l.isPanning=!0);break;case"ArrowDown":r?(c=a.rotateDown(s),l.isRotating=!0):(c=a.moveDown(o),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(e){let{transition:r}=this;return!r||!r.transitionInterpolator?Ht:e?{...r,transitionInterpolator:new se({...e,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var Ge=class{constructor(e,r,i){this.makeViewport=i,this._viewportProps=this.applyConstraints(e),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};var Ay=5,CP=1.2,Sy=512,Ey=[[-1/0,-90],[1/0,90]];function ja([t,e]){if(Math.abs(e)>90&&(e=Math.sign(e)*90),Number.isFinite(t)){let[i,o]=xe([t,e]);return[i,U(o,0,Sy)]}let[,r]=xe([0,e]);return[t,U(r,0,Sy)]}var yn=class extends Ge{constructor(e){let{width:r,height:i,latitude:o,longitude:n,zoom:s,bearing:a=0,pitch:c=0,altitude:l=1.5,position:f=[0,0,0],maxZoom:h=20,minZoom:u=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:g,startZoomLngLat:m,startRotatePos:_,startRotateLngLat:b,startBearing:y,startPitch:T,startZoom:S,normalize:A=!0}=e;X(Number.isFinite(n)),X(Number.isFinite(o)),X(Number.isFinite(s));let w=e.maxBounds||(A?Ey:null);super({width:r,height:i,latitude:o,longitude:n,zoom:s,bearing:a,pitch:c,altitude:l,maxZoom:h,minZoom:u,maxPitch:d,minPitch:p,normalize:A,position:f,maxBounds:w},{startPanLngLat:g,startZoomLngLat:m,startRotatePos:_,startRotateLngLat:b,startBearing:y,startPitch:T,startZoom:S},e.makeViewport),this.getAltitude=e.getAltitude}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:r}){let i=this.getState().startPanLngLat||this._unproject(r);if(!i)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){let r=this.getAltitude?.(e);return this._getUpdatedState({startRotatePos:e,startRotateLngLat:r!==void 0?this._unproject3D(e,r):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:r=0,deltaAngleY:i=0}){let{startRotatePos:o,startRotateLngLat:n,startBearing:s,startPitch:a}=this.getState();if(!o||s===void 0||a===void 0)return this;let c;if(e?c=this._getNewRotation(e,o,a,s):c={bearing:s+r,pitch:a+i},n){let l=this.makeViewport({...this.getViewportProps(),...c}),f="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[f](n,o)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:o,startZoomLngLat:n}=this.getState();if(n||(o=this.getViewportProps().zoom,n=this._unproject(r)||this._unproject(e)),!n)return this;let s=this._constrainZoom(o+Math.log2(i)),a=this.makeViewport({...this.getViewportProps(),zoom:s});return this._getUpdatedState({zoom:s,...a.panByPosition(n,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 r=e.getViewportProps(),i={...this.getViewportProps()},{bearing:o,longitude:n}=i;return Math.abs(o-r.bearing)>180&&(i.bearing=o<0?o+360:o-360),Math.abs(n-r.longitude)>180&&(i.longitude=n<0?n+360:n-360),i}applyConstraints(e){let{maxPitch:r,minPitch:i,pitch:o,longitude:n,bearing:s,normalize:a,maxBounds:c}=e;if(a&&((n<-180||n>180)&&(e.longitude=mt(n+180,360)-180),(s<-180||s>180)&&(e.bearing=mt(s+180,360)-180)),e.pitch=U(o,i,r),e.zoom=this._constrainZoom(e.zoom,e),c){let l=ja(c[0]),f=ja(c[1]),h=2**e.zoom,u=e.width/2/h,d=e.height/2/h,[p,g]=me([l[0]+u,l[1]+d]),[m,_]=me([f[0]-u,f[1]-d]);e.longitude=U(e.longitude,p,m),e.latitude=U(e.latitude,g,_)}return e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{maxZoom:i,maxBounds:o}=r,n=o!==null&&r.width>0&&r.height>0,{minZoom:s}=r;if(n){let a=ja(o[0]),c=ja(o[1]),l=c[0]-a[0],f=c[1]-a[1];Number.isFinite(l)&&l>0&&(s=Math.max(s,Math.log2(r.width/l))),Number.isFinite(f)&&f>0&&(s=Math.max(s,Math.log2(r.height/f))),s>i&&(s=i)}return U(e,s,i)}_zoomFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.zoom({pos:[r/2,i/2],scale:e})}_panFromCenter(e){let{width:r,height:i}=this.getViewportProps();return this.pan({startPos:[r/2,i/2],pos:[r/2+e[0],i/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){let r=this.makeViewport(this.getViewportProps());return e&&r.unproject(e)}_unproject3D(e,r){return this.makeViewport(this.getViewportProps()).unproject(e,{targetZ:r})}_getNewRotation(e,r,i,o){let n=e[0]-r[0],s=e[1]-r[1],a=e[1],c=r[1],{width:l,height:f}=this.getViewportProps(),h=n/l,u=0;s>0?Math.abs(f-c)>Ay&&(u=s/(c-f)*CP):s<0&&c>Ay&&(u=1-a/c),u=U(u,-1,1);let{minPitch:d,maxPitch:p}=this.getViewportProps(),g=o+180*h,m=i;return u>0?m=i+u*(p-i):u<0&&(m=i-u*(d-i)),{pitch:m,bearing:g}}},Xt=class extends ye{constructor(){super(...arguments),this.ControllerState=yn,this.transition={transitionDuration:300,transitionInterpolator:new se({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan",this.rotationPivot="center",this._getAltitude=e=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:r,y:i}=this.props,o=this.pickPosition(r+e[0],i+e[1]);if(o&&o.coordinate&&o.coordinate.length>=3)return o.coordinate[2]}}}setProps(e){"rotationPivot"in e&&(this.rotationPivot=e.rotationPivot||"center"),e.getAltitude=this._getAltitude,e.position=e.position||[0,0,0],e.maxBounds=e.maxBounds||(e.normalize===!1?null:Ey),super.setProps(e)}updateViewport(e,r=null,i={}){let o=e.getState();i.isDragging&&o.startRotateLngLat?i={...i,rotationPivotPosition:o.startRotateLngLat}:i.isDragging===!1&&(i={...i,rotationPivotPosition:void 0}),super.updateViewport(e,r,i)}};var $a=class extends _e{constructor(e={}){super(e)}getViewportType(){return _r}get ControllerType(){return Xt}};$a.displayName="MapView";var Ha=$a;var IP=new mr;function OP(t,e){let r=t.order??1/0,i=e.order??1/0;return r-i}var bn=class{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){let r=this._defaultEffects;if(!r.find(i=>i.id===e.id)){let i=r.findIndex(o=>OP(o,e)>0);i<0?r.push(e):r.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(K(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}getEffects(){return this._resolvedEffects}_setEffects(e){let r={};for(let o of this.effects)r[o.id]=o;let i=[];for(let o of e){let n=r[o.id],s=o;n&&n!==o?n.setProps?(n.setProps(o.props),s=n):n.cleanup(this._context):n||o.setup(this._context),i.push(s),delete r[o.id]}for(let o in r)r[o].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(o=>o instanceof mr)||this._resolvedEffects.push(IP),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 Tn=class extends Ye{shouldDrawLayer(e){let{operation:r}=e.props;return r.includes("draw")||r.includes("terrain")}render(e){return this._render(e)}};var NP="deckRenderer.renderLayers",Xr=class{constructor(e,r={}){this.device=e,this.stats=r.stats,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Tn(e),this.pickLayersPass=new kt(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 r=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};i.effects&&this._preRender(i.effects,i);let o=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);let n=r.render({...i,target:o}),s="stats"in n?n.stats:n;i.effects&&(this.lastPostProcessEffect&&(i.clearCanvas=e.clearCanvas===void 0?!0:e.clearCanvas),this._postRender(i.effects,i)),this.renderCount++,q(NP,this,s,e),this._updateStats(s)}needsRedraw(e={clearRedrawFlags:!1}){let r=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),r}finalize(){let{renderBuffers:e}=this;for(let r of e)r.delete();e.length=0}_updateStats(e){if(!this.stats)return;let r=0;for(let{visibleCount:i}of e)r+=i;this.stats.get("Layers rendered").addCount(r)}_preRender(e,r){this.lastPostProcessEffect=null,r.preRenderStats=r.preRenderStats||{};for(let i of e)r.preRenderStats[i.id]=i.preRender(r),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){let{renderBuffers:e}=this,r=this.device.canvasContext.getDrawingBufferSize(),[i,o]=r;e.length===0&&[0,1].map(n=>{let s=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"},width:i,height:o});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${n}`,colorAttachments:[s]}))});for(let n of e)n.resize(r)}_postRender(e,r){let{renderBuffers:i}=this,o={...r,inputBuffer:i[0],swapBuffer:i[1]};for(let n of e)if(n.postRender){o.target=n.id===this.lastPostProcessEffect?r.target:void 0;let s=n.postRender(o);o.inputBuffer=s,o.swapBuffer=s===i[0]?i[1]:i[0]}}};L();var DP={pickedColor:null,pickedObjectIndex:-1};function Mu({pickedColors:t,decodePickingColor:e,deviceX:r,deviceY:i,deviceRadius:o,deviceRect:n}){let{x:s,y:a,width:c,height:l}=n,f=o*o,h=-1,u=0;for(let d=0;d<l;d++){let p=d+a-i,g=p*p;if(g>f)u+=4*c;else for(let m=0;m<c;m++){if(t[u+3]-1>=0){let b=m+s-r,y=b*b+g;y<=f&&(f=y,h=u)}u+=4}}if(h>=0){let d=t.slice(h,h+4),p=e(d);if(p){let g=Math.floor(h/4/c),m=h/4-g*c;return{...p,pickedColor:d,pickedX:s+m,pickedY:a+g}}F.error("Picked non-existent layer. Is picking buffer corrupt?")()}return DP}function Cu({pickedColors:t,decodePickingColor:e}){let r=new Map;if(t){for(let i=0;i<t.length;i+=4)if(t[i+3]-1>=0){let n=t.slice(i,i+4),s=n.join(",");if(!r.has(s)){let a=e(n);a?r.set(s,{...a,color:n}):F.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(r.values())}function Xa({pickInfo:t,viewports:e,pixelRatio:r,x:i,y:o,z:n}){let s=e[0];e.length>1&&(s=BP(t?.pickedViewports||e,{x:i,y:o}));let a;if(s){let c=[i-s.x,o-s.y];n!==void 0&&(c[2]=n),a=s.unproject(c)}return{color:null,layer:null,viewport:s,index:-1,picked:!1,x:i,y:o,pixel:[i,o],coordinate:a,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:r}}function Iu(t){let{pickInfo:e,lastPickedInfo:r,mode:i,layers:o}=t,{pickedColor:n,pickedLayer:s,pickedObjectIndex:a}=e,c=s?[s]:[];if(i==="hover"){let h=r.index,u=r.layerId,d=s?s.props.id:null;if(d!==u||a!==h){if(d!==u){let p=o.find(g=>g.props.id===u);p&&c.unshift(p)}r.layerId=d,r.index=a,r.info=null}}let l=Xa(t),f=new Map;return f.set(null,l),c.forEach(h=>{let u={...l};h===s&&(u.color=n,u.index=a,u.picked=!0),u=Ya({layer:h,info:u,mode:i});let d=u.layer;h===s&&i==="hover"&&(r.info=u),f.set(d.id,u),i==="hover"&&d.updateAutoHighlight(u)}),f}function Ya({layer:t,info:e,mode:r}){for(;t&&e;){let i=e.layer||null;e.sourceLayer=i,e.layer=t,e=t.getPickingInfo({info:e,mode:r,sourceLayer:i}),t=t.parent}return e}function BP(t,e){for(let r=t.length-1;r>=0;r--){let i=t[r];if(i.containsPixel(e))return i}return t[0]}var xn=class{constructor(e,r={}){this._pickable=!0,this.device=e,this.stats=r.stats,this.pickLayersPass=new kt(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:r,layers:i,viewports:o},n=this.lastPickedInfo.info){let s=n&&n.layer&&n.layer.id,a=n&&n.viewport&&n.viewport.id,c=s?i.find(u=>u.id===s):null,l=a&&o.find(u=>u.id===a)||o[0],f=l&&l.unproject([e-l.x,r-l.y]);return{...n,...{x:e,y:r,viewport:l,coordinate:f,layer:c}}}_resizeBuffer(){if(!this.pickingFBO){let r=this.device.createTexture({format:"rgba8unorm",width:1,height:1,usage:B.RENDER_ATTACHMENT|B.COPY_SRC});if(this.pickingFBO=this.device.createFramebuffer({colorAttachments:[r],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float")){let i=this.device.createTexture({format:"rgba32float",width:1,height:1,usage:B.RENDER_ATTACHMENT|B.COPY_SRC}),o=this.device.createFramebuffer({colorAttachments:[i],depthStencilAttachment:"depth16unorm"});this.depthFBO=o}}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 r=e.filter(i=>this.pickLayersPass.shouldDrawLayer(i)&&!i.isComposite);return r.length?r:null}async _pickClosestObjectAsync({layers:e,views:r,viewports:i,x:o,y:n,radius:s=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:f,effects:h}){let u=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||i.length===0)return{result:[],emptyInfo:Xa({viewports:i,x:o,y:n,pixelRatio:u})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([o,n],!0),g=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(s*u),{width:_,height:b}=this.pickingFBO,y=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceWidth:_,deviceHeight:b}),T={x:o-s,y:n-s,width:s*2+1,height:s*2+1},S,A=[],w=new Set;for(let P=0;P<a;P++){let R;if(y){let C=await this._drawAndSampleAsync({layers:d,views:r,viewports:i,onViewportActive:f,deviceRect:y,cullRect:T,effects:h,pass:`picking:${c}`});R=Mu({...C,deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceRect:y})}else R={pickedColor:null,pickedObjectIndex:-1};let v,O=this._getDepthLayers(R,d,l);if(O.length>0){let{pickedColors:C}=await this._drawAndSampleAsync({layers:O,views:r,viewports:i,onViewportActive:f,deviceRect:{x:R.pickedX??g[0],y:R.pickedY??g[1],width:1,height:1},cullRect:T,effects:h,pass:`picking:${c}:z`},!0);C[3]&&(v=C[0])}R.pickedLayer&&P+1<a&&(w.add(R.pickedLayer),R.pickedLayer.disablePickingIndex(R.pickedObjectIndex)),S=Iu({pickInfo:R,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:i,x:o,y:n,z:v,pixelRatio:u});for(let C of S.values())C.layer&&A.push(C);if(!R.pickedColor)break}for(let P of w)P.restorePickingColors();return{result:A,emptyInfo:S.get(null)}}_pickClosestObject({layers:e,views:r,viewports:i,x:o,y:n,radius:s=0,depth:a=1,mode:c="query",unproject3D:l,onViewportActive:f,effects:h}){let u=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||i.length===0)return{result:[],emptyInfo:Xa({viewports:i,x:o,y:n,pixelRatio:u})};this._resizeBuffer();let p=this.device.canvasContext.cssToDevicePixels([o,n],!0),g=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(s*u),{width:_,height:b}=this.pickingFBO,y=this._getPickingRect({deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceWidth:_,deviceHeight:b}),T={x:o-s,y:n-s,width:s*2+1,height:s*2+1},S,A=[],w=new Set;for(let P=0;P<a;P++){let R;if(y){let C=this._drawAndSample({layers:d,views:r,viewports:i,onViewportActive:f,deviceRect:y,cullRect:T,effects:h,pass:`picking:${c}`});R=Mu({...C,deviceX:g[0],deviceY:g[1],deviceRadius:m,deviceRect:y})}else R={pickedColor:null,pickedObjectIndex:-1};let v,O=this._getDepthLayers(R,d,l);if(O.length>0){let{pickedColors:C}=this._drawAndSample({layers:O,views:r,viewports:i,onViewportActive:f,deviceRect:{x:R.pickedX??g[0],y:R.pickedY??g[1],width:1,height:1},cullRect:T,effects:h,pass:`picking:${c}:z`},!0);C[3]&&(v=C[0])}R.pickedLayer&&P+1<a&&(w.add(R.pickedLayer),R.pickedLayer.disablePickingIndex(R.pickedObjectIndex)),S=Iu({pickInfo:R,lastPickedInfo:this.lastPickedInfo,mode:c,layers:d,viewports:i,x:o,y:n,z:v,pixelRatio:u});for(let C of S.values())C.layer&&A.push(C);if(!R.pickedColor)break}for(let P of w)P.restorePickingColors();return{result:A,emptyInfo:S.get(null)}}async _pickVisibleObjectsAsync({layers:e,views:r,viewports:i,x:o,y:n,width:s=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:f,effects:h}){let u=this._getPickable(e);if(!u||i.length===0)return[];this._resizeBuffer();let d=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([o,n],!0),g=p.x,m=p.y+p.height,_=this.device.canvasContext.cssToDevicePixels([o+s,n+a],!0),b=_.x+_.width,y=_.y,T={x:g,y,width:b-g,height:m-y},S=await this._drawAndSampleAsync({layers:u,views:r,viewports:i,onViewportActive:f,deviceRect:T,cullRect:{x:o,y:n,width:s,height:a},effects:h,pass:`picking:${c}`}),A=Cu(S),w=new Map,P=[],R=Number.isFinite(l);for(let v=0;v<A.length&&!(R&&P.length>=l);v++){let O=A[v],C={color:O.pickedColor,layer:null,index:O.pickedObjectIndex,picked:!0,x:o,y:n,pixelRatio:d};C=Ya({layer:O.pickedLayer,info:C,mode:c});let z=C.layer.id;w.has(z)||w.set(z,new Set);let k=w.get(z),Q=C.object??C.index;k.has(Q)||(k.add(Q),P.push(C))}return P}_pickVisibleObjects({layers:e,views:r,viewports:i,x:o,y:n,width:s=1,height:a=1,mode:c="query",maxObjects:l=null,onViewportActive:f,effects:h}){let u=this._getPickable(e);if(!u||i.length===0)return[];this._resizeBuffer();let d=this.device.canvasContext.cssToDeviceRatio(),p=this.device.canvasContext.cssToDevicePixels([o,n],!0),g=p.x,m=p.y+p.height,_=this.device.canvasContext.cssToDevicePixels([o+s,n+a],!0),b=_.x+_.width,y=_.y,T={x:g,y,width:b-g,height:m-y},S=this._drawAndSample({layers:u,views:r,viewports:i,onViewportActive:f,deviceRect:T,cullRect:{x:o,y:n,width:s,height:a},effects:h,pass:`picking:${c}`}),A=Cu(S),w=new Map,P=[],R=Number.isFinite(l);for(let v=0;v<A.length&&!(R&&P.length>=l);v++){let O=A[v],C={color:O.pickedColor,layer:null,index:O.pickedObjectIndex,picked:!0,x:o,y:n,pixelRatio:d};C=Ya({layer:O.pickedLayer,info:C,mode:c});let z=C.layer.id;w.has(z)||w.set(z,new Set);let k=w.get(z),Q=C.object??C.index;k.has(Q)||(k.add(Q),P.push(C))}return P}async _drawAndSampleAsync({layers:e,views:r,viewports:i,onViewportActive:o,deviceRect:n,cullRect:s,effects:a,pass:c},l=!1){let f=l?this.depthFBO:this.pickingFBO,h={layers:e,layerFilter:this.layerFilter,views:r,viewports:i,onViewportActive:o,pickingFBO:f,deviceRect:n,cullRect:s,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let T of a)T.useInPicking&&(h.preRenderStats[T.id]=T.preRender(h));let{decodePickingColor:u,stats:d}=this.pickLayersPass.render(h);this._updateStats(d);let{x:p,y:g,width:m,height:_}=n,b=f.colorAttachments[0]?.texture;if(!b)throw new Error("Picking framebuffer color attachment is missing");let y=await this._readTextureDataAsync(b,{x:p,y:g,width:m,height:_},l?Float32Array:Uint8Array);if(!l){let T=!1;for(let S=3;S<y.length;S+=4)if(y[S]!==0){T=!0;break}!T&&y.length>0&&F.warn("Async pick readback returned only zero alpha values",{deviceRect:n,bytes:Array.from(y.subarray(0,Math.min(y.length,16)))})()}return{pickedColors:y,decodePickingColor:u}}async _readTextureDataAsync(e,r,i){let{width:o,height:n}=r,s=e.computeMemoryLayout(r),a=this.device.createBuffer({byteLength:s.byteLength,usage:I.COPY_DST|I.MAP_READ});try{e.readBuffer(r,a);let c=await a.readAsync(0,s.byteLength),l=i.BYTES_PER_ELEMENT;if(s.bytesPerRow%l!==0)throw new Error(`Texture readback row stride ${s.bytesPerRow} is not aligned to ${l}-byte elements.`);let f=new i(c.buffer,c.byteOffset,s.byteLength/l),h=o*4,u=s.bytesPerRow/l;if(u<h)throw new Error(`Texture readback row stride ${u} is smaller than packed row length ${h}.`);let d=new i(o*n*4);for(let p=0;p<n;p++){let g=p*u;d.set(f.subarray(g,g+h),p*h)}return d}finally{a.destroy()}}_drawAndSample({layers:e,views:r,viewports:i,onViewportActive:o,deviceRect:n,cullRect:s,effects:a,pass:c},l=!1){let f=l?this.depthFBO:this.pickingFBO,h={layers:e,layerFilter:this.layerFilter,views:r,viewports:i,onViewportActive:o,pickingFBO:f,deviceRect:n,cullRect:s,effects:a,pass:c,pickZ:l,preRenderStats:{},isPicking:!0};for(let y of a)y.useInPicking&&(h.preRenderStats[y.id]=y.preRender(h));let{decodePickingColor:u,stats:d}=this.pickLayersPass.render(h);this._updateStats(d);let{x:p,y:g,width:m,height:_}=n,b=new(l?Float32Array:Uint8Array)(m*_*4);return this.device.readPixelsToArrayWebGL(f,{sourceX:p,sourceY:g,sourceWidth:m,sourceHeight:_,target:b}),{pickedColors:b,decodePickingColor:u}}_updateStats(e){if(!this.stats)return;let r=0;for(let{visibleCount:i}of e)r+=i;this.stats.get("Layers picked").addCount(r)}_getDepthLayers(e,r,i){if(!i||!this.depthFBO)return[];let{pickedLayer:o}=e,n=o?.state?.terrainDrawMode==="drape";return o&&!n?[o]:r.filter(s=>s.props.operation.includes("terrain"))}_getPickingRect({deviceX:e,deviceY:r,deviceRadius:i,deviceWidth:o,deviceHeight:n}){let s=Math.max(0,e-i),a=Math.max(0,r-i),c=Math.min(o,e+i+1)-s,l=Math.min(n,r+i+1)-a;return c<=0||l<=0?null:{x:s,y:a,width:c,height:l}}};var FP={"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}},LP="top-left",wy="root",Ka=class{constructor({deck:e,parentElement:r}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,r?.classList.add("deck-widget-container"),this.parentElement=r}getWidgets(){return this.resolvedWidgets}setProps(e){if(e.widgets&&!K(e.widgets,this.widgets,1)){let r=e.widgets.filter(Boolean);this._setWidgets(r)}}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(r=>r.id===e.id)||(this._addWidget(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}onRedraw({viewports:e,layers:r}){let i=e.reduce((o,n)=>(o[n.id]=n,o),{});for(let o of this.getWidgets()){let{viewId:n}=o;if(n){let s=i[n];s&&(o.onViewportChange&&o.onViewportChange(s),o.onRedraw?.({viewports:[s],layers:r}))}else{if(o.onViewportChange)for(let s of e)o.onViewportChange(s);o.onRedraw?.({viewports:e,layers:r})}}this.lastViewports=i,this._updateContainers()}onHover(e,r){for(let i of this.getWidgets()){let{viewId:o}=i;(!o||o===e.viewport?.id)&&i.onHover?.(e,r)}}onEvent(e,r){let i=Di[r.type];if(i)for(let o of this.getWidgets()){let{viewId:n}=o;(!n||n===e.viewport?.id)&&o[i]?.(e,r)}}_setWidgets(e){let r={};for(let i of this.resolvedWidgets)r[i.id]=i;this.resolvedWidgets.length=0;for(let i of this.defaultWidgets)r[i.id]=null,this.resolvedWidgets.push(i);for(let i of e){let o=r[i.id];o?o.viewId!==i.viewId||o.placement!==i.placement?(this._removeWidget(o),this._addWidget(i)):i!==o&&(o.setProps(i.props),i=o):this._addWidget(i),r[i.id]=null,this.resolvedWidgets.push(i)}for(let i in r){let o=r[i];o&&this._removeWidget(o)}this.widgets=e}_addWidget(e){let{viewId:r=null,placement:i=LP}=e,o=e.props._container??r;e.widgetManager=this,e.deck=this.deck,e.rootElement=e._onAdd({deck:this.deck,viewId:r}),e.rootElement&&this._getContainer(o,i).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,r){if(e&&typeof e!="string")return e;let i=e||wy,o=this.containers[i];o||(o=document.createElement("div"),o.style.pointerEvents="none",o.style.position="absolute",o.style.overflow="hidden",this.parentElement?.append(o),this.containers[i]=o);let n=o.querySelector(`.${r}`);return n||(n=globalThis.document.createElement("div"),n.className=r,n.style.position="absolute",n.style.zIndex="2",Object.assign(n.style,FP[r]),o.append(n)),n}_updateContainers(){let e=this.deck.width,r=this.deck.height;for(let i in this.containers){let o=this.lastViewports[i]||null,n=i===wy||o,s=this.containers[i];n?(s.style.display="block",s.style.left=`${o?o.x:0}px`,s.style.top=`${o?o.y:0}px`,s.style.width=`${o?o.width:e}px`,s.style.height=`${o?o.height:r}px`):s.style.display="none"}}};function An(t,e){e&&Object.entries(e).map(([r,i])=>{r.startsWith("--")?t.style.setProperty(r,i):t.style[r]=i})}function Za(t,e){e&&Object.keys(e).map(r=>{r.startsWith("--")?t.style.removeProperty(r):t.style[r]=""})}var Tr=class{constructor(e){this.viewId=null,this.props={...this.constructor.defaultProps,...e},this.id=this.props.id}setProps(e){let r=this.props,i=this.rootElement;i&&r.className!==e.className&&(r.className&&i.classList.remove(r.className),e.className&&i.classList.add(e.className)),i&&!K(r.style,e.style,1)&&(Za(i,r.style),An(i,e.style)),Object.assign(this.props,e),this.updateHTML()}updateHTML(){this.rootElement&&this.onRenderHTML(this.rootElement)}getViewState(e){return this.deck?.viewManager?.getViewState(e)||{}}setViewState(e,r){this.deck?._onViewStateChange({viewId:e,viewState:r,interactionState:{}})}onCreateRootElement(){let e=["deck-widget",this.className,this.props.className],r=document.createElement("div");return e.filter(i=>typeof i=="string"&&i.length>0).forEach(i=>r.classList.add(i)),An(r,this.props.style),r}_onAdd(e){return this.onAdd(e)??this.onCreateRootElement()}onAdd(e){}onRemove(){}onViewportChange(e){}onRedraw(e){}onHover(e,r){}onClick(e,r){}onDrag(e,r){}onDragStart(e,r){}onDragEnd(e,r){}};Tr.defaultProps={id:"widget",style:{},_container:null,className:""};var UP={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"},Sn=class extends Tr{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,UP),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:r}=this,i=r&&r.props.getTooltip;if(!i)return;let o=i(e);this.setTooltip(o,e.x,e.y)}setTooltip(e,r,i){let o=this.rootElement;if(o){if(typeof e=="string")o.innerText=e;else if(e)e.text&&(o.innerText=e.text),e.html&&(o.innerHTML=e.html),e.className&&(o.className=e.className);else{this.isVisible=!1,o.style.display="none";return}this.isVisible=!0,o.style.display="block",o.style.transform=`translate(${r}px, ${i}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(o.style,e.style)}}};Sn.defaultProps={...Tr.defaultProps};L();Mc();ro();function Ar(){}var Kv=({isDragging:t})=>t?"grabbing":"grab",Zb={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,pickAsync:"auto",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:Ar,onWebGLInitialized:Ar,onResize:Ar,onViewStateChange:Ar,onInteractionStateChange:Ar,onBeforeRender:Ar,onAfterRender:Ar,onLoad:Ar,onError:t=>F.error(t.message,t.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:Kv,getTooltip:null,debug:!1,drawPickingColors:!1},On=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 Oe({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,layersCount:0,drawLayersCount:0,updateLayersCount:0,updateAttributesCount:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,pickLayersCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._hoverPickSequence=0,this._pointerDownPickSequence=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null,unproject3D:!1},this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=null,this._onPointerMove=i=>{let{_pickRequest:o}=this;if(i.type==="pointerleave")o.x=-1,o.y=-1,o.radius=0;else{if(i.leftButton||i.rightButton)return;{let n=i.offsetCenter;if(!n)return;o.x=n.x,o.y=n.y,o.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:o.x,y:o.y}),o.event=i},this._onEvent=i=>{let o=Di[i.type],n=i.offsetCenter;if(!o||!n||!this.layerManager)return;let s=this.layerManager.getLayers(),a=this._getInternalPickingMode();if(!a)return;if(a==="sync"){let l=i.type==="click"&&this._shouldUnproject3D(s)?this._getFirstPickedInfo(this._pickPointSync(this._getPointPickOptions(n.x,n.y,{unproject3D:!0},s))):this._getLastPointerDownPickingInfo(n.x,n.y,s);this._dispatchPickingEvent(l,i);return}(this._lastPointerDownInfoPromise||Promise.resolve(this._getLastPointerDownPickingInfo(n.x,n.y,s))).then(l=>{this._dispatchPickingEvent(l,i)}).catch(l=>this.props.onError?.(l))},this._onPointerDown=i=>{let o=i.offsetCenter;if(!o)return;let n=this._getInternalPickingMode();if(!n)return;let s=this.layerManager?.getLayers()||[],a=++this._pointerDownPickSequence;if(n==="sync"){let l=this._pickPointSync({x:o.x,y:o.y,radius:this.props.pickingRadius}),f=this._getFirstPickedInfo(l);this._lastPointerDownInfo=f,this._lastPointerDownInfoPromise=Promise.resolve(f);return}let c=this._pickPointAsync(this._getPointPickOptions(o.x,o.y,{},s)).then(l=>this._getFirstPickedInfo(l)).then(l=>(a===this._pointerDownPickSequence&&(this._lastPointerDownInfo=l),l)).catch(l=>{this.props.onError?.(l);let f=this.deckPicker&&this.viewManager?this._getLastPointerDownPickingInfo(o.x,o.y,s):{};return a===this._pointerDownPickSequence&&(this._lastPointerDownInfo=f),f});this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=c},this.props={...Zb,...e},e=this.props,e.viewState&&e.initialViewState&&F.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 r=this.device;if(!r&&e.gl){e.gl instanceof WebGLRenderingContext&&F.error("WebGL1 context not supported.")();let i=this.props.deviceProps?.onResize;r=In.attach(e.gl,{_cacheShaders:!0,_cachePipelines:!0,...this.props.deviceProps,onResize:(o,n)=>{let{width:s,height:a}=o.canvas;o.setDrawingBufferSize(s,a),this._needsRedraw="Canvas resized",i?.(o,n)}})}r||(r=this._createDevice(e)),this.animationLoop=this._createAnimationLoop(r,e),this.setProps(e),e._typedArrayManagerProps&&Ke.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._hoverPickSequence++,this._pointerDownPickSequence++,this._lastPointerDownInfo=null,this._lastPointerDownInfoPromise=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&&F.removed("onLayerHover","onHover")(),"onLayerClick"in e&&F.removed("onLayerClick","onClick")(),e.initialViewState&&!K(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._validateInternalPickingMode(),this._setCanvasSize(this.props);let r=Object.create(this.props);Object.assign(r,{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),F.log(`recreating animation loop for new device! id=${e.device.id}`)(),this.animationLoop=this._createAnimationLoop(e.device,e),this.animationLoop.start()),this.animationLoop?.setProps(r),e.useDevicePixels!==void 0&&this.device?.canvasContext?.setProps&&this.device.canvasContext.setProps({useDevicePixels:e.useDevicePixels}),this.layerManager&&(this.viewManager.setProps(r),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(r),this.effectManager.setProps(r),this.deckRenderer.setProps(r),this.deckPicker.setProps(r),this.widgetManager.setProps(r)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let r=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);let i=this.viewManager.needsRedraw(e),o=this.layerManager.needsRedraw(e),n=this.effectManager.needsRedraw(e),s=this.deckRenderer.needsRedraw(e);return r=r||i||o||n||s,r}redraw(e){if(!this.layerManager)return;let r=this.needsRedraw({clearRedrawFlags:!0});r=e||r,r&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(r):this._drawLayers(r))}get isInitialized(){return this.viewManager!==null}getViews(){return X(this.viewManager),this.viewManager.views}getView(e){return X(this.viewManager),this.viewManager.getView(e)}getViewports(e){return X(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}async pickObjectAsync(e){let r=(await this._pickAsync("pickObjectAsync","pickObject Time",e)).result;return r.length?r[0]:null}async pickObjectsAsync(e){return await this._pickAsync("pickObjectsAsync","pickObjects Time",e)}pickObject(e){let r=this._pick("pickObject","pickObject Time",e).result;return r.length?r[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)}_pickPositionForController(e,r){return this._getInternalPickingMode()!=="sync"?null:this.pickObject({x:e,y:r,radius:0,unproject3D:!0})}_addResources(e,r=!1){for(let i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:r})}_removeResources(e){for(let r of e)this.layerManager.resourceManager.remove(r)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_resolveInternalPickingMode(){let{pickAsync:e}=this.props,r=this.device?.type||this.props.deviceProps?.type;if(e==="auto")return r==="webgpu"?"async":"sync";if(e==="sync"&&r==="webgpu")throw new Error('`pickAsync: "sync"` is not supported when Deck is using a WebGPU device.');return e}_getInternalPickingMode(){try{return this._resolveInternalPickingMode()}catch(e){return this.props.onError?.(e),null}}_validateInternalPickingMode(){this._getInternalPickingMode()}_getFirstPickedInfo({result:e,emptyInfo:r}){return e[0]||r}_shouldUnproject3D(e=this.layerManager?.getLayers()||[]){return e.some(r=>r.props.pickable==="3d")}_getPointPickOptions(e,r,i={},o=this.layerManager?.getLayers()||[]){return{x:e,y:r,radius:this.props.pickingRadius,unproject3D:this._shouldUnproject3D(o),...i}}_pickPointSync(e){return this._pick("pickObject","pickObject Time",e)}_pickPointAsync(e){return this._pickAsync("pickObjectAsync","pickObject Time",e)}_getLastPointerDownPickingInfo(e,r,i=this.layerManager?.getLayers()||[]){return this.deckPicker.getLastPickedObject({x:e,y:r,layers:i,viewports:this.getViewports({x:e,y:r})},this._lastPointerDownInfo)}_applyHoverCallbacks({result:e,emptyInfo:r},i){if(!this.widgetManager)return;this.cursorState.isHovering=e.length>0;let o=r,n=!1;for(let s of e)o=s,n=s.layer?.onHover(s,i)||n;n||(this.props.onHover?.(o,i),this.widgetManager.onHover(o,i))}_dispatchPickingEvent(e,r){if(!this.layerManager||!this.widgetManager)return;let i=Di[r.type];if(!i)return;let{layer:o}=e,n=o&&(o[i]||o.props[i]),s=this.props[i],a=!1;n&&(a=n.call(o,e,r)),a||(s?.(e,r),this.widgetManager.onEvent(e,r))}_pickAsync(e,r,i){X(this.deckPicker);let{stats:o}=this;o.get("Pick Count").incrementCount(),o.get(r).timeStart();let n=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return o.get(r).timeEnd(),n}_pick(e,r,i){X(this.deckPicker);let{stats:o}=this;o.get("Pick Count").incrementCount(),o.get(r).timeStart();let n=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return o.get(r).timeEnd(),n}_createCanvas(e){let r=e.canvas;return typeof r=="string"&&(r=document.getElementById(r),X(r)),r||(r=document.createElement("canvas"),r.id=e.id||"deckgl-overlay",e.width&&typeof e.width=="number"&&(r.width=e.width),e.height&&typeof e.height=="number"&&(r.height=e.height),(e.parent||document.body).appendChild(r)),Object.assign(r.style,e.style),r}_setCanvasSize(e){if(!this.canvas)return;let{width:r,height:i}=e;if(r||r===0){let o=Number.isFinite(r)?`${r}px`:r;this.canvas.style.width=o}if(i||i===0){let o=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=o}}_updateCanvasSize(){let{canvas:e}=this;if(!e)return;let r=e.clientWidth??e.width,i=e.clientHeight??e.height;(r!==this.width||i!==this.height)&&(this.width=r,this.height=i,this.viewManager?.setProps({width:r,height:i}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:r,height:i}))}_createAnimationLoop(e,r){let{gl:i,onError:o}=r;return new bi({device:e,autoResizeDrawingBuffer:!i,autoResizeViewport:!1,onInitialize:n=>this._setDevice(n.device),onRender:this._onRenderFrame.bind(this),onError:o})}_createDevice(e){let r=this.props.deviceProps?.createCanvasContext,i=typeof r=="object"?r:void 0,o={adapters:[],_cacheShaders:!0,_cachePipelines:!0,...e.deviceProps};o.adapters.includes(In)||o.adapters.push(In);let n={alphaMode:this.props.deviceProps?.type==="webgpu"?"premultiplied":void 0},s=this.props.deviceProps?.onResize;return Gt.createDevice({_reuseDevices:!0,type:"webgl",...o,createCanvasContext:{...n,...i,canvas:this._createCanvas(e),useDevicePixels:this.props.useDevicePixels,autoResize:!0},onResize:(a,c)=>{this._needsRedraw="Canvas resized",s?.(a,c)}})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){let{views:e}=this.props,r=Array.isArray(e)?e:e?[e]:[new Ha({id:"default-view"})];return r.length&&this.props.controller&&(r[0].props.controller=this.props.controller),r}_onContextLost(){let{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){let{_pickRequest:e}=this;if(e.event){let r=e.event,i=this.layerManager?.getLayers()||[],o=this._getPointPickOptions(e.x,e.y,{radius:e.radius,mode:e.mode},i),n=this._getInternalPickingMode(),s=++this._hoverPickSequence;if(e.event=null,!n)return;if(n==="sync"){this._applyHoverCallbacks(this._pickPointSync(o),r);return}this._pickPointAsync(o).then(({result:a,emptyInfo:c})=>{s===this._hoverPickSequence&&this._applyHoverCallbacks({result:a,emptyInfo:c},r)}).catch(a=>this.props.onError?.(a))}}_updateCursor(){let e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,this._validateInternalPickingMode(),!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 r=new vr;r.play(),this.animationLoop.attachTimeline(r);let i=this.props.parent?.querySelector(".deck-events-root")||this.canvas;this.eventManager=new Jo(i,{touchAction:this.props.touchAction,recognizers:Object.keys(pu).map(s=>{let[a,c,l,f]=pu[s],h=this.props.eventRecognizerOptions?.[s],u={...c,...h,event:s};return{recognizer:new a(u),recognizeWith:l,requestFailure:f}}),events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(let s in Di)this.eventManager.on(s,this._onEvent);this.viewManager=new gn({timeline:r,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),pickPosition:this._pickPositionForController.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});let o=this.viewManager.getViewports()[0];this.layerManager=new $r(this.device,{deck:this,stats:this.stats,viewport:o,timeline:r}),this.effectManager=new bn({deck:this,device:this.device}),this.deckRenderer=new Xr(this.device,{stats:this.stats}),this.deckPicker=new xn(this.device,{stats:this.stats});let n=this.props.parent?.querySelector(".deck-widgets-root")||this.canvas?.parentElement;this.widgetManager=new Ka({deck:this,parentElement:n}),this.widgetManager.addDefault(new Sn),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,r){let{device:i,gl:o}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:o});let n={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(),...r};this.deckRenderer?.renderLayers(n),n.pass==="screen"&&this.widgetManager.onRedraw({viewports:n.viewports,layers:n.layers}),this.props.onAfterRender({device:i,gl:o})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60===0&&(this._getMetrics(),this.stats.reset(),F.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){let r=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:r},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 r=this.animationLoop.stats;e.get("GPU Time").addTime(r.get("GPU Time").lastTiming),e.get("CPU Time").addTime(r.get("CPU Time").lastTiming)}_getMetrics(){let{metrics:e,stats:r}=this;e.fps=r.get("frameRate").getHz(),e.setPropsTime=r.get("setProps Time").time,e.updateAttributesTime=r.get("Update Attributes").time,e.framesRedrawn=r.get("Redraw Count").count,e.pickTime=r.get("pickObject Time").time+r.get("pickMultipleObjects Time").time+r.get("pickObjects Time").time,e.pickCount=r.get("Pick Count").count,e.layersCount=this.layerManager?.layers.length??0,e.drawLayersCount=r.get("Layers rendered").lastSampleCount,e.pickLayersCount=r.get("Layers picked").lastSampleCount,e.updateAttributesCount=r.get("Layers updated").count,e.updateAttributesCount=r.get("Attributes updated").count,e.gpuTime=r.get("GPU Time").time,e.cpuTime=r.get("CPU Time").time,e.gpuTimePerFrame=r.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=r.get("CPU Time").getAverageTime();let i=Gt.stats.get("GPU Time and Memory");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}};On.defaultProps=Zb;On.VERSION=ua;var Nc=On;L();L();function qb(t){switch(t){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return go(t)}}var Gb=he.getDataType.bind(he);function Nn(t,e,r){if(e.size>4)return null;let i=r==="webgpu"&&e.type==="uint8"?"unorm8":e.type;return{attribute:t,format:e.size>1?`${i}x${e.size}`:e.type,byteOffset:e.offset||0}}function Sr(t){return t.stride||t.size*t.bytesPerElement}function Qb(t,e){return t.type===e.type&&t.size===e.size&&Sr(t)===Sr(e)&&(t.offset||0)===(e.offset||0)}function od(t,e){e.offset&&F.removed("shaderAttribute.offset","vertexOffset, elementOffset")();let r=Sr(t),i=e.vertexOffset!==void 0?e.vertexOffset:t.vertexOffset||0,o=e.elementOffset||0,n=i*r+o*t.bytesPerElement+(t.offset||0);return{...e,offset:n,stride:r}}function Zv(t,e){let r=od(t,e);return{high:r,low:{...r,offset:r.offset+t.size*4}}}var Dn=class{constructor(e,r,i){this._buffer=null,this.device=e,this.id=r.id||"",this.size=r.size||1;let o=r.logicalType||r.type,n=o==="float64",{defaultValue:s}=r;s=Number.isFinite(s)?[s]:s||new Array(this.size).fill(0);let a;n?a="float32":!o&&r.isIndexed?a="uint32":a=o||"float32";let c=qb(o||a);this.doublePrecision=n,n&&r.fp64===!1&&(c=Float32Array),this.value=null,this.settings={...r,defaultType:c,defaultValue:s,logicalType:o,type:a,normalized:a.includes("norm"),size:this.size,bytesPerElement:c.BYTES_PER_ELEMENT},this.state={...i,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*Sr(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),Ke.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,r=null){let i={};if(this.state.constant){let o=this.value;if(r){let n=od(this.getAccessor(),r),s=n.offset/o.BYTES_PER_ELEMENT,a=n.size||this.size;i[e]=o.subarray(s,s+a)}else i[e]=o}else i[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,r=null){let i=this.getAccessor(),o=[],n={name:this.id,byteStride:Sr(i)};if(this.doublePrecision){let s=Zv(i,r||{});o.push(Nn(e,{...i,...s.high},this.device.type),Nn(`${e}64Low`,{...i,...s.low},this.device.type))}else if(r){let s=od(i,r);o.push(Nn(e,{...i,...s},this.device.type))}else o.push(Nn(e,i,this.device.type));return n.attributes=o.filter(Boolean),n}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 r=Array.from(this.value);e=[r,r]}else{let{value:r,numInstances:i,size:o}=this,n=i*o;if(r&&n&&r.length>=n){let s=new Array(o).fill(1/0),a=new Array(o).fill(-1/0);for(let c=0;c<n;)for(let l=0;l<o;l++){let f=r[c++];f<s[l]&&(s[l]=f),f>a[l]&&(a[l]=f)}e=[s,a]}}return this.state.bounds=e,e}setData(e){let{state:r}=this,i;ArrayBuffer.isView(e)?i={value:e}:e instanceof I?i={buffer:e}:i=e;let o={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type)if(this.doublePrecision&&i.value instanceof Float64Array)o.type="float32";else{let s=Gb(i.value);o.type=o.normalized?s.replace("int","norm"):s}o.bytesPerElement=i.value.BYTES_PER_ELEMENT,o.stride=Sr(o)}if(r.bounds=null,i.constant){let n=i.value;if(n=this._normalizeValue(n,[],0),this.settings.normalized&&(n=this.normalizeConstant(n)),!(!r.constant||!this._areValuesEqual(n,this.value)))return!1;r.externalBuffer=null,r.constant=!0,this.value=ArrayBuffer.isView(n)?n:new Float32Array(n)}else if(i.buffer){let n=i.buffer;r.externalBuffer=n,r.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let n=i.value;r.externalBuffer=null,r.constant=!1,this.value=n;let{buffer:s}=this,a=Sr(o),c=(o.vertexOffset||0)*a;if(this.doublePrecision&&n instanceof Float64Array&&(n=Oa(n,o)),this.settings.isIndexed){let f=this.settings.defaultType;n.constructor!==f&&(n=new f(n))}let l=n.byteLength+c+a*2;(!s||s.byteLength<l)&&(s=this._createBuffer(l)),s.write(n,c)}return this.setAccessor(o),!0}updateSubBuffer(e={}){this.state.bounds=null;let r=this.value,{startOffset:i=0,endOffset:o}=e;this.buffer.write(this.doublePrecision&&r instanceof Float64Array?Oa(r,{size:this.size,startIndex:i,endIndex:o}):r.subarray(i,o),i*r.BYTES_PER_ELEMENT+this.byteOffset)}allocate(e,r=!1){let{state:i}=this,o=i.allocatedValue,n=Ke.allocate(o,e+1,{size:this.size,type:this.settings.defaultType,copy:r});this.value=n;let{byteOffset:s}=this,{buffer:a}=this;return(!a||a.byteLength<n.byteLength+s)&&(a=this._createBuffer(n.byteLength+s),r&&o&&a.write(o instanceof Float64Array?Oa(o,this):o,s)),i.allocatedValue=n,i.constant=!1,i.externalBuffer=null,this.setAccessor(this.settings),!0}_checkExternalBuffer(e){let{value:r}=e;if(!ArrayBuffer.isView(r))throw new Error(`Attribute ${this.id} value is not TypedArray`);let i=this.settings.defaultType,o=!1;if(this.doublePrecision&&(o=r.BYTES_PER_ELEMENT<4),o)throw new Error(`Attribute ${this.id} does not support ${r.constructor.name}`);!(r instanceof i)&&this.settings.normalized&&!("normalized"in e)&&F.warn(`Attribute ${this.id} is normalized`)()}normalizeConstant(e){switch(this.settings.type){case"snorm8":return new Float32Array(e).map(r=>(r+128)/255*2-1);case"snorm16":return new Float32Array(e).map(r=>(r+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(r=>r/255);case"unorm16":return new Float32Array(e).map(r=>r/65535);default:return e}}_normalizeValue(e,r,i){let{defaultValue:o,size:n}=this.settings;if(Number.isFinite(e))return r[i]=e,r;if(!e){let s=n;for(;--s>=0;)r[i+s]=o[s];return r}switch(n){case 4:r[i+3]=Number.isFinite(e[3])?e[3]:o[3];case 3:r[i+2]=Number.isFinite(e[2])?e[2]:o[2];case 2:r[i+1]=Number.isFinite(e[1])?e[1]:o[1];case 1:r[i+0]=Number.isFinite(e[0])?e[0]:o[0];break;default:let s=n;for(;--s>=0;)r[i+s]=Number.isFinite(e[s])?e[s]:o[s]}return r}_areValuesEqual(e,r){if(!e||!r)return!1;let{size:i}=this;for(let o=0;o<i;o++)if(e[o]!==r[o])return!1;return!0}_createBuffer(e){this._buffer&&this._buffer.destroy();let{isIndexed:r,type:i}=this.settings;return this._buffer=this.device.createBuffer({...this._buffer?.props,id:this.id,usage:(r?I.INDEX:I.VERTEX)|I.COPY_DST,indexType:r?i:void 0,byteLength:e}),this._buffer}};var Jb=[],e0=[];function Qi(t,e=0,r=1/0){let i=Jb,o={index:-1,data:t,target:[]};return t?typeof t[Symbol.iterator]=="function"?i=t:t.length>0&&(e0.length=t.length,i=e0):i=Jb,(e>0||Number.isFinite(r))&&(i=(Array.isArray(i)?i:Array.from(i)).slice(e,r),o.index=e-1),{iterable:i,objectInfo:o}}function Dc(t){return t&&t[Symbol.asyncIterator]}function Bc(t,e){let{size:r,stride:i,offset:o,startIndices:n,nested:s}=e,a=t.BYTES_PER_ELEMENT,c=i?i/a:r,l=o?o/a:0,f=Math.floor((t.length-l)/c);return(h,{index:u,target:d})=>{if(!n){let _=u*c+l;for(let b=0;b<r;b++)d[b]=t[_+b];return d}let p=n[u],g=n[u+1]||f,m;if(s){m=new Array(g-p);for(let _=p;_<g;_++){let b=_*c+l;d=new Array(r);for(let y=0;y<r;y++)d[y]=t[b+y];m[_-p]=d}}else if(c===r)m=t.subarray(p*r+l,g*r+l);else{m=new t.constructor((g-p)*r);let _=0;for(let b=p;b<g;b++){let y=b*c+l;for(let T=0;T<r;T++)m[_++]=t[y+T]}}return m}}var t0=[],Bn=[[0,1/0]];function r0(t,e){if(t===Bn||(e[0]<0&&(e[0]=0),e[0]>=e[1]))return t;let r=[],i=t.length,o=0;for(let n=0;n<i;n++){let s=t[n];s[1]<e[0]?(r.push(s),o=n+1):s[0]>e[1]?r.push(s):e=[Math.min(s[0],e[0]),Math.max(s[1],e[1])]}return r.splice(o,0,e),r}var Gv={interpolation:{duration:0,easing:t=>t},spring:{stiffness:.05,damping:.5}};function Fc(t,e){if(!t)return null;Number.isFinite(t)&&(t={type:"interpolation",duration:t});let r=t.type||"interpolation";return{...Gv[r],...e,...t,type:r}}var Yt=class extends Dn{constructor(e,r){super(e,r,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:Bn}),this.constant=!1,this.settings.update=r.update||(r.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 r=this.state.needsRedraw;return this.state.needsRedraw=r&&!e,r}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var r;(r=this.state).layoutChanged||(r.layoutChanged=!Qb(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:r}=this.settings,i=this.settings.transition,o=Array.isArray(r)?e[r.find(n=>e[n])]:e[r];return Fc(o,i)}setNeedsUpdate(e=this.id,r){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),r){let{startRow:i=0,endRow:o=1/0}=r;this.state.updateRanges=r0(this.state.updateRanges,[i,o])}else this.state.updateRanges=Bn}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=t0}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){let{state:r,settings:i}=this;return i.noAlloc?!1:i.update?(super.allocate(e,r.updateRanges!==Bn),!0):!1}updateBuffer({numInstances:e,data:r,props:i,context:o}){if(!this.needsUpdate())return!1;let{state:{updateRanges:n},settings:{update:s,noAlloc:a}}=this,c=!0;if(s){for(let[l,f]of n)s.call(o,this,{data:r,startRow:l,endRow:f,props:i,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength<this.value.byteLength+this.byteOffset)this.constant?this.setConstantValue(o,this.value):this.setData({value:this.value,constant:this.constant}),this.constant=!1;else for(let[l,f]of n){let h=Number.isFinite(l)?this.getVertexOffset(l):0,u=Number.isFinite(f)?this.getVertexOffset(f):a||!Number.isFinite(e)?this.value.length:e*this.size;super.updateSubBuffer({startOffset:h,endOffset:u})}this._checkAttributeArray()}else c=!1;return this.clearNeedsUpdate(),this.setNeedsRedraw(),c}setConstantValue(e,r){if(r===void 0||typeof r=="function")return!1;let i=this.settings.transform&&e?this.settings.transform.call(e,r):r;return this.device.type==="webgpu"?this.setConstantBufferValue(i,this.numInstances):(this.setData({constant:!0,value:i})&&this.setNeedsRedraw(),this.clearNeedsUpdate(),!0)}setConstantBufferValue(e,r){let i=this.settings.defaultType,o=this._normalizeValue(e,new i(this.size),0);if(this._hasConstantBufferValue(o,r))return this.constant=!1,this.clearNeedsUpdate(),!1;let n=new i(Math.max(r,1)*this.size);for(let a=0;a<n.length;a+=this.size)n.set(o,a);let s=this.setData({value:n});return this.constant=!1,this.clearNeedsUpdate(),s&&this.setNeedsRedraw(),s}_hasConstantBufferValue(e,r){let i=this.value,o=Math.max(r,1)*this.size;if(!ArrayBuffer.isView(i)||i.length!==o||i.length%this.size!==0)return!1;for(let n=0;n<i.length;n+=this.size)for(let s=0;s<this.size;s++)if(i[n+s]!==e[s])return!1;return!0}setExternalBuffer(e){let{state:r}=this;return e?(this.clearNeedsUpdate(),r.lastExternalBuffer===e||(r.lastExternalBuffer=e,this.setNeedsRedraw(),this.setData(e)),!0):(r.lastExternalBuffer=null,!1)}setBinaryValue(e,r=null){let{state:i,settings:o}=this;if(!e)return i.binaryValue=null,i.binaryAccessor=null,!1;if(o.noAlloc)return!1;if(i.binaryValue===e)return this.clearNeedsUpdate(),!0;if(i.binaryValue=e,this.setNeedsRedraw(),o.transform||r!==this.startIndices){ArrayBuffer.isView(e)&&(e={value:e});let s=e;X(ArrayBuffer.isView(s.value),`invalid ${o.accessor}`);let a=Boolean(s.size)&&s.size!==this.size;return i.binaryAccessor=Bc(s.value,{size:s.size||this.size,stride:s.stride,offset:s.offset,startIndices:r,nested:a}),!1}return this.clearNeedsUpdate(),this.setData(e),!0}getVertexOffset(e){let{startIndices:r}=this;return(r?e<r.length?r[e]:this.numInstances:e)*this.size}getValue(){let e=this.settings.shaderAttributes,r=super.getValue();if(!e)return r;for(let i in e)Object.assign(r,super.getValue(i,e[i]));return r}getBufferLayout(e){this.state.layoutChanged=!1;let r=this.settings.shaderAttributes,i=super._getBufferLayout(),{stepMode:o}=this.settings;if(o==="dynamic"?i.stepMode=e?e.isInstanced?"instance":"vertex":"instance":i.stepMode=o??"vertex",!r)return i;for(let n in r){let s=super._getBufferLayout(n,r[n]);i.attributes.push(...s.attributes)}return i}_autoUpdater(e,{data:r,startRow:i,endRow:o,props:n,numInstances:s}){let{settings:a,state:c,value:l,size:f,startIndices:h}=e,{accessor:u,transform:d}=a,p=c.binaryAccessor||(typeof u=="function"?u:n[u]);X(typeof p=="function",`accessor "${u}" is not a function`);let g=e.getVertexOffset(i),{iterable:m,objectInfo:_}=Qi(r,i,o);for(let b of m){_.index++;let y=p(b,_);if(d&&(y=d.call(this,y)),h){let T=(_.index<h.length-1?h[_.index+1]:s)-h[_.index];if(y&&Array.isArray(y[0])){let S=g;for(let A of y)e._normalizeValue(A,l,S),S+=f}else y&&y.length>f?l.set(y,g):(e._normalizeValue(y,_.target,0),Ua({target:l,source:_.target,start:g,count:T}));g+=T*f}else e._normalizeValue(y,l,g),g+=f}}_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,r=Math.min(4,this.size);if(e&&e.length>=r){let i=!0;switch(r){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}};function nd(t){let{source:e,target:r,start:i=0,size:o,getData:n}=t,s=t.end||r.length,a=e.length,c=s-i;if(a>c){r.set(e.subarray(0,c),i);return}if(r.set(e,i),!n)return;let l=a;for(;l<c;){let f=n(l,e);for(let h=0;h<o;h++)r[i+l]=f[h]||0,l++}}function i0({source:t,target:e,size:r,getData:i,sourceStartIndices:o,targetStartIndices:n}){if(!o||!n)return nd({source:t,target:e,size:r,getData:i}),e;let s=0,a=0,c=i&&((f,h)=>i(f+a,h)),l=Math.min(o.length,n.length);for(let f=1;f<l;f++){let h=o[f]*r,u=n[f]*r;nd({source:t.subarray(s,h),target:e,start:a,end:u,size:r,getData:c}),s=h,a=u}return a<e.length&&nd({source:[],target:e,start:a,size:r,getData:c}),e}function o0(t){let{device:e,settings:r,value:i}=t,o=new Yt(e,r);return o.setData({value:i instanceof Float64Array?new Float64Array(0):new Float32Array(0),normalized:r.normalized}),o}function Lc(t){switch(t){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 "${t}"`)}}function Uc(t){switch(t){case 1:return"float32";case 2:return"float32x2";case 3:return"float32x3";case 4:return"float32x4";default:throw new Error("invalid type size")}}function kc(t){t.push(t.shift())}function n0(t,e){let{doublePrecision:r,settings:i,value:o,size:n}=t,s=r&&o instanceof Float64Array?2:1,a=0,{shaderAttributes:c}=t.settings;if(c)for(let l of Object.values(c))a=Math.max(a,l.vertexOffset??0);return(i.noAlloc?o.length:(e+a)*n)*s}function Vc({device:t,source:e,target:r}){return(!r||r.byteLength<e.byteLength)&&(r?.destroy(),r=t.createBuffer({byteLength:e.byteLength,usage:e.usage})),r}function zc({device:t,buffer:e,attribute:r,fromLength:i,toLength:o,fromStartIndices:n,getData:s=a=>a}){let a=r.doublePrecision&&r.value instanceof Float64Array?2:1,c=r.size*a,l=r.byteOffset,f=r.settings.bytesPerElement<4?l/r.settings.bytesPerElement*4:l,h=r.startIndices,u=n&&h,d=r.isConstant;if(!u&&e&&i>=o)return e;let p=r.value instanceof Float64Array?Float32Array:r.value.constructor,g=d?r.value:new p(r.getBuffer().readSyncWebGL(l,o*p.BYTES_PER_ELEMENT).buffer);if(r.settings.normalized&&!d){let y=s;s=(T,S)=>r.normalizeConstant(y(T,S))}let m=d?(y,T)=>s(g,T):(y,T)=>s(g.subarray(y+l,y+l+c),T),_=e?new Float32Array(e.readSyncWebGL(f,i*4).buffer):new Float32Array(0),b=new Float32Array(o);return i0({source:_,target:b,sourceStartIndices:n,targetStartIndices:h,size:c,getData:m}),(!e||e.byteLength<b.byteLength+f)&&(e?.destroy(),e=t.createBuffer({byteLength:b.byteLength+f,usage:35050})),e.write(b,f),e}var Ji=class{constructor({device:e,attribute:r,timeline:i}){this.buffers=[],this.currentLength=0,this.device=e,this.transition=new qe(i),this.attribute=r,this.attributeInTransition=o0(r),this.currentStartIndices=r.startIndices}get inProgress(){return this.transition.inProgress}start(e,r,i=1/0){this.settings=e,this.currentStartIndices=this.attribute.startIndices,this.currentLength=n0(this.attribute,r),this.transition.start({...e,duration:i})}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 Fn=class extends Ji{constructor({device:e,attribute:r,timeline:i}){super({device:e,attribute:r,timeline:i}),this.type="interpolation",this.transform=t2(e,r)}start(e,r){let i=this.currentLength,o=this.currentStartIndices;if(super.start(e,r,e.duration),e.duration<=0){this.transition.cancel();return}let{buffers:n,attribute:s}=this;kc(n),n[0]=zc({device:this.device,buffer:n[0],attribute:s,fromLength:i,toLength:this.currentLength,fromStartIndices:o,getData:e.enter}),n[1]=Vc({device:this.device,source:n[0],target:n[1]}),this.setBuffer(n[1]);let{transform:a}=this,c=a.model,l=Math.floor(this.currentLength/s.size);a0(s)&&(l/=2),c.setVertexCount(l),s.isConstant?(c.setAttributes({aFrom:n[0]}),c.setConstantAttributes({aTo:s.value})):c.setAttributes({aFrom:n[0],aTo:s.getBuffer()}),a.transformFeedback.setBuffers({vCurrent:n[1]})}onUpdate(){let{duration:e,easing:r}=this.settings,{time:i}=this.transition,o=i/e;r&&(o=r(o));let{model:n}=this.transform,s={time:o};n.shaderInputs.setProps({interpolation:s}),this.transform.run({discard:!0})}delete(){super.delete(),this.transform.destroy()}},Qv=`layout(std140) uniform interpolationUniforms {
|
|
1998
1998
|
float time;
|
|
1999
1999
|
} interpolation;
|
|
2000
|
-
`,
|
|
2000
|
+
`,s0={name:"interpolation",vs:Qv,uniformTypes:{time:"f32"}},Jv=`#version 300 es
|
|
2001
2001
|
#define SHADER_NAME interpolation-transition-vertex-shader
|
|
2002
2002
|
|
|
2003
2003
|
in ATTRIBUTE_TYPE aFrom;
|
|
@@ -2008,7 +2008,7 @@ void main(void) {
|
|
|
2008
2008
|
vCurrent = mix(aFrom, aTo, interpolation.time);
|
|
2009
2009
|
gl_Position = vec4(0.0);
|
|
2010
2010
|
}
|
|
2011
|
-
`,
|
|
2011
|
+
`,e2=`#version 300 es
|
|
2012
2012
|
#define SHADER_NAME interpolation-transition-vertex-shader
|
|
2013
2013
|
|
|
2014
2014
|
in ATTRIBUTE_TYPE aFrom;
|
|
@@ -2031,11 +2031,11 @@ void main(void) {
|
|
|
2031
2031
|
}
|
|
2032
2032
|
gl_Position = vec4(0.0);
|
|
2033
2033
|
}
|
|
2034
|
-
`;function
|
|
2034
|
+
`;function a0(t){return t.doublePrecision&&t.value instanceof Float64Array}function t2(t,e){let r=e.size,i=Lc(r),o=Uc(r),n=e.getBufferLayout();return a0(e)?new je(t,{vs:e2,bufferLayout:[{name:"aFrom",byteStride:8*r,attributes:[{attribute:"aFrom",format:o,byteOffset:0},{attribute:"aFrom64Low",format:o,byteOffset:4*r}]},{name:"aTo",byteStride:8*r,attributes:[{attribute:"aTo",format:o,byteOffset:0},{attribute:"aTo64Low",format:o,byteOffset:4*r}]}],modules:[oh,s0],defines:{ATTRIBUTE_TYPE:i,ATTRIBUTE_SIZE:r},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new je(t,{vs:Jv,bufferLayout:[{name:"aFrom",format:o},{name:"aTo",format:n.attributes[0].format}],modules:[s0],defines:{ATTRIBUTE_TYPE:i},varyings:["vCurrent"],disableWarnings:!0})}var Ln=class extends Ji{constructor({device:e,attribute:r,timeline:i}){super({device:e,attribute:r,timeline:i}),this.type="spring",this.texture=a2(e),this.framebuffer=c2(e,this.texture),this.transform=s2(e,r)}start(e,r){let i=this.currentLength,o=this.currentStartIndices;super.start(e,r);let{buffers:n,attribute:s}=this;for(let c=0;c<2;c++)n[c]=zc({device:this.device,buffer:n[c],attribute:s,fromLength:i,toLength:this.currentLength,fromStartIndices:o,getData:e.enter});n[2]=Vc({device:this.device,source:n[0],target:n[2]}),this.setBuffer(n[1]);let{model:a}=this.transform;a.setVertexCount(Math.floor(this.currentLength/s.size)),s.isConstant?a.setConstantAttributes({aTo:s.value}):a.setAttributes({aTo:s.getBuffer()})}onUpdate(){let{buffers:e,transform:r,framebuffer:i,transition:o}=this,n=this.settings;r.model.setAttributes({aPrev:e[0],aCur:e[1]}),r.transformFeedback.setBuffers({vNext:e[2]});let s={stiffness:n.stiffness,damping:n.damping};r.model.shaderInputs.setProps({spring:s}),r.run({framebuffer:i,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),kc(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(i)[0]>0||o.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}},r2=`layout(std140) uniform springUniforms {
|
|
2035
2035
|
float damping;
|
|
2036
2036
|
float stiffness;
|
|
2037
2037
|
} spring;
|
|
2038
|
-
`,
|
|
2038
|
+
`,i2={name:"spring",vs:r2,uniformTypes:{damping:"f32",stiffness:"f32"}},o2=`#version 300 es
|
|
2039
2039
|
#define SHADER_NAME spring-transition-vertex-shader
|
|
2040
2040
|
|
|
2041
2041
|
#define EPSILON 0.00001
|
|
@@ -2062,7 +2062,7 @@ void main(void) {
|
|
|
2062
2062
|
gl_Position = vec4(0, 0, 0, 1);
|
|
2063
2063
|
gl_PointSize = 100.0;
|
|
2064
2064
|
}
|
|
2065
|
-
`,
|
|
2065
|
+
`,n2=`#version 300 es
|
|
2066
2066
|
#define SHADER_NAME spring-transition-is-transitioning-fragment-shader
|
|
2067
2067
|
|
|
2068
2068
|
in float vIsTransitioningFlag;
|
|
@@ -2074,6 +2074,6 @@ void main(void) {
|
|
|
2074
2074
|
discard;
|
|
2075
2075
|
}
|
|
2076
2076
|
fragColor = vec4(1.0);
|
|
2077
|
-
}`;function r2(t,e){let r=Bc(e.size),i=Lc(e.size);return new $e(t,{vs:e2,fs:t2,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[Jv],defines:{ATTRIBUTE_TYPE:r},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function i2(t){return t.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function o2(t,e){return t.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var n2={interpolation:Bn,spring:Ln},Fn=class{constructor(e,{id:r,timeline:i}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=e,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:r,numInstances:i}){this.numInstances=i||1;for(let o in e){let n=e[o],s=n.getTransitionSetting(r);s&&this._updateAttribute(o,n,s)}for(let o in this.transitions){let n=e[o];(!n||!n.getTransitionSetting(r))&&this._removeTransition(o)}}hasAttribute(e){let r=this.transitions[e];return r&&r.inProgress}getAttributes(){let e={};for(let r in this.transitions){let i=this.transitions[r];i.inProgress&&(e[r]=i.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let r in this.transitions)this.transitions[r].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,r,i){let o=this.transitions[e],n=!o||o.type!==i.type;if(n){o&&this._removeTransition(e);let s=n2[i.type];s?this.transitions[e]=new s({attribute:r,timeline:this.timeline,device:this.device}):(L.error(`unsupported transition type '${i.type}'`)(),n=!1)}(n||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}};var a0="attributeManager.invalidate",s2="attributeManager.updateStart",a2="attributeManager.updateEnd",c2="attribute.updateStart",l2="attribute.allocate",f2="attribute.updateEnd",Kr=class{constructor(e,{id:r="attribute-manager",stats:i,timeline:o}={}){this.mergeBoundsMemoized=ke(cy),this.id=r,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new Fn(e,{id:`${r}-transitions`,timeline:o}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let r of e)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(e,r){let i=this._invalidateTrigger(e,r);G(a0,this,e,i)}invalidateAll(e){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,e);G(a0,this,"all")}update({data:e,numInstances:r,startIndices:i=null,transitions:o,props:n={},buffers:s={},context:a={}}){let c=!1;G(s2,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let f=this.attributes[l],h=f.settings.accessor;f.startIndices=i,f.numInstances=r,n[l]&&L.removed(`props.${l}`,`data.attributes.${l}`)(),f.setExternalBuffer(s[l])||f.setBinaryValue(typeof h=="string"?s[h]:void 0,e.startIndices)||typeof h=="string"&&!s[h]&&f.setConstantValue(a,n[h])||f.needsUpdate()&&(c=!0,this._updateAttribute({attribute:f,numInstances:r,data:e,props:n,context:a})),this.needsRedraw=this.needsRedraw||f.needsRedraw()}c&&G(a2,this,r),this.stats&&(this.stats.get("Update Attributes").timeEnd(),c&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:o})}updateTransition(){let{attributeTransitionManager:e}=this,r=e.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let r=e.map(i=>this.attributes[i]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:i}=this,o={...i.getAttributes()};for(let n in r){let s=r[n];s.needsRedraw(e)&&!i.hasAttribute(n)&&(o[n]=s)}return o}getBufferLayouts(e){return Object.values(this.getAttributes()).map(r=>r.getBufferLayout(e))}_add(e,r){for(let i in e){let o=e[i],n={...o,id:i,size:o.isIndexed&&1||o.size||1,...r};this.attributes[i]=new Kt(this.device,n)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(o=>{e[o]||(e[o]=[]),e[o].push(r)});this.updateTriggers=e}_invalidateTrigger(e,r){let{attributes:i,updateTriggers:o}=this,n=o[e];return n&&n.forEach(s=>{let a=i[s];a&&a.setNeedsUpdate(a.id,r)}),n}_updateAttribute(e){let{attribute:r,numInstances:i}=e;if(G(c2,r),r.constant){r.setConstantValue(e.context,r.value);return}r.allocate(i)&&G(l2,r,i),r.updateBuffer(e)&&(this.needsRedraw=!0,G(f2,r,i))}};F();Pc();var Un=class extends Ge{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:r,toValue:i,duration:o,easing:n}}=this,s=n(e/o);this._value=Ot(r,i,s)}};var c0=1e-5;function l0(t,e,r,i,o){let n=e-t,a=(r-e)*o,c=-n*i;return a+c+n+e}function h2(t,e,r,i,o){if(Array.isArray(r)){let n=[];for(let s=0;s<r.length;s++)n[s]=l0(t[s],e[s],r[s],i,o);return n}return l0(t,e,r,i,o)}function f0(t,e){if(Array.isArray(t)){let r=0;for(let i=0;i<t.length;i++){let o=t[i]-e[i];r+=o*o}return Math.sqrt(r)}return Math.abs(t-e)}var kn=class extends Ge{get value(){return this._currValue}_onUpdate(){let{fromValue:e,toValue:r,damping:i,stiffness:o}=this.settings,{_prevValue:n=e,_currValue:s=e}=this,a=h2(n,s,r,i,o),c=f0(a,r),l=f0(a,s);c<c0&&l<c0&&(a=r,this.end()),this._prevValue=s,this._currValue=a}};var u2={interpolation:Un,spring:kn},Vn=class{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,r,i,o){let{transitions:n}=this;if(n.has(e)){let c=n.get(e),{value:l=c.settings.fromValue}=c;r=l,this.remove(e)}if(o=Dc(o),!o)return;let s=u2[o.type];if(!s){L.error(`unsupported transition type '${o.type}'`)();return}let a=new s(this.timeline);a.start({...o,fromValue:r,toValue:i}),n.set(e,a)}remove(e){let{transitions:r}=this;r.has(e)&&(r.get(e).cancel(),r.delete(e))}update(){let e={};for(let[r,i]of this.transitions)i.update(),e[r]=i.value,i.inProgress||this.remove(r);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function u0(t){let e=t[We];for(let r in e){let i=e[r],{validate:o}=i;if(o&&!o(t[r],i))throw new Error(`Invalid prop ${r}: ${t[r]}`)}}function d0(t,e){let r=Vc({newProps:t,oldProps:e,propTypes:t[We],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=p2(t,e),o=!1;return i||(o=g2(t,e)),{dataChanged:i,propsChanged:r,updateTriggersChanged:o,extensionsChanged:m2(t,e),transitionsChanged:d2(t,e)}}function d2(t,e){if(!t.transitions)return!1;let r={},i=t[We],o=!1;for(let n in t.transitions){let s=i[n],a=s&&s.type;(a==="number"||a==="color"||a==="array")&&nd(t[n],e[n],s)&&(r[n]=!0,o=!0)}return o?r:!1}function Vc({newProps:t,oldProps:e,ignoreProps:r={},propTypes:i={},triggerName:o="props"}){if(e===t)return!1;if(typeof t!="object"||t===null)return`${o} changed shallowly`;if(typeof e!="object"||e===null)return`${o} changed shallowly`;for(let n of Object.keys(t))if(!(n in r)){if(!(n in e))return`${o}.${n} added`;let s=nd(t[n],e[n],i[n]);if(s)return`${o}.${n} ${s}`}for(let n of Object.keys(e))if(!(n in r)){if(!(n in t))return`${o}.${n} dropped`;if(!Object.hasOwnProperty.call(t,n)){let s=nd(t[n],e[n],i[n]);if(s)return`${o}.${n} ${s}`}}return!1}function nd(t,e,r){let i=r&&r.equal;return i&&!i(t,e,r)||!i&&(i=t&&e&&t.equals,i&&!i.call(t,e))?"changed deeply":!i&&e!==t?"changed shallowly":null}function p2(t,e){if(e===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:i,_dataDiff:o}=t;return i?i(t.data,e.data)||(r="Data comparator detected a change"):t.data!==e.data&&(r="A new data container was supplied"),r&&o&&(r=o(t.data,e.data)||r),r}function g2(t,e){if(e===null)return{all:!0};if("all"in t.updateTriggers&&h0(t,e,"all"))return{all:!0};let r={},i=!1;for(let o in t.updateTriggers)o!=="all"&&h0(t,e,o)&&(r[o]=!0,i=!0);return i?r:!1}function m2(t,e){if(e===null)return!0;let r=e.extensions,{extensions:i}=t;if(i===r)return!1;if(!r||!i||i.length!==r.length)return!0;for(let o=0;o<i.length;o++)if(!i[o].equals(r[o]))return!0;return!1}function h0(t,e,r){let i=t.updateTriggers[r];i=i??{};let o=e.updateTriggers[r];return o=o??{},Vc({oldProps:o,newProps:i,triggerName:r})}var _2="count(): argument not an object",y2="count(): argument not a container";function zc(t){if(!T2(t))throw new Error(_2);if(typeof t.count=="function")return t.count();if(Number.isFinite(t.size))return t.size;if(Number.isFinite(t.length))return t.length;if(b2(t))return Object.keys(t).length;throw new Error(y2)}function b2(t){return t!==null&&typeof t=="object"&&t.constructor===Object}function T2(t){return t!==null&&typeof t=="object"}function zn(t,e){if(!e)return t;let r={...t,...e};if("defines"in e&&(r.defines={...t.defines,...e.defines}),"modules"in e&&(r.modules=(t.modules||[]).concat(e.modules),e.modules.some(i=>i.name==="project64"))){let i=r.modules.findIndex(o=>o.name==="project32");i>=0&&r.modules.splice(i,1)}if("inject"in e)if(!t.inject)r.inject=e.inject;else{let i={...t.inject};for(let o in e.inject)i[o]=(i[o]||"")+e.inject[o];r.inject=i}return r}F();var x2={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},sd={};function p0(t,e,r,i){if(r instanceof B)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let o=null;r.compressed&&(o={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let{width:n,height:s}=r.data,a=e.createTexture({...r,sampler:{...x2,...o,...i},mipLevels:e.getMipLevelCount(n,s)});return e.type==="webgl"?a.generateMipmapsWebGL():e.type==="webgpu"&&e.generateMipmapsWebGPU(a),sd[a.id]=t,a}function g0(t,e){!e||!(e instanceof B)||sd[e.id]===t&&(e.delete(),delete sd[e.id])}var A2={boolean:{validate(t,e){return!0},equal(t,e,r){return Boolean(t)===Boolean(e)}},number:{validate(t,e){return Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)}},color:{validate(t,e){return e.optional&&!t||ad(t)&&(t.length===3||t.length===4)},equal(t,e,r){return Z(t,e,1)}},accessor:{validate(t,e){let r=Wc(t);return r==="function"||r===Wc(e.value)},equal(t,e,r){return typeof e=="function"?!0:Z(t,e,1)}},array:{validate(t,e){return e.optional&&!t||ad(t)},equal(t,e,r){let{compare:i}=r,o=Number.isInteger(i)?i:i?1:0;return i?Z(t,e,o):t===e}},object:{equal(t,e,r){if(r.ignore)return!0;let{compare:i}=r,o=Number.isInteger(i)?i:i?1:0;return i?Z(t,e,o):t===e}},function:{validate(t,e){return e.optional&&!t||typeof t=="function"},equal(t,e,r){return!r.compare&&r.ignore!==!1||t===e}},data:{transform:(t,e,r)=>{if(!t)return t;let{dataTransform:i}=r.props;return i?i(t):typeof t.shape=="string"&&t.shape.endsWith("-table")&&Array.isArray(t.data)?t.data:t}},image:{transform:(t,e,r)=>{let i=r.context;return!i||!i.device?null:p0(r.id,i.device,t,{...e.parameters,...r.props.textureParameters})},release:(t,e,r)=>{g0(r.id,t)}}};function m0(t){let e={},r={},i={};for(let[o,n]of Object.entries(t)){let s=n?.deprecatedFor;if(s)i[o]=Array.isArray(s)?s:[s];else{let a=S2(o,n);e[o]=a,r[o]=a.value}}return{propTypes:e,defaultProps:r,deprecatedProps:i}}function S2(t,e){switch(Wc(e)){case"object":return Wn(t,e);case"array":return Wn(t,{type:"array",value:e,compare:!1});case"boolean":return Wn(t,{type:"boolean",value:e});case"number":return Wn(t,{type:"number",value:e});case"function":return Wn(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function Wn(t,e){return"type"in e?{name:t,...A2[e.type],...e}:"value"in e?{name:t,type:Wc(e.value),...e}:{name:t,type:"object",value:e}}function ad(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function Wc(t){return ad(t)?"array":t===null?"null":typeof t}function _0(t,e){let r;for(let n=e.length-1;n>=0;n--){let s=e[n];"extensions"in s&&(r=s.extensions)}let i=cd(t.constructor,r),o=Object.create(i);o[ji]=t,o[yt]={},o[qe]={};for(let n=0;n<e.length;++n){let s=e[n];for(let a in s)o[a]=s[a]}return Object.freeze(o),o}var E2="_mergedDefaultProps";function cd(t,e){if(!(t instanceof Ji.constructor))return{};let r=E2;if(e)for(let o of e){let n=o.constructor;n&&(r+=`:${n.extensionName||n.name}`)}let i=y0(t,r);return i||(t[r]=w2(t,e||[]))}function w2(t,e){if(!t.prototype)return null;let i=Object.getPrototypeOf(t),o=cd(i),n=y0(t,"defaultProps")||{},s=m0(n),a=Object.assign(Object.create(null),o,s.defaultProps),c=Object.assign(Object.create(null),o?.[We],s.propTypes),l=Object.assign(Object.create(null),o?.[Ba],s.deprecatedProps);for(let f of e){let h=cd(f.constructor);h&&(Object.assign(a,h),Object.assign(c,h[We]),Object.assign(l,h[Ba]))}return R2(a,t),v2(a,c),P2(a,l),a[We]=c,a[Ba]=l,e.length===0&&!ld(t,"_propTypes")&&(t._propTypes=c),a}function R2(t,e){let r=C2(e);Object.defineProperties(t,{id:{writable:!0,value:r}})}function P2(t,e){for(let r in e)Object.defineProperty(t,r,{enumerable:!1,set(i){let o=`${this.id}: ${r}`;for(let n of e[r])ld(this,n)||(this[n]=i);L.deprecated(o,e[r].join("/"))()}})}function v2(t,e){let r={},i={};for(let o in e){let n=e[o],{name:s,value:a}=n;n.async&&(r[s]=a,i[s]=M2(s))}t[zt]=r,t[yt]={},Object.defineProperties(t,i)}function M2(t){return{enumerable:!0,set(e){typeof e=="string"||e instanceof Promise||Oc(e)?this[yt][t]=e:this[qe][t]=e},get(){if(this[qe]){if(t in this[qe])return this[qe][t]||this[zt][t];if(t in this[yt]){let e=this[ji]&&this[ji].internalState;if(e&&e.hasAsyncProp(t))return e.getAsyncProp(t)||this[zt][t]}}return this[zt][t]}}}function ld(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function y0(t,e){return ld(t,e)&&t[e]}function C2(t){let e=t.componentName;return e||L.warn(`${t.name}.componentName not specified`)(),e||t.name}var I2=0,jn=class{constructor(...e){this.props=_0(this,e),this.id=this.props.id,this.count=I2++}clone(e){let{props:r}=this,i={};for(let o in r[zt])o in r[qe]?i[o]=r[qe][o]:o in r[yt]&&(i[o]=r[yt][o]);return new this.constructor({...r,...i,...e})}};jn.componentName="Component";jn.defaultProps={};var Ji=jn;var O2=Object.freeze({}),Zr=class{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let r=this.asyncProps[e];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||O2}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let r=this.asyncProps[e];return r&&r.resolvedValue}isAsyncPropLoading(e){if(e){let r=this.asyncProps[e];return Boolean(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(let r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(e,r){this._watchPromise(e,Promise.resolve(r))}setAsyncProps(e){this.component=e[ji]||this.component;let r=e[qe]||{},i=e[yt]||e,o=e[zt]||{};for(let n in r){let s=r[n];this._createAsyncPropData(n,o[n]),this._updateAsyncProp(n,s),r[n]=this.getAsyncProp(n)}for(let n in i){let s=i[n];this._createAsyncPropData(n,o[n]),this._updateAsyncProp(n,s)}}_fetch(e,r){return null}_onResolve(e,r){}_onError(e,r){}_updateAsyncProp(e,r){if(this._didAsyncInputValueChange(e,r)){if(typeof r=="string"&&(r=this._fetch(e,r)),r instanceof Promise){this._watchPromise(e,r);return}if(Oc(r)){this._resolveAsyncIterable(e,r);return}this._setPropValue(e,r)}}_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,r){let i=this.asyncProps[e];return r===i.resolvedValue||r===i.lastValue?!1:(i.lastValue=r,!0)}_setPropValue(e,r){this._freezeAsyncOldProps();let i=this.asyncProps[e];i&&(r=this._postProcessValue(i,r),i.resolvedValue=r,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,r,i){let o=this.asyncProps[e];o&&i>=o.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),o.resolvedValue=r,o.resolvedLoadCount=i,this.onAsyncPropUpdated(e,r))}_watchPromise(e,r){let i=this.asyncProps[e];if(i){i.pendingLoadCount++;let o=i.pendingLoadCount;r.then(n=>{this.component&&(n=this._postProcessValue(i,n),this._setAsyncPropValue(e,n,o),this._onResolve(e,n))}).catch(n=>{this._onError(e,n)})}}async _resolveAsyncIterable(e,r){if(e!=="data"){this._setPropValue(e,r);return}let i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;let o=i.pendingLoadCount,n=[],s=0;for await(let a of r){if(!this.component)return;let{dataTransform:c}=this.component.props;c?n=c(a,n):n=n.concat(a),Object.defineProperty(n,"__diff",{enumerable:!1,value:[{startRow:s,endRow:n.length}]}),s=n.length,this._setAsyncPropValue(e,n,o)}this._onResolve(e,n)}_postProcessValue(e,r){let i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(r,i,this.component):r}_createAsyncPropData(e,r){if(!this.asyncProps[e]){let o=this.component&&this.component.props[We];this.asyncProps[e]={type:o&&o[e],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var $n=class extends Zr{constructor({attributeManager:e,layer:r}){super(r),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,r){let i=this.layer,o=i?.props.fetch;return o?o(r,{propName:e,layer:i}):super._fetch(e,r)}_onResolve(e,r){let i=this.layer;if(i){let o=i.props.onDataLoad;e==="data"&&o&&o(r,{propName:e,layer:i})}}_onError(e,r){let i=this.layer;i&&i.raiseError(r,`loading ${e} of ${this.layer}`)}};var N2="layer.changeFlag",D2="layer.initialize",B2="layer.update",L2="layer.finalize",F2="layer.matched",b0=2**24-1,U2=Object.freeze([]),k2=ke(({oldViewport:t,viewport:e})=>t.equals(e)),ot=new Uint8ClampedArray(0),V2={data:{type:"data",value:U2,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__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:(t,{propName:e,layer:r,loaders:i,loadOptions:o,signal:n})=>{let{resourceManager:s}=r.context;o=o||r.getLoadOptions(),i=i||r.props.loaders,n&&(o={...o,core:{...o?.core,fetch:{...o?.core?.fetch,signal:n}}});let a=s.contains(t);return!a&&!o&&(s.add({resourceId:t,data:ur(t,i),persistent:!1}),a=!0),a?s.subscribe({resourceId:t,onChange:c=>r.internalState?.reloadAsyncProp(e,c),consumerId:r.id,requestId:e}):ur(t,i,o)}},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:k.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:t})=>[0,-t*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},Hn=class extends Ji{constructor(){super(...arguments),this.internalState=null,this.lifecycle=br.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){Y(this.internalState);let r=this.internalState.viewport||this.context.viewport,i=Eu(e,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[o,n,s]=Li(i,r.pixelProjectionMatrix);return e.length===2?[o,n]:[o,n,s]}unproject(e){return Y(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,r){Y(this.internalState);let i=this.internalState.viewport||this.context.viewport;return Oa(e,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}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 r of this.getModels())r.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===k.DEFAULT||e===k.LNGLAT||e===k.CARTESIAN}onHover(e,r){return this.props.onHover&&this.props.onHover(e,r)||!1}onClick(e,r){return this.props.onClick&&this.props.onClick(e,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,r=[]){return r[0]=e+1&255,r[1]=e+1>>8&255,r[2]=e+1>>8>>8&255,r}decodePickingColor(e){Y(e instanceof Uint8Array);let[r,i,o]=e;return r+i*256+o*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:zc(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=zn(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)e=zn(e,r.getShaders.call(this,r));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let r=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&r)if(Array.isArray(i))for(let o of i)r.invalidateAll(o);else r.invalidateAll();if(r){let{props:o}=e,n=this.internalState.hasPickingBuffer,s=Number.isInteger(o.highlightedObjectIndex)||Boolean(o.pickable)||o.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(n!==s){this.internalState.hasPickingBuffer=s;let{pickingColors:a,instancePickingColors:c}=r.attributes,l=a||c;l&&(s&&l.constant&&(l.constant=!1,r.invalidate(l.id)),!l.value&&!s&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(e){for(let i of this.getModels())i.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let r of this.getModels())r.draw(e.renderPass)}getPickingInfo({info:e,mode:r,sourceLayer:i}){let{index:o}=e;return o>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[o]),e}raiseError(e,r){r&&(e=new Error(`${r}: ${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 r=this.internalState.viewport;this.internalState.viewport=e,(!r||!k2({oldViewport:r,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let r=this.getAttributeManager();r&&(e==="all"?r.invalidateAll():r.invalidate(e))}updateAttributes(e){let r=!1;for(let i in e)e[i].layoutChanged()&&(r=!0);for(let i of this.getModels())this._setModelAttributes(i,e,r)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let r=this.props,i=this.getNumInstances(),o=this.getStartIndices();e.update({data:r.data,numInstances:i,startIndices:o,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let n=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(n)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let r=e.update(),i=Object.create(this.props);for(let o in r)Object.defineProperty(i,o,{value:r[o]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:r}){if(e.constant)return;let i=Math.floor(ot.length/4);if(this.internalState.usesPickingColorCache=!0,i<r){r>b0&&L.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),ot=Ze.allocate(ot,r,{size:4,copy:!0,maxCount:Math.max(r,b0)});let o=Math.floor(ot.length/4),n=[0,0,0];for(let s=i;s<o;s++)this.encodePickingColor(s,n),ot[s*4+0]=n[0],ot[s*4+1]=n[1],ot[s*4+2]=n[2],ot[s*4+3]=0}e.value=ot.subarray(0,r*4)}_setModelAttributes(e,r,i=!1){if(!Object.keys(r).length)return;if(i){let a=this.getAttributeManager();e.setBufferLayout(a.getBufferLayouts(e)),r=a.getAttributes()}let o=e.userData?.excludeAttributes||{},n={},s={};for(let a in r){if(o[a])continue;let c=r[a].getValue();for(let l in c){let f=c[l];f instanceof I?r[a].settings.isIndexed?e.setIndexBuffer(f):n[l]=f:f&&(s[l]=f)}}e.setAttributes(n),e.setConstantAttributes(s)}disablePickingIndex(e){let r=this.props.data;if(!("attributes"in r)){this._disablePickingIndex(e);return}let{pickingColors:i,instancePickingColors:o}=this.getAttributeManager().attributes,n=i||o,s=n&&r.attributes&&r.attributes[n.id];if(s&&s.value){let a=s.value,c=this.encodePickingColor(e);for(let l=0;l<r.length;l++){let f=n.getVertexOffset(l);a[f]===c[0]&&a[f+1]===c[1]&&a[f+2]===c[2]&&this._disablePickingIndex(l)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){let{pickingColors:r,instancePickingColors:i}=this.getAttributeManager().attributes,o=r||i;if(!o)return;let n=o.getVertexOffset(e),s=o.getVertexOffset(e+1);o.buffer.write(new Uint8Array(s-n),n)}restorePickingColors(){let{pickingColors:e,instancePickingColors:r}=this.getAttributeManager().attributes,i=e||r;i&&(this.internalState.usesPickingColorCache&&i.value.buffer!==ot.buffer&&(i.value=ot.subarray(0,i.value.length)),i.updateSubBuffer({startOffset:0}))}_initialize(){Y(!this.internalState),Y(Number.isFinite(this.props.coordinateSystem)),G(D2,this);let e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new $n({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(L.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new Vn(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){G(F2,this,this===e);let{state:r,internalState:i}=e;this!==e&&(this.internalState=i,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(G(B2,this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();let r=this.props,i=this.context,o=this.internalState,n=i.viewport,s=this._updateUniformTransition();o.propsInTransition=s,i.viewport=o.viewport||n,this.props=s;try{let a=this._getUpdateParams(),c=this.getModels();if(i.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let f of this.props.extensions)f.updateState.call(this,a,f);this.setNeedsRedraw(),this._updateAttributes();let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{i.viewport=n,this.props=r,this._clearChangeFlags(),o.needsUpdate=!1,o.resetOldProps()}}_finalize(){G(L2,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:r=null,uniforms:i={},parameters:o={}}){this._updateAttributeTransition();let n=this.props,s=this.context;this.props=this.internalState.propsInTransition||n;try{r&&this.setShaderModuleProps(r);let{getPolygonOffset:a}=this.props,c=a&&a(i)||[0,0];s.device instanceof it&&s.device.setParametersWebGL({polygonOffset:c});let l=s.device instanceof it?null:z2(o);if(W2(this.getModels(),e,o,l),s.device instanceof it)s.device.withParametersWebGL(o,()=>{let f={renderPass:e,shaderModuleProps:r,uniforms:i,parameters:o,context:s};for(let h of this.props.extensions)h.draw.call(this,f,h);this.draw(f)});else{l?.renderPassParameters&&e.setParameters(l.renderPassParameters);let f={renderPass:e,shaderModuleProps:r,uniforms:i,parameters:o,context:s};for(let h of this.props.extensions)h.draw.call(this,f,h);this.draw(f)}}finally{this.props=n}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let o in e)if(e[o]){let n=!1;switch(o){case"dataChanged":let s=e[o],a=r[o];s&&Array.isArray(a)&&(r.dataChanged=Array.isArray(s)?a.concat(s):s,n=!0);default:r[o]||(r[o]=e[o],n=!0)}n&&G(N2,this,o,e)}let i=Boolean(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=i,r.somethingChanged=i||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,r){let i=d0(e,r);if(i.updateTriggersChanged)for(let o in i.updateTriggersChanged)i.updateTriggersChanged[o]&&this.invalidateAttribute(o);if(i.transitionsChanged)for(let o in i.transitionsChanged)this.internalState.uniformTransitions.add(o,r[o],e[o],e.transitions?.[o]);return this.setChangeFlags(i)}validateProps(){u0(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let r={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&typeof i=="function"&&(r.highlightColor=i(e)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new Kr(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,r){let{props:i,oldProps:o}=e,n=this.state.model;n?.isInstanced&&n.setInstanceCount(this.getNumInstances());let{autoHighlight:s,highlightedObjectIndex:a,highlightColor:c}=i;if(r||o.autoHighlight!==s||o.highlightedObjectIndex!==a||o.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(r||o.autoHighlight!==s||a!==o.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 r=!1;r=r||this.internalState.needsRedraw&&this.id;let i=this.getAttributeManager(),o=i?i.getNeedsRedraw(e):!1;if(r=r||o,r)for(let n of this.props.extensions)n.onNeedsRedraw.call(this,n);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};Hn.defaultProps=V2;Hn.layerName="Layer";var jc=Hn;function z2(t){let{blendConstant:e,...r}=t;return e?{pipelineParameters:r,renderPassParameters:{blendConstant:e}}:{pipelineParameters:r}}function W2(t,e,r,i){for(let o of t)o.device.type==="webgpu"?(j2(o,e),o.setParameters({...o.parameters,...i?.pipelineParameters})):o.setParameters(r)}function j2(t,e){let r=e.props.framebuffer||(e.framebuffer??null);if(!r)return;let i=r.colorAttachments.map(s=>s?.texture?.format??null),o=r.depthStencilAttachment?.texture?.format,n=t;(!$2(n.props.colorAttachmentFormats,i)||n.props.depthStencilAttachmentFormat!==o)&&(n.props.colorAttachmentFormats=i,n.props.depthStencilAttachmentFormat=o,n._setPipelineNeedsUpdate("attachment formats"))}function $2(t,e){if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}var H2="compositeLayer.renderLayers",$c=class extends jc{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:r}=e;return r&&r.__source&&r.__source.parent&&r.__source.parent.id===this.id&&(e.object=r.__source.object,e.index=r.__source.index),e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,r){return r&&r.length}getSubLayerClass(e,r){let{_subLayerProps:i}=this.props;return i&&i[e]&&i[e].type||r}getSubLayerRow(e,r,i){return e.__source={parent:this,object:r,index:i},e}getSubLayerAccessor(e){if(typeof e=="function"){let r={index:-1,data:this.props.data,target:[]};return(i,o)=>i&&i.__source?(r.index=i.__source.index,e(i.__source.object,r)):e(i,o)}return e}getSubLayerProps(e={}){let{opacity:r,pickable:i,visible:o,parameters:n,getPolygonOffset:s,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:h,wrapLongitude:u,positionFormat:d,modelMatrix:p,extensions:g,fetch:m,operation:_,_subLayerProps:b}=this.props,y={id:"",updateTriggers:{},opacity:r,pickable:i,visible:o,parameters:n,getPolygonOffset:s,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:h,wrapLongitude:u,positionFormat:d,modelMatrix:p,extensions:g,fetch:m,operation:_},T=b&&e.id&&b[e.id],S=T&&T.updateTriggers,A=e.id||"sublayer";if(T){let w=this.props[We],P=e.type?e.type._propTypes:{};for(let R in T){let v=P[R]||w[R];v&&v.type==="accessor"&&(T[R]=this.getSubLayerAccessor(T[R]))}}Object.assign(y,e,T),y.id=`${this.props.id}-${A}`,y.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...S};for(let w of g){let P=w.getSubLayerProps.call(this,w);P&&Object.assign(y,P,{updateTriggers:Object.assign(y.updateTriggers,P.updateTriggers)})}return y}_updateAutoHighlight(e){for(let r of this.getSubLayers())r.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,r){let i=this.internalState.subLayers,o=!i||this.needsUpdate();if(o){let n=this.renderLayers();i=Tr(n,Boolean),this.internalState.subLayers=i}G(H2,this,o,i);for(let n of i)n.parent=this}};$c.layerName="CompositeLayer";var T0=$c;var fd=Math.PI/180;function X2({height:t,focalDistance:e,orbitAxis:r,rotationX:i,rotationOrbit:o,zoom:n}){let s=r==="Z"?[0,0,1]:[0,1,0],a=r==="Z"?[0,-e,0]:[0,0,e],c=new z().lookAt({eye:a,up:s});c.rotateX(i*fd),r==="Z"?c.rotateZ(o*fd):c.rotateY(o*fd);let l=Math.pow(2,n)/t;return c.scale(l),c}var Hc=class extends Se{constructor(e){let{height:r,projectionMatrix:i,fovy:o=50,orbitAxis:n="Z",target:s=[0,0,0],rotationX:a=0,rotationOrbit:c=0,zoom:l=0}=e,f=i?i[5]/2:Ut(o);super({...e,longitude:void 0,viewMatrix:X2({height:r||1,focalDistance:f,orbitAxis:n,rotationX:a,rotationOrbit:c,zoom:l}),fovy:o,focalDistance:f,position:s,zoom:l}),this.target=s,this.orbitAxis=n,this.rotationX=a,this.rotationOrbit=c,this.fovy=o,this.projectedCenter=this.project(this.center)}unproject(e,{topLeft:r=!0}={}){let[i,o,n=this.projectedCenter[2]]=e,s=r?o:this.height-o,[a,c,l]=ze([i,s,n],this.pixelUnprojectionMatrix);return[a,c,l]}panByPosition(e,r,i){let o=this.project(e),{near:n,far:s}=sy(this.projectionMatrix),a=n*s/(s-o[2]*(s-n)),c=n*s/(s-this.projectedCenter[2]*(s-n)),l=a/c,f=[this.width/2+(o[0]-r[0])*l,this.height/2+(o[1]-r[1])*l,this.projectedCenter[2]];return{target:this.unproject(f)}}};Hc.displayName="OrbitViewport";var Xc=Hc;var Y2=new z().lookAt({eye:[0,0,1]});function K2({width:t,height:e,near:r,far:i,padding:o}){let n=-t/2,s=t/2,a=-e/2,c=e/2;if(o){let{left:l=0,right:f=0,top:h=0,bottom:u=0}=o,d=U((l+t-f)/2,0,t)-t/2,p=U((h+e-u)/2,0,e)-e/2;n-=d,s-=d,a+=p,c+=p}return new z().ortho({left:n,right:s,bottom:a,top:c,near:r,far:i})}var Yc=class extends Se{constructor(e){let{width:r,height:i,near:o=.1,far:n=1e3,zoom:s=0,target:a=[0,0,0],padding:c=null,flipY:l=!0}=e,f=e.zoomX??(Array.isArray(s)?s[0]:s),h=e.zoomY??(Array.isArray(s)?s[1]:s),u=Math.min(f,h),d=Math.pow(2,u),p;if(f!==h){let g=Math.pow(2,f),m=Math.pow(2,h);p={unitsPerMeter:[g/d,m/d,1],metersPerUnit:[d/g,d/m,1]}}super({...e,longitude:void 0,position:a,viewMatrix:Y2.clone().scale([d,d*(l?-1:1),d]),projectionMatrix:K2({width:r||1,height:i||1,padding:c,near:o,far:n}),zoom:u,distanceScales:p}),this.target=a,this.zoomX=f,this.zoomY=h,this.flipY=l}projectFlat([e,r]){let{unitsPerMeter:i}=this.distanceScales;return[e*i[0],r*i[1]]}unprojectFlat([e,r]){let{metersPerUnit:i}=this.distanceScales;return[e*i[0],r*i[1]]}panByPosition(e,r,i){let o=ze(r,this.pixelUnprojectionMatrix),n=this.projectFlat(e),s=ee.add([],n,ee.negate([],o)),a=ee.add([],this.center,s);return{target:this.unprojectFlat(a)}}};Yc.displayName="OrthographicViewport";var Kc=Yc;var Zc=class extends Se{constructor(e){let{longitude:r,latitude:i,modelMatrix:o,bearing:n=0,pitch:s=0,up:a=[0,0,1]}=e,l=new je({bearing:n,pitch:s===-90?1e-4:90+s}).toVector3().normalize(),f=o?new z(o).transformAsVector(l):l,h=Number.isFinite(i)?rn({latitude:i}):0,u=Math.pow(2,h),d=new z().lookAt({eye:[0,0,0],center:f,up:a}).scale(u);super({...e,zoom:h,viewMatrix:d}),this.latitude=i,this.longitude=r,this.pitch=s,this.bearing=n,this.up=a}};Zc.displayName="FirstPersonViewport";var qc=Zc;var qr=20,x0=500,Xn=class extends Qe{constructor(e){let{width:r,height:i,position:o=[0,0,0],bearing:n=0,pitch:s=0,longitude:a=null,latitude:c=null,maxPitch:l=90,minPitch:f=-90,maxBounds:h=null,startRotatePos:u,startBearing:d,startPitch:p,startZoomPosition:g,startPanPos:m,startPanPosition:_}=e;super({width:r,height:i,position:o,bearing:n,pitch:s,longitude:a,latitude:c,maxPitch:l,minPitch:f,maxBounds:h},{startRotatePos:u,startBearing:d,startPitch:p,startZoomPosition:g,startPanPos:m,startPanPosition:_},e.makeViewport)}panStart({pos:e}){let{position:r}=this.getViewportProps();return this._getUpdatedState({startPanPos:e,startPanPosition:r})}pan({pos:e}){if(!e)return this;let{startPanPos:r=[0,0],startPanPosition:i=[0,0]}=this.getState(),{width:o,height:n,bearing:s,pitch:a}=this.getViewportProps(),c=x0*(e[0]-r[0])/o,l=x0*(e[1]-r[1])/n,f=new je({bearing:s,pitch:a}),h=new je({bearing:s,pitch:-90}),u=f.toVector3().normalize(),d=h.toVector3().cross(u).normalize();return this._getUpdatedState({position:new $(i).add(d.scale(c)).add(u.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:r=0,deltaAngleY:i=0}){let{startRotatePos:o,startBearing:n,startPitch:s}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!o||n===void 0||s===void 0)return this;let l;if(e){let f=(e[0]-o[0])/a,h=(e[1]-o[1])/c;l={bearing:n-f*180,pitch:s-h*90}}else l={bearing:n-r,pitch:s-i};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:r}){let i=this.getViewportProps(),o=this.getState().startZoomPosition||i.position,n=this.makeViewport(i),{projectionMatrix:s,width:a}=n,l=2*Math.atan(1/s[0])*(e[0]/a-.5),f=this.getDirection(!0);return this._move(f.rotateZ({radians:-l}),Math.log2(r)*qr,o)}zoomEnd(){return this._getUpdatedState({startZoomPosition:null})}moveLeft(e=qr){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:Math.PI/2}),e)}moveRight(e=qr){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:-Math.PI/2}),e)}moveUp(e=qr){let r=this.getDirection(!0);return this._move(r,e)}moveDown(e=qr){let r=this.getDirection(!0);return this._move(r.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=qr){return this._move(new $(0,0,1),e)}zoomOut(e=qr){return this._move(new $(0,0,-1),e)}shortestPathFrom(e){let r=e.getViewportProps(),i={...this.getViewportProps()},{bearing:o,longitude:n}=i;return Math.abs(o-r.bearing)>180&&(i.bearing=o<0?o+360:o-360),n!==null&&r.longitude!==null&&Math.abs(n-r.longitude)>180&&(i.longitude=n<0?n+360:n-360),i}_move(e,r,i=this.getViewportProps().position){let o=e.scale(r);return this._getUpdatedState({position:new $(i).add(o)})}getDirection(e=!1){return new je({bearing:this.getViewportProps().bearing,pitch:e?90:90+this.getViewportProps().pitch}).toVector3().normalize()}_getUpdatedState(e){return new Xn({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{pitch:r,maxPitch:i,minPitch:o,longitude:n,position:s,bearing:a,maxBounds:c}=e;if(e.pitch=U(r,o,i),n!==null&&(n<-180||n>180)&&(e.longitude=_t(n+180,360)-180),(a<-180||a>180)&&(e.bearing=_t(a+180,360)-180),c){let l=U(s[0],c[0][0],c[1][0]),f=U(s[1],c[0][1],c[1][1]),h=U(s[2]??0,c[0][2]??0,c[1][2]??0);(l!==s[0]||f!==s[1]||h!==s[2])&&(e.position=[l,f,h])}return e}},Gr=class extends be{constructor(){super(...arguments),this.ControllerState=Xn,this.transition={transitionDuration:300,transitionInterpolator:new ae(["position","pitch","bearing"])}}};var Gc=class extends ye{constructor(e={}){super(e)}getViewportType(){return qc}get ControllerType(){return Gr}};Gc.displayName="FirstPersonView";var A0=Gc;var hd=class extends Qe{constructor(e){let{width:r,height:i,rotationX:o=0,rotationOrbit:n=0,target:s=[0,0,0],zoom:a=0,minRotationX:c=-90,maxRotationX:l=90,minZoom:f=-1/0,maxZoom:h=1/0,maxBounds:u=null,startPanPosition:d,startRotatePos:p,startRotationX:g,startRotationOrbit:m,startZoomPosition:_,startZoom:b}=e;super({width:r,height:i,rotationX:o,rotationOrbit:n,target:s,zoom:a,minRotationX:c,maxRotationX:l,minZoom:f,maxZoom:h,maxBounds:u},{startPanPosition:d,startRotatePos:p,startRotationX:g,startRotationOrbit:m,startZoomPosition:_,startZoom:b},e.makeViewport),this.unproject3D=e.unproject3D}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:r}){let i=this.getState().startPanPosition||r;if(!i)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(n)}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:r=0,deltaAngleY:i=0}){let{startRotatePos:o,startRotationX:n,startRotationOrbit:s}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!o||n===void 0||s===void 0)return this;let l;if(e){let f=(e[0]-o[0])/a,h=(e[1]-o[1])/c;(n<-90||n>90)&&(f*=-1),l={rotationX:n+h*180,rotationOrbit:s+f*180}}else l={rotationX:n+i,rotationOrbit:s+r};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotationX:null,startRotationOrbit:null})}shortestPathFrom(e){let r=e.getViewportProps(),i={...this.getViewportProps()},{rotationOrbit:o}=i;return Math.abs(o-r.rotationOrbit)>180&&(i.rotationOrbit=o<0?o+360:o-360),i}zoomStart({pos:e}){return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:o,startZoomPosition:n}=this.getState();if(n||(o=this.getViewportProps().zoom,n=this._unproject(r||e)),!n)return this;let s=this._calculateNewZoom({scale:i,startZoom:o}),a=this.makeViewport({...this.getViewportProps(),zoom:s});return this._getUpdatedState({zoom:s,...a.panByPosition(n,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){let r=this.unproject3D?.(e);return r||this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:r}){r===void 0&&(r=this.getViewportProps().zoom);let i=r+Math.log2(e);return this._constrainZoom(i)}_panFromCenter(e){let{target:r}=this.getViewportProps(),i=this._project(r);return this.pan({startPosition:r,pos:[i[0]+e[0],i[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{maxRotationX:r,minRotationX:i,rotationOrbit:o}=e;return e.zoom=this._constrainZoom(e.zoom,e),e.rotationX=U(e.rotationX,i,r),(o<-180||o>180)&&(e.rotationOrbit=_t(o+180,360)-180),e.target=this._constrainTarget(e),e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{maxZoom:i,maxBounds:o}=r,{minZoom:n}=r;if(o&&r.width>0&&r.height>0){let s=o[1][0]-o[0][0],a=o[1][1]-o[0][1],c=(o[1][2]??0)-(o[0][2]??0),l=Math.sqrt(s*s+a*a+c*c);l>0&&(n=Math.max(n,Math.log2(Math.min(r.width,r.height)/l)),n>i&&(n=i))}return U(e,n,i)}_constrainTarget(e){let{target:r,maxBounds:i}=e;if(!i)return r;let[[o,n,s=0],[a,c,l=0]]=i;if(r[0]>=o&&r[0]<=a&&r[1]>=n&&r[1]<=c&&r[2]>=s&&r[2]<=l)return r;let f=this.makeViewport?.(e);if(f){let{cameraPosition:h}=f,u=h[0]-r[0],d=h[1]-r[1],p=h[2]-r[2],g=u*r[0]+d*r[1]+p*r[2],m=u*(u>=0?o:a)+d*(d>=0?n:c)+p*(p>=0?s:l),_=u*(u>=0?a:o)+d*(d>=0?c:n)+p*(p>=0?l:s);if((u||d||p)&&g>=m&&g<=_){let b=O=>U(O,o,a),y=O=>U(O,n,c),T=O=>U(O,s,l),S=O=>u*b(r[0]-O*u)+d*y(r[1]-O*d)+p*T(r[2]-O*p)-g,A=-1,w=1,P=S(A),R=S(w);for(;P<0;)w=A,R=P,A*=2,P=S(A);for(;R>0;)A=w,P=R,w*=2,R=S(w);for(let O=0;O<30;O++){let C=(A+w)/2;S(C)>0?A=C:w=C}let v=(A+w)/2;return[b(r[0]-v*u),y(r[1]-v*d),T(r[2]-v*p)]}}return[U(r[0],o,a),U(r[1],n,c),U(r[2],s,l)]}},Qr=class extends be{constructor(){super(...arguments),this.ControllerState=hd,this.transition={transitionDuration:300,transitionInterpolator:new ae({transitionProps:{compare:["target","zoom","rotationX","rotationOrbit"],required:["target","zoom"]}})},this._unproject3D=e=>{if(this.pickPosition){let{x:r,y:i}=this.props,o=this.pickPosition(r+e[0],i+e[1]);if(o&&o.coordinate)return o.coordinate}return null}}setProps(e){e.unproject3D=this._unproject3D,super.setProps(e)}};var Qc=class extends ye{constructor(e={}){super(e),this.props.orbitAxis=e.orbitAxis||"Z"}getViewportType(){return Xc}get ControllerType(){return Qr}};Qc.displayName="OrbitView";var S0=Qc;function E0({zoom:t=0,zoomX:e,zoomY:r}){return e=e??(Array.isArray(t)?t[0]:t),r=r??(Array.isArray(t)?t[1]:t),{zoomX:e,zoomY:r}}var ud=class extends Qe{constructor(e){let{width:r,height:i,target:o=[0,0,0],zoom:n=0,zoomAxis:s="all",minZoom:a=-1/0,maxZoom:c=1/0,minZoomX:l=a,maxZoomX:f=c,minZoomY:h=a,maxZoomY:u=c,maxBounds:d=null,startPanPosition:p,startZoomPosition:g,startZoom:m}=e,{zoomX:_,zoomY:b}=E0(e);super({width:r,height:i,target:o,zoom:n,zoomX:_,zoomY:b,zoomAxis:s,minZoomX:l,maxZoomX:f,minZoomY:h,maxZoomY:u,maxBounds:d},{startPanPosition:p,startZoomPosition:g,startZoom:m},e.makeViewport)}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:r}){let i=this.getState().startPanPosition||r;if(!i)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart(){return this}rotate(){return this}rotateEnd(){return this}shortestPathFrom(e){let r=e.getViewportProps();return{...this.getViewportProps()}}zoomStart({pos:e}){let{zoomX:r,zoomY:i}=this.getViewportProps();return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:[r,i]})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:o,startZoomPosition:n}=this.getState();if(!n){let{zoomX:c,zoomY:l}=this.getViewportProps();o=[c,l],n=this._unproject(r||e)}if(!n)return this;let s=this._constrainZoom(this._calculateNewZoom({scale:i,startZoom:o})),a=this.makeViewport({...this.getViewportProps(),...s});return this._getUpdatedState({...s,...a.panByPosition(n,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState(this._calculateNewZoom({scale:e}))}zoomOut(e=2){return this._getUpdatedState(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}rotateRight(e=15){return this}rotateUp(e=10){return this}rotateDown(e=10){return this}_project(e){return this.makeViewport(this.getViewportProps()).project(e)}_unproject(e){return this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:r}){let{zoomX:i,zoomY:o,zoomAxis:n}=this.getViewportProps();r===void 0&&(r=[i,o]);let s=Math.log2(e),[a,c]=r;switch(n){case"X":a+=s;break;case"Y":c+=s;break;default:a+=s,c+=s}return{zoomX:a,zoomY:c}}_panFromCenter(e){let{target:r}=this.getViewportProps(),i=this._project(r);return this.pan({startPosition:r,pos:[i[0]+e[0],i[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{zoomX:r,zoomY:i}=this._constrainZoom(e,e);e.zoomX=r,e.zoomY=i,e.zoom=Array.isArray(e.zoom)||e.zoomX!==e.zoomY?[e.zoomX,e.zoomY]:e.zoomX;let{maxBounds:o,target:n}=e;if(o){let s=e.width/2/2**r,a=e.height/2/2**i,c=o[0][0]+s,l=o[1][0]-s,f=o[0][1]+a,h=o[1][1]-a,u=U(n[0],c,l),d=U(n[1],f,h);(u!==n[0]||d!==n[1])&&(e.target=n.slice(),e.target[0]=u,e.target[1]=d)}return e}_constrainZoom({zoomX:e,zoomY:r},i){i||(i=this.getViewportProps());let{zoomAxis:o,maxZoomX:n,maxZoomY:s,maxBounds:a}=i,{minZoomX:c,minZoomY:l}=i;if(a!==null&&i.width>0&&i.height>0){let h=a[0],u=a[1],d=u[0]-h[0],p=u[1]-h[1];Number.isFinite(d)&&d>0&&(c=Math.max(c,Math.log2(i.width/d)),c>n&&(c=n)),Number.isFinite(p)&&p>0&&(l=Math.max(l,Math.log2(i.height/p)),l>s&&(l=s))}switch(o){case"X":e=U(e,c,n);break;case"Y":r=U(r,l,s);break;default:let h=Math.min(n-e,s-r,0);h===0&&(h=Math.max(c-e,l-r,0)),h!==0&&(e+=h,r+=h)}return{zoomX:e,zoomY:r}}},Jr=class extends be{constructor(){super(...arguments),this.ControllerState=ud,this.transition={transitionDuration:300,transitionInterpolator:new ae(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(e){Object.assign(e,E0(e)),super.setProps(e)}_onPanRotate(){return!1}};var Jc=class extends ye{constructor(e={}){super(e)}getViewportType(){return Kc}get ControllerType(){return Jr}};Jc.displayName="OrthographicView";var w0=Jc;var dd=Math.PI/180,Z2=180/Math.PI;function R0(t,e=0){let r=Math.min(180,t)*dd;return Ht*2*Math.sin(r/2)*Math.pow(2,e)}function P0(t,e=0){let r=t/Math.pow(2,e);return Math.asin(Math.min(1,r/Ht/2))*2*Z2}var pd=class extends _n{constructor(e){let{startPanPos:r,...i}=e;i.normalize=!1,super(i),r!==void 0&&(this._state.startPanPos=r)}panStart({pos:e}){let{latitude:r,longitude:i,zoom:o}=this.getViewportProps();return this._getUpdatedState({startPanLngLat:[i,r],startPanPos:e,startZoom:o})}pan({pos:e,startPos:r}){let i=this.getState(),o=i.startPanLngLat||this._unproject(r);if(!o)return this;let n=i.startZoom??this.getViewportProps().zoom,s=i.startPanPos||r,a=[o[0],o[1],n],l=this.makeViewport(this.getViewportProps()).panByPosition(a,e,s);return this._getUpdatedState(l)}panEnd(){return this._getUpdatedState({startPanLngLat:null,startPanPos:null,startZoom:null})}zoom({scale:e}){let i=(this.getState().startZoom||this.getViewportProps().zoom)+Math.log2(e);return this._getUpdatedState({zoom:i})}applyConstraints(e){let{longitude:r,latitude:i,maxBounds:o}=e;if(e.zoom=this._constrainZoom(e.zoom,e),(r<-180||r>180)&&(e.longitude=_t(r+180,360)-180),e.latitude=U(i,-me,me),o&&(e.longitude=U(e.longitude,o[0][0],o[1][0]),e.latitude=U(e.latitude,o[0][1],o[1][1])),o){let n=e.zoom-bt(i),s=o[1][0]-o[0][0],a=o[1][1]-o[0][1];if(a>0&&a<me*2){let c=Math.min(P0(e.height,n),a)/2;e.latitude=U(e.latitude,o[0][1]+c,o[1][1]-c)}if(s>0&&s<360){let c=Math.min(P0(e.width/Math.cos(e.latitude*dd),n),s)/2;e.longitude=U(e.longitude,o[0][0]+c,o[1][0]-c)}}return e.latitude!==i&&(e.zoom+=bt(e.latitude)-bt(i)),e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{latitude:i,maxZoom:o,maxBounds:n}=r,{minZoom:s}=r,a=bt(0),c=bt(i)-a;if(n!==null&&r.width>0&&r.height>0){let f=n[0][1],h=n[1][1],u=Math.sign(f)===Math.sign(h)?Math.min(Math.abs(f),Math.abs(h)):0,d=R0(n[1][0]-n[0][0])*Math.cos(u*dd),p=R0(n[1][1]-n[0][1]);d>0&&(s=Math.max(s,Math.log2(r.width/d)+a)),p>0&&(s=Math.max(s,Math.log2(r.height/p)+a)),s>o&&(s=o)}return U(e,s+c,o+c)}},ei=class extends be{constructor(){super(...arguments),this.ControllerState=pd,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 el=class extends ye{constructor(e={}){super(e)}getViewportType(e){return e.zoom>12?yr:$i}get ControllerType(){return ei}};el.displayName="GlobeView";var v0=el;var Yn=class extends Yt{constructor(){super(...arguments),this._terrainAltitude=void 0,this._terrainAltitudeTarget=void 0,this._pickFrameId=null,this._lastPickTime=0}setProps(e){if(super.setProps({rotationPivot:"3d",...e}),this._pickFrameId===null){let r=()=>{let i=Date.now();if(i-this._lastPickTime>500&&!this.isDragging()&&(this._lastPickTime=i,this._pickTerrainCenterAltitude(),this._terrainAltitude===void 0&&this._terrainAltitudeTarget!==void 0)){this._terrainAltitude=this._terrainAltitudeTarget;let o=new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),n=this._rebaseViewport(this._terrainAltitudeTarget,o);if(n){let s=new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state,...n});super.updateViewport(s)}}this._pickFrameId=requestAnimationFrame(r)};this._pickFrameId=requestAnimationFrame(r)}}finalize(){this._pickFrameId!==null&&(cancelAnimationFrame(this._pickFrameId),this._pickFrameId=null),super.finalize()}updateViewport(e,r=null,i={}){if(this._terrainAltitude===void 0){super.updateViewport(e,r,i);return}let o=.05;this._terrainAltitude+=(this._terrainAltitudeTarget-this._terrainAltitude)*o;let s=e.getViewportProps().position||[0,0,0];r={...r,position:[s[0],s[1],this._terrainAltitude]},super.updateViewport(e,r,i)}_pickTerrainCenterAltitude(){if(!this.pickPosition)return;let{x:e,y:r,width:i,height:o}=this.props,n=this.pickPosition(e+i/2,r+o/2);n?.coordinate&&n.coordinate.length>=3&&(this._terrainAltitudeTarget=n.coordinate[2])}_rebaseViewport(e,r){let i=r.getViewportProps(),o=this.makeViewport({...i,position:[0,0,0]}),n=o.cameraPosition,s=e*o.distanceScales.unitsPerMeter[2],a=n[2],c=a-s;if(c<=0)return null;let l=Math.log2(a/c),f=i.zoom+l,h=this.makeViewport({...i,zoom:f,position:[0,0,e]}),{width:u,height:d}=i,p=[u/2,d/2],g=o.unproject(p,{targetZ:e});if(g&&"panByPosition3D"in h&&typeof h.panByPosition3D=="function"){let m=h.panByPosition3D(g,p);return{position:[0,0,e],zoom:f,...m}}return null}};var Kn=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&&Z(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:r}=e.constructor,i={updateTriggers:{}};for(let o in r)if(o in this.props){let n=r[o],s=this.props[o];i[o]=s,n&&n.type==="accessor"&&(i.updateTriggers[o]=this.props.updateTriggers[o],typeof s=="function"&&(i[o]=this.getSubLayerAccessor(s)))}return i}initializeState(e,r){}updateState(e,r){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,r){}finalizeState(e,r){}};Kn.defaultProps={};Kn.extensionName="LayerExtension";var M0=Kn;var gd={bearing:0,pitch:0,position:[0,0,0]},q2={speed:1.2,curve:1.414},Zn=class extends $t{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={...q2,...e}}interpolateProps(e,r,i){let o=yu(e,r,i,this.opts);for(let n in gd)o[n]=Ot(e[n]||gd[n],r[n]||gd[n],i);return o}getDuration(e,r){let{transitionDuration:i}=r;return i==="auto"&&(i=bu(e,r,this.opts)),i}};F();var qn=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=e;this.typedArrayManager=Ze,this.attributes={},this._attributeDefs=r,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:r,buffers:i={},getGeometry:o,geometryBuffer:n,positionFormat:s,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=r,this.getGeometry=o,this.positionSize=n&&n.size||(s==="XY"?2:3),this.buffers=i,this.normalize=c,n&&(Y(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(n),c||(i.vertexPositions=n)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:r}){this._rebuildGeometry({startRow:e,endRow:r})}getGeometryFromBuffer(e){let r=e.value||e;return ArrayBuffer.isView(r)?Nc(r,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,r){let{attributes:i,buffers:o,_attributeDefs:n,typedArrayManager:s}=this;for(let a in n)if(a in o)s.release(i[a]),i[a]=null;else{let c=n[a];c.copy=r,i[a]=s.allocate(i[a],e,c)}}_forEachGeometry(e,r,i){let{data:o,getGeometry:n}=this,{iterable:s,objectInfo:a}=Gi(o,r,i);for(let c of s){a.index++;let l=n?n(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:r,vertexStarts:i,instanceCount:o}=this,{data:n,geometryBuffer:s}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(r=[0],i=[0]),this.normalize||!s)this._forEachGeometry((h,u)=>{let d=h&&this.normalizeGeometry(h);l[u]=d,i[u+1]=i[u]+(d?this.getGeometrySize(d):0)},a,c),o=i[i.length-1];else if(i=n.startIndices,o=i[n.length]||0,ArrayBuffer.isView(s))o=o||s.length/this.positionSize;else if(s instanceof I){let h=this.positionSize*4;o=o||s.byteLength/h}else if(s.buffer){let h=s.stride||this.positionSize*4;o=o||s.buffer.byteLength/h}else if(s.value){let h=s.value,u=s.stride/h.BYTES_PER_ELEMENT||this.positionSize;o=o||h.length/u}this._allocate(o,Boolean(e)),this.indexStarts=r,this.vertexStarts=i,this.instanceCount=o;let f={};this._forEachGeometry((h,u)=>{let d=l[u]||h;f.vertexStart=i[u],f.indexStart=r[u];let p=u<i.length-1?i[u+1]:o;f.geometrySize=p-i[u],f.geometryIndex=u,this.updateGeometryAttributes(d,f)},a,c),this.vertexCount=r[r.length-1]}};var tl=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 r=this.props,i={...this.props,...e};if(this.props=i,!this.map)return;this._update(r,i)&&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:r,container:i}=e;r.accessToken=e.mapboxApiAccessToken||"",this.map=new e.mapLib.Map({container:i,maxZoom:24,...e.mapOptions,...C0(e.viewState),style:e.mapStyle,interactive:!1,trackResize:!1}),Object.defineProperty(i,"offsetWidth",{get:()=>this.width}),Object.defineProperty(i,"clientWidth",{get:()=>this.width}),Object.defineProperty(i,"offsetHeight",{get:()=>this.height}),Object.defineProperty(i,"clientHeight",{get:()=>this.height}),this.map.resize()}_update(e,r){e.mapStyle!==r.mapStyle&&this.map.setStyle(r.mapStyle);let o=e.width!==r.width||e.height!==r.height;o&&(this.width=r.width,this.height=r.height,this.map.resize());let n=e.viewState,s=r.viewState,a=s.latitude!==n.latitude||s.longitude!==n.longitude||s.zoom!==n.zoom||s.pitch!==n.pitch||s.bearing!==n.bearing;return a&&this.map.jumpTo(C0(s)),o||a}};function C0(t){return{center:[t.longitude,t.latitude],zoom:t.zoom,bearing:t.bearing??0,pitch:t.pitch??0}}var I0={position:"absolute",left:0,top:0,width:"100%",height:"100%"};function G2(t){let{container:e=document.body}=t;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 i=document.createElement("div");e.appendChild(i),Object.assign(i.style,I0);let o=document.createElement("canvas");return e.appendChild(o),Object.assign(o.style,I0),{container:e,mapCanvas:i,deckCanvas:o}}var Gn=class extends Ic{constructor(e){if(typeof document>"u")throw Error("Deck can only be used in the browser");let{mapCanvas:r,deckCanvas:i}=G2(e),o=e.viewState||e.initialViewState,n=Number.isFinite(o&&o.latitude),{map:s=globalThis.mapboxgl||globalThis.maplibregl}=e;super({canvas:i,...e}),s&&s.Map?this._map=n&&new tl({...e,width:0,height:0,viewState:o,container:r,mapLib:s}):this._map=s}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,r){if(this._map){let i=this.getViewports()[0];i&&this._map.setProps({width:i.width,height:i.height,viewState:i})}super._drawLayers(e,r)}};globalThis.luma=globalThis.luma||{};globalThis.loaders=globalThis.loaders||{};Object.assign(globalThis.luma,xh);Object.assign(globalThis.loaders,Zh);return F0(Q2);})();
|
|
2077
|
+
}`;function s2(t,e){let r=Lc(e.size),i=Uc(e.size);return new je(t,{vs:o2,fs:n2,bufferLayout:[{name:"aPrev",format:i},{name:"aCur",format:i},{name:"aTo",format:e.getBufferLayout().attributes[0].format}],varyings:["vNext"],modules:[i2],defines:{ATTRIBUTE_TYPE:r},parameters:{depthCompare:"always",blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"}})}function a2(t){return t.createTexture({data:new Uint8Array(4),format:"rgba8unorm",width:1,height:1})}function c2(t,e){return t.createFramebuffer({id:"spring-transition-is-transitioning-framebuffer",width:1,height:1,colorAttachments:[e]})}var l2={interpolation:Fn,spring:Ln},Un=class{constructor(e,{id:r,timeline:i}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=r,this.device=e,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(let e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:r,numInstances:i}){this.numInstances=i||1;for(let o in e){let n=e[o],s=n.getTransitionSetting(r);s&&this._updateAttribute(o,n,s)}for(let o in this.transitions){let n=e[o];(!n||!n.getTransitionSetting(r))&&this._removeTransition(o)}}hasAttribute(e){let r=this.transitions[e];return r&&r.inProgress}getAttributes(){let e={};for(let r in this.transitions){let i=this.transitions[r];i.inProgress&&(e[r]=i.attributeInTransition)}return e}run(){if(this.numInstances===0)return!1;for(let r in this.transitions)this.transitions[r].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,r,i){let o=this.transitions[e],n=!o||o.type!==i.type;if(n){o&&this._removeTransition(e);let s=l2[i.type];s?this.transitions[e]=new s({attribute:r,timeline:this.timeline,device:this.device}):(F.error(`unsupported transition type '${i.type}'`)(),n=!1)}(n||r.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}};var c0="attributeManager.invalidate",f2="attributeManager.updateStart",h2="attributeManager.updateEnd",u2="attribute.updateStart",d2="attribute.allocate",p2="attribute.updateEnd",Zr=class{constructor(e,{id:r="attribute-manager",stats:i,timeline:o}={}){this.mergeBoundsMemoized=Ue(ly),this.id=r,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new Un(e,{id:`${r}-transitions`,timeline:o}),Object.seal(this)}finalize(){for(let e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){let r=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,r&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(let r of e)this.attributes[r]!==void 0&&(this.attributes[r].delete(),delete this.attributes[r])}invalidate(e,r){let i=this._invalidateTrigger(e,r);q(c0,this,e,i)}invalidateAll(e){for(let r in this.attributes)this.attributes[r].setNeedsUpdate(r,e);q(c0,this,"all")}update({data:e,numInstances:r,startIndices:i=null,transitions:o,props:n={},buffers:s={},context:a={}}){let c=!1;q(f2,this),this.stats&&this.stats.get("Update Attributes").timeStart();for(let l in this.attributes){let f=this.attributes[l],h=f.settings.accessor;f.startIndices=i,f.numInstances=r,n[l]&&F.removed(`props.${l}`,`data.attributes.${l}`)(),f.setExternalBuffer(s[l])||f.setBinaryValue(typeof h=="string"?s[h]:void 0,e.startIndices)||typeof h=="string"&&!s[h]&&f.setConstantValue(a,n[h])||f.needsUpdate()&&(c=!0,this._updateAttribute({attribute:f,numInstances:r,data:e,props:n,context:a})),this.needsRedraw=this.needsRedraw||f.needsRedraw()}c&&q(h2,this,r),this.stats&&(this.stats.get("Update Attributes").timeEnd(),c&&this.stats.get("Attributes updated").incrementCount()),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:r,transitions:o})}updateTransition(){let{attributeTransitionManager:e}=this,r=e.run();return this.needsRedraw=this.needsRedraw||r,r}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){let r=e.map(i=>this.attributes[i]?.getBounds());return this.mergeBoundsMemoized(r)}getChangedAttributes(e={clearChangedFlags:!1}){let{attributes:r,attributeTransitionManager:i}=this,o={...i.getAttributes()};for(let n in r){let s=r[n];s.needsRedraw(e)&&!i.hasAttribute(n)&&(o[n]=s)}return o}getBufferLayouts(e){return Object.values(this.getAttributes()).map(r=>r.getBufferLayout(e))}_add(e,r){for(let i in e){let o=e[i],n={...o,id:i,size:o.isIndexed&&1||o.size||1,...r};this.attributes[i]=new Yt(this.device,n)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){let e={};for(let r in this.attributes)this.attributes[r].getUpdateTriggers().forEach(o=>{e[o]||(e[o]=[]),e[o].push(r)});this.updateTriggers=e}_invalidateTrigger(e,r){let{attributes:i,updateTriggers:o}=this,n=o[e];return n&&n.forEach(s=>{let a=i[s];a&&a.setNeedsUpdate(a.id,r)}),n}_updateAttribute(e){let{attribute:r,numInstances:i}=e;if(q(u2,r),r.constant){r.setConstantValue(e.context,r.value);return}r.allocate(i)&&q(d2,r,i),r.updateBuffer(e)&&(this.needsRedraw=!0,q(p2,r,i))}};L();Mc();var kn=class extends qe{get value(){return this._value}_onUpdate(){let{time:e,settings:{fromValue:r,toValue:i,duration:o,easing:n}}=this,s=n(e/o);this._value=It(r,i,s)}};var l0=1e-5;function f0(t,e,r,i,o){let n=e-t,a=(r-e)*o,c=-n*i;return a+c+n+e}function g2(t,e,r,i,o){if(Array.isArray(r)){let n=[];for(let s=0;s<r.length;s++)n[s]=f0(t[s],e[s],r[s],i,o);return n}return f0(t,e,r,i,o)}function h0(t,e){if(Array.isArray(t)){let r=0;for(let i=0;i<t.length;i++){let o=t[i]-e[i];r+=o*o}return Math.sqrt(r)}return Math.abs(t-e)}var Vn=class extends qe{get value(){return this._currValue}_onUpdate(){let{fromValue:e,toValue:r,damping:i,stiffness:o}=this.settings,{_prevValue:n=e,_currValue:s=e}=this,a=g2(n,s,r,i,o),c=h0(a,r),l=h0(a,s);c<l0&&l<l0&&(a=r,this.end()),this._prevValue=s,this._currValue=a}};var m2={interpolation:kn,spring:Vn},zn=class{constructor(e){this.transitions=new Map,this.timeline=e}get active(){return this.transitions.size>0}add(e,r,i,o){let{transitions:n}=this;if(n.has(e)){let c=n.get(e),{value:l=c.settings.fromValue}=c;r=l,this.remove(e)}if(o=Fc(o),!o)return;let s=m2[o.type];if(!s){F.error(`unsupported transition type '${o.type}'`)();return}let a=new s(this.timeline);a.start({...o,fromValue:r,toValue:i}),n.set(e,a)}remove(e){let{transitions:r}=this;r.has(e)&&(r.get(e).cancel(),r.delete(e))}update(){let e={};for(let[r,i]of this.transitions)i.update(),e[r]=i.value,i.inProgress||this.remove(r);return e}clear(){for(let e of this.transitions.keys())this.remove(e)}};function d0(t){let e=t[ze];for(let r in e){let i=e[r],{validate:o}=i;if(o&&!o(t[r],i))throw new Error(`Invalid prop ${r}: ${t[r]}`)}}function p0(t,e){let r=Wc({newProps:t,oldProps:e,propTypes:t[ze],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),i=y2(t,e),o=!1;return i||(o=b2(t,e)),{dataChanged:i,propsChanged:r,updateTriggersChanged:o,extensionsChanged:T2(t,e),transitionsChanged:_2(t,e)}}function _2(t,e){if(!t.transitions)return!1;let r={},i=t[ze],o=!1;for(let n in t.transitions){let s=i[n],a=s&&s.type;(a==="number"||a==="color"||a==="array")&&sd(t[n],e[n],s)&&(r[n]=!0,o=!0)}return o?r:!1}function Wc({newProps:t,oldProps:e,ignoreProps:r={},propTypes:i={},triggerName:o="props"}){if(e===t)return!1;if(typeof t!="object"||t===null)return`${o} changed shallowly`;if(typeof e!="object"||e===null)return`${o} changed shallowly`;for(let n of Object.keys(t))if(!(n in r)){if(!(n in e))return`${o}.${n} added`;let s=sd(t[n],e[n],i[n]);if(s)return`${o}.${n} ${s}`}for(let n of Object.keys(e))if(!(n in r)){if(!(n in t))return`${o}.${n} dropped`;if(!Object.hasOwnProperty.call(t,n)){let s=sd(t[n],e[n],i[n]);if(s)return`${o}.${n} ${s}`}}return!1}function sd(t,e,r){let i=r&&r.equal;return i&&!i(t,e,r)||!i&&(i=t&&e&&t.equals,i&&!i.call(t,e))?"changed deeply":!i&&e!==t?"changed shallowly":null}function y2(t,e){if(e===null)return"oldProps is null, initial diff";let r=!1,{dataComparator:i,_dataDiff:o}=t;return i?i(t.data,e.data)||(r="Data comparator detected a change"):t.data!==e.data&&(r="A new data container was supplied"),r&&o&&(r=o(t.data,e.data)||r),r}function b2(t,e){if(e===null)return{all:!0};if("all"in t.updateTriggers&&u0(t,e,"all"))return{all:!0};let r={},i=!1;for(let o in t.updateTriggers)o!=="all"&&u0(t,e,o)&&(r[o]=!0,i=!0);return i?r:!1}function T2(t,e){if(e===null)return!0;let r=e.extensions,{extensions:i}=t;if(i===r)return!1;if(!r||!i||i.length!==r.length)return!0;for(let o=0;o<i.length;o++)if(!i[o].equals(r[o]))return!0;return!1}function u0(t,e,r){let i=t.updateTriggers[r];i=i??{};let o=e.updateTriggers[r];return o=o??{},Wc({oldProps:o,newProps:i,triggerName:r})}var x2="count(): argument not an object",A2="count(): argument not a container";function jc(t){if(!E2(t))throw new Error(x2);if(typeof t.count=="function")return t.count();if(Number.isFinite(t.size))return t.size;if(Number.isFinite(t.length))return t.length;if(S2(t))return Object.keys(t).length;throw new Error(A2)}function S2(t){return t!==null&&typeof t=="object"&&t.constructor===Object}function E2(t){return t!==null&&typeof t=="object"}function Wn(t,e){if(!e)return t;let r={...t,...e};if("defines"in e&&(r.defines={...t.defines,...e.defines}),"modules"in e&&(r.modules=(t.modules||[]).concat(e.modules),e.modules.some(i=>i.name==="project64"))){let i=r.modules.findIndex(o=>o.name==="project32");i>=0&&r.modules.splice(i,1)}if("inject"in e)if(!t.inject)r.inject=e.inject;else{let i={...t.inject};for(let o in e.inject)i[o]=(i[o]||"")+e.inject[o];r.inject=i}return r}L();var w2={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},ad={};function g0(t,e,r,i){if(r instanceof B)return r;r.constructor&&r.constructor.name!=="Object"&&(r={data:r});let o=null;r.compressed&&(o={minFilter:"linear",mipmapFilter:r.data.length>1?"nearest":"linear"});let{width:n,height:s}=r.data,a=e.createTexture({...r,sampler:{...w2,...o,...i},mipLevels:e.getMipLevelCount(n,s)});return e.type==="webgl"?a.generateMipmapsWebGL():e.type==="webgpu"&&e.generateMipmapsWebGPU(a),ad[a.id]=t,a}function m0(t,e){!e||!(e instanceof B)||ad[e.id]===t&&(e.delete(),delete ad[e.id])}var R2={boolean:{validate(t,e){return!0},equal(t,e,r){return Boolean(t)===Boolean(e)}},number:{validate(t,e){return Number.isFinite(t)&&(!("max"in e)||t<=e.max)&&(!("min"in e)||t>=e.min)}},color:{validate(t,e){return e.optional&&!t||cd(t)&&(t.length===3||t.length===4)},equal(t,e,r){return K(t,e,1)}},accessor:{validate(t,e){let r=$c(t);return r==="function"||r===$c(e.value)},equal(t,e,r){return typeof e=="function"?!0:K(t,e,1)}},array:{validate(t,e){return e.optional&&!t||cd(t)},equal(t,e,r){let{compare:i}=r,o=Number.isInteger(i)?i:i?1:0;return i?K(t,e,o):t===e}},object:{equal(t,e,r){if(r.ignore)return!0;let{compare:i}=r,o=Number.isInteger(i)?i:i?1:0;return i?K(t,e,o):t===e}},function:{validate(t,e){return e.optional&&!t||typeof t=="function"},equal(t,e,r){return!r.compare&&r.ignore!==!1||t===e}},data:{transform:(t,e,r)=>{if(!t)return t;let{dataTransform:i}=r.props;return i?i(t):typeof t.shape=="string"&&t.shape.endsWith("-table")&&Array.isArray(t.data)?t.data:t}},image:{transform:(t,e,r)=>{let i=r.context;return!i||!i.device?null:g0(r.id,i.device,t,{...e.parameters,...r.props.textureParameters})},release:(t,e,r)=>{m0(r.id,t)}}};function _0(t){let e={},r={},i={};for(let[o,n]of Object.entries(t)){let s=n?.deprecatedFor;if(s)i[o]=Array.isArray(s)?s:[s];else{let a=P2(o,n);e[o]=a,r[o]=a.value}}return{propTypes:e,defaultProps:r,deprecatedProps:i}}function P2(t,e){switch($c(e)){case"object":return jn(t,e);case"array":return jn(t,{type:"array",value:e,compare:!1});case"boolean":return jn(t,{type:"boolean",value:e});case"number":return jn(t,{type:"number",value:e});case"function":return jn(t,{type:"function",value:e,compare:!0});default:return{name:t,type:"unknown",value:e}}}function jn(t,e){return"type"in e?{name:t,...R2[e.type],...e}:"value"in e?{name:t,type:$c(e.value),...e}:{name:t,type:"object",value:e}}function cd(t){return Array.isArray(t)||ArrayBuffer.isView(t)}function $c(t){return cd(t)?"array":t===null?"null":typeof t}function y0(t,e){let r;for(let n=e.length-1;n>=0;n--){let s=e[n];"extensions"in s&&(r=s.extensions)}let i=ld(t.constructor,r),o=Object.create(i);o[$i]=t,o[_t]={},o[Ze]={};for(let n=0;n<e.length;++n){let s=e[n];for(let a in s)o[a]=s[a]}return Object.freeze(o),o}var v2="_mergedDefaultProps";function ld(t,e){if(!(t instanceof eo.constructor))return{};let r=v2;if(e)for(let o of e){let n=o.constructor;n&&(r+=`:${n.extensionName||n.name}`)}let i=b0(t,r);return i||(t[r]=M2(t,e||[]))}function M2(t,e){if(!t.prototype)return null;let i=Object.getPrototypeOf(t),o=ld(i),n=b0(t,"defaultProps")||{},s=_0(n),a=Object.assign(Object.create(null),o,s.defaultProps),c=Object.assign(Object.create(null),o?.[ze],s.propTypes),l=Object.assign(Object.create(null),o?.[La],s.deprecatedProps);for(let f of e){let h=ld(f.constructor);h&&(Object.assign(a,h),Object.assign(c,h[ze]),Object.assign(l,h[La]))}return C2(a,t),O2(a,c),I2(a,l),a[ze]=c,a[La]=l,e.length===0&&!fd(t,"_propTypes")&&(t._propTypes=c),a}function C2(t,e){let r=D2(e);Object.defineProperties(t,{id:{writable:!0,value:r}})}function I2(t,e){for(let r in e)Object.defineProperty(t,r,{enumerable:!1,set(i){let o=`${this.id}: ${r}`;for(let n of e[r])fd(this,n)||(this[n]=i);F.deprecated(o,e[r].join("/"))()}})}function O2(t,e){let r={},i={};for(let o in e){let n=e[o],{name:s,value:a}=n;n.async&&(r[s]=a,i[s]=N2(s))}t[Vt]=r,t[_t]={},Object.defineProperties(t,i)}function N2(t){return{enumerable:!0,set(e){typeof e=="string"||e instanceof Promise||Dc(e)?this[_t][t]=e:this[Ze][t]=e},get(){if(this[Ze]){if(t in this[Ze])return this[Ze][t]||this[Vt][t];if(t in this[_t]){let e=this[$i]&&this[$i].internalState;if(e&&e.hasAsyncProp(t))return e.getAsyncProp(t)||this[Vt][t]}}return this[Vt][t]}}}function fd(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function b0(t,e){return fd(t,e)&&t[e]}function D2(t){let e=t.componentName;return e||F.warn(`${t.name}.componentName not specified`)(),e||t.name}var B2=0,$n=class{constructor(...e){this.props=y0(this,e),this.id=this.props.id,this.count=B2++}clone(e){let{props:r}=this,i={};for(let o in r[Vt])o in r[Ze]?i[o]=r[Ze][o]:o in r[_t]&&(i[o]=r[_t][o]);return new this.constructor({...r,...i,...e})}};$n.componentName="Component";$n.defaultProps={};var eo=$n;var F2=Object.freeze({}),qr=class{constructor(e){this.component=e,this.asyncProps={},this.onAsyncPropUpdated=()=>{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(let e in this.asyncProps){let r=this.asyncProps[e];r&&r.type&&r.type.release&&r.type.release(r.resolvedValue,r.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||F2}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){let r=this.asyncProps[e];return r&&r.resolvedValue}isAsyncPropLoading(e){if(e){let r=this.asyncProps[e];return Boolean(r&&r.pendingLoadCount>0&&r.pendingLoadCount!==r.resolvedLoadCount)}for(let r in this.asyncProps)if(this.isAsyncPropLoading(r))return!0;return!1}reloadAsyncProp(e,r){this._watchPromise(e,Promise.resolve(r))}setAsyncProps(e){this.component=e[$i]||this.component;let r=e[Ze]||{},i=e[_t]||e,o=e[Vt]||{};for(let n in r){let s=r[n];this._createAsyncPropData(n,o[n]),this._updateAsyncProp(n,s),r[n]=this.getAsyncProp(n)}for(let n in i){let s=i[n];this._createAsyncPropData(n,o[n]),this._updateAsyncProp(n,s)}}_fetch(e,r){return null}_onResolve(e,r){}_onError(e,r){}_updateAsyncProp(e,r){if(this._didAsyncInputValueChange(e,r)){if(typeof r=="string"&&(r=this._fetch(e,r)),r instanceof Promise){this._watchPromise(e,r);return}if(Dc(r)){this._resolveAsyncIterable(e,r);return}this._setPropValue(e,r)}}_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,r){let i=this.asyncProps[e];return r===i.resolvedValue||r===i.lastValue?!1:(i.lastValue=r,!0)}_setPropValue(e,r){this._freezeAsyncOldProps();let i=this.asyncProps[e];i&&(r=this._postProcessValue(i,r),i.resolvedValue=r,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,r,i){let o=this.asyncProps[e];o&&i>=o.resolvedLoadCount&&r!==void 0&&(this._freezeAsyncOldProps(),o.resolvedValue=r,o.resolvedLoadCount=i,this.onAsyncPropUpdated(e,r))}_watchPromise(e,r){let i=this.asyncProps[e];if(i){i.pendingLoadCount++;let o=i.pendingLoadCount;r.then(n=>{this.component&&(n=this._postProcessValue(i,n),this._setAsyncPropValue(e,n,o),this._onResolve(e,n))}).catch(n=>{this._onError(e,n)})}}async _resolveAsyncIterable(e,r){if(e!=="data"){this._setPropValue(e,r);return}let i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;let o=i.pendingLoadCount,n=[],s=0;for await(let a of r){if(!this.component)return;let{dataTransform:c}=this.component.props;c?n=c(a,n):n=n.concat(a),Object.defineProperty(n,"__diff",{enumerable:!1,value:[{startRow:s,endRow:n.length}]}),s=n.length,this._setAsyncPropValue(e,n,o)}this._onResolve(e,n)}_postProcessValue(e,r){let i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(r,i,this.component):r}_createAsyncPropData(e,r){if(!this.asyncProps[e]){let o=this.component&&this.component.props[ze];this.asyncProps[e]={type:o&&o[e],lastValue:null,resolvedValue:r,pendingLoadCount:0,resolvedLoadCount:0}}}};var Hn=class extends qr{constructor({attributeManager:e,layer:r}){super(r),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,r){let i=this.layer,o=i?.props.fetch;return o?o(r,{propName:e,layer:i}):super._fetch(e,r)}_onResolve(e,r){let i=this.layer;if(i){let o=i.props.onDataLoad;e==="data"&&o&&o(r,{propName:e,layer:i})}}_onError(e,r){let i=this.layer;i&&i.raiseError(r,`loading ${e} of ${this.layer}`)}};var L2="layer.changeFlag",U2="layer.initialize",k2="layer.update",V2="layer.finalize",z2="layer.matched",T0=2**24-1,W2=Object.freeze([]),j2=Ue(({oldViewport:t,viewport:e})=>t.equals(e)),it=new Uint8ClampedArray(0),$2={data:{type:"data",value:W2,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:t=>t&&t.__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:(t,{propName:e,layer:r,loaders:i,loadOptions:o,signal:n})=>{let{resourceManager:s}=r.context;o=o||r.getLoadOptions(),i=i||r.props.loaders,n&&(o={...o,core:{...o?.core,fetch:{...o?.core?.fetch,signal:n}}});let a=s.contains(t);return!a&&!o&&(s.add({resourceId:t,data:hr(t,i),persistent:!1}),a=!0),a?s.subscribe({resourceId:t,onChange:c=>r.internalState?.reloadAsyncProp(e,c),consumerId:r.id,requestId:e}):hr(t,i,o)}},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:"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:t})=>[0,-t*100]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}},Xn=class extends eo{constructor(){super(...arguments),this.internalState=null,this.lifecycle=yr.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){X(this.internalState);let r=this.internalState.viewport||this.context.viewport,i=Na(e,{viewport:r,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[o,n,s]=Li(i,r.pixelProjectionMatrix);return e.length===2?[o,n]:[o,n,s]}unproject(e){return X(this.internalState),(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,r){X(this.internalState);let i=this.internalState.viewport||this.context.viewport;return Da(e,{viewport:i,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...r})}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 r of this.getModels())r.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==="default"||e==="lnglat"||e==="cartesian"}onHover(e,r){return this.props.onHover&&this.props.onHover(e,r)||!1}onClick(e,r){return this.props.onClick&&this.props.onClick(e,r)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,r=[]){return r[0]=e+1&255,r[1]=e+1>>8&255,r[2]=e+1>>8>>8&255,r}decodePickingColor(e){X(e instanceof Uint8Array);let[r,i,o]=e;return r+i*256+o*65536-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&this.state.numInstances!==void 0?this.state.numInstances:jc(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=Wn(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(let r of this.props.extensions)e=Wn(e,r.getShaders.call(this,r));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){let r=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&r)if(Array.isArray(i))for(let o of i)r.invalidateAll(o);else r.invalidateAll();if(r){let{props:o}=e,n=this.internalState.hasPickingBuffer,s=Number.isInteger(o.highlightedObjectIndex)||Boolean(o.pickable)||o.extensions.some(a=>a.getNeedsPickingBuffer.call(this,a));if(n!==s){this.internalState.hasPickingBuffer=s;let{pickingColors:a,instancePickingColors:c}=r.attributes,l=a||c;l&&(s&&l.constant&&(l.constant=!1,r.invalidate(l.id)),!l.value&&!s&&(l.constant=!0,l.value=[0,0,0]))}}}finalizeState(e){for(let i of this.getModels())i.destroy();let r=this.getAttributeManager();r&&r.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(let r of this.getModels())r.draw(e.renderPass)}getPickingInfo({info:e,mode:r,sourceLayer:i}){let{index:o}=e;return o>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[o]),e}raiseError(e,r){r&&(e=new Error(`${r}: ${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 r=this.internalState.viewport;this.internalState.viewport=e,(!r||!j2({oldViewport:r,viewport:e}))&&(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){let r=this.getAttributeManager();r&&(e==="all"?r.invalidateAll():r.invalidate(e))}updateAttributes(e){let r=!1;for(let i in e)e[i].layoutChanged()&&(r=!0);for(let i of this.getModels())this._setModelAttributes(i,e,r)}_updateAttributes(){let e=this.getAttributeManager();if(!e)return;let r=this.props,i=this.getNumInstances(),o=this.getStartIndices();e.update({data:r.data,numInstances:i,startIndices:o,props:r,transitions:r.transitions,buffers:r.data.attributes,context:this});let n=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(n)}_updateAttributeTransition(){let e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){let{uniformTransitions:e}=this.internalState;if(e.active){let r=e.update(),i=Object.create(this.props);for(let o in r)Object.defineProperty(i,o,{value:r[o]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:r}){if(e.constant)return;let i=Math.floor(it.length/4);if(this.internalState.usesPickingColorCache=!0,i<r){r>T0&&F.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),it=Ke.allocate(it,r,{size:4,copy:!0,maxCount:Math.max(r,T0)});let o=Math.floor(it.length/4),n=[0,0,0];for(let s=i;s<o;s++)this.encodePickingColor(s,n),it[s*4+0]=n[0],it[s*4+1]=n[1],it[s*4+2]=n[2],it[s*4+3]=0}e.value=it.subarray(0,r*4)}_setModelAttributes(e,r,i=!1){if(!Object.keys(r).length)return;if(i){let a=this.getAttributeManager();e.setBufferLayout(a.getBufferLayouts(e)),r=a.getAttributes()}let o=e.userData?.excludeAttributes||{},n={},s={};for(let a in r){if(o[a])continue;let c=r[a].getValue();for(let l in c){let f=c[l];f instanceof I?r[a].settings.isIndexed?e.setIndexBuffer(f):n[l]=f:f&&(s[l]=f)}}e.setAttributes(n),e.setConstantAttributes(s)}disablePickingIndex(e){let r=this.props.data;if(!("attributes"in r)){this._disablePickingIndex(e);return}let{pickingColors:i,instancePickingColors:o}=this.getAttributeManager().attributes,n=i||o,s=n&&r.attributes&&r.attributes[n.id];if(s&&s.value){let a=s.value,c=this.encodePickingColor(e);for(let l=0;l<r.length;l++){let f=n.getVertexOffset(l);a[f]===c[0]&&a[f+1]===c[1]&&a[f+2]===c[2]&&this._disablePickingIndex(l)}}else this._disablePickingIndex(e)}_disablePickingIndex(e){let{pickingColors:r,instancePickingColors:i}=this.getAttributeManager().attributes,o=r||i;if(!o)return;let n=o.getVertexOffset(e),s=o.getVertexOffset(e+1);o.buffer.write(new Uint8Array(s-n),n)}restorePickingColors(){let{pickingColors:e,instancePickingColors:r}=this.getAttributeManager().attributes,i=e||r;i&&(this.internalState.usesPickingColorCache&&i.value.buffer!==it.buffer&&(i.value=it.subarray(0,i.value.length)),i.updateSubBuffer({startOffset:0}))}_initialize(){X(!this.internalState),q(U2,this);let e=this._getAttributeManager();e&&e.addInstanced({instancePickingColors:{type:"uint8",size:4,noAlloc:!0,update:this.calculateInstancePickingColors}}),this.internalState=new Hn({attributeManager:e,layer:this}),this._clearChangeFlags(),this.state={},Object.defineProperty(this.state,"attributeManager",{get:()=>(F.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new zn(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(let r of this.props.extensions)r.initializeState.call(this,this.context,r);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){q(z2,this,this===e);let{state:r,internalState:i}=e;this!==e&&(this.internalState=i,this.state=r,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){let e=this.needsUpdate();if(q(k2,this,e),!e)return;this.context.stats.get("Layer updates").incrementCount();let r=this.props,i=this.context,o=this.internalState,n=i.viewport,s=this._updateUniformTransition();o.propsInTransition=s,i.viewport=o.viewport||n,this.props=s;try{let a=this._getUpdateParams(),c=this.getModels();if(i.device)this.updateState(a);else try{this.updateState(a)}catch{}for(let f of this.props.extensions)f.updateState.call(this,a,f);this.setNeedsRedraw(),this._updateAttributes();let l=this.getModels()[0]!==c[0];this._postUpdate(a,l)}finally{i.viewport=n,this.props=r,this._clearChangeFlags(),o.needsUpdate=!1,o.resetOldProps()}}_finalize(){q(V2,this),this.finalizeState(this.context);for(let e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,shaderModuleProps:r=null,uniforms:i={},parameters:o={}}){this._updateAttributeTransition();let n=this.props,s=this.context;this.props=this.internalState.propsInTransition||n;try{r&&this.setShaderModuleProps(r);let{getPolygonOffset:a}=this.props,c=a&&a(i)||[0,0];s.device instanceof rt&&s.device.setParametersWebGL({polygonOffset:c});let l=s.device instanceof rt?null:H2(o);if(X2(this.getModels(),e,o,l),s.device instanceof rt)s.device.withParametersWebGL(o,()=>{let f={renderPass:e,shaderModuleProps:r,uniforms:i,parameters:o,context:s};for(let h of this.props.extensions)h.draw.call(this,f,h);this.draw(f)});else{l?.renderPassParameters&&e.setParameters(l.renderPassParameters);let f={renderPass:e,shaderModuleProps:r,uniforms:i,parameters:o,context:s};for(let h of this.props.extensions)h.draw.call(this,f,h);this.draw(f)}}finally{this.props=n}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;let{changeFlags:r}=this.internalState;for(let o in e)if(e[o]){let n=!1;switch(o){case"dataChanged":let s=e[o],a=r[o];s&&Array.isArray(a)&&(r.dataChanged=Array.isArray(s)?a.concat(s):s,n=!0);default:r[o]||(r[o]=e[o],n=!0)}n&&q(L2,this,o,e)}let i=Boolean(r.dataChanged||r.updateTriggersChanged||r.propsChanged||r.extensionsChanged);r.propsOrDataChanged=i,r.somethingChanged=i||r.viewportChanged||r.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,r){let i=p0(e,r);if(i.updateTriggersChanged)for(let o in i.updateTriggersChanged)i.updateTriggersChanged[o]&&this.invalidateAttribute(o);if(i.transitionsChanged)for(let o in i.transitionsChanged)this.internalState.uniformTransitions.add(o,r[o],e[o],e.transitions?.[o]);return this.setChangeFlags(i)}validateProps(){d0(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){let r={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&typeof i=="function"&&(r.highlightColor=i(e)),this.setShaderModuleProps({picking:r}),this.setNeedsRedraw()}_getAttributeManager(){let e=this.context;return new Zr(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,r){let{props:i,oldProps:o}=e,n=this.state.model;n?.isInstanced&&n.setInstanceCount(this.getNumInstances());let{autoHighlight:s,highlightedObjectIndex:a,highlightColor:c}=i;if(r||o.autoHighlight!==s||o.highlightedObjectIndex!==a||o.highlightColor!==c){let l={};Array.isArray(c)&&(l.highlightColor=c),(r||o.autoHighlight!==s||a!==o.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 r=!1;r=r||this.internalState.needsRedraw&&this.id;let i=this.getAttributeManager(),o=i?i.getNeedsRedraw(e):!1;if(r=r||o,r)for(let n of this.props.extensions)n.onNeedsRedraw.call(this,n);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,r}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}};Xn.defaultProps=$2;Xn.layerName="Layer";var Hc=Xn;function H2(t){let{blendConstant:e,...r}=t;return e?{pipelineParameters:r,renderPassParameters:{blendConstant:e}}:{pipelineParameters:r}}function X2(t,e,r,i){for(let o of t)o.device.type==="webgpu"?(Y2(o,e),o.setParameters({...o.parameters,...i?.pipelineParameters})):o.setParameters(r)}function Y2(t,e){let r=e.props.framebuffer||(e.framebuffer??null);if(!r)return;let i=r.colorAttachments.map(s=>s?.texture?.format??null),o=r.depthStencilAttachment?.texture?.format,n=t;(!K2(n.props.colorAttachmentFormats,i)||n.props.depthStencilAttachmentFormat!==o)&&(n.props.colorAttachmentFormats=i,n.props.depthStencilAttachmentFormat=o,n._setPipelineNeedsUpdate("attachment formats"))}function K2(t,e){if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[r])return!1;return!0}var Z2="compositeLayer.renderLayers",Xc=class extends Hc{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:r}=e;return r&&r.__source&&r.__source.parent&&r.__source.parent.id===this.id&&(e.object=r.__source.object,e.index=r.__source.index),e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,r){return r&&r.length}getSubLayerClass(e,r){let{_subLayerProps:i}=this.props;return i&&i[e]&&i[e].type||r}getSubLayerRow(e,r,i){return e.__source={parent:this,object:r,index:i},e}getSubLayerAccessor(e){if(typeof e=="function"){let r={index:-1,data:this.props.data,target:[]};return(i,o)=>i&&i.__source?(r.index=i.__source.index,e(i.__source.object,r)):e(i,o)}return e}getSubLayerProps(e={}){let{opacity:r,pickable:i,visible:o,parameters:n,getPolygonOffset:s,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:h,wrapLongitude:u,positionFormat:d,modelMatrix:p,extensions:g,fetch:m,operation:_,_subLayerProps:b}=this.props,y={id:"",updateTriggers:{},opacity:r,pickable:i,visible:o,parameters:n,getPolygonOffset:s,highlightedObjectIndex:a,autoHighlight:c,highlightColor:l,coordinateSystem:f,coordinateOrigin:h,wrapLongitude:u,positionFormat:d,modelMatrix:p,extensions:g,fetch:m,operation:_},T=b&&e.id&&b[e.id],S=T&&T.updateTriggers,A=e.id||"sublayer";if(T){let w=this.props[ze],P=e.type?e.type._propTypes:{};for(let R in T){let v=P[R]||w[R];v&&v.type==="accessor"&&(T[R]=this.getSubLayerAccessor(T[R]))}}Object.assign(y,e,T),y.id=`${this.props.id}-${A}`,y.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...S};for(let w of g){let P=w.getSubLayerProps.call(this,w);P&&Object.assign(y,P,{updateTriggers:Object.assign(y.updateTriggers,P.updateTriggers)})}return y}_updateAutoHighlight(e){for(let r of this.getSubLayers())r.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,r){let i=this.internalState.subLayers,o=!i||this.needsUpdate();if(o){let n=this.renderLayers();i=br(n,Boolean),this.internalState.subLayers=i}q(Z2,this,o,i);for(let n of i)n.parent=this}};Xc.layerName="CompositeLayer";var x0=Xc;var hd=Math.PI/180;function q2({height:t,focalDistance:e,orbitAxis:r,rotationX:i,rotationOrbit:o,zoom:n}){let s=r==="Z"?[0,0,1]:[0,1,0],a=r==="Z"?[0,-e,0]:[0,0,e],c=new V().lookAt({eye:a,up:s});c.rotateX(i*hd),r==="Z"?c.rotateZ(o*hd):c.rotateY(o*hd);let l=Math.pow(2,n)/t;return c.scale(l),c}var Yc=class extends Ae{constructor(e){let{height:r,projectionMatrix:i,fovy:o=50,orbitAxis:n="Z",target:s=[0,0,0],rotationX:a=0,rotationOrbit:c=0,zoom:l=0}=e,f=i?i[5]/2:Lt(o);super({...e,longitude:void 0,viewMatrix:q2({height:r||1,focalDistance:f,orbitAxis:n,rotationX:a,rotationOrbit:c,zoom:l}),fovy:o,focalDistance:f,position:s,zoom:l}),this.target=s,this.orbitAxis=n,this.rotationX=a,this.rotationOrbit=c,this.fovy=o,this.projectedCenter=this.project(this.center)}unproject(e,{topLeft:r=!0}={}){let[i,o,n=this.projectedCenter[2]]=e,s=r?o:this.height-o,[a,c,l]=Ve([i,s,n],this.pixelUnprojectionMatrix);return[a,c,l]}panByPosition(e,r,i){let o=this.project(e),{near:n,far:s}=ay(this.projectionMatrix),a=n*s/(s-o[2]*(s-n)),c=n*s/(s-this.projectedCenter[2]*(s-n)),l=a/c,f=[this.width/2+(o[0]-r[0])*l,this.height/2+(o[1]-r[1])*l,this.projectedCenter[2]];return{target:this.unproject(f)}}};Yc.displayName="OrbitViewport";var Kc=Yc;var G2=new V().lookAt({eye:[0,0,1]});function Q2({width:t,height:e,near:r,far:i,padding:o}){let n=-t/2,s=t/2,a=-e/2,c=e/2;if(o){let{left:l=0,right:f=0,top:h=0,bottom:u=0}=o,d=U((l+t-f)/2,0,t)-t/2,p=U((h+e-u)/2,0,e)-e/2;n-=d,s-=d,a+=p,c+=p}return new V().ortho({left:n,right:s,bottom:a,top:c,near:r,far:i})}var Zc=class extends Ae{constructor(e){let{width:r,height:i,near:o=.1,far:n=1e3,zoom:s=0,target:a=[0,0,0],padding:c=null,flipY:l=!0}=e,f=e.zoomX??(Array.isArray(s)?s[0]:s),h=e.zoomY??(Array.isArray(s)?s[1]:s),u=Math.min(f,h),d=Math.pow(2,u),p;if(f!==h){let g=Math.pow(2,f),m=Math.pow(2,h);p={unitsPerMeter:[g/d,m/d,1],metersPerUnit:[d/g,d/m,1]}}super({...e,longitude:void 0,position:a,viewMatrix:G2.clone().scale([d,d*(l?-1:1),d]),projectionMatrix:Q2({width:r||1,height:i||1,padding:c,near:o,far:n}),zoom:u,distanceScales:p}),this.target=a,this.zoomX=f,this.zoomY=h,this.flipY=l}projectFlat([e,r]){let{unitsPerMeter:i}=this.distanceScales;return[e*i[0],r*i[1]]}unprojectFlat([e,r]){let{metersPerUnit:i}=this.distanceScales;return[e*i[0],r*i[1]]}panByPosition(e,r,i){let o=Ve(r,this.pixelUnprojectionMatrix),n=this.projectFlat(e),s=J.add([],n,J.negate([],o)),a=J.add([],this.center,s);return{target:this.unprojectFlat(a)}}};Zc.displayName="OrthographicViewport";var qc=Zc;var Gc=class extends Ae{constructor(e){let{longitude:r,latitude:i,modelMatrix:o,bearing:n=0,pitch:s=0,up:a=[0,0,1]}=e,l=new We({bearing:n,pitch:s===-90?1e-4:90+s}).toVector3().normalize(),f=o?new V(o).transformAsVector(l):l,h=Number.isFinite(i)?on({latitude:i}):0,u=Math.pow(2,h),d=new V().lookAt({eye:[0,0,0],center:f,up:a}).scale(u);super({...e,zoom:h,viewMatrix:d}),this.latitude=i,this.longitude=r,this.pitch=s,this.bearing=n,this.up=a}};Gc.displayName="FirstPersonViewport";var Qc=Gc;var Gr=20,A0=500,Yn=class extends Ge{constructor(e){let{width:r,height:i,position:o=[0,0,0],bearing:n=0,pitch:s=0,longitude:a=null,latitude:c=null,maxPitch:l=90,minPitch:f=-90,maxBounds:h=null,startRotatePos:u,startBearing:d,startPitch:p,startZoomPosition:g,startPanPos:m,startPanPosition:_}=e;super({width:r,height:i,position:o,bearing:n,pitch:s,longitude:a,latitude:c,maxPitch:l,minPitch:f,maxBounds:h},{startRotatePos:u,startBearing:d,startPitch:p,startZoomPosition:g,startPanPos:m,startPanPosition:_},e.makeViewport)}panStart({pos:e}){let{position:r}=this.getViewportProps();return this._getUpdatedState({startPanPos:e,startPanPosition:r})}pan({pos:e}){if(!e)return this;let{startPanPos:r=[0,0],startPanPosition:i=[0,0]}=this.getState(),{width:o,height:n,bearing:s,pitch:a}=this.getViewportProps(),c=A0*(e[0]-r[0])/o,l=A0*(e[1]-r[1])/n,f=new We({bearing:s,pitch:a}),h=new We({bearing:s,pitch:-90}),u=f.toVector3().normalize(),d=h.toVector3().cross(u).normalize();return this._getUpdatedState({position:new j(i).add(d.scale(c)).add(u.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:r=0,deltaAngleY:i=0}){let{startRotatePos:o,startBearing:n,startPitch:s}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!o||n===void 0||s===void 0)return this;let l;if(e){let f=(e[0]-o[0])/a,h=(e[1]-o[1])/c;l={bearing:n-f*180,pitch:s-h*90}}else l={bearing:n-r,pitch:s-i};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:r}){let i=this.getViewportProps(),o=this.getState().startZoomPosition||i.position,n=this.makeViewport(i),{projectionMatrix:s,width:a}=n,l=2*Math.atan(1/s[0])*(e[0]/a-.5),f=this.getDirection(!0);return this._move(f.rotateZ({radians:-l}),Math.log2(r)*Gr,o)}zoomEnd(){return this._getUpdatedState({startZoomPosition:null})}moveLeft(e=Gr){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:Math.PI/2}),e)}moveRight(e=Gr){let r=this.getDirection(!0);return this._move(r.rotateZ({radians:-Math.PI/2}),e)}moveUp(e=Gr){let r=this.getDirection(!0);return this._move(r,e)}moveDown(e=Gr){let r=this.getDirection(!0);return this._move(r.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=Gr){return this._move(new j(0,0,1),e)}zoomOut(e=Gr){return this._move(new j(0,0,-1),e)}shortestPathFrom(e){let r=e.getViewportProps(),i={...this.getViewportProps()},{bearing:o,longitude:n}=i;return Math.abs(o-r.bearing)>180&&(i.bearing=o<0?o+360:o-360),n!==null&&r.longitude!==null&&Math.abs(n-r.longitude)>180&&(i.longitude=n<0?n+360:n-360),i}_move(e,r,i=this.getViewportProps().position){let o=e.scale(r);return this._getUpdatedState({position:new j(i).add(o)})}getDirection(e=!1){return new We({bearing:this.getViewportProps().bearing,pitch:e?90:90+this.getViewportProps().pitch}).toVector3().normalize()}_getUpdatedState(e){return new Yn({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{pitch:r,maxPitch:i,minPitch:o,longitude:n,position:s,bearing:a,maxBounds:c}=e;if(e.pitch=U(r,o,i),n!==null&&(n<-180||n>180)&&(e.longitude=mt(n+180,360)-180),(a<-180||a>180)&&(e.bearing=mt(a+180,360)-180),c){let l=U(s[0],c[0][0],c[1][0]),f=U(s[1],c[0][1],c[1][1]),h=U(s[2]??0,c[0][2]??0,c[1][2]??0);(l!==s[0]||f!==s[1]||h!==s[2])&&(e.position=[l,f,h])}return e}},Qr=class extends ye{constructor(){super(...arguments),this.ControllerState=Yn,this.transition={transitionDuration:300,transitionInterpolator:new se(["position","pitch","bearing"])}}};var Jc=class extends _e{constructor(e={}){super(e)}getViewportType(){return Qc}get ControllerType(){return Qr}};Jc.displayName="FirstPersonView";var S0=Jc;var ud=class extends Ge{constructor(e){let{width:r,height:i,rotationX:o=0,rotationOrbit:n=0,target:s=[0,0,0],zoom:a=0,minRotationX:c=-90,maxRotationX:l=90,minZoom:f=-1/0,maxZoom:h=1/0,maxBounds:u=null,startPanPosition:d,startRotatePos:p,startRotationX:g,startRotationOrbit:m,startZoomPosition:_,startZoom:b}=e;super({width:r,height:i,rotationX:o,rotationOrbit:n,target:s,zoom:a,minRotationX:c,maxRotationX:l,minZoom:f,maxZoom:h,maxBounds:u},{startPanPosition:d,startRotatePos:p,startRotationX:g,startRotationOrbit:m,startZoomPosition:_,startZoom:b},e.makeViewport),this.unproject3D=e.unproject3D}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:r}){let i=this.getState().startPanPosition||r;if(!i)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(n)}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:r=0,deltaAngleY:i=0}){let{startRotatePos:o,startRotationX:n,startRotationOrbit:s}=this.getState(),{width:a,height:c}=this.getViewportProps();if(!o||n===void 0||s===void 0)return this;let l;if(e){let f=(e[0]-o[0])/a,h=(e[1]-o[1])/c;(n<-90||n>90)&&(f*=-1),l={rotationX:n+h*180,rotationOrbit:s+f*180}}else l={rotationX:n+i,rotationOrbit:s+r};return this._getUpdatedState(l)}rotateEnd(){return this._getUpdatedState({startRotationX:null,startRotationOrbit:null})}shortestPathFrom(e){let r=e.getViewportProps(),i={...this.getViewportProps()},{rotationOrbit:o}=i;return Math.abs(o-r.rotationOrbit)>180&&(i.rotationOrbit=o<0?o+360:o-360),i}zoomStart({pos:e}){return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:o,startZoomPosition:n}=this.getState();if(n||(o=this.getViewportProps().zoom,n=this._unproject(r||e)),!n)return this;let s=this._calculateNewZoom({scale:i,startZoom:o}),a=this.makeViewport({...this.getViewportProps(),zoom:s});return this._getUpdatedState({zoom:s,...a.panByPosition(n,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){let r=this.unproject3D?.(e);return r||this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:r}){r===void 0&&(r=this.getViewportProps().zoom);let i=r+Math.log2(e);return this._constrainZoom(i)}_panFromCenter(e){let{target:r}=this.getViewportProps(),i=this._project(r);return this.pan({startPosition:r,pos:[i[0]+e[0],i[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{maxRotationX:r,minRotationX:i,rotationOrbit:o}=e;return e.zoom=this._constrainZoom(e.zoom,e),e.rotationX=U(e.rotationX,i,r),(o<-180||o>180)&&(e.rotationOrbit=mt(o+180,360)-180),e.target=this._constrainTarget(e),e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{maxZoom:i,maxBounds:o}=r,{minZoom:n}=r;if(o&&r.width>0&&r.height>0){let s=o[1][0]-o[0][0],a=o[1][1]-o[0][1],c=(o[1][2]??0)-(o[0][2]??0),l=Math.sqrt(s*s+a*a+c*c);l>0&&(n=Math.max(n,Math.log2(Math.min(r.width,r.height)/l)),n>i&&(n=i))}return U(e,n,i)}_constrainTarget(e){let{target:r,maxBounds:i}=e;if(!i)return r;let[[o,n,s=0],[a,c,l=0]]=i;if(r[0]>=o&&r[0]<=a&&r[1]>=n&&r[1]<=c&&r[2]>=s&&r[2]<=l)return r;let f=this.makeViewport?.(e);if(f){let{cameraPosition:h}=f,u=h[0]-r[0],d=h[1]-r[1],p=h[2]-r[2],g=u*r[0]+d*r[1]+p*r[2],m=u*(u>=0?o:a)+d*(d>=0?n:c)+p*(p>=0?s:l),_=u*(u>=0?a:o)+d*(d>=0?c:n)+p*(p>=0?l:s);if((u||d||p)&&g>=m&&g<=_){let b=O=>U(O,o,a),y=O=>U(O,n,c),T=O=>U(O,s,l),S=O=>u*b(r[0]-O*u)+d*y(r[1]-O*d)+p*T(r[2]-O*p)-g,A=-1,w=1,P=S(A),R=S(w);for(;P<0;)w=A,R=P,A*=2,P=S(A);for(;R>0;)A=w,P=R,w*=2,R=S(w);for(let O=0;O<30;O++){let C=(A+w)/2;S(C)>0?A=C:w=C}let v=(A+w)/2;return[b(r[0]-v*u),y(r[1]-v*d),T(r[2]-v*p)]}}return[U(r[0],o,a),U(r[1],n,c),U(r[2],s,l)]}},Jr=class extends ye{constructor(){super(...arguments),this.ControllerState=ud,this.transition={transitionDuration:300,transitionInterpolator:new se({transitionProps:{compare:["target","zoom","rotationX","rotationOrbit"],required:["target","zoom"]}})},this._unproject3D=e=>{if(this.pickPosition){let{x:r,y:i}=this.props,o=this.pickPosition(r+e[0],i+e[1]);if(o&&o.coordinate)return o.coordinate}return null}}setProps(e){e.unproject3D=this._unproject3D,super.setProps(e)}};var el=class extends _e{constructor(e={}){super(e),this.props.orbitAxis=e.orbitAxis||"Z"}getViewportType(){return Kc}get ControllerType(){return Jr}};el.displayName="OrbitView";var E0=el;function w0({zoom:t=0,zoomX:e,zoomY:r}){return e=e??(Array.isArray(t)?t[0]:t),r=r??(Array.isArray(t)?t[1]:t),{zoomX:e,zoomY:r}}var dd=class extends Ge{constructor(e){let{width:r,height:i,target:o=[0,0,0],zoom:n=0,zoomAxis:s="all",minZoom:a=-1/0,maxZoom:c=1/0,minZoomX:l=a,maxZoomX:f=c,minZoomY:h=a,maxZoomY:u=c,maxBounds:d=null,startPanPosition:p,startZoomPosition:g,startZoom:m}=e,{zoomX:_,zoomY:b}=w0(e);super({width:r,height:i,target:o,zoom:n,zoomX:_,zoomY:b,zoomAxis:s,minZoomX:l,maxZoomX:f,minZoomY:h,maxZoomY:u,maxBounds:d},{startPanPosition:p,startZoomPosition:g,startZoom:m},e.makeViewport)}panStart({pos:e}){return this._getUpdatedState({startPanPosition:this._unproject(e)})}pan({pos:e,startPosition:r}){let i=this.getState().startPanPosition||r;if(!i)return this;let n=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanPosition:null})}rotateStart(){return this}rotate(){return this}rotateEnd(){return this}shortestPathFrom(e){let r=e.getViewportProps();return{...this.getViewportProps()}}zoomStart({pos:e}){let{zoomX:r,zoomY:i}=this.getViewportProps();return this._getUpdatedState({startZoomPosition:this._unproject(e),startZoom:[r,i]})}zoom({pos:e,startPos:r,scale:i}){let{startZoom:o,startZoomPosition:n}=this.getState();if(!n){let{zoomX:c,zoomY:l}=this.getViewportProps();o=[c,l],n=this._unproject(r||e)}if(!n)return this;let s=this._constrainZoom(this._calculateNewZoom({scale:i,startZoom:o})),a=this.makeViewport({...this.getViewportProps(),...s});return this._getUpdatedState({...s,...a.panByPosition(n,e)})}zoomEnd(){return this._getUpdatedState({startZoomPosition:null,startZoom:null})}zoomIn(e=2){return this._getUpdatedState(this._calculateNewZoom({scale:e}))}zoomOut(e=2){return this._getUpdatedState(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}rotateRight(e=15){return this}rotateUp(e=10){return this}rotateDown(e=10){return this}_project(e){return this.makeViewport(this.getViewportProps()).project(e)}_unproject(e){return this.makeViewport(this.getViewportProps()).unproject(e)}_calculateNewZoom({scale:e,startZoom:r}){let{zoomX:i,zoomY:o,zoomAxis:n}=this.getViewportProps();r===void 0&&(r=[i,o]);let s=Math.log2(e),[a,c]=r;switch(n){case"X":a+=s;break;case"Y":c+=s;break;default:a+=s,c+=s}return{zoomX:a,zoomY:c}}_panFromCenter(e){let{target:r}=this.getViewportProps(),i=this._project(r);return this.pan({startPosition:r,pos:[i[0]+e[0],i[1]+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}applyConstraints(e){let{zoomX:r,zoomY:i}=this._constrainZoom(e,e);e.zoomX=r,e.zoomY=i,e.zoom=Array.isArray(e.zoom)||e.zoomX!==e.zoomY?[e.zoomX,e.zoomY]:e.zoomX;let{maxBounds:o,target:n}=e;if(o){let s=e.width/2/2**r,a=e.height/2/2**i,c=o[0][0]+s,l=o[1][0]-s,f=o[0][1]+a,h=o[1][1]-a,u=U(n[0],c,l),d=U(n[1],f,h);(u!==n[0]||d!==n[1])&&(e.target=n.slice(),e.target[0]=u,e.target[1]=d)}return e}_constrainZoom({zoomX:e,zoomY:r},i){i||(i=this.getViewportProps());let{zoomAxis:o,maxZoomX:n,maxZoomY:s,maxBounds:a}=i,{minZoomX:c,minZoomY:l}=i;if(a!==null&&i.width>0&&i.height>0){let h=a[0],u=a[1],d=u[0]-h[0],p=u[1]-h[1];Number.isFinite(d)&&d>0&&(c=Math.max(c,Math.log2(i.width/d)),c>n&&(c=n)),Number.isFinite(p)&&p>0&&(l=Math.max(l,Math.log2(i.height/p)),l>s&&(l=s))}switch(o){case"X":e=U(e,c,n);break;case"Y":r=U(r,l,s);break;default:let h=Math.min(n-e,s-r,0);h===0&&(h=Math.max(c-e,l-r,0)),h!==0&&(e+=h,r+=h)}return{zoomX:e,zoomY:r}}},ei=class extends ye{constructor(){super(...arguments),this.ControllerState=dd,this.transition={transitionDuration:300,transitionInterpolator:new se(["target","zoomX","zoomY"])},this.dragMode="pan"}setProps(e){Object.assign(e,w0(e)),super.setProps(e)}_onPanRotate(){return!1}};var tl=class extends _e{constructor(e={}){super(e)}getViewportType(){return qc}get ControllerType(){return ei}};tl.displayName="OrthographicView";var R0=tl;var pd=Math.PI/180,J2=180/Math.PI;function P0(t,e=0){let r=Math.min(180,t)*pd;return $t*2*Math.sin(r/2)*Math.pow(2,e)}function v0(t,e=0){let r=t/Math.pow(2,e);return Math.asin(Math.min(1,r/$t/2))*2*J2}var gd=class extends yn{constructor(e){let{startPanPos:r,...i}=e;i.normalize=!1,super(i),r!==void 0&&(this._state.startPanPos=r)}panStart({pos:e}){let{latitude:r,longitude:i,zoom:o}=this.getViewportProps();return this._getUpdatedState({startPanLngLat:[i,r],startPanPos:e,startZoom:o})}pan({pos:e,startPos:r}){let i=this.getState(),o=i.startPanLngLat||this._unproject(r);if(!o)return this;let n=i.startZoom??this.getViewportProps().zoom,s=i.startPanPos||r,a=[o[0],o[1],n],l=this.makeViewport(this.getViewportProps()).panByPosition(a,e,s);return this._getUpdatedState(l)}panEnd(){return this._getUpdatedState({startPanLngLat:null,startPanPos:null,startZoom:null})}zoom({scale:e}){let i=(this.getState().startZoom||this.getViewportProps().zoom)+Math.log2(e);return this._getUpdatedState({zoom:i})}applyConstraints(e){let{longitude:r,latitude:i,maxBounds:o}=e;if(e.zoom=this._constrainZoom(e.zoom,e),(r<-180||r>180)&&(e.longitude=mt(r+180,360)-180),e.latitude=U(i,-ge,ge),o&&(e.longitude=U(e.longitude,o[0][0],o[1][0]),e.latitude=U(e.latitude,o[0][1],o[1][1])),o){let n=e.zoom-yt(i),s=o[1][0]-o[0][0],a=o[1][1]-o[0][1];if(a>0&&a<ge*2){let c=Math.min(v0(e.height,n),a)/2;e.latitude=U(e.latitude,o[0][1]+c,o[1][1]-c)}if(s>0&&s<360){let c=Math.min(v0(e.width/Math.cos(e.latitude*pd),n),s)/2;e.longitude=U(e.longitude,o[0][0]+c,o[1][0]-c)}}return e.latitude!==i&&(e.zoom+=yt(e.latitude)-yt(i)),e}_constrainZoom(e,r){r||(r=this.getViewportProps());let{latitude:i,maxZoom:o,maxBounds:n}=r,{minZoom:s}=r,a=yt(0),c=yt(i)-a;if(n!==null&&r.width>0&&r.height>0){let f=n[0][1],h=n[1][1],u=Math.sign(f)===Math.sign(h)?Math.min(Math.abs(f),Math.abs(h)):0,d=P0(n[1][0]-n[0][0])*Math.cos(u*pd),p=P0(n[1][1]-n[0][1]);d>0&&(s=Math.max(s,Math.log2(r.width/d)+a)),p>0&&(s=Math.max(s,Math.log2(r.height/p)+a)),s>o&&(s=o)}return U(e,s+c,o+c)}},ti=class extends ye{constructor(){super(...arguments),this.ControllerState=gd,this.transition={transitionDuration:300,transitionInterpolator:new se(["longitude","latitude","zoom"])},this.dragMode="pan"}setProps(e){super.setProps(e),this.dragRotate=!1,this.touchRotate=!1}};var rl=class extends _e{constructor(e={}){super(e)}getViewportType(e){return e.zoom>12?_r:Hi}get ControllerType(){return ti}};rl.displayName="GlobeView";var M0=rl;var Kn=class extends Xt{constructor(){super(...arguments),this._terrainAltitude=void 0,this._terrainAltitudeTarget=void 0,this._pickFrameId=null,this._lastPickTime=0}setProps(e){if(super.setProps({rotationPivot:"3d",...e}),this._pickFrameId===null){let r=()=>{let i=Date.now();if(i-this._lastPickTime>500&&!this.isDragging()&&(this._lastPickTime=i,this._pickTerrainCenterAltitude(),this._terrainAltitude===void 0&&this._terrainAltitudeTarget!==void 0)){this._terrainAltitude=this._terrainAltitudeTarget;let o=new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),n=this._rebaseViewport(this._terrainAltitudeTarget,o);if(n){let s=new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state,...n});super.updateViewport(s)}}this._pickFrameId=requestAnimationFrame(r)};this._pickFrameId=requestAnimationFrame(r)}}finalize(){this._pickFrameId!==null&&(cancelAnimationFrame(this._pickFrameId),this._pickFrameId=null),super.finalize()}updateViewport(e,r=null,i={}){if(this._terrainAltitude===void 0){super.updateViewport(e,r,i);return}let o=.05;this._terrainAltitude+=(this._terrainAltitudeTarget-this._terrainAltitude)*o;let s=e.getViewportProps().position||[0,0,0];r={...r,position:[s[0],s[1],this._terrainAltitude]},super.updateViewport(e,r,i)}_pickTerrainCenterAltitude(){if(!this.pickPosition)return;let{x:e,y:r,width:i,height:o}=this.props,n=this.pickPosition(e+i/2,r+o/2);n?.coordinate&&n.coordinate.length>=3&&(this._terrainAltitudeTarget=n.coordinate[2])}_rebaseViewport(e,r){let i=r.getViewportProps(),o=this.makeViewport({...i,position:[0,0,0]}),n=o.cameraPosition,s=e*o.distanceScales.unitsPerMeter[2],a=n[2],c=a-s;if(c<=0)return null;let l=Math.log2(a/c),f=i.zoom+l,h=this.makeViewport({...i,zoom:f,position:[0,0,e]}),{width:u,height:d}=i,p=[u/2,d/2],g=o.unproject(p,{targetZ:e});if(g&&"panByPosition3D"in h&&typeof h.panByPosition3D=="function"){let m=h.panByPosition3D(g,p);return{position:[0,0,e],zoom:f,...m}}return null}};var Zn=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&&K(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){let{defaultProps:r}=e.constructor,i={updateTriggers:{}};for(let o in r)if(o in this.props){let n=r[o],s=this.props[o];i[o]=s,n&&n.type==="accessor"&&(i.updateTriggers[o]=this.props.updateTriggers[o],typeof s=="function"&&(i[o]=this.getSubLayerAccessor(s)))}return i}initializeState(e,r){}updateState(e,r){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,r){}finalizeState(e,r){}};Zn.defaultProps={};Zn.extensionName="LayerExtension";var C0=Zn;var md={bearing:0,pitch:0,position:[0,0,0]},eM={speed:1.2,curve:1.414},qn=class extends jt{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={...eM,...e}}interpolateProps(e,r,i){let o=Tu(e,r,i,this.opts);for(let n in md)o[n]=It(e[n]||md[n],r[n]||md[n],i);return o}getDuration(e,r){let{transitionDuration:i}=r;return i==="auto"&&(i=xu(e,r,this.opts)),i}};L();var Gn=class{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;let{attributes:r={}}=e;this.typedArrayManager=Ke,this.attributes={},this._attributeDefs=r,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);let{data:r,buffers:i={},getGeometry:o,geometryBuffer:n,positionFormat:s,dataChanged:a,normalize:c=!0}=this.opts;if(this.data=r,this.getGeometry=o,this.positionSize=n&&n.size||(s==="XY"?2:3),this.buffers=i,this.normalize=c,n&&(X(r.startIndices),this.getGeometry=this.getGeometryFromBuffer(n),c||(i.vertexPositions=n)),this.geometryBuffer=i.vertexPositions,Array.isArray(a))for(let l of a)this._rebuildGeometry(l);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:r}){this._rebuildGeometry({startRow:e,endRow:r})}getGeometryFromBuffer(e){let r=e.value||e;return ArrayBuffer.isView(r)?Bc(r,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,r){let{attributes:i,buffers:o,_attributeDefs:n,typedArrayManager:s}=this;for(let a in n)if(a in o)s.release(i[a]),i[a]=null;else{let c=n[a];c.copy=r,i[a]=s.allocate(i[a],e,c)}}_forEachGeometry(e,r,i){let{data:o,getGeometry:n}=this,{iterable:s,objectInfo:a}=Qi(o,r,i);for(let c of s){a.index++;let l=n?n(c,a):null;e(l,a.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:r,vertexStarts:i,instanceCount:o}=this,{data:n,geometryBuffer:s}=this,{startRow:a=0,endRow:c=1/0}=e||{},l={};if(e||(r=[0],i=[0]),this.normalize||!s)this._forEachGeometry((h,u)=>{let d=h&&this.normalizeGeometry(h);l[u]=d,i[u+1]=i[u]+(d?this.getGeometrySize(d):0)},a,c),o=i[i.length-1];else if(i=n.startIndices,o=i[n.length]||0,ArrayBuffer.isView(s))o=o||s.length/this.positionSize;else if(s instanceof I){let h=this.positionSize*4;o=o||s.byteLength/h}else if(s.buffer){let h=s.stride||this.positionSize*4;o=o||s.buffer.byteLength/h}else if(s.value){let h=s.value,u=s.stride/h.BYTES_PER_ELEMENT||this.positionSize;o=o||h.length/u}this._allocate(o,Boolean(e)),this.indexStarts=r,this.vertexStarts=i,this.instanceCount=o;let f={};this._forEachGeometry((h,u)=>{let d=l[u]||h;f.vertexStart=i[u],f.indexStart=r[u];let p=u<i.length-1?i[u+1]:o;f.geometrySize=p-i[u],f.geometryIndex=u,this.updateGeometryAttributes(d,f)},a,c),this.vertexCount=r[r.length-1]}};var il=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 r=this.props,i={...this.props,...e};if(this.props=i,!this.map)return;this._update(r,i)&&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:r,container:i}=e;r.accessToken=e.mapboxApiAccessToken||"",this.map=new e.mapLib.Map({container:i,maxZoom:24,...e.mapOptions,...I0(e.viewState),style:e.mapStyle,interactive:!1,trackResize:!1}),Object.defineProperty(i,"offsetWidth",{get:()=>this.width}),Object.defineProperty(i,"clientWidth",{get:()=>this.width}),Object.defineProperty(i,"offsetHeight",{get:()=>this.height}),Object.defineProperty(i,"clientHeight",{get:()=>this.height}),this.map.resize()}_update(e,r){e.mapStyle!==r.mapStyle&&this.map.setStyle(r.mapStyle);let o=e.width!==r.width||e.height!==r.height;o&&(this.width=r.width,this.height=r.height,this.map.resize());let n=e.viewState,s=r.viewState,a=s.latitude!==n.latitude||s.longitude!==n.longitude||s.zoom!==n.zoom||s.pitch!==n.pitch||s.bearing!==n.bearing;return a&&this.map.jumpTo(I0(s)),o||a}};function I0(t){return{center:[t.longitude,t.latitude],zoom:t.zoom,bearing:t.bearing??0,pitch:t.pitch??0}}var O0={position:"absolute",left:0,top:0,width:"100%",height:"100%"};function tM(t){let{container:e=document.body}=t;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 i=document.createElement("div");e.appendChild(i),Object.assign(i.style,O0);let o=document.createElement("canvas");return e.appendChild(o),Object.assign(o.style,O0),{container:e,mapCanvas:i,deckCanvas:o}}var Qn=class extends Nc{constructor(e){if(typeof document>"u")throw Error("Deck can only be used in the browser");let{mapCanvas:r,deckCanvas:i}=tM(e),o=e.viewState||e.initialViewState,n=Number.isFinite(o&&o.latitude),{map:s=globalThis.mapboxgl||globalThis.maplibregl}=e;super({canvas:i,...e}),s&&s.Map?this._map=n&&new il({...e,width:0,height:0,viewState:o,container:r,mapLib:s}):this._map=s}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,r){if(this._map){let i=this.getViewports()[0];i&&this._map.setProps({width:i.width,height:i.height,viewState:i})}super._drawLayers(e,r)}};globalThis.luma=globalThis.luma||{};globalThis.loaders=globalThis.loaders||{};Object.assign(globalThis.luma,Sh);Object.assign(globalThis.loaders,Gh);return U0(rM);})();
|
|
2078
2078
|
return __exports__;
|
|
2079
2079
|
});
|