@deck.gl/arcgis 9.4.0-beta.1 → 9.4.0-beta.4
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 +570 -523
- package/dist/index.cjs +2356 -9307
- package/dist/index.cjs.map +3 -3
- package/dist.min.js +4 -4
- package/package.json +6 -6
package/dist.min.js
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
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 Ba=Object.create;var Xe=Object.defineProperty;var Fa=Object.getOwnPropertyDescriptor;var Oa=Object.getOwnPropertyNames;var Na=Object.getPrototypeOf,Va=Object.prototype.hasOwnProperty;var P=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var Ze=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},me=(e,t)=>{for(var r in t)Xe(e,r,{get:t[r],enumerable:!0})},qe=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Oa(t))!Va.call(e,i)&&i!==r&&Xe(e,i,{get:()=>t[i],enumerable:!(n=Fa(t,i))||n.enumerable});return e},Ct=(e,t,r)=>(qe(e,t,"default"),r&&qe(r,t,"default")),D=(e,t,r)=>(r=e!=null?Ba(Na(e)):{},qe(t||!e||!e.__esModule?Xe(r,"default",{value:e,enumerable:!0}):r,e)),Ga=e=>qe(Xe({},"__esModule",{value:!0}),e);var He=Ze((Cf,Fi)=>{Fi.exports=globalThis.deck});var Gi=Ze((kf,Vi)=>{Vi.exports=globalThis.luma});var I=Ze((Df,zi)=>{zi.exports=globalThis.luma});function $i(e,t){return Wi?Wi.makeDebugContext(e,t):(Wa(),e)}function ji(e){return za?.initialize(e)||null}function Wa(){Ui||(Ui=!0,Yi.log.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var Yi,Wi,za,Ui,qi=P(()=>{Yi=D(I(),1),Wi=null,za=null,Ui=!1});function cn(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function F(e,t,r){return t[e]!==void 0?t[e]:r[e]}var ge,N,Xi,X,Zi,pe,Hi,Qi,ln,mt,hn,Ki,un=P(()=>{ge={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},N=(e,t,r)=>t?e.enable(r):e.disable(r),Xi=(e,t,r)=>e.hint(r,t),X=(e,t,r)=>e.pixelStorei(r,t),Zi=(e,t,r)=>{let n=r===36006?36009:36008;return e.bindFramebuffer(n,t)},pe=(e,t,r)=>{let i={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[r];e.bindBuffer(i,t)};Hi={3042:N,32773:(e,t)=>e.blendColor(...t),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(e,t)=>e.clearColor(...t),3107:(e,t)=>e.colorMask(...t),2884:N,2885:(e,t)=>e.cullFace(t),2929:N,2931:(e,t)=>e.clearDepth(t),2932:(e,t)=>e.depthFunc(t),2928:(e,t)=>e.depthRange(...t),2930:(e,t)=>e.depthMask(t),3024:N,35723:Xi,35725:(e,t)=>e.useProgram(t),36007:(e,t)=>e.bindRenderbuffer(36161,t),36389:(e,t)=>e.bindTransformFeedback?.(36386,t),34229:(e,t)=>e.bindVertexArray(t),36006:Zi,36010:Zi,34964:pe,36662:pe,36663:pe,35053:pe,35055:pe,2886:(e,t)=>e.frontFace(t),33170:Xi,2849:(e,t)=>e.lineWidth(t),32823:N,32824:"polygonOffset",10752:"polygonOffset",35977:N,32926:N,32928:N,32938:"sampleCoverage",32939:"sampleCoverage",3089:N,3088:(e,t)=>e.scissor(...t),2960:N,2961:(e,t)=>e.clearStencil(t),2968:(e,t)=>e.stencilMaskSeparate(1028,t),36005:(e,t)=>e.stencilMaskSeparate(1029,t),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(e,t)=>e.viewport(...t),34383:N,10754:N,12288:N,12289:N,12290:N,12291:N,12292:N,12293:N,12294:N,12295:N,3333:X,3317:X,37440:X,37441:X,37443:X,3330:X,3332:X,3331:X,3314:X,32878:X,3316:X,3315:X,32877:X,framebuffer:(e,t)=>{let r=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,r)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{let r=typeof t=="number"?[t,t]:t;e.blendEquationSeparate(...r)},blendFunc:(e,t)=>{let r=t?.length===2?[...t,...t]:t;e.blendFuncSeparate(...r)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(t[0],t[1]||!1),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=cn(t)?t:[t,t];let[r,n]=t;e.stencilMaskSeparate(1028,r),e.stencilMaskSeparate(1029,n)},stencilFunc:(e,t)=>{t=cn(t)&&t.length===3?[...t,...t]:t;let[r,n,i,s,o,a]=t;e.stencilFuncSeparate(1028,r,n,i),e.stencilFuncSeparate(1029,s,o,a)},stencilOp:(e,t)=>{t=cn(t)&&t.length===3?[...t,...t]:t;let[r,n,i,s,o,a]=t;e.stencilOpSeparate(1028,r,n,i),e.stencilOpSeparate(1029,s,o,a)},viewport:(e,t)=>e.viewport(...t)};Qi={blendEquation:(e,t,r)=>e.blendEquationSeparate(F(32777,t,r),F(34877,t,r)),blendFunc:(e,t,r)=>e.blendFuncSeparate(F(32969,t,r),F(32968,t,r),F(32971,t,r),F(32970,t,r)),polygonOffset:(e,t,r)=>e.polygonOffset(F(32824,t,r),F(10752,t,r)),sampleCoverage:(e,t,r)=>e.sampleCoverage(F(32938,t,r),F(32939,t,r)),stencilFuncFront:(e,t,r)=>e.stencilFuncSeparate(1028,F(2962,t,r),F(2967,t,r),F(2963,t,r)),stencilFuncBack:(e,t,r)=>e.stencilFuncSeparate(1029,F(34816,t,r),F(36003,t,r),F(36004,t,r)),stencilOpFront:(e,t,r)=>e.stencilOpSeparate(1028,F(2964,t,r),F(2965,t,r),F(2966,t,r)),stencilOpBack:(e,t,r)=>e.stencilOpSeparate(1029,F(34817,t,r),F(34818,t,r),F(34819,t,r))},ln={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,r)=>e({[t]:r}),hint:(e,t,r)=>e({[t]:r}),useProgram:(e,t)=>e({35725:t}),bindRenderbuffer:(e,t,r)=>e({36007:r}),bindTransformFeedback:(e,t,r)=>e({36389:r}),bindVertexArray:(e,t)=>e({34229:t}),bindFramebuffer:(e,t,r)=>{switch(t){case 36160:return e({36006:r,36010:r});case 36009:return e({36006:r});case 36008:return e({36010:r});default:return null}},bindBuffer:(e,t,r)=>{let n={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[t];return n?e({[n]:r}):{valueChanged:!0}},blendColor:(e,t,r,n,i)=>e({32773:new Float32Array([t,r,n,i])}),blendEquation:(e,t)=>e({32777:t,34877:t}),blendEquationSeparate:(e,t,r)=>e({32777:t,34877:r}),blendFunc:(e,t,r)=>e({32969:t,32968:r,32971:t,32970:r}),blendFuncSeparate:(e,t,r,n,i)=>e({32969:t,32968:r,32971:n,32970:i}),clearColor:(e,t,r,n,i)=>e({3106:new Float32Array([t,r,n,i])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,r,n,i)=>e({3107:[t,r,n,i]}),cullFace:(e,t)=>e({2885:t}),depthFunc:(e,t)=>e({2932:t}),depthRange:(e,t,r)=>e({2928:new Float32Array([t,r])}),depthMask:(e,t)=>e({2930:t}),frontFace:(e,t)=>e({2886:t}),lineWidth:(e,t)=>e({2849:t}),polygonOffset:(e,t,r)=>e({32824:t,10752:r}),sampleCoverage:(e,t,r)=>e({32938:t,32939:r}),scissor:(e,t,r,n,i)=>e({3088:new Int32Array([t,r,n,i])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,r)=>e({[t===1028?2968:36005]:r}),stencilFunc:(e,t,r,n)=>e({2962:t,2967:r,2963:n,34816:t,36003:r,36004:n}),stencilFuncSeparate:(e,t,r,n,i)=>e({[t===1028?2962:34816]:r,[t===1028?2967:36003]:n,[t===1028?2963:36004]:i}),stencilOp:(e,t,r,n)=>e({2964:t,2965:r,2966:n,34817:t,34818:r,34819:n}),stencilOpSeparate:(e,t,r,n,i)=>e({[t===1028?2964:34817]:r,[t===1028?2965:34818]:n,[t===1028?2966:34819]:i}),viewport:(e,t,r,n,i)=>e({2978:[t,r,n,i]})},mt=(e,t)=>e.isEnabled(t),hn={3042:mt,2884:mt,2929:mt,3024:mt,32823:mt,32926:mt,32928:mt,3089:mt,2960:mt,35977:mt},Ki=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 et(e,t){if(Ua(t))return;let r={};for(let i in t){let s=Number(i),o=Hi[i];o&&(typeof o=="string"?r[o]=!0:o(e,t[i],s))}let n=e.lumaState?.cache;if(n)for(let i in r){let s=Qi[i];s(e,t,n)}}function Qe(e,t=ge){if(typeof t=="number"){let i=t,s=hn[i];return s?s(e,i):e.getParameter(i)}let r=Array.isArray(t)?t:Object.keys(t),n={};for(let i of r){let s=hn[i];n[i]=s?s(e,Number(i)):e.getParameter(Number(i))}return n}function Ji(e){et(e,ge)}function Ua(e){for(let t in e)return!1;return!0}var Yt=P(()=>{un()});function es(e,t){if(e===t)return!0;if(ts(e)&&ts(t)&&e.length===t.length){for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}return!1}function ts(e){return Array.isArray(e)||ArrayBuffer.isView(e)}var rs=P(()=>{});function ns(e,t){let r=e[t].bind(e);e[t]=function(i){if(i===void 0||Ki.has(i))return r(i);let s=rt.get(e);return i in s.cache||(s.cache[i]=r(i)),s.enable?s.cache[i]:r(i)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function Ya(e,t,r){if(!e[t])return;let n=e[t].bind(e);e[t]=function(...s){let o=rt.get(e),{valueChanged:a,oldValue:c}=r(o._updateCache,...s);return a&&n(...s),c},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function $a(e){let t=e.useProgram.bind(e);e.useProgram=function(n){let i=rt.get(e);i.program!==n&&(t(n),i.program=n)}}var rt,fn=P(()=>{Yt();rs();un();rt=class{static get(t){return t.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(t,r){this.gl=t,this.log=r?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(t={}){this.stateStack.push({})}pop(){let t=this.stateStack[this.stateStack.length-1];et(this.gl,t),this.stateStack.pop()}trackState(t,r){if(this.cache=r?.copyState?Qe(t):Object.assign({},ge),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,$a(t);for(let n in ln){let i=ln[n];Ya(t,n,i)}ns(t,"getParameter"),ns(t,"isEnabled")}_updateCache(t){let r=!1,n,i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in t){let o=t[s],a=this.cache[s];es(o,a)||(r=!0,n=a,i&&!(s in i)&&(i[s]=a),this.cache[s]=o)}return{valueChanged:r,oldValue:n}}}});function be(e){let t=e.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return t._polyfilled??=!1,t.extensions||={},e.luma=t,t}var dn=P(()=>{});function is(e,t,r){let n="",i=c=>{let l=c.statusMessage;l&&(n||=l)};e.addEventListener("webglcontextcreationerror",i,!1);let s=r.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},a=null;try{a||=e.getContext("webgl2",o),!a&&o.failIfMajorPerformanceCaveat&&(n||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&s&&(o.failIfMajorPerformanceCaveat=!1,a=e.getContext("webgl2",o),c=!0),a||(a=e.getContext("webgl",{}),a&&(a=null,n||="Your browser only supports WebGL1")),!a)throw n||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${n}`);let l=be(a);l.softwareRenderer=c;let{onContextLost:h,onContextRestored:u}=t;return e.addEventListener("webglcontextlost",f=>h(f),!1),e.addEventListener("webglcontextrestored",f=>u(f),!1),a}finally{e.removeEventListener("webglcontextcreationerror",i,!1)}}var ss=P(()=>{dn()});function nt(e,t,r){return r[t]===void 0&&(r[t]=e.getExtension(t)||null),r[t]}var xe=P(()=>{});function os(e,t){let r=e.getParameter(7936),n=e.getParameter(7937);nt(e,"WEBGL_debug_renderer_info",t);let i=t.WEBGL_debug_renderer_info,s=e.getParameter(i?i.UNMASKED_VENDOR_WEBGL:7936),o=e.getParameter(i?i.UNMASKED_RENDERER_WEBGL:7937),a=s||r,c=o||n,l=e.getParameter(7938),h=as(a,c),u=ja(a,c),f=qa(a,c);return{type:"webgl",gpu:h,gpuType:f,gpuBackend:u,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function as(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function ja(e,t){return/Metal/i.exec(e)||/Metal/i.exec(t)?"metal":/ANGLE/i.exec(e)||/ANGLE/i.exec(t)?"opengl":"unknown"}function qa(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(as(e,t)){case"apple":return Xa(e,t)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function Xa(e,t){return/Apple (M\d|A\d|GPU)/i.test(`${e} ${t}`)}var cs=P(()=>{xe()});function Ke(e){switch(e){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(e))}var mn=P(()=>{});function us(e){return e in tr}function wn(e,t,r){return fs(e,t,r,new Set)}function fs(e,t,r,n){let i=tr[t];if(!i||n.has(t))return!1;n.add(t);let s=(i.features||[]).every(o=>fs(e,o,r,n));return n.delete(t),s?(i.extensions||[]).every(o=>!!nt(e,o,r)):!1}function ds(e,t,r){let n=t.create,i=er[t.format];i?.gl===void 0&&(n=!1),i?.x&&(n=n&&!!nt(e,i.x,r)),t.format==="stencil8"&&(n=!1);let s=i?.r===!1?!1:i?.r===void 0||wn(e,i.r,r),o=n&&t.render&&s&&rc(e,t.format,r);return{format:t.format,create:n&&t.create,render:o,filter:n&&t.filter,blend:n&&t.blend,store:n&&t.store}}function rc(e,t,r){let n=er[t],i=n?.gl;if(i===void 0||n?.x&&!nt(e,n.x,r))return!1;let s=e.getParameter(32873),o=e.getParameter(36006),a=e.createTexture(),c=e.createFramebuffer();if(!a||!c)return!1;let l=0,h=Number(e.getError());for(;h!==l;)h=e.getError();let u=!1;try{if(e.bindTexture(3553,a),e.texStorage2D(3553,1,i,1,1),Number(e.getError())!==l)return!1;e.bindFramebuffer(36160,c),e.framebufferTexture2D(36160,36064,3553,a,0),u=Number(e.checkFramebufferStatus(36160))===36053&&Number(e.getError())===l}finally{e.bindFramebuffer(36160,o),e.deleteFramebuffer(c),e.bindTexture(3553,s),e.deleteTexture(a)}return u}function rr(e){let t=er[e],r=ic(e),n=yn.textureFormatDecoder.getInfo(e);return n.compressed&&(t.dataFormat=r),{internalFormat:r,format:t?.dataFormat||nc(n.channels,n.integer,n.normalized,r),type:n.dataType?Ke(n.dataType):t?.types?.[0]||5121,compressed:n.compressed||!1}}function ms(e){switch(yn.textureFormatDecoder.getInfo(e).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${e}`)}}function nc(e,t,r,n){if(n===6408||n===6407)return n;switch(e){case"r":return t&&!r?36244:6403;case"rg":return t&&!r?33320:33319;case"rgb":return t&&!r?36248:6407;case"rgba":return t&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function ic(e){let r=er[e]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${e}`);return r}var yn,ye,we,$t,jt,Za,Ha,Qa,Ka,Ja,tc,ls,hs,pn,gn,bn,xn,Je,ec,tr,er,qt=P(()=>{yn=D(I(),1);xe();mn();ye="WEBGL_compressed_texture_s3tc",we="WEBGL_compressed_texture_s3tc_srgb",$t="EXT_texture_compression_rgtc",jt="EXT_texture_compression_bptc",Za="WEBGL_compressed_texture_etc",Ha="WEBGL_compressed_texture_astc",Qa="WEBGL_compressed_texture_etc1",Ka="WEBGL_compressed_texture_pvrtc",Ja="WEBGL_compressed_texture_atc",tc="EXT_texture_norm16",ls="EXT_render_snorm",hs="EXT_color_buffer_float",pn="snorm8-renderable-webgl",gn="norm16-renderable-webgl",bn="snorm16-renderable-webgl",xn="float16-renderable-webgl",Je="float32-renderable-webgl",ec="rgb9e5ufloat-renderable-webgl",tr={"float32-renderable-webgl":{extensions:[hs]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[ls]},"norm16-webgl":{extensions:[tc]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[ls]},"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:[ye,we,$t,jt]},"texture-compression-bc5-webgl":{extensions:[$t]},"texture-compression-bc7-webgl":{extensions:[jt]},"texture-compression-etc2":{extensions:[Za]},"texture-compression-astc":{extensions:[Ha]},"texture-compression-etc1-webgl":{extensions:[Qa]},"texture-compression-pvrtc-webgl":{extensions:[Ka]},"texture-compression-atc-webgl":{extensions:[Ja]}};er={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:pn},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:pn},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:xn},r16unorm:{gl:33322,rb:!0,r:gn},r16snorm:{gl:36760,r:bn},"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:pn},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:xn},rg16unorm:{gl:33324,r:gn},rg16snorm:{gl:36761,r:bn},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:Je},rgb9e5ufloat:{gl:35901,r:ec},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:Je},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:xn},rgba16unorm:{gl:32859,rb:!0,r:gn},rgba16snorm:{gl:36763,r:bn},"rgb32float-webgl":{gl:34837,x:hs,r:Je,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:Je},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:ye},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:we},"bc1-rgba-unorm":{gl:33777,x:ye},"bc1-rgba-unorm-srgb":{gl:35916,x:we},"bc2-rgba-unorm":{gl:33778,x:ye},"bc2-rgba-unorm-srgb":{gl:35918,x:we},"bc3-rgba-unorm":{gl:33779,x:ye},"bc3-rgba-unorm-srgb":{gl:35919,x:we},"bc4-r-unorm":{gl:36283,x:$t},"bc4-r-snorm":{gl:36284,x:$t},"bc5-rg-unorm":{gl:36285,x:$t},"bc5-rg-snorm":{gl:36286,x:$t},"bc6h-rgb-ufloat":{gl:36495,x:jt},"bc6h-rgb-float":{gl:36494,x:jt},"bc7-rgba-unorm":{gl:36492,x:jt},"bc7-rgba-unorm-srgb":{gl:36493,x:jt},"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 ir,ps,nr,gs=P(()=>{ir=D(I(),1);xe();qt();ps={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":e=>(0,ir.isHTMLInCanvasSupported)()&&typeof e.texElementImage2D=="function","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"},nr=class extends ir.DeviceFeatures{gl;extensions;testedFeatures=new Set;constructor(t,r,n){super([],n),this.gl=t,this.extensions=r,nt(t,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let t=this.getFeatures();for(let r of t)this.has(r)&&(yield r);return[]}has(t){return this.disabledFeatures?.[t]?!1:(this.testedFeatures.has(t)||(this.testedFeatures.add(t),us(t)&&wn(this.gl,t,this.extensions)&&this.features.add(t),this.getWebGLFeature(t)&&this.features.add(t)),this.features.has(t))}initializeFeatures(){let t=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of t)this.has(r)}getFeatures(){return[...Object.keys(ps),...Object.keys(tr)]}getWebGLFeature(t){let r=ps[t];return typeof r=="string"?!!nt(this.gl,r,this.extensions):typeof r=="function"?r(this.gl):!!r}}});var bs,sr,xs=P(()=>{bs=D(I(),1),sr=class extends bs.DeviceLimits{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(t){super(),this.gl=t}getParameter(t){return this.limits[t]===void 0&&(this.limits[t]=this.gl.getParameter(t)),this.limits[t]||0}}});function sc(e){return e<34069?e+34069:e}function oc(e){switch(e){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${e}`}}var ys,pt,or=P(()=>{ys=D(I(),1);qt();pt=class extends ys.Framebuffer{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(t,r){super(t,r);let n=r.handle,i=n===null;this.device=t,this.gl=t.gl,this.handle=n||i?n:this.gl.createFramebuffer(),i||(t._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),r.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let t=this.gl.bindFramebuffer(36160,this.handle);for(let r=0;r<this.colorAttachments.length;++r){let n=this.colorAttachments[r];if(n){let i=36064+r;this._attachTextureView(i,n)}}if(this.depthStencilAttachment){let r=ms(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 ${oc(r)}`)}this.gl.bindFramebuffer(36160,t)}_attachTextureView(t,r){let{gl:n}=this.device,{texture:i}=r,s=r.props.baseMipLevel,o=r.props.baseArrayLayer;switch(n.bindTexture(i.glTarget,i.handle),i.glTarget){case 35866:case 32879:n.framebufferTextureLayer(36160,t,i.handle,s,o);break;case 34067:let a=sc(o);n.framebufferTexture2D(36160,t,a,i.handle,s);break;case 3553:n.framebufferTexture2D(36160,t,3553,i.handle,s);break;default:throw new Error("Illegal texture type")}n.bindTexture(i.glTarget,null)}resizeAttachments(t,r){if(this.handle===null){this.width=t,this.height=r;return}super.resizeAttachments(t,r)}}});var ws,ar,Es=P(()=>{ws=D(I(),1);or();ar=class extends ws.CanvasContext{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(t,r){super(r),this.device=t,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 pt(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var Ts,cr,_s=P(()=>{Ts=D(I(),1),cr=class extends Ts.PresentationContext{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(t,r={}){super(r),this.device=t;let n=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${n}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let s=this.canvas.getContext("2d");if(!s)throw new Error(`${n}: Failed to create 2d presentation context`);this.context2d=s,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let t=this.device.getDefaultCanvasContext(),[r,n]=t.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||r===0||n===0||t.canvas.width===0||t.canvas.height===0)){if(r!==this.drawingBufferWidth||n!==this.drawingBufferHeight||t.canvas.width!==this.drawingBufferWidth||t.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${r}x${n} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(t.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(t){let r=this.device.getDefaultCanvasContext();return r.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),r.getCurrentFramebuffer(t)}}});function vs(e="id"){En[e]=En[e]||1;let t=En[e]++;return`${e}-${t}`}var En,Ss=P(()=>{En={}});function ac(e){return e&Lt.Buffer.INDEX?34963:e&Lt.Buffer.VERTEX?34962:e&Lt.Buffer.UNIFORM?35345:34962}function cc(e){return e&Lt.Buffer.INDEX||e&Lt.Buffer.VERTEX?35044:e&Lt.Buffer.UNIFORM?35048:35044}var Lt,it,lr=P(()=>{Lt=D(I(),1),it=class extends Lt.Buffer{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(t,r={}){super(t,r),this.device=t,this.gl=this.device.gl;let n=typeof r=="object"?r.handle:void 0;this.handle=n||this.gl.createBuffer(),t._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=ac(this.props.usage),this.glUsage=cc(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(t,r=0,n=t.byteLength+r){let i=this.glTarget;this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,n,this.glUsage),this.gl.bufferSubData(i,r,t),this.gl.bindBuffer(i,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(t,r,n),this.props.handle?this.trackReferencedMemory(n,"Buffer"):this.trackAllocatedMemory(n)}_initWithByteLength(t){let r=t;t===0&&(r=new Float32Array(0));let n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,r,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=t,this.byteLength=t,this._setDebugData(null,0,t),this.props.handle?this.trackReferencedMemory(t,"Buffer"):this.trackAllocatedMemory(t),this}write(t,r=0){let n=ArrayBuffer.isView(t)?t:new Uint8Array(t),i=0,s=void 0,o=36663;this.gl.bindBuffer(o,this.handle),i!==0||s!==void 0?this.gl.bufferSubData(o,r,n,i,s):this.gl.bufferSubData(o,r,n),this.gl.bindBuffer(o,null),this._setDebugData(t,r,t.byteLength)}async mapAndWriteAsync(t,r=0,n=this.byteLength-r){let i=new ArrayBuffer(n);await t(i,"copied"),this.write(i,r)}async readAsync(t=0,r){return this.readSyncWebGL(t,r)}async mapAndReadAsync(t,r=0,n){let i=await this.readAsync(r,n);return await t(i.buffer,"copied")}readSyncWebGL(t=0,r){r=r??this.byteLength-t;let n=new Uint8Array(r),i=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,t,n,i,r),this.gl.bindBuffer(36662,null),this._setDebugData(n,t,r),n}}});function Ms(e){let t=e.split(/\r?\n/),r=[];for(let n of t){if(n.length<=1)continue;let i=n.trim(),s=n.split(":"),o=s[0]?.trim();if(s.length===2){let[d,p]=s;if(!d||!p){r.push({message:i,type:hr(o||"info"),lineNum:0,linePos:0});continue}r.push({message:p.trim(),type:hr(d),lineNum:0,linePos:0});continue}let[a,c,l,...h]=s;if(!a||!c||!l){r.push({message:s.slice(1).join(":").trim()||i,type:hr(o||"info"),lineNum:0,linePos:0});continue}let u=parseInt(l,10);Number.isNaN(u)&&(u=0);let f=parseInt(c,10);Number.isNaN(f)&&(f=0),r.push({message:h.join(":").trim(),type:hr(a),lineNum:u,linePos:f})}return r}function hr(e){let t=["warning","error","info"],r=e.toLowerCase();return t.includes(r)?r:"info"}var Ps=P(()=>{});function lc(e){return e.split(/\r?\n/).find(t=>t.trim())?.trim()}var Ee,ur,Cs=P(()=>{Ee=D(I(),1);Ps();ur=class extends Ee.Shader{device;handle;_compilationInfoLog="";constructor(t,r){super(t,r),this.device=t;let n=this.props.handle;switch(this.props.stage){case"vertex":this.handle=n||this.device.gl.createShader(35633);break;case"fragment":this.handle=n||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}t._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 t=this._getCompilationInfoLog();return t?Ms(t):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(t){t=t.startsWith("#version ")?t:`#version 300 es
|
|
8
|
-
${t}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,t),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(this._getCompilationErrorMessage(t));return}return
|
|
9
|
-
Source: ${o}`:"",l=s.message.trim()||n||"WebGL did not provide a shader compiler log";return`GLSL compilation errors in ${r}:${a}: ${l}${c}`}_getCompilationInfoLog(){let t=this.device.gl.getShaderInfoLog(this.handle)?.trim();return t&&(this._compilationInfoLog=t),this._compilationInfoLog}}});function Rs(e,t,r,n){if(dc(t))return n(e);let i=e;i.pushState();try{return hc(e,t),et(i.gl,r),n(e)}finally{i.popState()}}function hc(e,t){let r=e,{gl:n}=r;if(t.cullMode)switch(t.cullMode){case"none":n.disable(2884);break;case"front":n.enable(2884),n.cullFace(1028);break;case"back":n.enable(2884),n.cullFace(1029);break}if(t.frontFace&&n.frontFace(Dt("frontFace",t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has("depth-clip-control")&&n.enable(34383),t.depthBias!==void 0&&(n.enable(32823),n.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0)),t.provokingVertex&&e.features.has("provoking-vertex-webgl")){let s=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=Dt("provokingVertex",t.provokingVertex,{first:36429,last:36430});s?.provokingVertexWEBGL(o)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has("polygon-mode-webgl")){if(t.polygonMode){let s=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=Dt("polygonMode",t.polygonMode,{fill:6914,line:6913});s?.polygonModeWEBGL(1028,o),s?.polygonModeWEBGL(1029,o)}t.polygonOffsetLine&&n.enable(10754)}if(e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&n.enable(12288),t.clipDistance1&&n.enable(12289),t.clipDistance2&&n.enable(12290),t.clipDistance3&&n.enable(12291),t.clipDistance4&&n.enable(12292),t.clipDistance5&&n.enable(12293),t.clipDistance6&&n.enable(12294),t.clipDistance7&&n.enable(12295)),t.depthWriteEnabled!==void 0&&n.depthMask(fc("depthWriteEnabled",t.depthWriteEnabled)),t.depthCompare&&(t.depthCompare!=="always"?n.enable(2929):n.disable(2929),n.depthFunc(dr("depthCompare",t.depthCompare))),t.clearDepth!==void 0&&n.clearDepth(t.clearDepth),t.stencilWriteMask){let i=t.stencilWriteMask;n.stencilMaskSeparate(1028,i),n.stencilMaskSeparate(1029,i)}if(t.stencilReadMask&&As.log.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){let i=t.stencilReadMask||4294967295,s=dr("depthCompare",t.stencilCompare);t.stencilCompare!=="always"?n.enable(2960):n.disable(2960),n.stencilFuncSeparate(1028,s,0,i),n.stencilFuncSeparate(1029,s,0,i)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){let i=Tn("stencilPassOperation",t.stencilPassOperation),s=Tn("stencilFailOperation",t.stencilFailOperation),o=Tn("stencilDepthFailOperation",t.stencilDepthFailOperation);n.stencilOpSeparate(1028,s,o,i),n.stencilOpSeparate(1029,s,o,i)}switch(t.blend){case!0:n.enable(3042);break;case!1:n.disable(3042);break;default:}if(t.blendColorOperation||t.blendAlphaOperation){let i=Ls("blendColorOperation",t.blendColorOperation||"add"),s=Ls("blendAlphaOperation",t.blendAlphaOperation||"add");n.blendEquationSeparate(i,s);let o=fr("blendColorSrcFactor",t.blendColorSrcFactor||"one"),a=fr("blendColorDstFactor",t.blendColorDstFactor||"zero"),c=fr("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),l=fr("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");n.blendFuncSeparate(o,a,c,l)}}function dr(e,t){return Dt(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Tn(e,t){return Dt(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function Ls(e,t){return Dt(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function fr(e,t,r="color"){return Dt(e,t,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant: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 uc(e,t){return`Illegal parameter ${t} for ${e}`}function Dt(e,t,r){if(!(t in r))throw new Error(uc(e,t));return r[t]}function fc(e,t){return t}function dc(e){let t=!0;for(let r in e){t=!1;break}return t}var As,_n=P(()=>{As=D(I(),1);Yt()});function mr(e){let t={};return e.addressModeU&&(t[10242]=vn(e.addressModeU)),e.addressModeV&&(t[10243]=vn(e.addressModeV)),e.addressModeW&&(t[32882]=vn(e.addressModeW)),e.magFilter&&(t[10240]=Sn(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=mc(e.minFilter||"linear",e.mipmapFilter)),e.lodMinClamp!==void 0&&(t[33082]=e.lodMinClamp),e.lodMaxClamp!==void 0&&(t[33083]=e.lodMaxClamp),e.type==="comparison-sampler"&&(t[34892]=34894),e.compare&&(t[34893]=dr("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function vn(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function Sn(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}function mc(e,t="none"){if(!t)return Sn(e);switch(t){case"none":return Sn(e);case"nearest":switch(e){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(e){case"nearest":return 9986;case"linear":return 9987}}}var Mn=P(()=>{_n()});var ks,pr,Ds=P(()=>{ks=D(I(),1);Mn();pr=class extends ks.Sampler{device;handle;parameters;constructor(t,r){super(t,r),this.device=t,this.parameters=mr(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(t){for(let[r,n]of Object.entries(t)){let i=Number(r);switch(i){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,i,n);break;default:this.device.gl.samplerParameteri(this.handle,i,n);break}}}}});function st(e,t,r){if(pc(t))return r(e);let{nocatch:n=!0}=t,i=rt.get(e);i.push(),et(e,t);let s;if(n)s=r(e),i.pop();else try{s=r(e)}finally{i.pop()}return s}function pc(e){for(let t in e)return!1;return!0}var gr=P(()=>{Yt();fn()});var br,gt,Pn=P(()=>{br=D(I(),1),gt=class extends br.TextureView{device;gl;handle;texture;constructor(t,r){super(t,{...br.Texture.defaultProps,...r}),this.device=t,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}});function xr(e){return gc[e]}var gc,Cn=P(()=>{gc={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 bc(e,t=0){return t?new e.constructor(e.buffer,e.byteOffset+t,(e.byteLength-t)/e.BYTES_PER_ELEMENT):e}function xc(e,t){if(t%e.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${t} must align to typed array element size ${e.BYTES_PER_ELEMENT}`);return t/e.BYTES_PER_ELEMENT}function yc(e){switch(e){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(e)}function Te(e,t,r){return t==="cube"?34069+r:e}var At,bt,yr=P(()=>{At=D(I(),1);qt();Mn();gr();Pn();Cn();bt=class extends At.Texture{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(t,r){super(t,r,{byteAlignment:1}),this.device=t,this.gl=this.device.gl;let n=rr(this.props.format);if(this.glTarget=yc(this.props.dimension),this.glInternalFormat=n.internalFormat,this.glFormat=n.format,this.glType=n.type,this.compressed=n.compressed,this.isHandleBorrowed&&this.props.handle===void 0)throw new Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);let{dimension:i,width:s,height:o,depth:a,mipLevels:c,glTarget:l,glInternalFormat:h}=this;if(!this.compressed)switch(i){case"2d":case"cube":this.gl.texStorage2D(l,c,h,s,o);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,h,s,o,a);break;default:throw new Error(i)}this.gl.bindTexture(this.glTarget,null),this._initializeData(r.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new gt(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(t){return new gt(this.device,{...t,texture:this})}clone(t){if(this.isHandleBorrowed&&t&&(t.width!==this.width||t.height!==this.height))throw new Error(`Cannot resize borrowed read-only ${this}`);return super.clone(t)}setSampler(t={}){this._assertWritable("set sampler parameters on"),super.setSampler(t);let r=mr(this.sampler.props);this._setSamplerParameters(r)}copyExternalImage(t){this._assertWritable("copy external image data into");let r=this._normalizeCopyExternalImageOptions(t);if(r.sourceX||r.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:n,glType:i}=this,{image:s,depth:o,mipLevel:a,x:c,y:l,z:h,width:u,height:f}=r,d=Te(this.glTarget,this.dimension,h),p=r.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),st(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(d,a,c,l,u,f,n,i,s);break;case"2d-array":case"3d":this.gl.texSubImage3D(d,a,c,l,h,u,f,o,n,i,s);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyElementImage(t){this._assertWritable("copy element image data into");let r=this._normalizeCopyElementImageOptions(t),{glFormat:n}=this,{element:i,depth:s,mipLevel:o,sourceX:a,sourceY:c,sourceWidth:l,sourceHeight:h,x:u,y:f,z:d,width:p,height:g}=r,m=Te(this.glTarget,this.dimension,d),b=r.flipY?{37440:!0}:{},_=this.gl;if(s!==1||this.dimension!=="2d"&&this.dimension!=="cube")throw new Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(o!==0||u!==0||f!==0)throw new Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if(typeof _.texElementImage2D!="function")throw new Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),st(this.gl,b,()=>{_.texElementImage2D?.(m,n,i,{sx:a,sy:c,swidth:l??p,sheight:h??g,width:p,height:g})}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyImageData(t){super.copyImageData(t)}readBuffer(t={},r){if(!r)throw new Error(`${this} readBuffer requires a destination buffer`);let n=this._getSupportedColorReadOptions(t),i=t.byteOffset??0,s=this.computeMemoryLayout(n);if(r.byteLength<i+s.byteLength)throw new Error(`${this} readBuffer target is too small (${r.byteLength} < ${i+s.byteLength})`);let o=r;this.gl.bindBuffer(35051,o.handle);try{this._readColorTextureLayers(n,s,a=>{this.gl.readPixels(n.x,n.y,n.width,n.height,this.glFormat,this.glType,i+a)})}finally{this.gl.bindBuffer(35051,null)}return r}async readDataAsync(t={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(t,r={}){this._assertWritable("write buffer data into");let n=this._normalizeTextureWriteOptions(r),{width:i,height:s,depthOrArrayLayers:o,mipLevel:a,byteOffset:c,x:l,y:h,z:u}=n,{glFormat:f,glType:d,compressed:p}=this,g=Te(this.glTarget,this.dimension,u);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:m}=this.device.getTextureFormatInfo(this.format),b=m?n.bytesPerRow/m:void 0,_={3317:this.byteAlignment,...b!==void 0?{3314:b}:{},32878:n.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,t.handle),st(this.gl,_,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(g,a,l,h,i,s,f,d,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(g,a,l,h,u,i,s,o,f,d,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(t,r={}){this._assertWritable("write data into");let n=this._normalizeTextureWriteOptions(r),i=ArrayBuffer.isView(t)?t:new Uint8Array(t),{width:s,height:o,depthOrArrayLayers:a,mipLevel:c,x:l,y:h,z:u,byteOffset:f}=n,{glFormat:d,glType:p,compressed:g}=this,m=Te(this.glTarget,this.dimension,u),b;if(!g){let{bytesPerPixel:x}=this.device.getTextureFormatInfo(this.format);x&&(b=n.bytesPerRow/x)}let _=this.compressed?{}:{3317:this.byteAlignment,...b!==void 0?{3314:b}:{},32878:n.rowsPerImage},y=xc(i,f),E=g?bc(i,f):i,v=this._getMipLevelSize(c),w=l===0&&h===0&&u===0&&s===v.width&&o===v.height&&a===v.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),st(this.gl,_,()=>{switch(this.dimension){case"2d":case"cube":g?w?this.gl.compressedTexImage2D(m,c,d,s,o,0,E):this.gl.compressedTexSubImage2D(m,c,l,h,s,o,d,E):this.gl.texSubImage2D(m,c,l,h,s,o,d,p,i,y);break;case"2d-array":case"3d":g?w?this.gl.compressedTexImage3D(m,c,d,s,o,a,0,E):this.gl.compressedTexSubImage3D(m,c,l,h,u,s,o,a,d,E):this.gl.texSubImage3D(m,c,l,h,u,s,o,a,d,p,i,y);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(t,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(t={}){let r=this._getSupportedColorReadOptions(t),n=this.computeMemoryLayout(r),i=xr(this.glType),s=(0,At.getTypedArrayConstructor)(i),o=new s(n.byteLength/s.BYTES_PER_ELEMENT);return this._readColorTextureLayers(r,n,a=>{let c=new s(o.buffer,o.byteOffset+a,n.bytesPerImage/s.BYTES_PER_ELEMENT);this.gl.readPixels(r.x,r.y,r.width,r.height,this.glFormat,this.glType,c)}),o.buffer}_readColorTextureLayers(t,r,n){let i=this._getFramebuffer(),s=r.bytesPerRow/r.bytesPerPixel,o={3333:this.byteAlignment,...s!==t.width?{3330:s}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,i.handle);try{this.gl.readBuffer(36064),st(this.gl,o,()=>{for(let l=0;l<t.depthOrArrayLayers;l++)this._attachReadSubresource(i,t.mipLevel,t.z+l),n(l*r.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,c||null),this.gl.readBuffer(a)}}_attachReadSubresource(t,r,n){let i=`${r}:${n}`;if(this._framebufferAttachmentKey!==i){switch(this.dimension){case"2d":this.gl.framebufferTexture2D(36160,36064,3553,this.handle,r);break;case"cube":this.gl.framebufferTexture2D(36160,36064,Te(this.glTarget,this.dimension,n),this.handle,r);break;case"2d-array":case"3d":this.gl.framebufferTextureLayer(36160,36064,this.handle,r,n);break;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){let s=Number(this.gl.checkFramebufferStatus(36160));if(s!==36053)throw new Error(`${t} incomplete for ${this} readback (${s})`)}this._framebufferAttachmentKey=i}}generateMipmapsWebGL(t){if(this._assertWritable("generate mipmaps for"),!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(At.log.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!t?.force)))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(n){At.log.warn(`Error generating mipmap for ${this}: ${n.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(t){At.log.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(t))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,n]of Object.entries(t)){let i=Number(r),s=n;switch(i){case 33082:case 33083:this.gl.texParameterf(this.glTarget,i,s);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,i,s);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,i,s);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,i,s);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,i,s);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(t){let{gl:r}=this;return t!==void 0&&(this._textureUnit=t,r.activeTexture(33984+t)),r.bindTexture(this.glTarget,this.handle),t}_unbind(t){let{gl:r}=this;return t!==void 0&&(this._textureUnit=t,r.activeTexture(33984+t)),r.bindTexture(this.glTarget,null),t}_assertWritable(t){if(this.isHandleBorrowed)throw new Error(`Cannot ${t} borrowed read-only ${this}`)}}});function Is(e,t,r,n){let i=e,s=n;s===!0&&(s=1),s===!1&&(s=0);let o=typeof s=="number"?[s]:s;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof n!="number")throw new Error("samplers must be set to integers");return e.uniform1i(t,n);case 5126:return e.uniform1fv(t,o);case 35664:return e.uniform2fv(t,o);case 35665:return e.uniform3fv(t,o);case 35666:return e.uniform4fv(t,o);case 5124:return e.uniform1iv(t,o);case 35667:return e.uniform2iv(t,o);case 35668:return e.uniform3iv(t,o);case 35669:return e.uniform4iv(t,o);case 35670:return e.uniform1iv(t,o);case 35671:return e.uniform2iv(t,o);case 35672:return e.uniform3iv(t,o);case 35673:return e.uniform4iv(t,o);case 5125:return i.uniform1uiv(t,o,1);case 36294:return i.uniform2uiv(t,o,2);case 36295:return i.uniform3uiv(t,o,3);case 36296:return i.uniform4uiv(t,o,4);case 35674:return e.uniformMatrix2fv(t,!1,o);case 35675:return e.uniformMatrix3fv(t,!1,o);case 35676:return e.uniformMatrix4fv(t,!1,o);case 35685:return i.uniformMatrix2x3fv(t,!1,o);case 35686:return i.uniformMatrix2x4fv(t,!1,o);case 35687:return i.uniformMatrix3x2fv(t,!1,o);case 35688:return i.uniformMatrix3x4fv(t,!1,o);case 35689:return i.uniformMatrix4x2fv(t,!1,o);case 35690:return i.uniformMatrix4x3fv(t,!1,o)}throw new Error("Illegal uniform")}var Bs=P(()=>{});function wc(e,t){let r={...e,attributes:e.attributes.map(n=>({...n})),bindings:e.bindings.map(n=>({...n}))};for(let n of t?.attributes||[]){let i=r.attributes.find(s=>s.name===n.name);i?(i.type=n.type||i.type,i.stepMode=n.stepMode||i.stepMode):U.log.warn(`shader layout attribute ${n.name} not present in shader`)}for(let n of t?.bindings||[]){let i=Os(r,n.name);if(!i){U.log.warn(`shader layout binding ${n.name} not present in shader`);continue}Object.assign(i,n)}return r}function Os(e,t){return e.bindings.find(r=>r.name===t||r.name===`${t}Uniforms`||`${r.name}Uniforms`===t)}function Fs(e,t){return e[t]||e[`${t}Uniforms`]||e[t.replace(/Uniforms$/,"")]}var U,wr,Ns=P(()=>{U=D(I(),1);Bs();lr();or();yr();Pn();wr=class extends U.RenderPipeline{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(t,r){super(t,r),this.device=t;let n=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(r);this.sharedRenderPipeline=n,this.handle=n.handle,this.vs=n.vs,this.fs=n.fs,this.linkStatus=n.linkStatus,this.introspectedLayout=n.introspectedLayout,this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=r.shaderLayout?wc(this.introspectedLayout,r.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(t,r){let n=(0,U.flattenBindingsByGroup)((0,U.normalizeBindingsByGroup)(this.shaderLayout,t));for(let[i,s]of Object.entries(n)){let o=Os(this.shaderLayout,i);if(o){switch(s||U.log.warn(`Unsetting binding "${i}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof it)&&!(s.buffer instanceof it))throw new Error("buffer value");break;case"texture":if(!(s instanceof gt||s instanceof bt||s instanceof pt))throw new Error(`${this} Bad texture binding for ${i}`);break;case"sampler":U.log.warn(`Ignoring sampler ${i}`)();break;default:throw new Error(o.type)}this.bindings[i]=s}else{let a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");r?.disableWarnings||U.log.warn(`No binding "${i}" in render pipeline "${this.id}", expected one of ${a}`,s)()}}}draw(t){let r=t.renderPass,n=t.bindGroups?(0,U.flattenBindingsByGroup)(t.bindGroups):t.bindings||this.bindings;return r.setPipeline(this),r.setBindings(n),r.setVertexArray(t.vertexArray),r.draw({parameters:t.parameters,topology:t.topology,isInstanced:t.isInstanced,vertexCount:t.vertexCount,indexCount:t.indexCount,instanceCount:t.instanceCount,firstVertex:t.firstVertex,firstIndex:t.firstIndex,firstInstance:t.firstInstance,baseVertex:t.baseVertex,transformFeedback:t.transformFeedback,uniforms:t.uniforms})}_areTexturesRenderable(t){let r=!0;for(let n of this.shaderLayout.bindings)Fs(t,n.name)||(U.log.warn(`Binding ${n.name} not found in ${this.id}`)(),r=!1);return r}_applyBindings(t,r){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:n}=this.device;n.useProgram(this.handle);let i=0,s=0;for(let o of this.shaderLayout.bindings){let a=Fs(t,o.name);if(!a)throw new Error(`No value for binding ${o.name} in ${this.id}`);switch(o.type){case"uniform":let{name:c}=o,l=n.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);if(n.uniformBlockBinding(this.handle,l,s),a instanceof it)n.bindBufferBase(35345,s,a.handle);else{let u=a;n.bindBufferRange(35345,s,u.buffer.handle,u.offset||0,u.size||u.buffer.byteLength-(u.offset||0))}s+=1;break;case"texture":if(!(a instanceof gt||a instanceof bt||a instanceof pt))throw new Error("texture");let h;if(a instanceof gt)h=a.texture;else if(a instanceof bt)h=a;else if(a instanceof pt&&a.colorAttachments[0]instanceof gt)U.log.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),h=a.colorAttachments[0].texture;else throw new Error("No texture");n.activeTexture(33984+i),n.bindTexture(h.glTarget,h.handle),i+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${o.type}' not supported in WebGL`)}}}_applyUniforms(t){for(let r of this.shaderLayout.uniforms||[]){let{name:n,location:i,type:s,textureUnit:o}=r,a=t[n]??o;a!==void 0&&Is(this.device.gl,i,s,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});function Vs(e){return Tc[e]}function Er(e){return Ec[e]}function Tr(e){return!!zs[e]}function Gs(e){return zs[e]}var Ec,zs,Tc,_r=P(()=>{Ec={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>"},zs={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"}},Tc={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 Ws(e,t){let r={attributes:[],bindings:[]};r.attributes=_c(e,t);let n=Mc(e,t);for(let a of n){let c=a.uniforms.map(l=>({name:l.name,format:l.format,byteOffset:l.byteOffset,byteStride:l.byteStride,arrayLength:l.arrayLength}));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 i=Sc(e,t),s=0;for(let a of i)if(Tr(a.type)){let{viewDimension:c,sampleType:l}=Gs(a.type);r.bindings.push({type:"texture",name:a.name,group:0,location:s,viewDimension:c,sampleType:l}),a.textureUnit=s,s+=1}i.length&&(r.uniforms=i);let o=vc(e,t);return o?.length&&(r.varyings=o),r}function _c(e,t){let r=[],n=e.getProgramParameter(t,35721);for(let i=0;i<n;i++){let s=e.getActiveAttrib(t,i);if(!s)throw new Error("activeInfo");let{name:o,type:a}=s,c=e.getAttribLocation(t,o);if(c>=0){let l=Er(a),h=/instance/i.test(o)?"instance":"vertex";r.push({name:o,location:c,stepMode:h,type:l})}}return r.sort((i,s)=>i.location-s.location),r}function vc(e,t){let r=[],n=e.getProgramParameter(t,35971);for(let i=0;i<n;i++){let s=e.getTransformFeedbackVarying(t,i);if(!s)throw new Error("activeInfo");let{name:o,type:a,size:c}=s,l=Er(a),{type:h,components:u}=(0,Xt.getVariableShaderTypeInfo)(l);r.push({location:i,name:o,type:h,size:c*u})}return r.sort((i,s)=>i.location-s.location),r}function Sc(e,t){let r=[],n=e.getProgramParameter(t,35718);for(let i=0;i<n;i++){let s=e.getActiveUniform(t,i);if(!s)throw new Error("activeInfo");let{name:o,size:a,type:c}=s,{name:l,isArray:h}=Pc(o),u=e.getUniformLocation(t,l),f={location:u,name:l,size:a,type:c,isArray:h};if(r.push(f),f.size>1)for(let d=0;d<f.size;d++){let p=`${l}[${d}]`;u=e.getUniformLocation(t,p);let g={...f,name:p,location:u};r.push(g)}}return r}function Mc(e,t){let r=(s,o)=>e.getActiveUniformBlockParameter(t,s,o),n=[],i=e.getProgramParameter(t,35382);for(let s=0;s<i;s++){let o={name:e.getActiveUniformBlockName(t,s)||"",location:r(s,35391),byteLength:r(s,35392),vertex:r(s,35396),fragment:r(s,35398),uniformCount:r(s,35394),uniforms:[]},a=r(s,35395)||[],c=e.getActiveUniforms(t,a,35383),l=e.getActiveUniforms(t,a,35384),h=e.getActiveUniforms(t,a,35387),u=e.getActiveUniforms(t,a,35388);for(let p=0;p<o.uniformCount;++p){let g=a[p];if(g!==void 0){let m=e.getActiveUniform(t,g);if(!m)throw new Error("activeInfo");let b=Er(c[p]);o.uniforms.push({name:m.name,format:b,type:c[p],arrayLength:l[p],byteOffset:h[p],byteStride:u[p]})}}let f=new Set(o.uniforms.map(p=>p.name.split(".")[0]).filter(p=>!!p)),d=o.name.replace(/Uniforms$/,"");if(f.size===1&&!f.has(o.name)&&!f.has(d)){let[p]=f;Xt.log.warn(`Uniform block "${o.name}" uses GLSL instance "${p}". luma.gl binds uniform buffers by block name ("${o.name}") and alias ("${d}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}n.push(o)}return n.sort((s,o)=>s.location-o.location),n}function Pc(e){if(e[e.length-1]!=="]")return{name:e,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(e);return{name:(0,Xt.assertDefined)(r?.[1],`Failed to parse GLSL uniform name ${e}`),length:r?.[2]?1:0,isArray:!!r?.[2]}}var Xt,Us=P(()=>{Xt=D(I(),1);_r()});var wt,Ys,vr,$s=P(()=>{wt=D(I(),1);Us();_r();Ys=4,vr=class extends wt.SharedRenderPipeline{device;handle;vs;fs;introspectedLayout={attributes:[],bindings:[],uniforms:[]};linkStatus="pending";constructor(t,r){super(t,r),this.device=t,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(),wt.log.time(3,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=Ws(this.device.gl,this.handle),wt.log.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:t}=this.device;if(t.attachShader(this.handle,this.vs.handle),t.attachShader(this.handle,this.fs.handle),wt.log.time(Ys,`linkProgram for ${this.id}`)(),t.linkProgram(this.handle),wt.log.timeEnd(Ys,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let n=this._getLinkStatus();this._reportLinkStatus(n);return}wt.log.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),wt.log.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}async _reportLinkStatus(t){switch(t){case"success":return;default:let r=t==="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 n=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${t}: ${n}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:t}=this.device;return t.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),t.validateProgram(this.handle),t.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:t}=this.device;t.useProgram(this.handle);let r=0,n=t.getProgramParameter(this.handle,35718);for(let i=0;i<n;i++){let s=t.getActiveUniform(this.handle,i);if(s&&Tr(s.type)){let o=s.name.endsWith("[0]"),a=o?s.name.slice(0,-3):s.name,c=t.getUniformLocation(this.handle,a);c!==null&&(r=this._assignSamplerUniform(c,s,o,r))}}}_assignSamplerUniform(t,r,n,i){let{gl:s}=this.device;if(n&&r.size>1){let o=Int32Array.from({length:r.size},(a,c)=>i+c);return s.uniform1iv(t,o),i+r.size}return s.uniform1i(t,i),i+1}async _waitForLinkComplete(){let t=async i=>await new Promise(s=>setTimeout(s,i));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}let{gl:n}=this.device;for(;;){if(n.getProgramParameter(this.handle,37297))return;await t(10)}}}});function Cc(e,t){let r=t.sourceBuffer,n=t.destinationBuffer;e.gl.bindBuffer(36662,r.handle),e.gl.bindBuffer(36663,n.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function Lc(e,t){let{sourceBuffer:r,byteOffset:n=0,destinationTexture:i,mipLevel:s=0,origin:o=[0,0,0],aspect:a="all",bytesPerRow:c,rowsPerImage:l,size:h}=t;if(a!=="all")throw new Error("copyBufferToTexture aspect is not supported in WebGL");i.writeBuffer(r,{byteOffset:n,bytesPerRow:c,rowsPerImage:l,mipLevel:s,x:o[0]??0,y:o[1]??0,z:o[2]??0,width:h[0],height:h[1],depthOrArrayLayers:h[2]})}function Ac(e,t){let{sourceTexture:r,mipLevel:n=0,aspect:i="all",width:s=t.sourceTexture.width,height:o=t.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:h=0,bytesPerRow:u,rowsPerImage:f}=t;if(r instanceof It.Texture){r.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:s,height:o,depthOrArrayLayers:a,mipLevel:n,aspect:i,byteOffset:h},l);return}if(i!=="all")throw new Error("aspect not supported in WebGL");if(n!==0||a!==void 0||u||f)throw new Error("not implemented");let{framebuffer:d,destroyFramebuffer:p}=js(r),g;try{let m=l,b=s||d.width,_=o||d.height,y=(0,It.assertDefined)(d.colorAttachments[0]),E=rr(y.texture.props.format),v=E.format,w=E.type;e.gl.bindBuffer(35051,m.handle),g=e.gl.bindFramebuffer(36160,d.handle),e.gl.readPixels(c[0],c[1],b,_,v,w,h)}finally{e.gl.bindBuffer(35051,null),g!==void 0&&e.gl.bindFramebuffer(36160,g),p&&d.destroy()}}function Rc(e,t){let{sourceTexture:r,destinationMipLevel:n=0,origin:i=[0,0],destinationOrigin:s=[0,0,0],destinationTexture:o}=t,{width:a=t.destinationTexture.width,height:c=t.destinationTexture.height}=t,{framebuffer:l,destroyFramebuffer:h}=js(r),[u=0,f=0]=i,[d,p,g]=s,m=e.gl.bindFramebuffer(36160,l.handle),b,_;if(o instanceof bt)b=o,a=Number.isFinite(a)?a:b.width,c=Number.isFinite(c)?c:b.height,b._bind(0),_=b.glTarget;else throw new Error("invalid destination");switch(_){case 3553:case 34067:e.gl.copyTexSubImage2D(_,n,d,p,u,f,a,c);break;case 35866:case 32879:e.gl.copyTexSubImage3D(_,n,d,p,g,u,f,a,c);break;default:}b&&b._unbind(),e.gl.bindFramebuffer(36160,m),h&&l.destroy()}function js(e){if(e instanceof It.Texture){let{width:t,height:r,id:n}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${n}`,width:t,height:r,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}var It,Sr,qs=P(()=>{It=D(I(),1);qt();yr();Sr=class extends It.CommandBuffer{device;handle=null;commands=[];constructor(t,r={}){super(t,r),this.device=t}_executeCommands(t=this.commands){for(let r of t)switch(r.name){case"copy-buffer-to-buffer":Cc(this.device,r.options);break;case"copy-buffer-to-texture":Lc(this.device,r.options);break;case"copy-texture-to-buffer":Ac(this.device,r.options);break;case"copy-texture-to-texture":Rc(this.device,r.options);break;default:throw new Error(r.name)}}}});function Xs(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(e)}}function Zs(e){switch(e){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(e)}}var Ln=P(()=>{});var Et,kc,Mr,Hs=P(()=>{Et=D(I(),1);gr();Yt();Ln();_n();kc=[1,2,4,8],Mr=class extends Et.RenderPass{device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(t,r){super(t,r),this.device=t;let n=this.props.framebuffer,i=!n||n.handle===null;i&&t.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let s;if(!r?.parameters?.viewport)if(!i&&n){let{width:o,height:a}=n;s=[0,0,o,a]}else{let[o,a]=t.getDefaultCanvasContext().getDrawingBufferSize();s=[0,0,o,a]}if(this.device.pushState(),this.setParameters({viewport:s,...this.props.parameters}),!i&&n?.colorAttachments.length){let o=n.colorAttachments.map((a,c)=>36064+c);this.device.gl.drawBuffers(o)}else i&&this.device.gl.drawBuffers([1029]);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(t){}popDebugGroup(){}insertDebugMarker(t){}executeBundles(t){throw new Error("Render bundles are only supported in WebGPU")}setParameters(t={}){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,t.viewport&&(t.viewport.length>=6?(r.viewport=t.viewport.slice(0,4),r.depthRange=[t.viewport[4],t.viewport[5]]):r.viewport=t.viewport),t.scissorRect&&(r.scissorTest=!0,r.scissor=t.scissorRect),t.blendConstant&&(r.blendColor=t.blendConstant),t.stencilReference!==void 0&&(r[2967]=t.stencilReference,r[36003]=t.stencilReference),"colorMask"in t&&(r.colorMask=kc.map(n=>!!(n&t.colorMask))),this.glParameters=r,et(this.device.gl,r)}setPipeline(t){this.pipeline=t}setBindings(t,r){if(!this.pipeline)throw new Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=(0,Et.flattenBindingsByGroup)((0,Et.normalizeBindingsByGroup)(this.pipeline.shaderLayout,t)),this.bindingsPipeline=this.pipeline}setVertexArray(t){this.vertexArray=t}draw(t){let r=this.pipeline,n=this.vertexArray;if(!r)throw new Error("RenderPass.setPipeline() must be called before draw()");if(!n)throw new Error("RenderPass.setVertexArray() must be called before draw()");if(r.shaderLayout.bindings.length>0&&this.bindingsPipeline!==r)throw new Error("RenderPass.setBindings() must be called after setPipeline() before draw()");r._syncLinkStatus();let{parameters:i=r.props.parameters,topology:s=r.props.topology,vertexCount:o,indexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:h=0,transformFeedback:u,uniforms:f=r.uniforms}=t,d=Xs(s),p=!!n.indexBuffer,g=n.indexBuffer?.glIndexType,m=a??o??0;if(r.linkStatus!=="success")return Et.log.info(2,`RenderPipeline:${r.id}.draw() aborted - waiting for shader linking`)(),!1;if(!r._areTexturesRenderable(this.bindings))return Et.log.info(2,`RenderPipeline:${r.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(r.handle),n.bindBeforeRender(this);let b=u;return b&&b.begin(r.props.topology),r._applyBindings(this.bindings,{disableWarnings:r.props.disableWarnings}),r._applyUniforms(f),Rs(this.device,i,this.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(d,m,g,h,c||0):p?this.device.gl.drawElements(d,m,g,h):l?this.device.gl.drawArraysInstanced(d,h,o||0,c||0):this.device.gl.drawArrays(d,h,o||0),b&&b.end()}),n.unbindAfterRender(this),!0}drawIndirect(t,r=0){throw new Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(t,r=0){throw new Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(t){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let t={...this.glParameters},r=0;this.props.clearColors&&this.props.clearColors.forEach((n,i)=>{n&&this.clearColorBuffer(i,n)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(r|=16384,t.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=256,t.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=1024,t.clearStencil=this.props.clearStencil),r!==0&&st(this.device.gl,t,()=>{this.device.gl.clear(r)})}clearColorBuffer(t=0,r=[0,0,0,0]){st(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,t,r);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,t,r);break;case Float32Array:this.device.gl.clearBufferfv(6144,t,r);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var Qs,_e,Ks=P(()=>{Qs=D(I(),1);qs();Hs();_e=class extends Qs.CommandEncoder{device;handle=null;commandBuffer;constructor(t,r){super(t,r),this.device=t,this.commandBuffer=new Sr(t,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(t={}){return new Mr(this.device,this._applyTimeProfilingToPassProps(t))}beginComputePass(t={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(t){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:t})}copyBufferToTexture(t){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:t})}copyTextureToBuffer(t){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:t})}copyTextureToTexture(t){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:t})}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}resolveQuerySet(t,r,n){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(t,r){t.writeTimestamp(r)}}});var Pr,Dc,Cr,Ic,Js,An=P(()=>{Pr=globalThis,Dc=globalThis.document||{},Cr=globalThis.process||{},Ic=globalThis.console,Js=globalThis.navigator||{}});function Lr(e){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let t=typeof navigator<"u"&&navigator.userAgent,r=e||t;return!!(r&&r.indexOf("Electron")>=0)}var Rn=P(()=>{});function Tt(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Lr()}var kn=P(()=>{Rn()});function Dn(e){return!e&&!Tt()?"Node":Lr(e)?"Electron":(e||Js.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var to=P(()=>{kn();Rn();An()});var In,ve=P(()=>{An();kn();to();In="4.1.1"});function eo(e){let{target:t,source:r,start:n=0,count:i=1}=e,s=r.length,o=i*s,a=0;for(let c=n;a<s;a++)t[c++]=r[a]??0;for(;a<o;)a<o-a?(t.copyWithin(n+a,n,n+a),a*=2):(t.copyWithin(n+a,n,n+o-a),a=o);return e.target}var ro=P(()=>{});function Fc(e){return Array.isArray(e)?new Float32Array(e):e}function Oc(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}var Zt,Ar,no=P(()=>{Zt=D(I(),1);ve();mn();ro();Ar=class e extends Zt.VertexArray{get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(t){return Dn()==="Chrome"}constructor(t,r){super(t,r),this.device=t,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=new Array(this.maxVertexAttributes).fill(null);for(let n of Object.values((0,Zt.getAttributeInfosFromLayouts)(r.shaderLayout,r.bufferLayout)))this.attributeInfosByLocation[n.location]=n}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(t){let r=t;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(t,r){let n=r;if(n.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:i,type:s,stride:o,offset:a,normalized:c,integer:l,divisor:h}=this._getAccessor(t);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),l?this.device.gl.vertexAttribIPointer(t,i,s,o,a):this.device.gl.vertexAttribPointer(t,i,s,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(t),this.device.gl.vertexAttribDivisor(t,h||0),this.attributes[t]=n,this.device.gl.bindVertexArray(null)}setConstantWebGL(t,r){this._enable(t,!1),this.attributes[t]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let t=0;t<this.maxVertexAttributes;++t){let r=this.attributes[t];ArrayBuffer.isView(r)&&this.device.setConstantAttributeWebGL(t,r)}}_getAccessor(t){let r=this.attributeInfosByLocation[t];if(!r)throw new Error(`Unknown attribute location ${t}`);let n=Ke(r.bufferDataType);return{size:r.bufferComponents,type:n,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(t,r=!0){let i=e.isConstantAttributeZeroSupported(this.device)||t!==0;(r||i)&&(t=Number(t),this.device.gl.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(t):this.device.gl.disableVertexAttribArray(t),this.device.gl.bindVertexArray(null))}getConstantBuffer(t,r){let n=Fc(r),i=n.byteLength*t,s=n.length*t;if(this.buffer&&i!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${i} !== ${this.buffer.byteLength}.`);let o=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:i}),o||=!Oc(n,this.bufferValue),o){let a=(0,Zt.getScratchArray)(r.constructor,s);eo({target:a,source:n,start:0,count:s}),this.buffer.write(a),this.bufferValue=r}return this.buffer}}});function io(e){return typeof e=="number"?Number.isInteger(e):/^\d+$/.test(e)}var kr,Rr,so=P(()=>{kr=D(I(),1);Bn();Ln();Rr=class extends kr.TransformFeedback{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(t,r){super(t,r),this.device=t,this.gl=t.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(t="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(Zs(t))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(t){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[r,n]of Object.entries(t))this.setBuffer(r,n)})}setBuffer(t,r){let n=this._getVaryingIndex(t),{buffer:i,byteLength:s,byteOffset:o}=this._getBufferRange(r);if(n<0){this.unusedBuffers[t]=i,kr.log.warn(`${this.id} unusedBuffers varying buffer ${t}`)();return}this.buffers[n]={buffer:i,byteLength:s,byteOffset:o},this.bindOnUse||this._bindBuffer(n,i,o,s)}getBuffer(t){if(io(t))return this.buffers[t]||null;let r=this._getVaryingIndex(t);return this.buffers[r]??null}bind(t=this.handle){if(typeof t!="function")return this.gl.bindTransformFeedback(36386,t),this;let r;return this._bound?r=t():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=t(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(t){if(t instanceof it)return{buffer:t,byteOffset:0,byteLength:t.byteLength};let{buffer:r,byteOffset:n=0,byteLength:i=t.buffer.byteLength}=t;return{buffer:r,byteOffset:n,byteLength:i}}_getVaryingIndex(t){if(io(t))return Number(t);for(let r of this.layout.varyings||[])if(t===r.name)return r.location;return-1}_bindBuffers(){for(let[t,r]of Object.entries(this.buffers)){let{buffer:n,byteLength:i,byteOffset:s}=this._getBufferRange(r);this._bindBuffer(Number(t),n,s,i)}}_unbindBuffers(){for(let t in this.buffers)this.gl.bindBufferBase(35982,Number(t),null)}_bindBuffer(t,r,n=0,i){let s=r&&r.handle;!s||i===void 0?this.gl.bindBufferBase(35982,t,s):this.gl.bindBufferRange(35982,t,s,n,i)}}});var oo,Dr,ao=P(()=>{oo=D(I(),1),Dr=class extends oo.QuerySet{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(t,r){if(super(t,r),this.device=t,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 n=this.device.gl.createQuery();if(!n)throw new Error("WebGL query not supported");this.handle=n}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let t of this._timestampPairs){t.activeQuery&&(this._cancelPendingQuery(t.activeQuery),this.device.gl.deleteQuery(t.activeQuery.handle));for(let r of t.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 t of Array.from(this._pendingReads))this._cancelPendingQuery(t);this.destroyResource()}}isResultAvailable(t){return this.props.type==="timestamp"?t===void 0?this._timestampPairs.some((r,n)=>this._isTimestampPairAvailable(n)):this._isTimestampPairAvailable(this._getTimestampPairIndex(t)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(t){let r=t?.firstQuery||0,n=t?.queryCount||this.props.count-r;if(this._validateRange(r,n),this.props.type==="timestamp"){let i=new Array(n).fill(0n),s=Math.floor(r/2),o=Math.floor((r+n-1)/2);for(let a=s;a<=o;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,h=l+1;l>=r&&l<r+n&&(i[l-r]=0n),h>=r&&h<r+n&&(i[h-r]=c)}return i}if(!this._occlusionQuery)throw new Error("Occlusion query has not been started");return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(t,r){if(this.props.type!=="timestamp")throw new Error("Timestamp durations require a timestamp QuerySet");if(t<0||r>=this.props.count||r<=t)throw new Error("Timestamp duration range is out of bounds");if(t%2!==0||r!==t+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let n=await this._consumeTimestampPairResult(this._getTimestampPairIndex(t));return Number(n)/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(t){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let r=this._getTimestampPairIndex(t),n=this._timestampPairs[r];if(t%2===0){if(n.activeQuery)throw new Error("Timestamp query pair is already active");let i=this.device.gl.createQuery();if(!i)throw new Error("WebGL query not supported");let s={handle:i,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,i),n.activeQuery=s;return}if(!n.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),n.completedQueries.push(n.activeQuery),n.activeQuery=null}_validateRange(t,r){if(t<0||r<0||t+r>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(t){if(t<0||t>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(t/2)}_isTimestampPairAvailable(t){let r=this._timestampPairs[t];return!r||r.completedQueries.length===0?!1:this._pollQueryAvailability(r.completedQueries[0])}_pollQueryAvailability(t){if(t.cancelled||this.destroyed)return t.result=0n,!0;if(t.result!==null||t.disjoint)return!0;if(!this.device.gl.getQueryParameter(t.handle,34919))return!1;let n=!!this.device.gl.getParameter(36795);return t.disjoint=n,t.result=n?0n:BigInt(this.device.gl.getQueryParameter(t.handle,34918)),!0}async _consumeTimestampPairResult(t){let r=this._timestampPairs[t];if(!r||r.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let n=r.completedQueries.shift();try{return await this._consumeQueryResult(n)}finally{this.device.gl.deleteQuery(n.handle)}}_consumeQueryResult(t){return t.promise||(this._pendingReads.add(t),t.promise=new Promise((r,n)=>{t.resolve=r,t.reject=n;let i=()=>{if(t.pollRequestId=null,t.cancelled||this.destroyed){this._pendingReads.delete(t),t.promise=null,t.resolve=null,t.reject=null,r(0n);return}if(!this._pollQueryAvailability(t)){t.pollRequestId=this._requestAnimationFrame(i);return}this._pendingReads.delete(t),t.promise=null,t.resolve=null,t.reject=null,t.disjoint?n(new Error("GPU timestamp query was invalidated by a disjoint event")):r(t.result||0n)};i()})),t.promise}_cancelPendingQuery(t){if(this._pendingReads.delete(t),t.cancelled=!0,t.pollRequestId!==null&&(this._cancelAnimationFrame(t.pollRequestId),t.pollRequestId=null),t.resolve){let r=t.resolve;t.promise=null,t.resolve=null,t.reject=null,r(0n)}}_requestAnimationFrame(t){return requestAnimationFrame(t)}_cancelAnimationFrame(t){cancelAnimationFrame(t)}}});var co,Ir,lo=P(()=>{co=D(I(),1),Ir=class extends co.Fence{device;gl;handle;signaled;_signaled=!1;constructor(t,r={}){super(t,{}),this.device=t,this.gl=t.gl;let n=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!n)throw new Error("Failed to create WebGL fence");this.handle=n,this.signaled=new Promise(i=>{let s=()=>{let o=this.gl.clientWaitSync(this.handle,0,0);o===this.gl.ALREADY_SIGNALED||o===this.gl.CONDITION_SATISFIED?(this._signaled=!0,i()):setTimeout(s,1)};s()})}isSignaled(){if(this._signaled)return!0;let t=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=t===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function Fn(e){switch(e){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function ho(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var uo=P(()=>{});function fo(e,t){let{sourceX:r=0,sourceY:n=0,sourceAttachment:i=0}=t||{},{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:h}=t||{},{framebuffer:u,deleteFramebuffer:f}=po(e),{gl:d,handle:p}=u;o||=u.width,a||=u.height;let g=u.colorAttachments[i]?.texture;if(!g)throw new Error(`Invalid framebuffer attachment ${i}`);c=g?.depth||1,l||=g?.glFormat||6408,h||=g?.glType||5121,s=Vc(s,h,l,o,a,c);let m=Se.dataTypeDecoder.getDataType(s);h=h||Vs(m);let b=d.bindFramebuffer(36160,p);return d.readBuffer(36064+i),d.readPixels(r,n,o,a,l,h,s),d.readBuffer(36064),d.bindFramebuffer(36160,b||null),f&&u.destroy(),s}function mo(e,t){let{target:r,sourceX:n=0,sourceY:i=0,sourceFormat:s=6408,targetByteOffset:o=0}=t||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=t||{},{framebuffer:h,deleteFramebuffer:u}=po(e);a=a||h.width,c=c||h.height;let f=h;l=l||5121;let d=r;if(!d){let g=Fn(s),m=ho(l),b=o+a*c*g*m;d=f.device.createBuffer({byteLength:b})}let p=e.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:e,width:a,height:c,origin:[n,i],destinationBuffer:d,byteOffset:o}),p.destroy(),u&&h.destroy(),d}function po(e){return e instanceof Se.Framebuffer?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:Nc(e),deleteFramebuffer:!0}}function Nc(e,t){let{device:r,width:n,height:i,id:s}=e;return r.createFramebuffer({...t,id:`framebuffer-for-${s}`,width:n,height:i,colorAttachments:[e]})}function Vc(e,t,r,n,i,s){if(e)return e;t||=5121;let o=xr(t),a=Se.dataTypeDecoder.getTypedArrayConstructor(o),c=Fn(r);return new a(n*i*c)}var Se,go=P(()=>{Se=D(I(),1);_r();uo();Cn()});function Gc(e,t,r){switch(r.length){case 1:e.gl.vertexAttrib1fv(t,r);break;case 2:e.gl.vertexAttrib2fv(t,r);break;case 3:e.gl.vertexAttrib3fv(t,r);break;case 4:e.gl.vertexAttrib4fv(t,r);break;default:}}function zc(e,t,r){e.gl.vertexAttribI4iv(t,r)}function Wc(e,t,r){e.gl.vertexAttribI4uiv(t,r)}function Uc(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}var ot,Me,bo=P(()=>{ot=D(I(),1);fn();ss();dn();cs();gs();xs();Es();_s();qi();qt();Ss();lr();Cs();Ds();yr();or();Ns();$s();Ks();no();so();ao();lo();go();Yt();gr();xe();Me=class e extends ot.Device{static getDeviceFromContext(t){return t?t.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(t){return t!=="unorm8x4-bgra"}constructor(t){super({...t,id:t.id||vs("webgl-device")});let r=ot.Device._getCanvasContextProps(t);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let n=r.canvas?.gl??null,i=e.getDeviceFromContext(n);if(i)throw new Error(`WebGL context already attached to device ${i.id}`);this.canvasContext=new ar(this,r),this.lost=new Promise(h=>{this._resolveContextLost=h});let s={...t.webgl};r.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),t.powerPreference!==void 0&&(s.powerPreference=t.powerPreference),t.failIfMajorPerformanceCaveat!==void 0&&(s.failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat);let a=this.props._handle||is(this.canvasContext.canvas,{onContextLost:h=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:h=>{console.log("WebGL context restored")}},s);if(!a)throw new Error("WebGL context creation failed");if(i=e.getDeviceFromContext(a),i){if(t._reuseDevices)return ot.log.log(1,`Not creating a new Device, instead returning a reference to Device ${i.id} already attached to WebGL context`,i)(),this.canvasContext.destroy(),i._reused=!0,i;throw new Error(`WebGL context already attached to device ${i.id}`)}this.handle=a,this.gl=a,this.spectorJS=ji({...this.props,gl:this.handle});let c=be(this.handle);c.device=this,c.extensions||(c.extensions={}),this.extensions=c.extensions,this.info=os(this.gl,this.extensions),this.limits=new sr(this.gl),this.features=new nr(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new rt(this.gl,{log:(...h)=>ot.log.log(1,...h)()}).trackState(this.gl,{copyState:!1}),(t.debug||t.debugWebGL)&&(this.gl=$i(this.gl,{debugWebGL:!0,traceWebGL:t.debugWebGL}),ot.log.warn("WebGL debug mode activated. Performance reduced.")()),t.debugWebGL&&(ot.log.level=Math.max(ot.log.level,1)),this.commandEncoder=new _e(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(!this.props._reuseDevices&&!this._reused){this._isLost=!0,this.commandEncoder?.destroy();let t=be(this.handle);t.device=null}}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(t){throw new Error("WebGL only supports a single canvas")}createPresentationContext(t){return new cr(this,t||{})}createBuffer(t){let r=this._normalizeBufferProps(t);return new it(this,r)}createTexture(t){return new bt(this,t)}createExternalTexture(t){throw new Error("ExternalTexture is not available on WebGL")}createSampler(t){return new pr(this,t)}createShader(t){return new ur(this,t)}createFramebuffer(t){return new pt(this,t)}createVertexArray(t){return new Ar(this,t)}createTransformFeedback(t){return new Rr(this,t)}createQuerySet(t){return new Dr(this,t)}createFence(){return new Ir(this)}createRenderPipeline(t){return new wr(this,t)}_createSharedRenderPipelineWebGL(t){return new vr(this,t)}createComputePipeline(t){throw new Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(t){throw new Error("Render bundles are only supported in WebGPU")}createCommandEncoder(t={}){return new _e(this,t)}submit(t){let r=null;t||({submittedCommandEncoder:r,commandBuffer:t}=this._finalizeDefaultCommandEncoderForSubmit());try{t._executeCommands(),r&&r.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=r._gpuTimeMs}).catch(()=>{})}finally{t.destroy()}}writeBufferViaCommandEncoder(t,r,n,i=0){r.write(n,i)}_finalizeDefaultCommandEncoderForSubmit(){let t=this.commandEncoder,r=t.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:t.props.id,timeProfilingQuerySet:t.getTimeProfilingQuerySet()}),{submittedCommandEncoder:t,commandBuffer:r}}readPixelsToArrayWebGL(t,r){return fo(t,r)}readPixelsToBufferWebGL(t,r){return mo(t,r)}setParametersWebGL(t){et(this.gl,t)}getParametersWebGL(t){return Qe(this.gl,t)}withParametersWebGL(t,r){return st(this.gl,t,r)}resetWebGL(){ot.log.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),Ji(this.gl)}_getDeviceSpecificTextureFormatCapabilities(t){return ds(this.gl,t,this.extensions)}loseDevice(){let t=!1,n=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return n&&(t=!0,n.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),t}pushState(){rt.get(this.gl).push()}popState(){rt.get(this.gl).pop()}getGLKey(t,r){let n=Number(t);for(let i in this.gl)if(this.gl[i]===n)return`GL.${i}`;return r?.emptyIfUnknown?"":String(t)}getGLKeys(t){let r={emptyIfUnknown:!0};return Object.entries(t).reduce((n,[i,s])=>(n[`${i}:${this.getGLKey(i,r)}`]=`${s}:${this.getGLKey(s,r)}`,n),{})}setConstantAttributeWebGL(t,r){let n=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(n).fill(null);let i=this._constants[t];switch(i&&Uc(i,r)&&ot.log.info(1,`setConstantAttributeWebGL(${t}) could have been skipped, value unchanged`)(),this._constants[t]=r,r.constructor){case Float32Array:Gc(this,t,r);break;case Int32Array:zc(this,t,r);break;case Uint32Array:Wc(this,t,r);break;default:throw new Error("constant")}}getExtension(t){return nt(this.gl,t,this.extensions),this.extensions}_setWebGLDebugMetadata(t,r,n){t.luma=r;let i={props:n.spector,id:n.spector.id};t.__SPECTOR_Metadata=i}}});var Bn=P(()=>{bo();lr()});var Da=Ze((sn,ka)=>{(function(e,t){typeof sn=="object"&&typeof ka<"u"?t(sn):typeof define=="function"&&define.amd?define(["exports"],t):t(e.esriLoader=e.esriLoader||{})})(sn,(function(e){"use strict";var t=typeof window<"u",r={Promise:t?window.Promise:void 0},n="4.25",i="next";function s(x){if(x.toLowerCase()===i)return i;var T=x&&x.match(/^(\d)\.(\d+)/);return T&&{major:parseInt(T[1],10),minor:parseInt(T[2],10)}}function o(x){return x===void 0&&(x=n),"https://js.arcgis.com/".concat(x,"/")}function a(x){x===void 0&&(x=n);var T=o(x),M=s(x);if(M!==i&&M.major===3){var S=M.minor<=10?"js/":"";return"".concat(T).concat(S,"esri/css/esri.css")}else return"".concat(T,"esri/themes/light/main.css")}function c(x){var T=document.createElement("link");return T.rel="stylesheet",T.href=x,T}function l(x,T){if(T){var M=document.querySelector(T);M.parentNode.insertBefore(x,M)}else document.head.appendChild(x)}function h(x){return document.querySelector('link[href*="'.concat(x,'"]'))}function u(x){return!x||s(x)?a(x):x}function f(x,T){var M=u(x),S=h(M);return S||(S=c(M),l(S,T)),S}var d={};function p(x){var T=document.createElement("script");return T.type="text/javascript",T.src=x,T.setAttribute("data-esri-loader","loading"),T}function g(x,T,M){var S;M&&(S=m(x,M));var C=function(){T(x),x.removeEventListener("load",C,!1),S&&x.removeEventListener("error",S,!1)};x.addEventListener("load",C,!1)}function m(x,T){var M=function(S){T(S.error||new Error("There was an error attempting to load ".concat(x.src))),x.removeEventListener("error",M,!1)};return x.addEventListener("error",M,!1),M}function b(x){x===void 0&&(x={}),d=x}function _(){return document.querySelector("script[data-esri-loader]")}function y(){var x=window.require;return x&&x.on}function E(x){x===void 0&&(x={});var T={};[d,x].forEach(function(C){for(var L in C)Object.prototype.hasOwnProperty.call(C,L)&&(T[L]=C[L])});var M=T.version,S=T.url||o(M);return new r.Promise(function(C,L){var R=_();if(R){var A=R.getAttribute("src");A!==S?L(new Error("The ArcGIS API for JavaScript is already loaded (".concat(A,")."))):y()?C(R):g(R,C,L)}else if(y())L(new Error("The ArcGIS API for JavaScript is already loaded."));else{var B=T.css;if(B){var ft=B===!0;f(ft?M:B,T.insertCssBefore)}R=p(S),g(R,function(){R.setAttribute("data-esri-loader","loaded"),C(R)},L),document.body.appendChild(R)}})}function v(x){return new r.Promise(function(T,M){var S=window.require.on("error",M);window.require(x,function(){for(var C=[],L=0;L<arguments.length;L++)C[L]=arguments[L];S.remove(),T(C)})})}function w(x,T){if(T===void 0&&(T={}),y())return v(x);var M=_(),S=M&&M.getAttribute("src");return!T.url&&S&&(T.url=S),E(T).then(function(){return v(x)})}e.utils=r,e.loadModules=w,e.getScript=_,e.isLoaded=y,e.loadScript=E,e.setDefaultOptions=b,e.loadCss=f,Object.defineProperty(e,"__esModule",{value:!0})}))});var $e={};me($e,{loadArcGISModules:()=>Sf});var dt={},Oi=D(He(),1);Ct(dt,D(He(),1));if(!Oi.Layer)throw new Error("@deck.gl/core is not found");Ct($e,dt);var Ni={layers:{},layerFilter:{},parameters:{},effects:{},pickingRadius:{},onBeforeRender:{},onAfterRender:{},onClick:{},onHover:{},onDragStart:{},onDrag:{},onDragEnd:{},onError:{},debug:{},drawPickingColors:{},getCursor:{},getTooltip:{}};function on(e){return e.createSubclass({properties:Ni,constructor(){this._callbacks={},this.watch(Object.keys(Ni),(r,n,i)=>{this.emit("change",{[i]:r})})},on(r,n){this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push(n)},emit(r,n){let i=this._callbacks[r];if(i)for(let s of i)s(n)},toJSON(){let r={};for(let n of this.keys())this[n]!==void 0&&(r[n]=this[n]);return r}})}function an(e,t,r){return t.createSubclass({properties:{deck:{},blendMode:{},effect:{}},constructor(){this.deck=new e},createLayerView(n){return n.type==="2d"?new r({view:n,layer:this}):(console.error("DeckLayer does not support SceneView at the moment. Use DeckRenderer instead."),null)}})}var xo=D(He(),1),Br=D(Gi(),1);Bn();async function Yc(e){return new Promise(t=>{let r=new xo.Deck({controller:!1,gl:e,parameters:{depthCompare:"less-equal"},width:null,height:null,onDeviceInitialized:n=>{t({deckInstance:r,device:n})}})})}async function Fr(e){let{deckInstance:t,device:r}=await Yc(e),n=r.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),i=new Br.Model(r,{vs:`#version 300 es
|
|
7
|
+
"use strict";var __exports__=(()=>{var ka=Object.create;var Ye=Object.defineProperty;var Ia=Object.getOwnPropertyDescriptor;var Ba=Object.getOwnPropertyNames;var Da=Object.getPrototypeOf,Fa=Object.prototype.hasOwnProperty;var P=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var je=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},ce=(e,t)=>{for(var r in t)Ye(e,r,{get:t[r],enumerable:!0})},$e=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ba(t))!Fa.call(e,i)&&i!==r&&Ye(e,i,{get:()=>t[i],enumerable:!(n=Ia(t,i))||n.enumerable});return e},St=(e,t,r)=>($e(e,t,"default"),r&&$e(r,t,"default")),I=(e,t,r)=>(r=e!=null?ka(Da(e)):{},$e(t||!e||!e.__esModule?Ye(r,"default",{value:e,enumerable:!0}):r,e)),Oa=e=>$e(Ye({},"__esModule",{value:!0}),e);var qe=je((Rf,ki)=>{ki.exports=globalThis.deck});var Fi=je((Df,Di)=>{Di.exports=globalThis.luma});var B=je((Ff,Oi)=>{Oi.exports=globalThis.luma});function zi(e,t){return Ni?Ni.makeDebugContext(e,t):(Va(),e)}function Wi(e){return Na?.initialize(e)||null}function Va(){Vi||(Vi=!0,Gi.log.warn("Import @luma.gl/webgl/debug before enabling WebGL debugging.")())}var Gi,Ni,Na,Vi,Ui=P(()=>{Gi=I(B(),1),Ni=null,Na=null,Vi=!1});function sn(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function F(e,t,r){return t[e]!==void 0?t[e]:r[e]}var he,V,$i,q,Yi,le,ji,qi,on,ft,an,Xi,cn=P(()=>{he={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},V=(e,t,r)=>t?e.enable(r):e.disable(r),$i=(e,t,r)=>e.hint(r,t),q=(e,t,r)=>e.pixelStorei(r,t),Yi=(e,t,r)=>{let n=r===36006?36009:36008;return e.bindFramebuffer(n,t)},le=(e,t,r)=>{let i={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[r];e.bindBuffer(i,t)};ji={3042:V,32773:(e,t)=>e.blendColor(...t),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(e,t)=>e.clearColor(...t),3107:(e,t)=>e.colorMask(...t),2884:V,2885:(e,t)=>e.cullFace(t),2929:V,2931:(e,t)=>e.clearDepth(t),2932:(e,t)=>e.depthFunc(t),2928:(e,t)=>e.depthRange(...t),2930:(e,t)=>e.depthMask(t),3024:V,35723:$i,35725:(e,t)=>e.useProgram(t),36007:(e,t)=>e.bindRenderbuffer(36161,t),36389:(e,t)=>e.bindTransformFeedback?.(36386,t),34229:(e,t)=>e.bindVertexArray(t),36006:Yi,36010:Yi,34964:le,36662:le,36663:le,35053:le,35055:le,2886:(e,t)=>e.frontFace(t),33170:$i,2849:(e,t)=>e.lineWidth(t),32823:V,32824:"polygonOffset",10752:"polygonOffset",35977:V,32926:V,32928:V,32938:"sampleCoverage",32939:"sampleCoverage",3089:V,3088:(e,t)=>e.scissor(...t),2960:V,2961:(e,t)=>e.clearStencil(t),2968:(e,t)=>e.stencilMaskSeparate(1028,t),36005:(e,t)=>e.stencilMaskSeparate(1029,t),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(e,t)=>e.viewport(...t),34383:V,10754:V,12288:V,12289:V,12290:V,12291:V,12292:V,12293:V,12294:V,12295:V,3333:q,3317:q,37440:q,37441:q,37443:q,3330:q,3332:q,3331:q,3314:q,32878:q,3316:q,3315:q,32877:q,framebuffer:(e,t)=>{let r=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,r)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{let r=typeof t=="number"?[t,t]:t;e.blendEquationSeparate(...r)},blendFunc:(e,t)=>{let r=t?.length===2?[...t,...t]:t;e.blendFuncSeparate(...r)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(t[0],t[1]||!1),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=sn(t)?t:[t,t];let[r,n]=t;e.stencilMaskSeparate(1028,r),e.stencilMaskSeparate(1029,n)},stencilFunc:(e,t)=>{t=sn(t)&&t.length===3?[...t,...t]:t;let[r,n,i,s,o,a]=t;e.stencilFuncSeparate(1028,r,n,i),e.stencilFuncSeparate(1029,s,o,a)},stencilOp:(e,t)=>{t=sn(t)&&t.length===3?[...t,...t]:t;let[r,n,i,s,o,a]=t;e.stencilOpSeparate(1028,r,n,i),e.stencilOpSeparate(1029,s,o,a)},viewport:(e,t)=>e.viewport(...t)};qi={blendEquation:(e,t,r)=>e.blendEquationSeparate(F(32777,t,r),F(34877,t,r)),blendFunc:(e,t,r)=>e.blendFuncSeparate(F(32969,t,r),F(32968,t,r),F(32971,t,r),F(32970,t,r)),polygonOffset:(e,t,r)=>e.polygonOffset(F(32824,t,r),F(10752,t,r)),sampleCoverage:(e,t,r)=>e.sampleCoverage(F(32938,t,r),F(32939,t,r)),stencilFuncFront:(e,t,r)=>e.stencilFuncSeparate(1028,F(2962,t,r),F(2967,t,r),F(2963,t,r)),stencilFuncBack:(e,t,r)=>e.stencilFuncSeparate(1029,F(34816,t,r),F(36003,t,r),F(36004,t,r)),stencilOpFront:(e,t,r)=>e.stencilOpSeparate(1028,F(2964,t,r),F(2965,t,r),F(2966,t,r)),stencilOpBack:(e,t,r)=>e.stencilOpSeparate(1029,F(34817,t,r),F(34818,t,r),F(34819,t,r))},on={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,r)=>e({[t]:r}),hint:(e,t,r)=>e({[t]:r}),useProgram:(e,t)=>e({35725:t}),bindRenderbuffer:(e,t,r)=>e({36007:r}),bindTransformFeedback:(e,t,r)=>e({36389:r}),bindVertexArray:(e,t)=>e({34229:t}),bindFramebuffer:(e,t,r)=>{switch(t){case 36160:return e({36006:r,36010:r});case 36009:return e({36006:r});case 36008:return e({36010:r});default:return null}},bindBuffer:(e,t,r)=>{let n={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[t];return n?e({[n]:r}):{valueChanged:!0}},blendColor:(e,t,r,n,i)=>e({32773:new Float32Array([t,r,n,i])}),blendEquation:(e,t)=>e({32777:t,34877:t}),blendEquationSeparate:(e,t,r)=>e({32777:t,34877:r}),blendFunc:(e,t,r)=>e({32969:t,32968:r,32971:t,32970:r}),blendFuncSeparate:(e,t,r,n,i)=>e({32969:t,32968:r,32971:n,32970:i}),clearColor:(e,t,r,n,i)=>e({3106:new Float32Array([t,r,n,i])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,r,n,i)=>e({3107:[t,r,n,i]}),cullFace:(e,t)=>e({2885:t}),depthFunc:(e,t)=>e({2932:t}),depthRange:(e,t,r)=>e({2928:new Float32Array([t,r])}),depthMask:(e,t)=>e({2930:t}),frontFace:(e,t)=>e({2886:t}),lineWidth:(e,t)=>e({2849:t}),polygonOffset:(e,t,r)=>e({32824:t,10752:r}),sampleCoverage:(e,t,r)=>e({32938:t,32939:r}),scissor:(e,t,r,n,i)=>e({3088:new Int32Array([t,r,n,i])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,r)=>e({[t===1028?2968:36005]:r}),stencilFunc:(e,t,r,n)=>e({2962:t,2967:r,2963:n,34816:t,36003:r,36004:n}),stencilFuncSeparate:(e,t,r,n,i)=>e({[t===1028?2962:34816]:r,[t===1028?2967:36003]:n,[t===1028?2963:36004]:i}),stencilOp:(e,t,r,n)=>e({2964:t,2965:r,2966:n,34817:t,34818:r,34819:n}),stencilOpSeparate:(e,t,r,n,i)=>e({[t===1028?2964:34817]:r,[t===1028?2965:34818]:n,[t===1028?2966:34819]:i}),viewport:(e,t,r,n,i)=>e({2978:[t,r,n,i]})},ft=(e,t)=>e.isEnabled(t),an={3042:ft,2884:ft,2929:ft,3024:ft,32823:ft,32926:ft,32928:ft,3089:ft,2960:ft,35977:ft},Xi=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 et(e,t){if(Ga(t))return;let r={};for(let i in t){let s=Number(i),o=ji[i];o&&(typeof o=="string"?r[o]=!0:o(e,t[i],s))}let n=e.lumaState?.cache;if(n)for(let i in r){let s=qi[i];s(e,t,n)}}function Xe(e,t=he){if(typeof t=="number"){let i=t,s=an[i];return s?s(e,i):e.getParameter(i)}let r=Array.isArray(t)?t:Object.keys(t),n={};for(let i of r){let s=an[i];n[i]=s?s(e,Number(i)):e.getParameter(Number(i))}return n}function Zi(e){et(e,he)}function Ga(e){for(let t in e)return!1;return!0}var zt=P(()=>{cn()});function Ki(e,t){if(e===t)return!0;if(Hi(e)&&Hi(t)&&e.length===t.length){for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}return!1}function Hi(e){return Array.isArray(e)||ArrayBuffer.isView(e)}var Qi=P(()=>{});function Ji(e,t){let r=e[t].bind(e);e[t]=function(i){if(i===void 0||Xi.has(i))return r(i);let s=rt.get(e);return i in s.cache||(s.cache[i]=r(i)),s.enable?s.cache[i]:r(i)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function za(e,t,r){if(!e[t])return;let n=e[t].bind(e);e[t]=function(...s){let o=rt.get(e),{valueChanged:a,oldValue:c}=r(o._updateCache,...s);return a&&n(...s),c},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}function Wa(e){let t=e.useProgram.bind(e);e.useProgram=function(n){let i=rt.get(e);i.program!==n&&(t(n),i.program=n)}}var rt,ln=P(()=>{zt();Qi();cn();rt=class{static get(t){return t.lumaState}gl;program=null;stateStack=[];enable=!0;cache=null;log;initialized=!1;constructor(t,r){this.gl=t,this.log=r?.log||(()=>{}),this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(t={}){this.stateStack.push({})}pop(){let t=this.stateStack[this.stateStack.length-1];et(this.gl,t),this.stateStack.pop()}trackState(t,r){if(this.cache=r?.copyState?Xe(t):Object.assign({},he),this.initialized)throw new Error("WebGLStateTracker");this.initialized=!0,this.gl.lumaState=this,Wa(t);for(let n in on){let i=on[n];za(t,n,i)}Ji(t,"getParameter"),Ji(t,"isEnabled")}_updateCache(t){let r=!1,n,i=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(let s in t){let o=t[s],a=this.cache[s];Ki(o,a)||(r=!0,n=a,i&&!(s in i)&&(i[s]=a),this.cache[s]=o)}return{valueChanged:r,oldValue:n}}}});function ue(e){let t=e.luma||{_polyfilled:!1,extensions:{},softwareRenderer:!1};return t._polyfilled??=!1,t.extensions||={},e.luma=t,t}var hn=P(()=>{});function ts(e,t,r){let n="",i=c=>{let l=c.statusMessage;l&&(n||=l)};e.addEventListener("webglcontextcreationerror",i,!1);let s=r.failIfMajorPerformanceCaveat!==!0,o={preserveDrawingBuffer:!0,...r,failIfMajorPerformanceCaveat:!0},a=null;try{a||=e.getContext("webgl2",o),!a&&o.failIfMajorPerformanceCaveat&&(n||="Only software GPU is available. Set `failIfMajorPerformanceCaveat: false` to allow.");let c=!1;if(!a&&s&&(o.failIfMajorPerformanceCaveat=!1,a=e.getContext("webgl2",o),c=!0),a||(a=e.getContext("webgl",{}),a&&(a=null,n||="Your browser only supports WebGL1")),!a)throw n||="Your browser does not support WebGL",new Error(`Failed to create WebGL context: ${n}`);let l=ue(a);l.softwareRenderer=c;let{onContextLost:h,onContextRestored:u}=t;return e.addEventListener("webglcontextlost",f=>h(f),!1),e.addEventListener("webglcontextrestored",f=>u(f),!1),a}finally{e.removeEventListener("webglcontextcreationerror",i,!1)}}var es=P(()=>{hn()});function nt(e,t,r){return r[t]===void 0&&(r[t]=e.getExtension(t)||null),r[t]}var fe=P(()=>{});function rs(e,t){let r=e.getParameter(7936),n=e.getParameter(7937);nt(e,"WEBGL_debug_renderer_info",t);let i=t.WEBGL_debug_renderer_info,s=e.getParameter(i?i.UNMASKED_VENDOR_WEBGL:7936),o=e.getParameter(i?i.UNMASKED_RENDERER_WEBGL:7937),a=s||r,c=o||n,l=e.getParameter(7938),h=ns(a,c),u=Ua(a,c),f=$a(a,c);return{type:"webgl",gpu:h,gpuType:f,gpuBackend:u,vendor:a,renderer:c,version:l,shadingLanguage:"glsl",shadingLanguageVersion:300}}function ns(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function Ua(e,t){return/Metal/i.exec(e)||/Metal/i.exec(t)?"metal":/ANGLE/i.exec(e)||/ANGLE/i.exec(t)?"opengl":"unknown"}function $a(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(ns(e,t)){case"apple":return Ya(e,t)?"integrated":"unknown";case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function Ya(e,t){return/Apple (M\d|A\d|GPU)/i.test(`${e} ${t}`)}var is=P(()=>{fe()});function Ze(e){switch(e){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(e))}var un=P(()=>{});function as(e){return e in Ke}function bn(e,t,r){return cs(e,t,r,new Set)}function cs(e,t,r,n){let i=Ke[t];if(!i||n.has(t))return!1;n.add(t);let s=(i.features||[]).every(o=>cs(e,o,r,n));return n.delete(t),s?(i.extensions||[]).every(o=>!!nt(e,o,r)):!1}function ls(e,t,r){let n=t.create,i=Qe[t.format];i?.gl===void 0&&(n=!1),i?.x&&(n=n&&!!nt(e,i.x,r)),t.format==="stencil8"&&(n=!1);let s=i?.r===!1?!1:i?.r===void 0||bn(e,i.r,r),o=n&&t.render&&s&&Ja(e,t.format,r);return{format:t.format,create:n&&t.create,render:o,filter:n&&t.filter,blend:n&&t.blend,store:n&&t.store}}function Ja(e,t,r){let n=Qe[t],i=n?.gl;if(i===void 0||n?.x&&!nt(e,n.x,r))return!1;let s=e.getParameter(32873),o=e.getParameter(36006),a=e.createTexture(),c=e.createFramebuffer();if(!a||!c)return!1;let l=0,h=Number(e.getError());for(;h!==l;)h=e.getError();let u=!1;try{if(e.bindTexture(3553,a),e.texStorage2D(3553,1,i,1,1),Number(e.getError())!==l)return!1;e.bindFramebuffer(36160,c),e.framebufferTexture2D(36160,36064,3553,a,0),u=Number(e.checkFramebufferStatus(36160))===36053&&Number(e.getError())===l}finally{e.bindFramebuffer(36160,o),e.deleteFramebuffer(c),e.bindTexture(3553,s),e.deleteTexture(a)}return u}function Je(e){let t=Qe[e],r=ec(e),n=gn.textureFormatDecoder.getInfo(e);return n.compressed&&(t.dataFormat=r),{internalFormat:r,format:t?.dataFormat||tc(n.channels,n.integer,n.normalized,r),type:n.dataType?Ze(n.dataType):t?.types?.[0]||5121,compressed:n.compressed||!1}}function hs(e){switch(gn.textureFormatDecoder.getInfo(e).attachment){case"depth":return 36096;case"stencil":return 36128;case"depth-stencil":return 33306;default:throw new Error(`Not a depth stencil format: ${e}`)}}function tc(e,t,r,n){if(n===6408||n===6407)return n;switch(e){case"r":return t&&!r?36244:6403;case"rg":return t&&!r?33320:33319;case"rgb":return t&&!r?36248:6407;case"rgba":return t&&!r?36249:6408;case"bgra":throw new Error("bgra pixels not supported by WebGL");default:return 6408}}function ec(e){let r=Qe[e]?.gl;if(r===void 0)throw new Error(`Unsupported texture format ${e}`);return r}var gn,de,me,Wt,Ut,ja,qa,Xa,Za,Ha,Ka,ss,os,fn,dn,mn,pn,He,Qa,Ke,Qe,$t=P(()=>{gn=I(B(),1);fe();un();de="WEBGL_compressed_texture_s3tc",me="WEBGL_compressed_texture_s3tc_srgb",Wt="EXT_texture_compression_rgtc",Ut="EXT_texture_compression_bptc",ja="WEBGL_compressed_texture_etc",qa="WEBGL_compressed_texture_astc",Xa="WEBGL_compressed_texture_etc1",Za="WEBGL_compressed_texture_pvrtc",Ha="WEBGL_compressed_texture_atc",Ka="EXT_texture_norm16",ss="EXT_render_snorm",os="EXT_color_buffer_float",fn="snorm8-renderable-webgl",dn="norm16-renderable-webgl",mn="snorm16-renderable-webgl",pn="float16-renderable-webgl",He="float32-renderable-webgl",Qa="rgb9e5ufloat-renderable-webgl",Ke={"float32-renderable-webgl":{extensions:[os]},"float16-renderable-webgl":{extensions:["EXT_color_buffer_half_float"]},"rgb9e5ufloat-renderable-webgl":{extensions:["WEBGL_render_shared_exponent"]},"snorm8-renderable-webgl":{extensions:[ss]},"norm16-webgl":{extensions:[Ka]},"norm16-renderable-webgl":{features:["norm16-webgl"]},"snorm16-renderable-webgl":{features:["norm16-webgl"],extensions:[ss]},"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:[de,me,Wt,Ut]},"texture-compression-bc5-webgl":{extensions:[Wt]},"texture-compression-bc7-webgl":{extensions:[Ut]},"texture-compression-etc2":{extensions:[ja]},"texture-compression-astc":{extensions:[qa]},"texture-compression-etc1-webgl":{extensions:[Xa]},"texture-compression-pvrtc-webgl":{extensions:[Za]},"texture-compression-atc-webgl":{extensions:[Ha]}};Qe={r8unorm:{gl:33321,rb:!0},r8snorm:{gl:36756,r:fn},r8uint:{gl:33330,rb:!0},r8sint:{gl:33329,rb:!0},rg8unorm:{gl:33323,rb:!0},rg8snorm:{gl:36757,r:fn},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:pn},r16unorm:{gl:33322,rb:!0,r:dn},r16snorm:{gl:36760,r:mn},"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:fn},rgba8uint:{gl:36220},rgba8sint:{gl:36238},bgra8unorm:{},"bgra8unorm-srgb":{},rg16uint:{gl:33338},rg16sint:{gl:33337},rg16float:{gl:33327,rb:!0,r:pn},rg16unorm:{gl:33324,r:dn},rg16snorm:{gl:36761,r:mn},r32uint:{gl:33334,rb:!0},r32sint:{gl:33333,rb:!0},r32float:{gl:33326,r:He},rgb9e5ufloat:{gl:35901,r:Qa},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:He},rgba16uint:{gl:36214,rb:!0},rgba16sint:{gl:36232,rb:!0},rgba16float:{gl:34842,r:pn},rgba16unorm:{gl:32859,rb:!0,r:dn},rgba16snorm:{gl:36763,r:mn},"rgb32float-webgl":{gl:34837,x:os,r:He,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,rb:!0},rgba32sint:{gl:36226,rb:!0},rgba32float:{gl:34836,rb:!0,r:He},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:de},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:me},"bc1-rgba-unorm":{gl:33777,x:de},"bc1-rgba-unorm-srgb":{gl:35916,x:me},"bc2-rgba-unorm":{gl:33778,x:de},"bc2-rgba-unorm-srgb":{gl:35918,x:me},"bc3-rgba-unorm":{gl:33779,x:de},"bc3-rgba-unorm-srgb":{gl:35919,x:me},"bc4-r-unorm":{gl:36283,x:Wt},"bc4-r-snorm":{gl:36284,x:Wt},"bc5-rg-unorm":{gl:36285,x:Wt},"bc5-rg-snorm":{gl:36286,x:Wt},"bc6h-rgb-ufloat":{gl:36495,x:Ut},"bc6h-rgb-float":{gl:36494,x:Ut},"bc7-rgba-unorm":{gl:36492,x:Ut},"bc7-rgba-unorm-srgb":{gl:36493,x:Ut},"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 er,us,tr,fs=P(()=>{er=I(B(),1);fe();$t();us={"depth-clip-control":"EXT_depth_clamp","timestamp-query":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","html-in-canvas":e=>(0,er.isHTMLInCanvasSupported)()&&typeof e.texElementImage2D=="function","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"},tr=class extends er.DeviceFeatures{gl;extensions;testedFeatures=new Set;constructor(t,r,n){super([],n),this.gl=t,this.extensions=r,nt(t,"EXT_color_buffer_float",r)}*[Symbol.iterator](){let t=this.getFeatures();for(let r of t)this.has(r)&&(yield r);return[]}has(t){return this.disabledFeatures?.[t]?!1:(this.testedFeatures.has(t)||(this.testedFeatures.add(t),as(t)&&bn(this.gl,t,this.extensions)&&this.features.add(t),this.getWebGLFeature(t)&&this.features.add(t)),this.features.has(t))}initializeFeatures(){let t=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(let r of t)this.has(r)}getFeatures(){return[...Object.keys(us),...Object.keys(Ke)]}getWebGLFeature(t){let r=us[t];return typeof r=="string"?!!nt(this.gl,r,this.extensions):typeof r=="function"?r(this.gl):!!r}}});var ds,rr,ms=P(()=>{ds=I(B(),1),rr=class extends ds.DeviceLimits{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxBindGroupsPlusVertexBuffers(){return 0}get maxBindingsPerBindGroup(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageBuffersInVertexStage(){return 0}get maxStorageBuffersInFragmentStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxStorageTexturesInVertexStage(){return 0}get maxStorageTexturesInFragmentStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get maxBufferSize(){return Number.MAX_SAFE_INTEGER}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderVariables(){return this.getParameter(35659)}get maxColorAttachments(){return this.getParameter(36063)}get maxColorAttachmentBytesPerSample(){return 0}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(t){super(),this.gl=t}getParameter(t){return this.limits[t]===void 0&&(this.limits[t]=this.gl.getParameter(t)),this.limits[t]||0}}});function rc(e){return e<34069?e+34069:e}function nc(e){switch(e){case 36053:return"success";case 36054:return"Mismatched attachments";case 36055:return"No attachments";case 36057:return"Height/width mismatch";case 36061:return"Unsupported or split attachments";case 36182:return"Samples mismatch";default:return`${e}`}}var ps,dt,nr=P(()=>{ps=I(B(),1);$t();dt=class extends ps.Framebuffer{device;gl;handle;colorAttachments=[];depthStencilAttachment=null;constructor(t,r){super(t,r);let n=r.handle,i=n===null;this.device=t,this.gl=t.gl,this.handle=n||i?n:this.gl.createFramebuffer(),i||(t._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),r.handle||(this.autoCreateAttachmentTextures(),this.updateAttachments()))}destroy(){super.destroy(),!this.destroyed&&this.handle!==null&&!this.props.handle&&this.gl.deleteFramebuffer(this.handle)}updateAttachments(){let t=this.gl.bindFramebuffer(36160,this.handle);for(let r=0;r<this.colorAttachments.length;++r){let n=this.colorAttachments[r];if(n){let i=36064+r;this._attachTextureView(i,n)}}if(this.depthStencilAttachment){let r=hs(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 ${nc(r)}`)}this.gl.bindFramebuffer(36160,t)}_attachTextureView(t,r){let{gl:n}=this.device,{texture:i}=r,s=r.props.baseMipLevel,o=r.props.baseArrayLayer;switch(n.bindTexture(i.glTarget,i.handle),i.glTarget){case 35866:case 32879:n.framebufferTextureLayer(36160,t,i.handle,s,o);break;case 34067:let a=rc(o);n.framebufferTexture2D(36160,t,a,i.handle,s);break;case 3553:n.framebufferTexture2D(36160,t,3553,i.handle,s);break;default:throw new Error("Illegal texture type")}n.bindTexture(i.glTarget,null)}resizeAttachments(t,r){if(this.handle===null){this.width=t,this.height=r;return}super.resizeAttachments(t,r)}}});var gs,ir,bs=P(()=>{gs=I(B(),1);nr();ir=class extends gs.CanvasContext{device;handle=null;_framebuffer=null;get[Symbol.toStringTag](){return"WebGLCanvasContext"}constructor(t,r){super(r),this.device=t,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 dt(this.device,{id:"canvas-context-framebuffer",handle:null,width:this.drawingBufferWidth,height:this.drawingBufferHeight}),this._framebuffer}}});var xs,sr,ys=P(()=>{xs=I(B(),1),sr=class extends xs.PresentationContext{device;handle=null;context2d;get[Symbol.toStringTag](){return"WebGLPresentationContext"}constructor(t,r={}){super(r),this.device=t;let n=`${this[Symbol.toStringTag]}(${this.id})`;if(!this.device.getDefaultCanvasContext().offscreenCanvas)throw new Error(`${n}: WebGL PresentationContext requires the default CanvasContext canvas to be an OffscreenCanvas`);let s=this.canvas.getContext("2d");if(!s)throw new Error(`${n}: Failed to create 2d presentation context`);this.context2d=s,this._setAutoCreatedCanvasId(`${this.device.id}-presentation-canvas`),this._configureDevice(),this._startObservers()}present(){this._resizeDrawingBufferIfNeeded(),this.device.submit();let t=this.device.getDefaultCanvasContext(),[r,n]=t.getDrawingBufferSize();if(!(this.drawingBufferWidth===0||this.drawingBufferHeight===0||r===0||n===0||t.canvas.width===0||t.canvas.height===0)){if(r!==this.drawingBufferWidth||n!==this.drawingBufferHeight||t.canvas.width!==this.drawingBufferWidth||t.canvas.height!==this.drawingBufferHeight)throw new Error(`${this[Symbol.toStringTag]}(${this.id}): Default canvas context size ${r}x${n} does not match presentation size ${this.drawingBufferWidth}x${this.drawingBufferHeight}`);this.context2d.clearRect(0,0,this.drawingBufferWidth,this.drawingBufferHeight),this.context2d.drawImage(t.canvas,0,0)}}_configureDevice(){}_getCurrentFramebuffer(t){let r=this.device.getDefaultCanvasContext();return r.setDrawingBufferSize(this.drawingBufferWidth,this.drawingBufferHeight),r.getCurrentFramebuffer(t)}}});function ws(e="id"){xn[e]=xn[e]||1;let t=xn[e]++;return`${e}-${t}`}var xn,Es=P(()=>{xn={}});function ic(e){return e&Mt.Buffer.INDEX?34963:e&Mt.Buffer.VERTEX?34962:e&Mt.Buffer.UNIFORM?35345:34962}function sc(e){return e&Mt.Buffer.INDEX||e&Mt.Buffer.VERTEX?35044:e&Mt.Buffer.UNIFORM?35048:35044}var Mt,it,or=P(()=>{Mt=I(B(),1),it=class extends Mt.Buffer{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength=0;bytesUsed=0;constructor(t,r={}){super(t,r),this.device=t,this.gl=this.device.gl;let n=typeof r=="object"?r.handle:void 0;this.handle=n||this.gl.createBuffer(),t._setWebGLDebugMetadata(this.handle,this,{spector:{...this.props,data:typeof this.props.data}}),this.glTarget=ic(this.props.usage),this.glUsage=sc(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(t,r=0,n=t.byteLength+r){let i=this.glTarget;this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,n,this.glUsage),this.gl.bufferSubData(i,r,t),this.gl.bindBuffer(i,null),this.bytesUsed=n,this.byteLength=n,this._setDebugData(t,r,n),this.props.handle?this.trackReferencedMemory(n,"Buffer"):this.trackAllocatedMemory(n)}_initWithByteLength(t){let r=t;t===0&&(r=new Float32Array(0));let n=this.glTarget;return this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,r,this.glUsage),this.gl.bindBuffer(n,null),this.bytesUsed=t,this.byteLength=t,this._setDebugData(null,0,t),this.props.handle?this.trackReferencedMemory(t,"Buffer"):this.trackAllocatedMemory(t),this}write(t,r=0){let n=ArrayBuffer.isView(t)?t:new Uint8Array(t),i=0,s=void 0,o=36663;this.gl.bindBuffer(o,this.handle),i!==0||s!==void 0?this.gl.bufferSubData(o,r,n,i,s):this.gl.bufferSubData(o,r,n),this.gl.bindBuffer(o,null),this._setDebugData(t,r,t.byteLength)}async mapAndWriteAsync(t,r=0,n=this.byteLength-r){let i=new ArrayBuffer(n);await t(i,"copied"),this.write(i,r)}async readAsync(t=0,r){return this.readSyncWebGL(t,r)}async mapAndReadAsync(t,r=0,n){let i=await this.readAsync(r,n);return await t(i.buffer,"copied")}readSyncWebGL(t=0,r){r=r??this.byteLength-t;let n=new Uint8Array(r),i=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,t,n,i,r),this.gl.bindBuffer(36662,null),this._setDebugData(n,t,r),n}}});function Ts(e){let t=e.split(/\r?\n/),r=[];for(let n of t){if(n.length<=1)continue;let i=n.trim(),s=n.split(":"),o=s[0]?.trim();if(s.length===2){let[d,p]=s;if(!d||!p){r.push({message:i,type:ar(o||"info"),lineNum:0,linePos:0});continue}r.push({message:p.trim(),type:ar(d),lineNum:0,linePos:0});continue}let[a,c,l,...h]=s;if(!a||!c||!l){r.push({message:s.slice(1).join(":").trim()||i,type:ar(o||"info"),lineNum:0,linePos:0});continue}let u=parseInt(l,10);Number.isNaN(u)&&(u=0);let f=parseInt(c,10);Number.isNaN(f)&&(f=0),r.push({message:h.join(":").trim(),type:ar(a),lineNum:u,linePos:f})}return r}function ar(e){let t=["warning","error","info"],r=e.toLowerCase();return t.includes(r)?r:"info"}var _s=P(()=>{});function oc(e){return e.split(/\r?\n/).find(t=>t.trim())?.trim()}var pe,cr,vs=P(()=>{pe=I(B(),1);_s();cr=class extends pe.Shader{device;handle;_compilationInfoLog="";constructor(t,r){super(t,r),this.device=t;let n=this.props.handle;switch(this.props.stage){case"vertex":this.handle=n||this.device.gl.createShader(35633);break;case"fragment":this.handle=n||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}t._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 t=this._getCompilationInfoLog();return t?Ts(t):[]}getTranslatedSource(){return this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders?.getTranslatedShaderSource(this.handle)||null}_compile(t){t=t.startsWith("#version ")?t:`#version 300 es
|
|
8
|
+
${t}`;let{gl:r}=this.device;if(r.shaderSource(this.handle,t),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(this._getCompilationErrorMessage(t));return}return pe.log.once(1,"Shader compilation is asynchronous")(),this._waitForCompilationComplete().then(()=>{pe.log.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()})}async _waitForCompilationComplete(){let t=async i=>await new Promise(s=>setTimeout(s,i));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}let{gl:n}=this.device;for(;;){if(n.getShaderParameter(this.handle,37297))return;await t(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error",this.compilationStatus==="error"&&this._getCompilationInfoLog()}_getCompilationErrorMessage(t){let r=`${this.props.stage} shader ${this.props.id}`,n=oc(this._getCompilationInfoLog()),i=this.getCompilationInfoSync(),s=i.find(h=>h.type==="error"&&h.message.trim())||i.find(h=>h.message.trim())||i.find(h=>h.type==="error")||i[0];if(!s)return n?`GLSL compilation errors in ${r}: ${n}`:`GLSL compilation errors in ${r}: WebGL did not provide a shader compiler log`;let o=s.lineNum?t.split(/\r?\n/)[s.lineNum-1]?.trim():void 0,a=s.lineNum?` line ${s.lineNum}`:"",c=o?`
|
|
9
|
+
Source: ${o}`:"",l=s.message.trim()||n||"WebGL did not provide a shader compiler log";return`GLSL compilation errors in ${r}:${a}: ${l}${c}`}_getCompilationInfoLog(){let t=this.device.gl.getShaderInfoLog(this.handle)?.trim();return t&&(this._compilationInfoLog=t),this._compilationInfoLog}}});function Ps(e,t,r,n){if(hc(t))return n(e);let i=e;i.pushState();try{return ac(e,t),et(i.gl,r),n(e)}finally{i.popState()}}function ac(e,t){let r=e,{gl:n}=r;if(t.cullMode)switch(t.cullMode){case"none":n.disable(2884);break;case"front":n.enable(2884),n.cullFace(1028);break;case"back":n.enable(2884),n.cullFace(1029);break}if(t.frontFace&&n.frontFace(Lt("frontFace",t.frontFace,{ccw:2305,cw:2304})),t.unclippedDepth&&e.features.has("depth-clip-control")&&n.enable(34383),t.depthBias!==void 0&&(n.enable(32823),n.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0)),t.provokingVertex&&e.features.has("provoking-vertex-webgl")){let s=r.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,o=Lt("provokingVertex",t.provokingVertex,{first:36429,last:36430});s?.provokingVertexWEBGL(o)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has("polygon-mode-webgl")){if(t.polygonMode){let s=r.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,o=Lt("polygonMode",t.polygonMode,{fill:6914,line:6913});s?.polygonModeWEBGL(1028,o),s?.polygonModeWEBGL(1029,o)}t.polygonOffsetLine&&n.enable(10754)}if(e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&n.enable(12288),t.clipDistance1&&n.enable(12289),t.clipDistance2&&n.enable(12290),t.clipDistance3&&n.enable(12291),t.clipDistance4&&n.enable(12292),t.clipDistance5&&n.enable(12293),t.clipDistance6&&n.enable(12294),t.clipDistance7&&n.enable(12295)),t.depthWriteEnabled!==void 0&&n.depthMask(lc("depthWriteEnabled",t.depthWriteEnabled)),t.depthCompare&&(t.depthCompare!=="always"?n.enable(2929):n.disable(2929),n.depthFunc(hr("depthCompare",t.depthCompare))),t.clearDepth!==void 0&&n.clearDepth(t.clearDepth),t.stencilWriteMask){let i=t.stencilWriteMask;n.stencilMaskSeparate(1028,i),n.stencilMaskSeparate(1029,i)}if(t.stencilReadMask&&Ms.log.warn("stencilReadMask not supported under WebGL"),t.stencilCompare){let i=t.stencilReadMask||4294967295,s=hr("depthCompare",t.stencilCompare);t.stencilCompare!=="always"?n.enable(2960):n.disable(2960),n.stencilFuncSeparate(1028,s,0,i),n.stencilFuncSeparate(1029,s,0,i)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){let i=yn("stencilPassOperation",t.stencilPassOperation),s=yn("stencilFailOperation",t.stencilFailOperation),o=yn("stencilDepthFailOperation",t.stencilDepthFailOperation);n.stencilOpSeparate(1028,s,o,i),n.stencilOpSeparate(1029,s,o,i)}switch(t.blend){case!0:n.enable(3042);break;case!1:n.disable(3042);break;default:}if(t.blendColorOperation||t.blendAlphaOperation){let i=Ss("blendColorOperation",t.blendColorOperation||"add"),s=Ss("blendAlphaOperation",t.blendAlphaOperation||"add");n.blendEquationSeparate(i,s);let o=lr("blendColorSrcFactor",t.blendColorSrcFactor||"one"),a=lr("blendColorDstFactor",t.blendColorDstFactor||"zero"),c=lr("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),l=lr("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");n.blendFuncSeparate(o,a,c,l)}}function hr(e,t){return Lt(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function yn(e,t){return Lt(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function Ss(e,t){return Lt(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function lr(e,t,r="color"){return Lt(e,t,{one:1,zero:0,src:768,"one-minus-src":769,dst:774,"one-minus-dst":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,constant: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 cc(e,t){return`Illegal parameter ${t} for ${e}`}function Lt(e,t,r){if(!(t in r))throw new Error(cc(e,t));return r[t]}function lc(e,t){return t}function hc(e){let t=!0;for(let r in e){t=!1;break}return t}var Ms,wn=P(()=>{Ms=I(B(),1);zt()});function ur(e){let t={};return e.addressModeU&&(t[10242]=En(e.addressModeU)),e.addressModeV&&(t[10243]=En(e.addressModeV)),e.addressModeW&&(t[32882]=En(e.addressModeW)),e.magFilter&&(t[10240]=Tn(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=uc(e.minFilter||"linear",e.mipmapFilter)),e.lodMinClamp!==void 0&&(t[33082]=e.lodMinClamp),e.lodMaxClamp!==void 0&&(t[33083]=e.lodMaxClamp),e.type==="comparison-sampler"&&(t[34892]=34894),e.compare&&(t[34893]=hr("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function En(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function Tn(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}function uc(e,t="none"){if(!t)return Tn(e);switch(t){case"none":return Tn(e);case"nearest":switch(e){case"nearest":return 9984;case"linear":return 9985}break;case"linear":switch(e){case"nearest":return 9986;case"linear":return 9987}}}var _n=P(()=>{wn()});var Cs,fr,Ls=P(()=>{Cs=I(B(),1);_n();fr=class extends Cs.Sampler{device;handle;parameters;constructor(t,r){super(t,r),this.device=t,this.parameters=ur(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(t){for(let[r,n]of Object.entries(t)){let i=Number(r);switch(i){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,i,n);break;default:this.device.gl.samplerParameteri(this.handle,i,n);break}}}}});function st(e,t,r){if(fc(t))return r(e);let{nocatch:n=!0}=t,i=rt.get(e);i.push(),et(e,t);let s;if(n)s=r(e),i.pop();else try{s=r(e)}finally{i.pop()}return s}function fc(e){for(let t in e)return!1;return!0}var dr=P(()=>{zt();ln()});var mr,mt,vn=P(()=>{mr=I(B(),1),mt=class extends mr.TextureView{device;gl;handle;texture;constructor(t,r){super(t,{...mr.Texture.defaultProps,...r}),this.device=t,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}});function pr(e){return dc[e]}var dc,Sn=P(()=>{dc={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 mc(e,t=0){return t?new e.constructor(e.buffer,e.byteOffset+t,(e.byteLength-t)/e.BYTES_PER_ELEMENT):e}function pc(e,t){if(t%e.BYTES_PER_ELEMENT!==0)throw new Error(`Texture byteOffset ${t} must align to typed array element size ${e.BYTES_PER_ELEMENT}`);return t/e.BYTES_PER_ELEMENT}function gc(e){switch(e){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(e)}function ge(e,t,r){return t==="cube"?34069+r:e}var Pt,pt,gr=P(()=>{Pt=I(B(),1);$t();_n();dr();vn();Sn();pt=class extends Pt.Texture{device;gl;handle;sampler=void 0;view;glTarget;glFormat;glType;glInternalFormat;compressed;_textureUnit=0;_framebuffer=null;_framebufferAttachmentKey=null;constructor(t,r){super(t,r,{byteAlignment:1}),this.device=t,this.gl=this.device.gl;let n=Je(this.props.format);if(this.glTarget=gc(this.props.dimension),this.glInternalFormat=n.internalFormat,this.glFormat=n.format,this.glType=n.type,this.compressed=n.compressed,this.isHandleBorrowed&&this.props.handle===void 0)throw new Error("Borrowed WebGL textures require a texture handle");if(this.handle=this.props.handle||this.gl.createTexture(),this.device._setWebGLDebugMetadata(this.handle,this,{spector:this.props}),!this.isHandleBorrowed){this.gl.bindTexture(this.glTarget,this.handle);let{dimension:i,width:s,height:o,depth:a,mipLevels:c,glTarget:l,glInternalFormat:h}=this;if(!this.compressed)switch(i){case"2d":case"cube":this.gl.texStorage2D(l,c,h,s,o);break;case"2d-array":case"3d":this.gl.texStorage3D(l,c,h,s,o,a);break;default:throw new Error(i)}this.gl.bindTexture(this.glTarget,null),this._initializeData(r.data)}this.ownsHandle?this.trackAllocatedMemory(this.getAllocatedByteLength(),"Texture"):this.trackReferencedMemory(this.getAllocatedByteLength(),"Texture"),this.isHandleBorrowed||this.setSampler(this.props.sampler),this.view=new mt(this.device,{...this.props,texture:this}),Object.seal(this)}destroy(){this.handle&&(this._framebuffer?.destroy(),this._framebuffer=null,this._framebufferAttachmentKey=null,this.removeStats(),this.ownsHandle?(this.gl.deleteTexture(this.handle),this.trackDeallocatedMemory("Texture")):this.trackDeallocatedReferencedMemory("Texture"),this.destroyed=!0)}createView(t){return new mt(this.device,{...t,texture:this})}clone(t){if(this.isHandleBorrowed&&t&&(t.width!==this.width||t.height!==this.height))throw new Error(`Cannot resize borrowed read-only ${this}`);return super.clone(t)}setSampler(t={}){this._assertWritable("set sampler parameters on"),super.setSampler(t);let r=ur(this.sampler.props);this._setSamplerParameters(r)}copyExternalImage(t){this._assertWritable("copy external image data into");let r=this._normalizeCopyExternalImageOptions(t);if(r.sourceX||r.sourceY)throw new Error("WebGL does not support sourceX/sourceY)");let{glFormat:n,glType:i}=this,{image:s,depth:o,mipLevel:a,x:c,y:l,z:h,width:u,height:f}=r,d=ge(this.glTarget,this.dimension,h),p=r.flipY?{37440:!0}:{};return this.gl.bindTexture(this.glTarget,this.handle),st(this.gl,p,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(d,a,c,l,u,f,n,i,s);break;case"2d-array":case"3d":this.gl.texSubImage3D(d,a,c,l,h,u,f,o,n,i,s);break;default:}}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyElementImage(t){this._assertWritable("copy element image data into");let r=this._normalizeCopyElementImageOptions(t),{glFormat:n}=this,{element:i,depth:s,mipLevel:o,sourceX:a,sourceY:c,sourceWidth:l,sourceHeight:h,x:u,y:f,z:d,width:p,height:g}=r,m=ge(this.glTarget,this.dimension,d),x=r.flipY?{37440:!0}:{},_=this.gl;if(s!==1||this.dimension!=="2d"&&this.dimension!=="cube")throw new Error(`${this} copyElementImage only supports 2d and cube textures on WebGL`);if(o!==0||u!==0||f!==0)throw new Error(`${this} copyElementImage only supports full base-level uploads on WebGL`);if(typeof _.texElementImage2D!="function")throw new Error(`${this} copyElementImage is not supported by this WebGL implementation`);return this.gl.bindTexture(this.glTarget,this.handle),st(this.gl,x,()=>{_.texElementImage2D?.(m,n,i,{sx:a,sy:c,swidth:l??p,sheight:h??g,width:p,height:g})}),this.gl.bindTexture(this.glTarget,null),{width:r.width,height:r.height}}copyImageData(t){super.copyImageData(t)}readBuffer(t={},r){if(!r)throw new Error(`${this} readBuffer requires a destination buffer`);let n=this._getSupportedColorReadOptions(t),i=t.byteOffset??0,s=this.computeMemoryLayout(n);if(r.byteLength<i+s.byteLength)throw new Error(`${this} readBuffer target is too small (${r.byteLength} < ${i+s.byteLength})`);let o=r;this.gl.bindBuffer(35051,o.handle);try{this._readColorTextureLayers(n,s,a=>{this.gl.readPixels(n.x,n.y,n.width,n.height,this.glFormat,this.glType,i+a)})}finally{this.gl.bindBuffer(35051,null)}return r}async readDataAsync(t={}){throw new Error(`${this} readDataAsync is deprecated; use readBuffer() with an explicit destination buffer or DynamicTexture.readAsync()`)}writeBuffer(t,r={}){this._assertWritable("write buffer data into");let n=this._normalizeTextureWriteOptions(r),{width:i,height:s,depthOrArrayLayers:o,mipLevel:a,byteOffset:c,x:l,y:h,z:u}=n,{glFormat:f,glType:d,compressed:p}=this,g=ge(this.glTarget,this.dimension,u);if(p)throw new Error("writeBuffer for compressed textures is not implemented in WebGL");let{bytesPerPixel:m}=this.device.getTextureFormatInfo(this.format),x=m?n.bytesPerRow/m:void 0,_={3317:this.byteAlignment,...x!==void 0?{3314:x}:{},32878:n.rowsPerImage};this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,t.handle),st(this.gl,_,()=>{switch(this.dimension){case"2d":case"cube":this.gl.texSubImage2D(g,a,l,h,i,s,f,d,c);break;case"2d-array":case"3d":this.gl.texSubImage3D(g,a,l,h,u,i,s,o,f,d,c);break;default:}}),this.gl.bindBuffer(35052,null),this.gl.bindTexture(this.glTarget,null)}writeData(t,r={}){this._assertWritable("write data into");let n=this._normalizeTextureWriteOptions(r),i=ArrayBuffer.isView(t)?t:new Uint8Array(t),{width:s,height:o,depthOrArrayLayers:a,mipLevel:c,x:l,y:h,z:u,byteOffset:f}=n,{glFormat:d,glType:p,compressed:g}=this,m=ge(this.glTarget,this.dimension,u),x;if(!g){let{bytesPerPixel:y}=this.device.getTextureFormatInfo(this.format);y&&(x=n.bytesPerRow/y)}let _=this.compressed?{}:{3317:this.byteAlignment,...x!==void 0?{3314:x}:{},32878:n.rowsPerImage},b=pc(i,f),w=g?mc(i,f):i,v=this._getMipLevelSize(c),E=l===0&&h===0&&u===0&&s===v.width&&o===v.height&&a===v.depthOrArrayLayers;this.gl.bindTexture(this.glTarget,this.handle),this.gl.bindBuffer(35052,null),st(this.gl,_,()=>{switch(this.dimension){case"2d":case"cube":g?E?this.gl.compressedTexImage2D(m,c,d,s,o,0,w):this.gl.compressedTexSubImage2D(m,c,l,h,s,o,d,w):this.gl.texSubImage2D(m,c,l,h,s,o,d,p,i,b);break;case"2d-array":case"3d":g?E?this.gl.compressedTexImage3D(m,c,d,s,o,a,0,w):this.gl.compressedTexSubImage3D(m,c,l,h,u,s,o,a,d,w):this.gl.texSubImage3D(m,c,l,h,u,s,o,a,d,p,i,b);break;default:}}),this.gl.bindTexture(this.glTarget,null)}_getRowByteAlignment(t,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(t={}){let r=this._getSupportedColorReadOptions(t),n=this.computeMemoryLayout(r),i=pr(this.glType),s=(0,Pt.getTypedArrayConstructor)(i),o=new s(n.byteLength/s.BYTES_PER_ELEMENT);return this._readColorTextureLayers(r,n,a=>{let c=new s(o.buffer,o.byteOffset+a,n.bytesPerImage/s.BYTES_PER_ELEMENT);this.gl.readPixels(r.x,r.y,r.width,r.height,this.glFormat,this.glType,c)}),o.buffer}_readColorTextureLayers(t,r,n){let i=this._getFramebuffer(),s=r.bytesPerRow/r.bytesPerPixel,o={3333:this.byteAlignment,...s!==t.width?{3330:s}:{}},a=this.gl.getParameter(3074),c=this.gl.bindFramebuffer(36160,i.handle);try{this.gl.readBuffer(36064),st(this.gl,o,()=>{for(let l=0;l<t.depthOrArrayLayers;l++)this._attachReadSubresource(i,t.mipLevel,t.z+l),n(l*r.bytesPerImage)})}finally{this.gl.bindFramebuffer(36160,c||null),this.gl.readBuffer(a)}}_attachReadSubresource(t,r,n){let i=`${r}:${n}`;if(this._framebufferAttachmentKey!==i){switch(this.dimension){case"2d":this.gl.framebufferTexture2D(36160,36064,3553,this.handle,r);break;case"cube":this.gl.framebufferTexture2D(36160,36064,ge(this.glTarget,this.dimension,n),this.handle,r);break;case"2d-array":case"3d":this.gl.framebufferTextureLayer(36160,36064,this.handle,r,n);break;default:throw new Error(`${this} color readback does not support ${this.dimension} textures`)}if(this.device.props.debug){let s=Number(this.gl.checkFramebufferStatus(36160));if(s!==36053)throw new Error(`${t} incomplete for ${this} readback (${s})`)}this._framebufferAttachmentKey=i}}generateMipmapsWebGL(t){if(this._assertWritable("generate mipmaps for"),!(!(this.device.isTextureFormatRenderable(this.props.format)&&this.device.isTextureFormatFilterable(this.props.format))&&(Pt.log.warn(`${this} is not renderable or filterable, may not be able to generate mipmaps`)(),!t?.force)))try{this.gl.bindTexture(this.glTarget,this.handle),this.gl.generateMipmap(this.glTarget)}catch(n){Pt.log.warn(`Error generating mipmap for ${this}: ${n.message}`)()}finally{this.gl.bindTexture(this.glTarget,null)}}_setSamplerParameters(t){Pt.log.log(2,`${this.id} sampler parameters`,this.device.getGLKeys(t))(),this.gl.bindTexture(this.glTarget,this.handle);for(let[r,n]of Object.entries(t)){let i=Number(r),s=n;switch(i){case 33082:case 33083:this.gl.texParameterf(this.glTarget,i,s);break;case 10240:case 10241:this.gl.texParameteri(this.glTarget,i,s);break;case 10242:case 10243:case 32882:this.gl.texParameteri(this.glTarget,i,s);break;case 34046:this.device.features.has("texture-filterable-anisotropic-webgl")&&this.gl.texParameteri(this.glTarget,i,s);break;case 34892:case 34893:this.gl.texParameteri(this.glTarget,i,s);break}}this.gl.bindTexture(this.glTarget,null)}_getActiveUnit(){return this.gl.getParameter(34016)-33984}_bind(t){let{gl:r}=this;return t!==void 0&&(this._textureUnit=t,r.activeTexture(33984+t)),r.bindTexture(this.glTarget,this.handle),t}_unbind(t){let{gl:r}=this;return t!==void 0&&(this._textureUnit=t,r.activeTexture(33984+t)),r.bindTexture(this.glTarget,null),t}_assertWritable(t){if(this.isHandleBorrowed)throw new Error(`Cannot ${t} borrowed read-only ${this}`)}}});function As(e,t,r,n){let i=e,s=n;s===!0&&(s=1),s===!1&&(s=0);let o=typeof s=="number"?[s]:s;switch(r){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof n!="number")throw new Error("samplers must be set to integers");return e.uniform1i(t,n);case 5126:return e.uniform1fv(t,o);case 35664:return e.uniform2fv(t,o);case 35665:return e.uniform3fv(t,o);case 35666:return e.uniform4fv(t,o);case 5124:return e.uniform1iv(t,o);case 35667:return e.uniform2iv(t,o);case 35668:return e.uniform3iv(t,o);case 35669:return e.uniform4iv(t,o);case 35670:return e.uniform1iv(t,o);case 35671:return e.uniform2iv(t,o);case 35672:return e.uniform3iv(t,o);case 35673:return e.uniform4iv(t,o);case 5125:return i.uniform1uiv(t,o,1);case 36294:return i.uniform2uiv(t,o,2);case 36295:return i.uniform3uiv(t,o,3);case 36296:return i.uniform4uiv(t,o,4);case 35674:return e.uniformMatrix2fv(t,!1,o);case 35675:return e.uniformMatrix3fv(t,!1,o);case 35676:return e.uniformMatrix4fv(t,!1,o);case 35685:return i.uniformMatrix2x3fv(t,!1,o);case 35686:return i.uniformMatrix2x4fv(t,!1,o);case 35687:return i.uniformMatrix3x2fv(t,!1,o);case 35688:return i.uniformMatrix3x4fv(t,!1,o);case 35689:return i.uniformMatrix4x2fv(t,!1,o);case 35690:return i.uniformMatrix4x3fv(t,!1,o)}throw new Error("Illegal uniform")}var Rs=P(()=>{});function ks(e){return xc[e]}function br(e){return bc[e]}function xr(e){return!!Bs[e]}function Is(e){return Bs[e]}var bc,Bs,xc,yr=P(()=>{bc={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>"},Bs={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"}},xc={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 Fs(e,t,r={}){let n={attributes:[],bindings:[]};n.attributes=yc(e,t);let i=Tc(e,t,r);for(let c of i){let l=c.uniforms.map(h=>({name:h.name,format:h.format,byteOffset:h.byteOffset,byteStride:h.byteStride,arrayLength:h.arrayLength}));n.bindings.push({type:"uniform",name:c.name,group:0,location:c.location,visibility:(c.vertex?1:0)|(c.fragment?2:0),minBindingSize:c.byteLength,uniforms:l})}let s=Ec(e,t),o=0;for(let c of s)if(xr(c.type)){let{viewDimension:l,sampleType:h}=Is(c.type);n.bindings.push({type:"texture",name:c.name,group:0,location:o,viewDimension:l,sampleType:h}),c.textureUnit=o,o+=1}s.length&&(n.uniforms=s);let a=wc(e,t);return a?.length&&(n.varyings=a),n}function yc(e,t){let r=[],n=e.getProgramParameter(t,35721);for(let i=0;i<n;i++){let s=e.getActiveAttrib(t,i);if(!s)throw new Error("activeInfo");let{name:o,type:a}=s,c=e.getAttribLocation(t,o);if(c>=0){let l=br(a),h=/instance/i.test(o)?"instance":"vertex";r.push({name:o,location:c,stepMode:h,type:l})}}return r.sort((i,s)=>i.location-s.location),r}function wc(e,t){let r=[],n=e.getProgramParameter(t,35971);for(let i=0;i<n;i++){let s=e.getTransformFeedbackVarying(t,i);if(!s)throw new Error("activeInfo");let{name:o,type:a,size:c}=s,l=br(a),{type:h,components:u}=(0,yt.getVariableShaderTypeInfo)(l);r.push({location:i,name:o,type:h,size:c*u})}return r.sort((i,s)=>i.location-s.location),r}function Ec(e,t){let r=[],n=e.getProgramParameter(t,35718);for(let i=0;i<n;i++){let s=e.getActiveUniform(t,i);if(!s)throw new Error("activeInfo");let{name:o,size:a,type:c}=s,{name:l,isArray:h}=Lc(o),u=e.getUniformLocation(t,l),f={location:u,name:l,size:a,type:c,isArray:h};if(r.push(f),f.size>1)for(let d=0;d<f.size;d++){let p=`${l}[${d}]`;u=e.getUniformLocation(t,p);let g={...f,name:p,location:u};r.push(g)}}return r}function Tc(e,t,r){let n=[],i=vc(e,t,r);for(let[o,a]of i){n.push(a);try{let c=Ds(e,t,o,a.name);_c(c,a)}catch(c){let l=c instanceof Error?c.message:String(c);yt.log.once(0,`WebGL uniform block reflection failed for "${a.name}"; using supplied std140 metadata. ${l}`)()}}let s=e.getProgramParameter(t,35382);if(!Number.isInteger(s)||s<0)throw new Error(`Failed to reflect WebGL uniform blocks: ACTIVE_UNIFORM_BLOCKS returned ${String(s)}`);for(let o=0;o<s;o++)i.has(o)||n.push(Ds(e,t,o));return n.sort((o,a)=>o.location-a.location),n}function _c(e,t){for(let r of e.uniforms){let n=t.uniforms.find(i=>r.name===i.name||r.name.endsWith(`.${i.name}`));if(!n)throw new Error(`Failed to validate WebGL uniform block "${t.name}": reflected unexpected member "${r.name}"`);if(r.format!==n.format||r.arrayLength!==n.arrayLength||r.byteOffset!==n.byteOffset||r.byteStride!==n.byteStride)throw new Error(`Failed to validate WebGL uniform block "${t.name}": reflected layout for "${r.name}" does not match supplied std140 metadata`)}}function vc(e,t,r){let n=new Map;for(let s of r.uniformBlockLayouts||[])n.set(s.name,Mc(s));for(let s of r.shaderLayout?.bindings||[])Cc(s)&&n.set(s.name,s);let i=new Map;for(let s of n.values()){let o=Sc(e,t,s.name);if(!o)continue;let{blockIndex:a,blockName:c}=o;if(i.has(a))throw new Error(`Multiple supplied uniform block layouts resolve to active WebGL block "${c}"`);i.set(a,{name:c,location:a,byteLength:s.minBindingSize,vertex:!!(s.visibility&&s.visibility&1),fragment:!!(s.visibility&&s.visibility&2),uniformCount:s.uniforms.length,uniforms:s.uniforms.map(l=>({...l}))})}return i}function Sc(e,t,r){let n=r.endsWith("Uniforms")?[r,r.slice(0,-8)]:[r,`${r}Uniforms`];for(let i of n){let s=e.getUniformBlockIndex(t,i);if(s!==4294967295){if(!Number.isInteger(s)||s<0)throw new Error(`Failed to resolve WebGL uniform block "${i}": getUniformBlockIndex returned ${String(s)}`);return{blockIndex:s,blockName:i}}}return null}function Ds(e,t,r,n){let i=n||e.getActiveUniformBlockName(t,r);if(!i)throw new Error(`Failed to reflect WebGL uniform block at index ${r}: missing block name`);let s=(b,w)=>{let v=e.getActiveUniformBlockParameter(t,r,b);if(v==null)throw new Error(`Failed to reflect WebGL uniform block "${i}": ${w} returned null`);return v},o=At(s(35391,"UNIFORM_BLOCK_BINDING"),i,"UNIFORM_BLOCK_BINDING",0),a=At(s(35392,"UNIFORM_BLOCK_DATA_SIZE"),i,"UNIFORM_BLOCK_DATA_SIZE",0),c=At(s(35394,"UNIFORM_BLOCK_ACTIVE_UNIFORMS"),i,"UNIFORM_BLOCK_ACTIVE_UNIFORMS",0),l=Os(s(35395,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES"),i,"UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",c),h=be(e,t,l,35383,"UNIFORM_TYPE",i,c),u=be(e,t,l,35384,"UNIFORM_SIZE",i,c),f=be(e,t,l,35386,"UNIFORM_BLOCK_INDEX",i,c),d=be(e,t,l,35387,"UNIFORM_OFFSET",i,c),p=be(e,t,l,35388,"UNIFORM_ARRAY_STRIDE",i,c),g=[];for(let b=0;b<c;b++){if(f[b]!==r)throw new Error(`Failed to reflect WebGL uniform block "${i}": active uniform index ${l[b]} belongs to block ${f[b]}, expected ${r}`);let w=l[b],v=e.getActiveUniform(t,w);if(!v)throw new Error(`Failed to reflect WebGL uniform block "${i}": getActiveUniform(${w}) returned null`);let E=At(h[b],i,`UNIFORM_TYPE[${b}]`,1),y=At(u[b],i,`UNIFORM_SIZE[${b}]`,1),T=At(d[b],i,`UNIFORM_OFFSET[${b}]`,0),M=At(p[b],i,`UNIFORM_ARRAY_STRIDE[${b}]`,0);if(v.type!==E||v.size!==y)throw new Error(`Failed to reflect WebGL uniform block "${i}": getActiveUniform(${w}) disagrees with getActiveUniforms`);g.push({name:v.name,format:br(E),arrayLength:y,byteOffset:T,byteStride:M})}let m={name:i,location:o,byteLength:a,vertex:!!s(35396,"UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER"),fragment:!!s(35398,"UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER"),uniformCount:c,uniforms:g},x=new Set(m.uniforms.map(b=>b.name.split(".")[0]).filter(b=>!!b)),_=m.name.replace(/Uniforms$/,"");if(x.size===1&&!x.has(m.name)&&!x.has(_)){let[b]=x;yt.log.warn(`Uniform block "${m.name}" uses GLSL instance "${b}". luma.gl binds uniform buffers by block name ("${m.name}") and alias ("${_}"). Prefer matching the instance name to one of those to avoid confusing silent mismatches.`)()}return m}function be(e,t,r,n,i,s,o){let a=e.getActiveUniforms(t,r,n);if(a===null)throw new Error(`Failed to reflect WebGL uniform block "${s}": ${i} returned null`);return Os(a,s,i,o)}function Os(e,t,r,n){if(!Array.isArray(e)&&!ArrayBuffer.isView(e))throw new Error(`Failed to reflect WebGL uniform block "${t}": ${r} returned a non-array value`);let i=Array.from(e);if(i.length!==n||i.some(s=>!Number.isInteger(s)))throw new Error(`Failed to reflect WebGL uniform block "${t}": ${r} returned ${i.length} invalid values, expected ${n}`);return i}function At(e,t,r,n){if(!Number.isInteger(e)||e<n)throw new Error(`Failed to reflect WebGL uniform block "${t}": ${r} returned ${String(e)}`);return e}function Mc(e){let t=(0,yt.makeShaderBlockLayout)(e.uniformTypes,{layout:"std140"}),r=Pc(e.uniformTypes,t.fields);return{type:"uniform",name:e.name,group:0,location:0,minBindingSize:t.byteLength,uniforms:r}}function Pc(e,t){let r=[],n=(s,o)=>{if(typeof o=="string"){let a=t[s];if(!a)throw new Error(`Missing std140 layout field ${s}`);r.push({name:s,format:a.shaderType,arrayLength:1,byteOffset:a.offset*4,byteStride:0});return}if(Array.isArray(o)){i(s,o[0],o[1]);return}for(let[a,c]of Object.entries(o))n(`${s}.${a}`,c)},i=(s,o,a)=>{if(typeof o=="string"){let c=t[`${s}[0]`],l=a>1?t[`${s}[1]`]:void 0;if(!c)throw new Error(`Missing std140 array layout field ${s}[0]`);r.push({name:`${s}[0]`,format:c.shaderType,arrayLength:a,byteOffset:c.offset*4,byteStride:l?(l.offset-c.offset)*4:0});return}if(Array.isArray(o))throw new Error(`Nested uniform arrays are not supported for ${s}`);for(let[c,l]of Object.entries(o)){if(typeof l!="string")throw new Error(`Composite uniform array members are not supported for ${s}`);let h=`${s}[0].${c}`,u=`${s}[1].${c}`,f=t[h],d=a>1?t[u]:void 0;if(!f)throw new Error(`Missing std140 array layout field ${h}`);r.push({name:h,format:f.shaderType,arrayLength:a,byteOffset:f.offset*4,byteStride:d?(d.offset-f.offset)*4:0})}};for(let[s,o]of Object.entries(e))n(s,o);return r}function Cc(e){return e.type==="uniform"&&Number.isInteger(e.minBindingSize)&&e.minBindingSize>=0&&Array.isArray(e.uniforms)&&e.uniforms.every(t=>typeof t.name=="string"&&typeof t.format=="string"&&Number.isInteger(t.arrayLength)&&t.arrayLength>0&&Number.isInteger(t.byteOffset)&&t.byteOffset>=0&&Number.isInteger(t.byteStride)&&t.byteStride>=0)}function Lc(e){if(e[e.length-1]!=="]")return{name:e,length:1,isArray:!1};let r=/([^[]*)(\[[0-9]+\])?/.exec(e);return{name:(0,yt.assertDefined)(r?.[1],`Failed to parse GLSL uniform name ${e}`),length:r?.[2]?1:0,isArray:!!r?.[2]}}var yt,Ns=P(()=>{yt=I(B(),1);yr()});function Ac(e,t){let r={...e,attributes:e.attributes.map(n=>({...n})),bindings:e.bindings.map(n=>({...n}))};for(let n of t?.attributes||[]){let i=r.attributes.find(s=>s.name===n.name);i?(i.type=n.type||i.type,i.stepMode=n.stepMode||i.stepMode):U.log.warn(`shader layout attribute ${n.name} not present in shader`)}for(let n of t?.bindings||[]){let i=Gs(r,n.name);if(!i){U.log.warn(`shader layout binding ${n.name} not present in shader`);continue}Object.assign(i,n)}return r}function Gs(e,t){return e.bindings.find(r=>r.name===t||r.name===`${t}Uniforms`||`${r.name}Uniforms`===t)}function Vs(e,t){return e[t]||e[`${t}Uniforms`]||e[t.replace(/Uniforms$/,"")]}var U,wr,zs=P(()=>{U=I(B(),1);Rs();or();nr();gr();vn();Ns();wr=class extends U.RenderPipeline{device;handle;vs;fs;introspectedLayout;bindings={};uniforms={};varyings=null;_uniformCount=0;_uniformSetters={};get[Symbol.toStringTag](){return"WEBGLRenderPipeline"}constructor(t,r){super(t,r),this.device=t;let n=this.sharedRenderPipeline||this.device._createSharedRenderPipelineWebGL(r);this.sharedRenderPipeline=n,this.handle=n.handle,this.vs=n.vs,this.fs=n.fs,this.linkStatus=n.linkStatus,this.introspectedLayout=Fs(this.device.gl,this.handle,{uniformBlockLayouts:r._uniformBlockLayouts,shaderLayout:r.shaderLayout}),this.device._setWebGLDebugMetadata(this.handle,this,{spector:{id:this.props.id}}),this.shaderLayout=r.shaderLayout?Ac(this.introspectedLayout,r.shaderLayout):this.introspectedLayout}destroy(){this.destroyed||(this.sharedRenderPipeline&&!this.props._sharedRenderPipeline&&this.sharedRenderPipeline.destroy(),this.destroyResource())}setBindings(t,r){let n=(0,U.flattenBindingsByGroup)((0,U.normalizeBindingsByGroup)(this.shaderLayout,t));for(let[i,s]of Object.entries(n)){let o=Gs(this.shaderLayout,i);if(o){switch(s||U.log.warn(`Unsetting binding "${i}" in render pipeline "${this.id}"`)(),o.type){case"uniform":if(!(s instanceof it)&&!(s.buffer instanceof it))throw new Error("buffer value");break;case"texture":if(!(s instanceof mt||s instanceof pt||s instanceof dt))throw new Error(`${this} Bad texture binding for ${i}`);break;case"sampler":U.log.warn(`Ignoring sampler ${i}`)();break;default:throw new Error(o.type)}this.bindings[i]=s}else{let a=this.shaderLayout.bindings.map(c=>`"${c.name}"`).join(", ");r?.disableWarnings||U.log.warn(`No binding "${i}" in render pipeline "${this.id}", expected one of ${a}`,s)()}}}draw(t){let r=t.renderPass,n=t.bindGroups?(0,U.flattenBindingsByGroup)(t.bindGroups):t.bindings||this.bindings;return r.setPipeline(this),r.setBindings(n),r.setVertexArray(t.vertexArray),r.draw({parameters:t.parameters,topology:t.topology,isInstanced:t.isInstanced,vertexCount:t.vertexCount,indexCount:t.indexCount,instanceCount:t.instanceCount,firstVertex:t.firstVertex,firstIndex:t.firstIndex,firstInstance:t.firstInstance,baseVertex:t.baseVertex,transformFeedback:t.transformFeedback,uniforms:t.uniforms})}_areTexturesRenderable(t){let r=!0;for(let n of this.shaderLayout.bindings)Vs(t,n.name)||(U.log.warn(`Binding ${n.name} not found in ${this.id}`)(),r=!1);return r}_applyBindings(t,r){if(this._syncLinkStatus(),this.linkStatus!=="success")return;let{gl:n}=this.device;n.useProgram(this.handle);let i=0,s=0;for(let o of this.shaderLayout.bindings){let a=Vs(t,o.name);if(!a)throw new Error(`No value for binding ${o.name} in ${this.id}`);switch(o.type){case"uniform":let{name:c}=o,l=n.getUniformBlockIndex(this.handle,c);if(l===4294967295)throw new Error(`Invalid uniform block name ${c}`);if(n.uniformBlockBinding(this.handle,l,s),a instanceof it)n.bindBufferBase(35345,s,a.handle);else{let u=a;n.bindBufferRange(35345,s,u.buffer.handle,u.offset||0,u.size||u.buffer.byteLength-(u.offset||0))}s+=1;break;case"texture":if(!(a instanceof mt||a instanceof pt||a instanceof dt))throw new Error("texture");let h;if(a instanceof mt)h=a.texture;else if(a instanceof pt)h=a;else if(a instanceof dt&&a.colorAttachments[0]instanceof mt)U.log.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),h=a.colorAttachments[0].texture;else throw new Error("No texture");n.activeTexture(33984+i),n.bindTexture(h.glTarget,h.handle),i+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${o.type}' not supported in WebGL`)}}}_applyUniforms(t){for(let r of this.shaderLayout.uniforms||[]){let{name:n,location:i,type:s,textureUnit:o}=r,a=t[n]??o;a!==void 0&&As(this.device.gl,i,s,a)}}_syncLinkStatus(){this.linkStatus=this.sharedRenderPipeline.linkStatus}}});var Rt,Ws,Er,Us=P(()=>{Rt=I(B(),1);yr();Ws=4,Er=class extends Rt.SharedRenderPipeline{device;handle;vs;fs;linkStatus="pending";constructor(t,r){super(t,r),this.device=t,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()}destroy(){this.destroyed||(this.device.gl.useProgram(null),this.device.gl.deleteProgram(this.handle),this.handle.destroyed=!0,this.destroyResource())}async _linkShaders(){let{gl:t}=this.device;if(t.attachShader(this.handle,this.vs.handle),t.attachShader(this.handle,this.fs.handle),Rt.log.time(Ws,`linkProgram for ${this.id}`)(),t.linkProgram(this.handle),Rt.log.timeEnd(Ws,`linkProgram for ${this.id}`)(),!this.device.features.has("compilation-status-async-webgl")){let n=this._getLinkStatus();this._reportLinkStatus(n);return}Rt.log.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),Rt.log.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();let r=this._getLinkStatus();this._reportLinkStatus(r)}async _reportLinkStatus(t){switch(t){case"success":return;default:let r=t==="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 n=this.device.gl.getProgramInfoLog(this.handle);this.device.reportError(new Error(`${r} during ${t}: ${n}`),this)(),this.device.debug()}}_getLinkStatus(){let{gl:t}=this.device;return t.getProgramParameter(this.handle,35714)?(this._initializeSamplerUniforms(),t.validateProgram(this.handle),t.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation-error")):(this.linkStatus="error","link-error")}_initializeSamplerUniforms(){let{gl:t}=this.device;t.useProgram(this.handle);let r=0,n=t.getProgramParameter(this.handle,35718);for(let i=0;i<n;i++){let s=t.getActiveUniform(this.handle,i);if(s&&xr(s.type)){let o=s.name.endsWith("[0]"),a=o?s.name.slice(0,-3):s.name,c=t.getUniformLocation(this.handle,a);c!==null&&(r=this._assignSamplerUniform(c,s,o,r))}}}_assignSamplerUniform(t,r,n,i){let{gl:s}=this.device;if(n&&r.size>1){let o=Int32Array.from({length:r.size},(a,c)=>i+c);return s.uniform1iv(t,o),i+r.size}return s.uniform1i(t,i),i+1}async _waitForLinkComplete(){let t=async i=>await new Promise(s=>setTimeout(s,i));if(!this.device.features.has("compilation-status-async-webgl")){await t(10);return}let{gl:n}=this.device;for(;;){if(n.getProgramParameter(this.handle,37297))return;await t(10)}}}});function Rc(e,t){let r=t.sourceBuffer,n=t.destinationBuffer;e.gl.bindBuffer(36662,r.handle),e.gl.bindBuffer(36663,n.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function kc(e,t){let{sourceBuffer:r,byteOffset:n=0,destinationTexture:i,mipLevel:s=0,origin:o=[0,0,0],aspect:a="all",bytesPerRow:c,rowsPerImage:l,size:h}=t;if(a!=="all")throw new Error("copyBufferToTexture aspect is not supported in WebGL");i.writeBuffer(r,{byteOffset:n,bytesPerRow:c,rowsPerImage:l,mipLevel:s,x:o[0]??0,y:o[1]??0,z:o[2]??0,width:h[0],height:h[1],depthOrArrayLayers:h[2]})}function Ic(e,t){let{sourceTexture:r,mipLevel:n=0,aspect:i="all",width:s=t.sourceTexture.width,height:o=t.sourceTexture.height,depthOrArrayLayers:a,origin:c=[0,0,0],destinationBuffer:l,byteOffset:h=0,bytesPerRow:u,rowsPerImage:f}=t;if(r instanceof kt.Texture){r.readBuffer({x:c[0]??0,y:c[1]??0,z:c[2]??0,width:s,height:o,depthOrArrayLayers:a,mipLevel:n,aspect:i,byteOffset:h},l);return}if(i!=="all")throw new Error("aspect not supported in WebGL");if(n!==0||a!==void 0||u||f)throw new Error("not implemented");let{framebuffer:d,destroyFramebuffer:p}=$s(r),g;try{let m=l,x=s||d.width,_=o||d.height,b=(0,kt.assertDefined)(d.colorAttachments[0]),w=Je(b.texture.props.format),v=w.format,E=w.type;e.gl.bindBuffer(35051,m.handle),g=e.gl.bindFramebuffer(36160,d.handle),e.gl.readPixels(c[0],c[1],x,_,v,E,h)}finally{e.gl.bindBuffer(35051,null),g!==void 0&&e.gl.bindFramebuffer(36160,g),p&&d.destroy()}}function Bc(e,t){let{sourceTexture:r,destinationMipLevel:n=0,origin:i=[0,0],destinationOrigin:s=[0,0,0],destinationTexture:o}=t,{width:a=t.destinationTexture.width,height:c=t.destinationTexture.height}=t,{framebuffer:l,destroyFramebuffer:h}=$s(r),[u=0,f=0]=i,[d,p,g]=s,m=e.gl.bindFramebuffer(36160,l.handle),x,_;if(o instanceof pt)x=o,a=Number.isFinite(a)?a:x.width,c=Number.isFinite(c)?c:x.height,x._bind(0),_=x.glTarget;else throw new Error("invalid destination");switch(_){case 3553:case 34067:e.gl.copyTexSubImage2D(_,n,d,p,u,f,a,c);break;case 35866:case 32879:e.gl.copyTexSubImage3D(_,n,d,p,g,u,f,a,c);break;default:}x&&x._unbind(),e.gl.bindFramebuffer(36160,m),h&&l.destroy()}function $s(e){if(e instanceof kt.Texture){let{width:t,height:r,id:n}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${n}`,width:t,height:r,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}var kt,Tr,Ys=P(()=>{kt=I(B(),1);$t();gr();Tr=class extends kt.CommandBuffer{device;handle=null;commands=[];constructor(t,r={}){super(t,r),this.device=t}_executeCommands(t=this.commands){for(let r of t)switch(r.name){case"copy-buffer-to-buffer":Rc(this.device,r.options);break;case"copy-buffer-to-texture":kc(this.device,r.options);break;case"copy-texture-to-buffer":Ic(this.device,r.options);break;case"copy-texture-to-texture":Bc(this.device,r.options);break;default:throw new Error(r.name)}}}});function js(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"triangle-list":return 4;case"triangle-strip":return 5;default:throw new Error(e)}}function qs(e){switch(e){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(e)}}var Mn=P(()=>{});var wt,Dc,_r,Xs=P(()=>{wt=I(B(),1);dr();zt();Mn();wn();Dc=[1,2,4,8],_r=class extends wt.RenderPass{device;handle=null;glParameters={};pipeline=null;bindings={};bindingsPipeline=null;vertexArray=null;constructor(t,r){super(t,r),this.device=t;let n=this.props.framebuffer,i=!n||n.handle===null;i&&t.getDefaultCanvasContext()._resizeDrawingBufferIfNeeded();let s;if(!r?.parameters?.viewport)if(!i&&n){let{width:o,height:a}=n;s=[0,0,o,a]}else{let[o,a]=t.getDefaultCanvasContext().getDrawingBufferSize();s=[0,0,o,a]}if(this.device.pushState(),this.setParameters({viewport:s,...this.props.parameters}),!i&&n?.colorAttachments.length){let o=n.colorAttachments.map((a,c)=>36064+c);this.device.gl.drawBuffers(o)}else i&&this.device.gl.drawBuffers([1029]);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(t){}popDebugGroup(){}insertDebugMarker(t){}executeBundles(t){throw new Error("Render bundles are only supported in WebGPU")}setParameters(t={}){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,t.viewport&&(t.viewport.length>=6?(r.viewport=t.viewport.slice(0,4),r.depthRange=[t.viewport[4],t.viewport[5]]):r.viewport=t.viewport),t.scissorRect&&(r.scissorTest=!0,r.scissor=t.scissorRect),t.blendConstant&&(r.blendColor=t.blendConstant),t.stencilReference!==void 0&&(r[2967]=t.stencilReference,r[36003]=t.stencilReference),"colorMask"in t&&(r.colorMask=Dc.map(n=>!!(n&t.colorMask))),this.glParameters=r,et(this.device.gl,r)}setPipeline(t){this.pipeline=t}setBindings(t,r){if(!this.pipeline)throw new Error("RenderPass.setPipeline() must be called before setBindings()");this.bindings=(0,wt.flattenBindingsByGroup)((0,wt.normalizeBindingsByGroup)(this.pipeline.shaderLayout,t)),this.bindingsPipeline=this.pipeline}setVertexArray(t){this.vertexArray=t}draw(t){let r=this.pipeline,n=this.vertexArray;if(!r)throw new Error("RenderPass.setPipeline() must be called before draw()");if(!n)throw new Error("RenderPass.setVertexArray() must be called before draw()");if(r.shaderLayout.bindings.length>0&&this.bindingsPipeline!==r)throw new Error("RenderPass.setBindings() must be called after setPipeline() before draw()");r._syncLinkStatus();let{parameters:i=r.props.parameters,topology:s=r.props.topology,vertexCount:o,indexCount:a,instanceCount:c,isInstanced:l=!1,firstVertex:h=0,transformFeedback:u,uniforms:f=r.uniforms}=t,d=js(s),p=!!n.indexBuffer,g=n.indexBuffer?.glIndexType,m=a??o??0;if(r.linkStatus!=="success")return wt.log.info(2,`RenderPipeline:${r.id}.draw() aborted - waiting for shader linking`)(),!1;if(!r._areTexturesRenderable(this.bindings))return wt.log.info(2,`RenderPipeline:${r.id}.draw() aborted - textures not yet loaded`)(),!1;this.device.gl.useProgram(r.handle),n.bindBeforeRender(this);let x=u;return x&&x.begin(r.props.topology),r._applyBindings(this.bindings,{disableWarnings:r.props.disableWarnings}),r._applyUniforms(f),Ps(this.device,i,this.glParameters,()=>{p&&l?this.device.gl.drawElementsInstanced(d,m,g,h,c||0):p?this.device.gl.drawElements(d,m,g,h):l?this.device.gl.drawArraysInstanced(d,h,o||0,c||0):this.device.gl.drawArrays(d,h,o||0),x&&x.end()}),n.unbindAfterRender(this),!0}drawIndirect(t,r=0){throw new Error("Indirect drawing is only supported in WebGPU")}drawIndexedIndirect(t,r=0){throw new Error("Indirect drawing is only supported in WebGPU")}beginOcclusionQuery(t){this.props.occlusionQuerySet?.beginOcclusionQuery()}endOcclusionQuery(){this.props.occlusionQuerySet?.endOcclusionQuery()}clear(){let t={...this.glParameters},r=0;this.props.clearColors&&this.props.clearColors.forEach((n,i)=>{n&&this.clearColorBuffer(i,n)}),this.props.clearColor!==!1&&this.props.clearColors===void 0&&(r|=16384,t.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=256,t.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=1024,t.clearStencil=this.props.clearStencil),r!==0&&st(this.device.gl,t,()=>{this.device.gl.clear(r)})}clearColorBuffer(t=0,r=[0,0,0,0]){st(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int8Array:case Int16Array:case Int32Array:this.device.gl.clearBufferiv(6144,t,r);break;case Uint8Array:case Uint8ClampedArray:case Uint16Array:case Uint32Array:this.device.gl.clearBufferuiv(6144,t,r);break;case Float32Array:this.device.gl.clearBufferfv(6144,t,r);break;default:throw new Error("clearColorBuffer: color must be typed array")}})}}});var Zs,xe,Hs=P(()=>{Zs=I(B(),1);Ys();Xs();xe=class extends Zs.CommandEncoder{device;handle=null;commandBuffer;constructor(t,r){super(t,r),this.device=t,this.commandBuffer=new Tr(t,{id:this.id,userData:this.userData})}destroy(){this.destroyResource()}finish(){return this.destroy(),this.commandBuffer}beginRenderPass(t={}){return new _r(this.device,this._applyTimeProfilingToPassProps(t))}beginComputePass(t={}){throw new Error("ComputePass not supported in WebGL")}copyBufferToBuffer(t){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:t})}copyBufferToTexture(t){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:t})}copyTextureToBuffer(t){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:t})}copyTextureToTexture(t){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:t})}pushDebugGroup(t){}popDebugGroup(){}insertDebugMarker(t){}resolveQuerySet(t,r,n){throw new Error("resolveQuerySet is not supported in WebGL")}writeTimestamp(t,r){t.writeTimestamp(r)}}});var vr,Fc,Sr,Oc,Ks,Pn=P(()=>{vr=globalThis,Fc=globalThis.document||{},Sr=globalThis.process||{},Oc=globalThis.console,Ks=globalThis.navigator||{}});function Mr(e){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&process.versions?.electron)return!0;let t=typeof navigator<"u"&&navigator.userAgent,r=e||t;return!!(r&&r.indexOf("Electron")>=0)}var Cn=P(()=>{});function Et(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||Mr()}var Ln=P(()=>{Cn()});function An(e){return!e&&!Et()?"Node":Mr(e)?"Electron":(e||Ks.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown"}var Qs=P(()=>{Ln();Cn();Pn()});var Rn,ye=P(()=>{Pn();Ln();Qs();Rn="4.1.1"});function Js(e){let{target:t,source:r,start:n=0,count:i=1}=e,s=r.length,o=i*s,a=0;for(let c=n;a<s;a++)t[c++]=r[a]??0;for(;a<o;)a<o-a?(t.copyWithin(n+a,n,n+a),a*=2):(t.copyWithin(n+a,n,n+o-a),a=o);return e.target}var to=P(()=>{});function Vc(e){return Array.isArray(e)?new Float32Array(e):e}function Gc(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}var Yt,Pr,eo=P(()=>{Yt=I(B(),1);ye();un();to();Pr=class e extends Yt.VertexArray{get[Symbol.toStringTag](){return"VertexArray"}device;handle;attributeInfosByLocation;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(t){return An()==="Chrome"}constructor(t,r){super(t,r),this.device=t,this.handle=this.device.gl.createVertexArray(),this.attributeInfosByLocation=new Array(this.maxVertexAttributes).fill(null);for(let n of Object.values((0,Yt.getAttributeInfosFromLayouts)(r.shaderLayout,r.bufferLayout)))this.attributeInfosByLocation[n.location]=n}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(t){let r=t;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(t,r){let n=r;if(n.glTarget===34963)throw new Error("Use .setIndexBuffer()");let{size:i,type:s,stride:o,offset:a,normalized:c,integer:l,divisor:h}=this._getAccessor(t);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,n.handle),l?this.device.gl.vertexAttribIPointer(t,i,s,o,a):this.device.gl.vertexAttribPointer(t,i,s,c,o,a),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(t),this.device.gl.vertexAttribDivisor(t,h||0),this.attributes[t]=n,this.device.gl.bindVertexArray(null)}setConstantWebGL(t,r){this._enable(t,!1),this.attributes[t]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let t=0;t<this.maxVertexAttributes;++t){let r=this.attributes[t];ArrayBuffer.isView(r)&&this.device.setConstantAttributeWebGL(t,r)}}_getAccessor(t){let r=this.attributeInfosByLocation[t];if(!r)throw new Error(`Unknown attribute location ${t}`);let n=Ze(r.bufferDataType);return{size:r.bufferComponents,type:n,stride:r.byteStride,offset:r.byteOffset,normalized:r.normalized,integer:r.integer,divisor:r.stepMode==="instance"?1:0}}_enable(t,r=!0){let i=e.isConstantAttributeZeroSupported(this.device)||t!==0;(r||i)&&(t=Number(t),this.device.gl.bindVertexArray(this.handle),r?this.device.gl.enableVertexAttribArray(t):this.device.gl.disableVertexAttribArray(t),this.device.gl.bindVertexArray(null))}getConstantBuffer(t,r){let n=Vc(r),i=n.byteLength*t,s=n.length*t;if(this.buffer&&i!==this.buffer.byteLength)throw new Error(`Buffer size is immutable, byte length ${i} !== ${this.buffer.byteLength}.`);let o=!this.buffer;if(this.buffer=this.buffer||this.device.createBuffer({byteLength:i}),o||=!Gc(n,this.bufferValue),o){let a=(0,Yt.getScratchArray)(r.constructor,s);Js({target:a,source:n,start:0,count:s}),this.buffer.write(a),this.bufferValue=r}return this.buffer}}});function ro(e){return typeof e=="number"?Number.isInteger(e):/^\d+$/.test(e)}var Lr,Cr,no=P(()=>{Lr=I(B(),1);kn();Mn();Cr=class extends Lr.TransformFeedback{device;gl;handle;layout;buffers={};unusedBuffers={};bindOnUse=!0;_bound=!1;constructor(t,r){super(t,r),this.device=t,this.gl=t.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(t="point-list"){this.gl.bindTransformFeedback(36386,this.handle),this.bindOnUse&&this._bindBuffers(),this.gl.beginTransformFeedback(qs(t))}end(){this.gl.endTransformFeedback(),this.bindOnUse&&this._unbindBuffers(),this.gl.bindTransformFeedback(36386,null)}setBuffers(t){this.buffers={},this.unusedBuffers={},this.bind(()=>{for(let[r,n]of Object.entries(t))this.setBuffer(r,n)})}setBuffer(t,r){let n=this._getVaryingIndex(t),{buffer:i,byteLength:s,byteOffset:o}=this._getBufferRange(r);if(n<0){this.unusedBuffers[t]=i,Lr.log.warn(`${this.id} unusedBuffers varying buffer ${t}`)();return}this.buffers[n]={buffer:i,byteLength:s,byteOffset:o},this.bindOnUse||this._bindBuffer(n,i,o,s)}getBuffer(t){if(ro(t))return this.buffers[t]||null;let r=this._getVaryingIndex(t);return this.buffers[r]??null}bind(t=this.handle){if(typeof t!="function")return this.gl.bindTransformFeedback(36386,t),this;let r;return this._bound?r=t():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=t(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(t){if(t instanceof it)return{buffer:t,byteOffset:0,byteLength:t.byteLength};let{buffer:r,byteOffset:n=0,byteLength:i=t.buffer.byteLength}=t;return{buffer:r,byteOffset:n,byteLength:i}}_getVaryingIndex(t){if(ro(t))return Number(t);for(let r of this.layout.varyings||[])if(t===r.name)return r.location;return-1}_bindBuffers(){for(let[t,r]of Object.entries(this.buffers)){let{buffer:n,byteLength:i,byteOffset:s}=this._getBufferRange(r);this._bindBuffer(Number(t),n,s,i)}}_unbindBuffers(){for(let t in this.buffers)this.gl.bindBufferBase(35982,Number(t),null)}_bindBuffer(t,r,n=0,i){let s=r&&r.handle;!s||i===void 0?this.gl.bindBufferBase(35982,t,s):this.gl.bindBufferRange(35982,t,s,n,i)}}});var io,Ar,so=P(()=>{io=I(B(),1),Ar=class extends io.QuerySet{device;handle;_timestampPairs=[];_pendingReads=new Set;_occlusionQuery=null;_occlusionActive=!1;get[Symbol.toStringTag](){return"QuerySet"}constructor(t,r){if(super(t,r),this.device=t,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 n=this.device.gl.createQuery();if(!n)throw new Error("WebGL query not supported");this.handle=n}Object.seal(this)}destroy(){if(!this.destroyed){this.handle&&this.device.gl.deleteQuery(this.handle);for(let t of this._timestampPairs){t.activeQuery&&(this._cancelPendingQuery(t.activeQuery),this.device.gl.deleteQuery(t.activeQuery.handle));for(let r of t.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 t of Array.from(this._pendingReads))this._cancelPendingQuery(t);this.destroyResource()}}isResultAvailable(t){return this.props.type==="timestamp"?t===void 0?this._timestampPairs.some((r,n)=>this._isTimestampPairAvailable(n)):this._isTimestampPairAvailable(this._getTimestampPairIndex(t)):this._occlusionQuery?this._pollQueryAvailability(this._occlusionQuery):!1}async readResults(t){let r=t?.firstQuery||0,n=t?.queryCount||this.props.count-r;if(this._validateRange(r,n),this.props.type==="timestamp"){let i=new Array(n).fill(0n),s=Math.floor(r/2),o=Math.floor((r+n-1)/2);for(let a=s;a<=o;a++){let c=await this._consumeTimestampPairResult(a),l=a*2,h=l+1;l>=r&&l<r+n&&(i[l-r]=0n),h>=r&&h<r+n&&(i[h-r]=c)}return i}if(!this._occlusionQuery)throw new Error("Occlusion query has not been started");return[await this._consumeQueryResult(this._occlusionQuery)]}async readTimestampDuration(t,r){if(this.props.type!=="timestamp")throw new Error("Timestamp durations require a timestamp QuerySet");if(t<0||r>=this.props.count||r<=t)throw new Error("Timestamp duration range is out of bounds");if(t%2!==0||r!==t+1)throw new Error("WebGL timestamp durations require adjacent even/odd query indices");let n=await this._consumeTimestampPairResult(this._getTimestampPairIndex(t));return Number(n)/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(t){if(this.props.type!=="timestamp")throw new Error("Timestamp writes require a timestamp QuerySet");let r=this._getTimestampPairIndex(t),n=this._timestampPairs[r];if(t%2===0){if(n.activeQuery)throw new Error("Timestamp query pair is already active");let i=this.device.gl.createQuery();if(!i)throw new Error("WebGL query not supported");let s={handle:i,promise:null,result:null,disjoint:!1,cancelled:!1,pollRequestId:null,resolve:null,reject:null};this.device.gl.beginQuery(35007,i),n.activeQuery=s;return}if(!n.activeQuery)throw new Error("Timestamp query pair was ended before it was started");this.device.gl.endQuery(35007),n.completedQueries.push(n.activeQuery),n.activeQuery=null}_validateRange(t,r){if(t<0||r<0||t+r>this.props.count)throw new Error("Query read range is out of bounds")}_getTimestampPairIndex(t){if(t<0||t>=this.props.count)throw new Error("Query index is out of bounds");return Math.floor(t/2)}_isTimestampPairAvailable(t){let r=this._timestampPairs[t];return!r||r.completedQueries.length===0?!1:this._pollQueryAvailability(r.completedQueries[0])}_pollQueryAvailability(t){if(t.cancelled||this.destroyed)return t.result=0n,!0;if(t.result!==null||t.disjoint)return!0;if(!this.device.gl.getQueryParameter(t.handle,34919))return!1;let n=!!this.device.gl.getParameter(36795);return t.disjoint=n,t.result=n?0n:BigInt(this.device.gl.getQueryParameter(t.handle,34918)),!0}async _consumeTimestampPairResult(t){let r=this._timestampPairs[t];if(!r||r.completedQueries.length===0)throw new Error("Timestamp query pair has no completed result");let n=r.completedQueries.shift();try{return await this._consumeQueryResult(n)}finally{this.device.gl.deleteQuery(n.handle)}}_consumeQueryResult(t){return t.promise||(this._pendingReads.add(t),t.promise=new Promise((r,n)=>{t.resolve=r,t.reject=n;let i=()=>{if(t.pollRequestId=null,t.cancelled||this.destroyed){this._pendingReads.delete(t),t.promise=null,t.resolve=null,t.reject=null,r(0n);return}if(!this._pollQueryAvailability(t)){t.pollRequestId=this._requestAnimationFrame(i);return}this._pendingReads.delete(t),t.promise=null,t.resolve=null,t.reject=null,t.disjoint?n(new Error("GPU timestamp query was invalidated by a disjoint event")):r(t.result||0n)};i()})),t.promise}_cancelPendingQuery(t){if(this._pendingReads.delete(t),t.cancelled=!0,t.pollRequestId!==null&&(this._cancelAnimationFrame(t.pollRequestId),t.pollRequestId=null),t.resolve){let r=t.resolve;t.promise=null,t.resolve=null,t.reject=null,r(0n)}}_requestAnimationFrame(t){return requestAnimationFrame(t)}_cancelAnimationFrame(t){cancelAnimationFrame(t)}}});var oo,Rr,ao=P(()=>{oo=I(B(),1),Rr=class extends oo.Fence{device;gl;handle;signaled;_signaled=!1;constructor(t,r={}){super(t,{}),this.device=t,this.gl=t.gl;let n=this.props.handle||this.gl.fenceSync(this.gl.SYNC_GPU_COMMANDS_COMPLETE,0);if(!n)throw new Error("Failed to create WebGL fence");this.handle=n,this.signaled=new Promise(i=>{let s=()=>{let o=this.gl.clientWaitSync(this.handle,0,0);o===this.gl.ALREADY_SIGNALED||o===this.gl.CONDITION_SATISFIED?(this._signaled=!0,i()):setTimeout(s,1)};s()})}isSignaled(){if(this._signaled)return!0;let t=this.gl.getSyncParameter(this.handle,this.gl.SYNC_STATUS);return this._signaled=t===this.gl.SIGNALED,this._signaled}destroy(){this.destroyed||this.gl.deleteSync(this.handle)}}});function In(e){switch(e){case 6406:case 33326:case 6403:case 36244:return 1;case 33339:case 33340:case 33328:case 33320:case 33319:return 2;case 6407:case 36248:case 34837:return 3;case 6408:case 36249:case 34836:return 4;default:return 0}}function co(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return 0}}var lo=P(()=>{});function ho(e,t){let{sourceX:r=0,sourceY:n=0,sourceAttachment:i=0}=t||{},{target:s=null,sourceWidth:o,sourceHeight:a,sourceDepth:c,sourceFormat:l,sourceType:h}=t||{},{framebuffer:u,deleteFramebuffer:f}=fo(e),{gl:d,handle:p}=u;o||=u.width,a||=u.height;let g=u.colorAttachments[i]?.texture;if(!g)throw new Error(`Invalid framebuffer attachment ${i}`);c=g?.depth||1,l||=g?.glFormat||6408,h||=g?.glType||5121,s=Wc(s,h,l,o,a,c);let m=we.dataTypeDecoder.getDataType(s);h=h||ks(m);let x=d.bindFramebuffer(36160,p);return d.readBuffer(36064+i),d.readPixels(r,n,o,a,l,h,s),d.readBuffer(36064),d.bindFramebuffer(36160,x||null),f&&u.destroy(),s}function uo(e,t){let{target:r,sourceX:n=0,sourceY:i=0,sourceFormat:s=6408,targetByteOffset:o=0}=t||{},{sourceWidth:a,sourceHeight:c,sourceType:l}=t||{},{framebuffer:h,deleteFramebuffer:u}=fo(e);a=a||h.width,c=c||h.height;let f=h;l=l||5121;let d=r;if(!d){let g=In(s),m=co(l),x=o+a*c*g*m;d=f.device.createBuffer({byteLength:x})}let p=e.device.createCommandEncoder();return p.copyTextureToBuffer({sourceTexture:e,width:a,height:c,origin:[n,i],destinationBuffer:d,byteOffset:o}),p.destroy(),u&&h.destroy(),d}function fo(e){return e instanceof we.Framebuffer?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:zc(e),deleteFramebuffer:!0}}function zc(e,t){let{device:r,width:n,height:i,id:s}=e;return r.createFramebuffer({...t,id:`framebuffer-for-${s}`,width:n,height:i,colorAttachments:[e]})}function Wc(e,t,r,n,i,s){if(e)return e;t||=5121;let o=pr(t),a=we.dataTypeDecoder.getTypedArrayConstructor(o),c=In(r);return new a(n*i*c)}var we,mo=P(()=>{we=I(B(),1);yr();lo();Sn()});function Uc(e,t,r){switch(r.length){case 1:e.gl.vertexAttrib1fv(t,r);break;case 2:e.gl.vertexAttrib2fv(t,r);break;case 3:e.gl.vertexAttrib3fv(t,r);break;case 4:e.gl.vertexAttrib4fv(t,r);break;default:}}function $c(e,t,r){e.gl.vertexAttribI4iv(t,r)}function Yc(e,t,r){e.gl.vertexAttribI4uiv(t,r)}function jc(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}var ot,Ee,po=P(()=>{ot=I(B(),1);ln();es();hn();is();fs();ms();bs();ys();Ui();$t();Es();or();vs();Ls();gr();nr();zs();Us();Hs();eo();no();so();ao();mo();zt();dr();fe();Ee=class e extends ot.Device{static getDeviceFromContext(t){return t?t.luma?.device??null:null}type="webgl";handle;features;limits;info;canvasContext;preferredColorFormat="rgba8unorm";preferredDepthFormat="depth24plus";commandEncoder;lost;_resolveContextLost;_isLost=!1;gl;_constants;extensions;_polyfilled=!1;spectorJS;get[Symbol.toStringTag](){return"WebGLDevice"}toString(){return`${this[Symbol.toStringTag]}(${this.id})`}isVertexFormatSupported(t){return t!=="unorm8x4-bgra"}constructor(t){super({...t,id:t.id||ws("webgl-device")});let r=ot.Device._getCanvasContextProps(t);if(!r)throw new Error("WebGLDevice requires props.createCanvasContext to be set");let n=r.canvas?.gl??null,i=e.getDeviceFromContext(n);if(i)throw new Error(`WebGL context already attached to device ${i.id}`);this.canvasContext=new ir(this,r),this.lost=new Promise(h=>{this._resolveContextLost=h});let s={...t.webgl};r.alphaMode==="premultiplied"&&(s.premultipliedAlpha=!0),t.powerPreference!==void 0&&(s.powerPreference=t.powerPreference),t.failIfMajorPerformanceCaveat!==void 0&&(s.failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat);let a=this.props._handle||ts(this.canvasContext.canvas,{onContextLost:h=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."}),onContextRestored:h=>{console.log("WebGL context restored")}},s);if(!a)throw new Error("WebGL context creation failed");if(i=e.getDeviceFromContext(a),i){if(t._reuseDevices)return ot.log.log(1,`Not creating a new Device, instead returning a reference to Device ${i.id} already attached to WebGL context`,i)(),this.canvasContext.destroy(),i._reused=!0,i;throw new Error(`WebGL context already attached to device ${i.id}`)}this.handle=a,this.gl=a,this.spectorJS=Wi({...this.props,gl:this.handle});let c=ue(this.handle);c.device=this,c.extensions||(c.extensions={}),this.extensions=c.extensions,this.info=rs(this.gl,this.extensions),this.limits=new rr(this.gl),this.features=new tr(this.gl,this.extensions,this.props._disabledFeatures),this.props._initializeFeatures&&this.features.initializeFeatures(),new rt(this.gl,{log:(...h)=>ot.log.log(1,...h)()}).trackState(this.gl,{copyState:!1}),(t.debug||t.debugWebGL)&&(this.gl=zi(this.gl,{debugWebGL:!0,traceWebGL:t.debugWebGL}),ot.log.warn("WebGL debug mode activated. Performance reduced.")()),t.debugWebGL&&(ot.log.level=Math.max(ot.log.level,1)),this.commandEncoder=new xe(this,{id:`${this}-command-encoder`}),this.canvasContext._startObservers()}destroy(){if(!this.props._reuseDevices&&!this._reused){this._isLost=!0,this.commandEncoder?.destroy();let t=ue(this.handle);t.device=null}}get isLost(){return this._isLost||this.gl.isContextLost()}createCanvasContext(t){throw new Error("WebGL only supports a single canvas")}createPresentationContext(t){return new sr(this,t||{})}createBuffer(t){let r=this._normalizeBufferProps(t);return new it(this,r)}createTexture(t){return new pt(this,t)}createExternalTexture(t){throw new Error("ExternalTexture is not available on WebGL")}createSampler(t){return new fr(this,t)}createShader(t){return new cr(this,t)}createFramebuffer(t){return new dt(this,t)}createVertexArray(t){return new Pr(this,t)}createTransformFeedback(t){return new Cr(this,t)}createQuerySet(t){return new Ar(this,t)}createFence(){return new Rr(this)}createRenderPipeline(t){return new wr(this,t)}_createSharedRenderPipelineWebGL(t){return new Er(this,t)}createComputePipeline(t){throw new Error("ComputePipeline not supported in WebGL")}createRenderBundleEncoder(t){throw new Error("Render bundles are only supported in WebGPU")}createCommandEncoder(t={}){return new xe(this,t)}submit(t){let r=null;t||({submittedCommandEncoder:r,commandBuffer:t}=this._finalizeDefaultCommandEncoderForSubmit());try{t._executeCommands(),r&&r.resolveTimeProfilingQuerySet().then(()=>{this.commandEncoder._gpuTimeMs=r._gpuTimeMs}).catch(()=>{})}finally{t.destroy()}}writeBufferViaCommandEncoder(t,r,n,i=0){r.write(n,i)}_finalizeDefaultCommandEncoderForSubmit(){let t=this.commandEncoder,r=t.finish();return this.commandEncoder.destroy(),this.commandEncoder=this.createCommandEncoder({id:t.props.id,timeProfilingQuerySet:t.getTimeProfilingQuerySet()}),{submittedCommandEncoder:t,commandBuffer:r}}readPixelsToArrayWebGL(t,r){return ho(t,r)}readPixelsToBufferWebGL(t,r){return uo(t,r)}setParametersWebGL(t){et(this.gl,t)}getParametersWebGL(t){return Xe(this.gl,t)}withParametersWebGL(t,r){return st(this.gl,t,r)}resetWebGL(){ot.log.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),Zi(this.gl)}_getDeviceSpecificTextureFormatCapabilities(t){return ls(this.gl,t,this.extensions)}loseDevice(){let t=!1,n=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return n&&(t=!0,n.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),t}pushState(){rt.get(this.gl).push()}popState(){rt.get(this.gl).pop()}getGLKey(t,r){let n=Number(t);for(let i in this.gl)if(this.gl[i]===n)return`GL.${i}`;return r?.emptyIfUnknown?"":String(t)}getGLKeys(t){let r={emptyIfUnknown:!0};return Object.entries(t).reduce((n,[i,s])=>(n[`${i}:${this.getGLKey(i,r)}`]=`${s}:${this.getGLKey(s,r)}`,n),{})}setConstantAttributeWebGL(t,r){let n=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(n).fill(null);let i=this._constants[t];switch(i&&jc(i,r)&&ot.log.info(1,`setConstantAttributeWebGL(${t}) could have been skipped, value unchanged`)(),this._constants[t]=r,r.constructor){case Float32Array:Uc(this,t,r);break;case Int32Array:$c(this,t,r);break;case Uint32Array:Yc(this,t,r);break;default:throw new Error("constant")}}getExtension(t){return nt(this.gl,t,this.extensions),this.extensions}_setWebGLDebugMetadata(t,r,n){t.luma=r;let i={props:n.spector,id:n.spector.id};t.__SPECTOR_Metadata=i}}});var kn=P(()=>{po();or()});var Aa=je((en,La)=>{(function(e,t){typeof en=="object"&&typeof La<"u"?t(en):typeof define=="function"&&define.amd?define(["exports"],t):t(e.esriLoader=e.esriLoader||{})})(en,(function(e){"use strict";var t=typeof window<"u",r={Promise:t?window.Promise:void 0},n="4.25",i="next";function s(y){if(y.toLowerCase()===i)return i;var T=y&&y.match(/^(\d)\.(\d+)/);return T&&{major:parseInt(T[1],10),minor:parseInt(T[2],10)}}function o(y){return y===void 0&&(y=n),"https://js.arcgis.com/".concat(y,"/")}function a(y){y===void 0&&(y=n);var T=o(y),M=s(y);if(M!==i&&M.major===3){var S=M.minor<=10?"js/":"";return"".concat(T).concat(S,"esri/css/esri.css")}else return"".concat(T,"esri/themes/light/main.css")}function c(y){var T=document.createElement("link");return T.rel="stylesheet",T.href=y,T}function l(y,T){if(T){var M=document.querySelector(T);M.parentNode.insertBefore(y,M)}else document.head.appendChild(y)}function h(y){return document.querySelector('link[href*="'.concat(y,'"]'))}function u(y){return!y||s(y)?a(y):y}function f(y,T){var M=u(y),S=h(M);return S||(S=c(M),l(S,T)),S}var d={};function p(y){var T=document.createElement("script");return T.type="text/javascript",T.src=y,T.setAttribute("data-esri-loader","loading"),T}function g(y,T,M){var S;M&&(S=m(y,M));var C=function(){T(y),y.removeEventListener("load",C,!1),S&&y.removeEventListener("error",S,!1)};y.addEventListener("load",C,!1)}function m(y,T){var M=function(S){T(S.error||new Error("There was an error attempting to load ".concat(y.src))),y.removeEventListener("error",M,!1)};return y.addEventListener("error",M,!1),M}function x(y){y===void 0&&(y={}),d=y}function _(){return document.querySelector("script[data-esri-loader]")}function b(){var y=window.require;return y&&y.on}function w(y){y===void 0&&(y={});var T={};[d,y].forEach(function(C){for(var L in C)Object.prototype.hasOwnProperty.call(C,L)&&(T[L]=C[L])});var M=T.version,S=T.url||o(M);return new r.Promise(function(C,L){var R=_();if(R){var A=R.getAttribute("src");A!==S?L(new Error("The ArcGIS API for JavaScript is already loaded (".concat(A,")."))):b()?C(R):g(R,C,L)}else if(b())L(new Error("The ArcGIS API for JavaScript is already loaded."));else{var D=T.css;if(D){var ht=D===!0;f(ht?M:D,T.insertCssBefore)}R=p(S),g(R,function(){R.setAttribute("data-esri-loader","loaded"),C(R)},L),document.body.appendChild(R)}})}function v(y){return new r.Promise(function(T,M){var S=window.require.on("error",M);window.require(y,function(){for(var C=[],L=0;L<arguments.length;L++)C[L]=arguments[L];S.remove(),T(C)})})}function E(y,T){if(T===void 0&&(T={}),b())return v(y);var M=_(),S=M&&M.getAttribute("src");return!T.url&&S&&(T.url=S),w(T).then(function(){return v(y)})}e.utils=r,e.loadModules=E,e.getScript=_,e.isLoaded=b,e.loadScript=w,e.setDefaultOptions=x,e.loadCss=f,Object.defineProperty(e,"__esModule",{value:!0})}))});var We={};ce(We,{loadArcGISModules:()=>Cf});var ut={},Ii=I(qe(),1);St(ut,I(qe(),1));if(!Ii.Layer)throw new Error("@deck.gl/core is not found");St(We,ut);var Bi={layers:{},layerFilter:{},parameters:{},effects:{},pickingRadius:{},onBeforeRender:{},onAfterRender:{},onClick:{},onHover:{},onDragStart:{},onDrag:{},onDragEnd:{},onError:{},debug:{},drawPickingColors:{},getCursor:{},getTooltip:{}};function rn(e){return e.createSubclass({properties:Bi,constructor(){this._callbacks={},this.watch(Object.keys(Bi),(r,n,i)=>{this.emit("change",{[i]:r})})},on(r,n){this._callbacks[r]=this._callbacks[r]||[],this._callbacks[r].push(n)},emit(r,n){let i=this._callbacks[r];if(i)for(let s of i)s(n)},toJSON(){let r={};for(let n of this.keys())this[n]!==void 0&&(r[n]=this[n]);return r}})}function nn(e,t,r){return t.createSubclass({properties:{deck:{},blendMode:{},effect:{}},constructor(){this.deck=new e},createLayerView(n){return n.type==="2d"?new r({view:n,layer:this}):(console.error("DeckLayer does not support SceneView at the moment. Use DeckRenderer instead."),null)}})}var go=I(qe(),1),kr=I(Fi(),1);kn();async function qc(e){return new Promise(t=>{let r=new go.Deck({controller:!1,gl:e,parameters:{depthCompare:"less-equal"},width:null,height:null,onDeviceInitialized:n=>{t({deckInstance:r,device:n})}})})}async function Ir(e){let{deckInstance:t,device:r}=await qc(e),n=r.createTexture({format:"rgba8unorm",width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),i=new kr.Model(r,{vs:`#version 300 es
|
|
10
10
|
in vec2 pos;
|
|
11
11
|
out vec2 v_texcoord;
|
|
12
12
|
void main(void) {
|
|
@@ -26,6 +26,6 @@ void main(void) {
|
|
|
26
26
|
// input correctly; multiplying again here would darken overlays.
|
|
27
27
|
fragColor = imageColor;
|
|
28
28
|
}
|
|
29
|
-
`,bindings:{deckglTexture:n},parameters:{depthWriteEnabled:!1,depthCompare:"always",blendColorSrcFactor:"one",blendColorDstFactor:"one-minus-src-alpha",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",blendColorOperation:"add",blendAlphaOperation:"add"},geometry:new Br.Geometry({topology:"triangle-strip",attributes:{pos:{size:2,value:new Int8Array([-1,-1,1,-1,-1,1,-1,1,1,1,1,-1])}}}),vertexCount:6,disableWarnings:!0}),s=r.createFramebuffer({id:"deckfbo",width:1,height:1,colorAttachments:[n],depthStencilAttachment:"depth16unorm"});return t.setProps({_framebuffer:s,_customRender:o=>{if(o==="arcgis"){let a=r.gl;a.blendFuncSeparate(a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA),t._drawLayers(o)}else this.redraw()}}),{deck:t,texture:n,fbo:s,model:i}}function Pe(e,t){let{model:r,deck:n,fbo:i}=e,s=r.device;if(s instanceof Me){let o=s.getParametersWebGL(36006),{width:a,height:c,views:l,viewState:h,...u}=t,f=window.devicePixelRatio,d=Math.round(a*f),p=Math.round(c*f);i.resize({width:d,height:p});let g=i.colorAttachments[0].texture??i.colorAttachments[0];g!==e.texture&&(e.texture=g,r.setBindings({deckglTexture:g}));let m={width:a,height:c,viewState:h||u};l&&(m.views=l),n.setProps(m),n.redraw("arcgis");let{gl:b}=s;o?(b.bindFramebuffer(36160,o),b.drawBuffers([36064])):b.drawBuffers([1029]),b.enable(3042),b.blendFuncSeparate(1,771,1,771),b.blendEquationSeparate(32774,32774);let _={handle:o,width:d,height:p,colorAttachments:[null]},y=s.beginRenderPass({framebuffer:_,parameters:{viewport:[0,0,d,p]},clearColor:!1,clearDepth:!1});try{r.draw(y)}finally{y.end()}}}function Ht(e){e.deck.finalize(),e.model.destroy(),e.fbo.destroy(),e.texture.destroy()}function On(e){return e.createSubclass({properties:{cancelInitialization:null,resources:null},async attach(){let t=this.context,r=!1;this.cancelInitialization=()=>r=!0;let n=await Fr.call(this,t);if(r){Ht(n);return}this.resources=n,this.layer.deck.on("change",i=>n.deck.setProps(i)),n.deck.setProps(this.layer.deck.toJSON())},redraw(){this.requestRender()},detach(){this.cancelInitialization?.(),this.resources&&(Ht(this.resources),this.resources=null)},render(t){if(!this.resources)return;let[r,n]=this.view.state.size,i=t.state;Pe(this.resources,{width:r,height:n,latitude:this.view.center.latitude,longitude:this.view.center.longitude,zoom:this.view.featuresTilingScheme.scaleToLevel(i.scale),bearing:-i.rotation,pitch:0})}})}var $c=/^(?:\d+\.?\d*|\.\d+)$/;function $(e){switch(typeof e){case"number":if(!Number.isFinite(e))throw new Error(`Could not parse position string ${e}`);return{type:"literal",value:e};case"string":try{let t=jc(e);return new Vn(t).parseExpression()}catch(t){let r=t instanceof Error?t.message:String(t);throw new Error(`Could not parse position string ${e}: ${r}`)}default:throw new Error(`Could not parse position string ${e}`)}}function Nn(e,t){switch(e.type){case"literal":return e.value;case"percentage":return Math.round(e.value*t);case"binary":let r=Nn(e.left,t),n=Nn(e.right,t);return e.operator==="+"?r+n:r-n;default:throw new Error("Unknown layout expression type")}}function j(e,t){return Nn(e,t)}function jc(e){let t=[],r=0;for(;r<e.length;){let n=e[r];if(/\s/.test(n)){r++;continue}if(n==="+"||n==="-"||n==="("||n===")"||n==="%"){t.push({type:"symbol",value:n}),r++;continue}if(yo(n)||n==="."){let i=r,s=n===".";for(r++;r<e.length;){let a=e[r];if(yo(a)){r++;continue}if(a==="."&&!s){s=!0,r++;continue}break}let o=e.slice(i,r);if(!$c.test(o))throw new Error("Invalid number token");t.push({type:"number",value:parseFloat(o)});continue}if(wo(n)){let i=r;for(;r<e.length&&wo(e[r]);)r++;let s=e.slice(i,r).toLowerCase();t.push({type:"word",value:s});continue}throw new Error("Invalid token in position string")}return t}var Vn=class{constructor(t){this.index=0;this.tokens=t}parseExpression(){let t=this.parseBinaryExpression();if(this.index<this.tokens.length)throw new Error("Unexpected token at end of expression");return t}parseBinaryExpression(){let t=this.parseFactor(),r=this.peek();for(;qc(r);){this.index++;let n=this.parseFactor();t={type:"binary",operator:r.value,left:t,right:n},r=this.peek()}return t}parseFactor(){let t=this.peek();if(!t)throw new Error("Unexpected end of expression");if(t.type==="symbol"&&t.value==="+")return this.index++,this.parseFactor();if(t.type==="symbol"&&t.value==="-"){this.index++;let r=this.parseFactor();return{type:"binary",operator:"-",left:{type:"literal",value:0},right:r}}if(t.type==="symbol"&&t.value==="("){this.index++;let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(t.type==="word"&&t.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(t.type==="number"){this.index++;let r=t.value,n=this.peek();return n&&n.type==="symbol"&&n.value==="%"?(this.index++,{type:"percentage",value:r/100}):n&&n.type==="word"&&n.value==="px"?(this.index++,{type:"literal",value:r}):{type:"literal",value:r}}throw new Error("Unexpected token in expression")}consumeSymbol(t){let r=this.peek();return r&&r.type==="symbol"&&r.value===t?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}};function yo(e){return e>="0"&&e<="9"}function wo(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}function qc(e){return!!(e&&e.type==="symbol"&&(e.value==="+"||e.value==="-"))}function Bt(e,t,r){if(e===t)return!0;if(!r||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Bt(e[n],t[n],r-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof e=="object"&&typeof t=="object"){let n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(let s of n)if(!t.hasOwnProperty(s)||!Bt(e[s],t[s],r-1))return!1;return!0}return!1}function Eo(e,t){let r={...e};for(let n in t)n!=="id"&&(Array.isArray(r[n])&&Array.isArray(t[n])?r[n]=Xc(r[n],t[n]):r[n]=t[n]);return r}function Xc(e,t){e=e.slice();for(let r=0;r<t.length;r++){let n=t[r];Number.isFinite(n)&&(e[r]=n)}return e}var Ce=class{constructor(t){let{id:r,x:n=0,y:i=0,width:s="100%",height:o="100%",padding:a=null}=t;this.id=r||this.constructor.displayName||"view",this.props={...t,id:this.id},this._x=$(n),this._y=$(i),this._width=$(s),this._height=$(o),this._padding=a&&{left:$(a.left||0),right:$(a.right||0),top:$(a.top||0),bottom:$(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(t){return this===t?!0:this.constructor===t.constructor&&Bt(this.props,t.props,2)}clone(t){let r=this.constructor;return new r({...this.props,...t})}makeViewport({width:t,height:r,viewState:n}){n=this.filterViewState(n);let i=this.getDimensions({width:t,height:r});if(!i.height||!i.width)return null;let s=this.getViewportType(n);return new s({...n,...this.props,...i})}getViewStateId(){let{viewState:t}=this.props;return typeof t=="string"?t:t?.id||this.id}filterViewState(t){return this.props.viewState&&typeof this.props.viewState=="object"?this.props.viewState.id?Eo(t,this.props.viewState):this.props.viewState:t}getDimensions({width:t,height:r}){let n={x:j(this._x,t),y:j(this._y,r),width:j(this._width,t),height:j(this._height,r)};return this._padding&&(n.padding={left:j(this._padding.left,t),top:j(this._padding.top,r),right:j(this._padding.right,t),bottom:j(this._padding.bottom,r)}),n}get controller(){let t=this.props.controller;return t?t===!0?{type:this.ControllerType}:typeof t=="function"?{type:t}:{type:this.ControllerType,...t}:null}};ve();function Qt(e,t){if(!e)throw new Error(t||"Assertion failed")}function Gn(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return Qt(Number.isFinite(t)&&t>=0),t}function To(e){let{logLevel:t,message:r}=e;e.logLevel=Gn(t);let n=e.args?Array.from(e.args):[];for(;n.length&&n.shift()!==r;);switch(typeof t){case"string":case"function":r!==void 0&&n.unshift(r),e.message=t;break;case"object":Object.assign(e,t);break;default:}typeof e.message=="function"&&(e.message=e.message());let i=typeof e.message;return Qt(i==="string"||i==="object"),Object.assign(e,{args:n},e.opts)}var Ft=()=>{},Or=class{constructor({level:t=0}={}){this.userData={},this._onceCache=new Set,this._level=t}set level(t){this.setLevel(t)}get level(){return this.getLevel()}setLevel(t){return this._level=t,this}getLevel(){return this._level}warn(t,...r){return this._log("warn",0,t,r,{once:!0})}error(t,...r){return this._log("error",0,t,r)}log(t,r,...n){return this._log("log",t,r,n)}info(t,r,...n){return this._log("info",t,r,n)}once(t,r,...n){return this._log("once",t,r,n,{once:!0})}_log(t,r,n,i,s={}){let o=To({logLevel:r,message:n,args:this._buildArgs(r,n,i),opts:s});return this._createLogFunction(t,o,s)}_buildArgs(t,r,n){return[t,r,...n]}_createLogFunction(t,r,n){if(!this._shouldLog(r.logLevel))return Ft;let i=this._getOnceTag(n.tag??r.tag??r.message);if((n.once||r.once)&&i!==void 0){if(this._onceCache.has(i))return Ft;this._onceCache.add(i)}return this._emit(t,r)}_shouldLog(t){return this.getLevel()>=Gn(t)}_getOnceTag(t){if(t!==void 0)try{return typeof t=="string"?t:String(t)}catch{return}}};function Zc(e){try{let t=window[e],r="__storage_test__";return t.setItem(r,r),t.removeItem(r),t}catch{return null}}var Nr=class{constructor(t,r,n="sessionStorage"){this.storage=Zc(n),this.id=t,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let t={};if(this.storage){let r=this.storage.getItem(this.id);t=r?JSON.parse(r):{}}return Object.assign(this.config,t),this}};function _o(e){let t;return e<10?t=`${e.toFixed(2)}ms`:e<100?t=`${e.toFixed(1)}ms`:e<1e3?t=`${e.toFixed(0)}ms`:t=`${(e/1e3).toFixed(2)}s`,t}function vo(e,t=8){let r=Math.max(t-e.length,0);return`${" ".repeat(r)}${e}`}ve();var Vr;(function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Vr||(Vr={}));var Hc=10;function So(e){return typeof e!="string"?e:(e=e.toUpperCase(),Vr[e]||Vr.WHITE)}function Mo(e,t,r){return!Tt&&typeof e=="string"&&(t&&(e=`\x1B[${So(t)}m${e}\x1B[39m`),r&&(e=`\x1B[${So(r)+Hc}m${e}\x1B[49m`)),e}function Po(e,t=["constructor"]){let r=Object.getPrototypeOf(e),n=Object.getOwnPropertyNames(r),i=e;for(let s of n){let o=i[s];typeof o=="function"&&(t.find(a=>s===a)||(i[s]=o.bind(e)))}}ve();function Kt(){let e;if(Tt()&&Pr.performance)e=Pr?.performance?.now?.();else if("hrtime"in Cr){let t=Cr?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var Jt={debug:Tt()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},zn={enabled:!0,level:0},_t=class extends Or{constructor({id:t}={id:""}){super({level:0}),this.VERSION=In,this._startTs=Kt(),this._deltaTs=Kt(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=t,this.userData={},this._storage=new Nr(`__probe-${this.id}__`,{[this.id]:zn}),this.timeStamp(`${this.id} started`),Po(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Kt()-this._startTs).toPrecision(10))}getDelta(){return Number((Kt()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(t=!0){return this._updateConfiguration({enabled:t}),this}setLevel(t){return this._updateConfiguration({level:t}),this}get(t){return this._getConfiguration()[t]}set(t,r){this._updateConfiguration({[t]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,r){if(!t)throw new Error(r||"Assertion failed")}warn(t,...r){return this._log("warn",0,t,r,{method:Jt.warn,once:!0})}error(t,...r){return this._log("error",0,t,r,{method:Jt.error})}deprecated(t,r){return this.warn(`\`${t}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(t,r){return this.error(`\`${t}\` has been removed. Use \`${r}\` instead`)}probe(t,r,...n){return this._log("log",t,r,n,{method:Jt.log,time:!0,once:!0})}log(t,r,...n){return this._log("log",t,r,n,{method:Jt.debug})}info(t,r,...n){return this._log("info",t,r,n,{method:console.info})}once(t,r,...n){return this._log("once",t,r,n,{method:Jt.debug||Jt.info,once:!0})}table(t,r,n){return r?this._log("table",t,r,n&&[n]||[],{method:console.table||Ft,tag:Kc(r)}):Ft}time(t,r){return this._log("time",t,r,[],{method:console.time?console.time:console.info})}timeEnd(t,r){return this._log("time",t,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(t,r){return this._log("time",t,r,[],{method:console.timeStamp||Ft})}group(t,r,n={collapsed:!1}){let i=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",t,r,[],{method:i})}groupCollapsed(t,r,n={}){return this.group(t,r,Object.assign({},n,{collapsed:!0}))}groupEnd(t){return this._log("groupEnd",t,"",[],{method:console.groupEnd||Ft})}withGroup(t,r,n){this.group(t,r)();try{n()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&super._shouldLog(t)}_emit(t,r){let n=r.method;Qt(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Kt();let i=Qc(this.id,r.message,r);return n.bind(console,i,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(zn),this._storage.config[this.id]}_updateConfiguration(t){let r=this._storage.config[this.id]||{...zn};this._storage.setConfiguration({[this.id]:{...r,...t}})}};_t.VERSION=In;function Qc(e,t,r){if(typeof t=="string"){let n=r.time?vo(_o(r.total)):"";t=r.time?`${e}: ${n} ${t}`:`${e}: ${t}`,t=Mo(t,r.color,r.background)}return t}function Kc(e){for(let t in e)for(let r in e[t])return r||"untitled";return"empty"}globalThis.probe={};var Gp=new _t({id:"@probe.gl/log"});var Jc=new _t({id:"deck"}),te=Jc;var jp=1/Math.PI*180,qp=1/180*Math.PI,tl={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...tl}};var G=globalThis.mathgl.config;function Wn(e,{precision:t=G.precision}={}){return e=el(e),`${parseFloat(e.toPrecision(t))}`}function vt(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Y(e,t,r){return nl(e,n=>Math.max(t,Math.min(r,n)))}function Le(e,t,r){return vt(e)?e.map((n,i)=>Le(n,t[i],r)):r*t+(1-r)*e}function St(e,t,r){let n=G.EPSILON;r&&(G.EPSILON=r);try{if(e===t)return!0;if(vt(e)&&vt(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;++i)if(!St(e[i],t[i]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=G.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{G.EPSILON=n}}function el(e){return Math.round(e/G.EPSILON)*G.EPSILON}function rl(e){return e.clone?e.clone():new Array(e.length)}function nl(e,t,r){if(vt(e)){let n=e;r=r||rl(n);for(let i=0;i<r.length&&i<n.length;++i){let s=typeof e=="number"?e:e[i];r[i]=t(s,i,r)}return r}return t(e)}var ee=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=t[n+r];return this.check()}toArray(t=[],r=0){for(let n=0;n<this.ELEMENTS;++n)t[r+n]=this[n];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:vt(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(G)}formatString(t){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+Wn(this[n],t);return`${t.printTypes?this.constructor.name:""}[${r}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!St(this[r],t[r]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==t[r])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,r,n){if(n===void 0)return this.lerp(this,t,r);for(let i=0;i<this.ELEMENTS;++i){let s=t[i],o=typeof r=="number"?r:r[i];this[i]=s+n*(o-s)}return this.check()}min(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(t[r],this[r]);return this.check()}max(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(t[r],this[r]);return this.check()}clamp(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t[n]),r[n]);return this.check()}add(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(t){if(typeof t=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;else for(let r=0;r<this.ELEMENTS&&r<t.length;++r)this[r]*=t[r];return this.check()}multiplyByScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}check(){if(G.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)t=t&&Number.isFinite(this[r]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=t;return this.check()}addScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t),r);return this.check()}get elements(){return this}};function il(e,t){if(e.length!==t)return!1;for(let r=0;r<e.length;++r)if(!Number.isFinite(e[r]))return!1;return!0}function z(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function Gr(e,t,r=""){if(G.debug&&!il(e,t))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return e}function Un(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var zr=class extends ee{get x(){return this[0]}set x(t){this[0]=z(t)}get y(){return this[1]}set y(t){this[1]=z(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*this[r];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let r=0;for(let n=0;n<this.ELEMENTS;++n){let i=this[n]-t[n];r+=i*i}return z(r)}dot(t){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*t[n];return z(r)}normalize(){let t=this.magnitude();if(t!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=t;return this.check()}multiply(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Un(t>=0&&t<this.ELEMENTS,"index is out of range"),z(this[t])}setComponent(t,r){return Un(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=r,this.check()}addVectors(t,r){return this.copy(t).add(r)}subVectors(t,r){return this.copy(t).subtract(r)}multiplyVectors(t,r){return this.copy(t).multiply(r)}addScaledVector(t,r){return this.add(new this.constructor(t).multiplyScalar(r))}};var at={};me(at,{add:()=>ll,angle:()=>Cl,ceil:()=>hl,clone:()=>sl,copy:()=>al,create:()=>Co,cross:()=>El,dist:()=>Ol,distance:()=>ko,div:()=>Fl,divide:()=>Ro,dot:()=>wl,equals:()=>kl,exactEquals:()=>Rl,floor:()=>ul,forEach:()=>Gl,fromValues:()=>ol,inverse:()=>xl,len:()=>Dl,length:()=>Io,lerp:()=>Tl,max:()=>dl,min:()=>fl,mul:()=>Bl,multiply:()=>Ao,negate:()=>bl,normalize:()=>yl,random:()=>_l,rotate:()=>Pl,round:()=>ml,scale:()=>pl,scaleAndAdd:()=>gl,set:()=>cl,sqrDist:()=>Nl,sqrLen:()=>Vl,squaredDistance:()=>Do,squaredLength:()=>Bo,str:()=>Al,sub:()=>Il,subtract:()=>Lo,transformMat2:()=>vl,transformMat2d:()=>Sl,transformMat3:()=>Ml,transformMat4:()=>Yn,zero:()=>Ll});var O=typeof Float32Array<"u"?Float32Array:Array,xt=Math.random;function K(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var ig=Math.PI/180;function Co(){let e=new O(2);return O!=Float32Array&&(e[0]=0,e[1]=0),e}function sl(e){let t=new O(2);return t[0]=e[0],t[1]=e[1],t}function ol(e,t){let r=new O(2);return r[0]=e,r[1]=t,r}function al(e,t){return e[0]=t[0],e[1]=t[1],e}function cl(e,t,r){return e[0]=t,e[1]=r,e}function ll(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function Lo(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function Ao(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function Ro(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function hl(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e}function ul(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e}function fl(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e}function dl(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e}function ml(e,t){return e[0]=K(t[0]),e[1]=K(t[1]),e}function pl(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function gl(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e}function ko(e,t){let r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function Do(e,t){let r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n}function Io(e){let t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function Bo(e){let t=e[0],r=e[1];return t*t+r*r}function bl(e,t){return e[0]=-t[0],e[1]=-t[1],e}function xl(e,t){return e[0]=1/t[0],e[1]=1/t[1],e}function yl(e,t){let r=t[0],n=t[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e}function wl(e,t){return e[0]*t[0]+e[1]*t[1]}function El(e,t,r){let n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e}function Tl(e,t,r,n){let i=t[0],s=t[1];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e}function _l(e,t){t=t===void 0?1:t;let r=xt()*2*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e}function vl(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e}function Sl(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e}function Ml(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e}function Yn(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e}function Pl(e,t,r,n){let i=t[0]-r[0],s=t[1]-r[1],o=Math.sin(n),a=Math.cos(n);return e[0]=i*a-s*o+r[0],e[1]=i*o+s*a+r[1],e}function Cl(e,t){let r=e[0],n=e[1],i=t[0],s=t[1],o=Math.sqrt((r*r+n*n)*(i*i+s*s)),a=o&&(r*i+n*s)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function Ll(e){return e[0]=0,e[1]=0,e}function Al(e){return`vec2(${e[0]}, ${e[1]})`}function Rl(e,t){return e[0]===t[0]&&e[1]===t[1]}function kl(e,t){let r=e[0],n=e[1],i=t[0],s=t[1];return Math.abs(r-i)<=1e-6*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-s)<=1e-6*Math.max(1,Math.abs(n),Math.abs(s))}var Dl=Io,Il=Lo,Bl=Ao,Fl=Ro,Ol=ko,Nl=Do,Vl=Bo,Gl=(function(){let e=Co();return function(t,r,n,i,s,o){let a,c;for(r||(r=2),n||(n=0),i?c=Math.min(i*r+n,t.length):c=t.length,a=n;a<c;a+=r)e[0]=t[a],e[1]=t[a+1],s(e,e,o),t[a]=e[0],t[a+1]=e[1];return t}})();function Fo(e,t,r){let n=t[0],i=t[1],s=r[3]*n+r[7]*i||1;return e[0]=(r[0]*n+r[4]*i)/s,e[1]=(r[1]*n+r[5]*i)/s,e}function Ur(e,t,r){let n=t[0],i=t[1],s=t[2],o=r[3]*n+r[7]*i+r[11]*s||1;return e[0]=(r[0]*n+r[4]*i+r[8]*s)/o,e[1]=(r[1]*n+r[5]*i+r[9]*s)/o,e[2]=(r[2]*n+r[6]*i+r[10]*s)/o,e}function Oo(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e[2]=t[2],e}var ct={};me(ct,{add:()=>$l,angle:()=>Kn,bezier:()=>sh,ceil:()=>jl,clone:()=>zl,copy:()=>Ul,create:()=>No,cross:()=>jn,dist:()=>mh,distance:()=>Uo,div:()=>dh,divide:()=>Wo,dot:()=>$n,equals:()=>hh,exactEquals:()=>lh,floor:()=>ql,forEach:()=>xh,fromValues:()=>Wl,hermite:()=>ih,inverse:()=>th,len:()=>gh,length:()=>Vo,lerp:()=>rh,max:()=>Zl,min:()=>Xl,mul:()=>fh,multiply:()=>zo,negate:()=>Jl,normalize:()=>eh,random:()=>oh,rotateX:()=>Zn,rotateY:()=>Hn,rotateZ:()=>Qn,round:()=>Hl,scale:()=>Ql,scaleAndAdd:()=>Kl,set:()=>Yl,slerp:()=>nh,sqrDist:()=>ph,sqrLen:()=>bh,squaredDistance:()=>Yo,squaredLength:()=>$o,str:()=>ch,sub:()=>uh,subtract:()=>Go,transformMat3:()=>qn,transformMat4:()=>Ae,transformQuat:()=>Xn,zero:()=>ah});function No(){let e=new O(3);return O!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function zl(e){let t=new O(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Vo(e){let t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function Wl(e,t,r){let n=new O(3);return n[0]=e,n[1]=t,n[2]=r,n}function Ul(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Yl(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function $l(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function Go(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function zo(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function Wo(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function jl(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function ql(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function Xl(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function Zl(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function Hl(e,t){return e[0]=K(t[0]),e[1]=K(t[1]),e[2]=K(t[2]),e}function Ql(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function Kl(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e}function Uo(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)}function Yo(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i}function $o(e){let t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function Jl(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function th(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function eh(e,t){let r=t[0],n=t[1],i=t[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function $n(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function jn(e,t,r){let n=t[0],i=t[1],s=t[2],o=r[0],a=r[1],c=r[2];return e[0]=i*c-s*a,e[1]=s*o-n*c,e[2]=n*a-i*o,e}function rh(e,t,r,n){let i=t[0],s=t[1],o=t[2];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=o+n*(r[2]-o),e}function nh(e,t,r,n){let i=Math.acos(Math.min(Math.max($n(t,r),-1),1)),s=Math.sin(i),o=Math.sin((1-n)*i)/s,a=Math.sin(n*i)/s;return e[0]=o*t[0]+a*r[0],e[1]=o*t[1]+a*r[1],e[2]=o*t[2]+a*r[2],e}function ih(e,t,r,n,i,s){let o=s*s,a=o*(2*s-3)+1,c=o*(s-2)+s,l=o*(s-1),h=o*(3-2*s);return e[0]=t[0]*a+r[0]*c+n[0]*l+i[0]*h,e[1]=t[1]*a+r[1]*c+n[1]*l+i[1]*h,e[2]=t[2]*a+r[2]*c+n[2]*l+i[2]*h,e}function sh(e,t,r,n,i,s){let o=1-s,a=o*o,c=s*s,l=a*o,h=3*s*a,u=3*c*o,f=c*s;return e[0]=t[0]*l+r[0]*h+n[0]*u+i[0]*f,e[1]=t[1]*l+r[1]*h+n[1]*u+i[1]*f,e[2]=t[2]*l+r[2]*h+n[2]*u+i[2]*f,e}function oh(e,t){t=t===void 0?1:t;let r=xt()*2*Math.PI,n=xt()*2-1,i=Math.sqrt(1-n*n)*t;return e[0]=Math.cos(r)*i,e[1]=Math.sin(r)*i,e[2]=n*t,e}function Ae(e,t,r){let n=t[0],i=t[1],s=t[2],o=r[3]*n+r[7]*i+r[11]*s+r[15];return o=o||1,e[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/o,e[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/o,e[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/o,e}function qn(e,t,r){let n=t[0],i=t[1],s=t[2];return e[0]=n*r[0]+i*r[3]+s*r[6],e[1]=n*r[1]+i*r[4]+s*r[7],e[2]=n*r[2]+i*r[5]+s*r[8],e}function Xn(e,t,r){let n=r[0],i=r[1],s=r[2],o=r[3],a=t[0],c=t[1],l=t[2],h=i*l-s*c,u=s*a-n*l,f=n*c-i*a,d=i*f-s*u,p=s*h-n*f,g=n*u-i*h,m=o*2;return h*=m,u*=m,f*=m,d*=2,p*=2,g*=2,e[0]=a+h+d,e[1]=c+u+p,e[2]=l+f+g,e}function Zn(e,t,r,n){let i=[],s=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],s[0]=i[0],s[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),s[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),e[0]=s[0]+r[0],e[1]=s[1]+r[1],e[2]=s[2]+r[2],e}function Hn(e,t,r,n){let i=[],s=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],s[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),s[1]=i[1],s[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),e[0]=s[0]+r[0],e[1]=s[1]+r[1],e[2]=s[2]+r[2],e}function Qn(e,t,r,n){let i=[],s=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],s[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),s[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),s[2]=i[2],e[0]=s[0]+r[0],e[1]=s[1]+r[1],e[2]=s[2]+r[2],e}function Kn(e,t){let r=e[0],n=e[1],i=e[2],s=t[0],o=t[1],a=t[2],c=Math.sqrt((r*r+n*n+i*i)*(s*s+o*o+a*a)),l=c&&$n(e,t)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function ah(e){return e[0]=0,e[1]=0,e[2]=0,e}function ch(e){return`vec3(${e[0]}, ${e[1]}, ${e[2]})`}function lh(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function hh(e,t){let r=e[0],n=e[1],i=e[2],s=t[0],o=t[1],a=t[2];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-o)<=1e-6*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))}var uh=Go,fh=zo,dh=Wo,mh=Uo,ph=Yo,gh=Vo,bh=$o,xh=(function(){let e=No();return function(t,r,n,i,s,o){let a,c;for(r||(r=3),n||(n=0),i?c=Math.min(i*r+n,t.length):c=t.length,a=n;a<c;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],s(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}})();var Jn=[0,0,0],Yr,Mt=class e extends zr{static get ZERO(){return Yr||(Yr=new e(0,0,0),Object.freeze(Yr)),Yr}constructor(t=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&vt(t)?this.copy(t):(G.debug&&(z(t),z(r),z(n)),this[0]=t,this[1]=r,this[2]=n)}set(t,r,n){return this[0]=t,this[1]=r,this[2]=n,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return G.debug&&(z(t.x),z(t.y),z(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=z(t)}angle(t){return Kn(this,t)}cross(t){return jn(this,this,t),this.check()}rotateX({radians:t,origin:r=Jn}){return Zn(this,this,r,t),this.check()}rotateY({radians:t,origin:r=Jn}){return Hn(this,this,r,t),this.check()}rotateZ({radians:t,origin:r=Jn}){return Qn(this,this,r,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Ae(this,this,t),this.check()}transformAsVector(t){return Ur(this,this,t),this.check()}transformByMatrix3(t){return qn(this,this,t),this.check()}transformByMatrix2(t){return Oo(this,this,t),this.check()}transformByQuaternion(t){return Xn(this,this,t),this.check()}};var $r=class extends ee{toString(){let t="[";if(G.printRowMajor){t+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)t+=` ${this[n*this.RANK+r]}`}else{t+="column-major:";for(let r=0;r<this.ELEMENTS;++r)t+=` ${this[r]}`}return t+="]",t}getElementIndex(t,r){return r*this.RANK+t}getElement(t,r){return this[r*this.RANK+t]}setElement(t,r,n){return this[r*this.RANK+t]=z(n),this}getColumn(t,r=new Array(this.RANK).fill(-0)){let n=t*this.RANK;for(let i=0;i<this.RANK;++i)r[i]=this[n+i];return r}setColumn(t,r){let n=t*this.RANK;for(let i=0;i<this.RANK;++i)this[n+i]=r[i];return this}};var W={};me(W,{add:()=>Uh,adjoint:()=>vh,clone:()=>wh,copy:()=>Eh,create:()=>yh,decompose:()=>Ih,determinant:()=>ri,equals:()=>qh,exactEquals:()=>jh,frob:()=>Wh,fromQuat:()=>li,fromQuat2:()=>Rh,fromRotation:()=>Ph,fromRotationTranslation:()=>qo,fromRotationTranslationScale:()=>Bh,fromRotationTranslationScaleOrigin:()=>Fh,fromScaling:()=>Mh,fromTranslation:()=>Sh,fromValues:()=>Th,fromXRotation:()=>Ch,fromYRotation:()=>Lh,fromZRotation:()=>Ah,frustum:()=>hi,getRotation:()=>Dh,getScaling:()=>Xo,getTranslation:()=>kh,identity:()=>jo,invert:()=>ei,lookAt:()=>di,mul:()=>Xh,multiply:()=>Re,multiplyScalar:()=>Yh,multiplyScalarAndAdd:()=>$h,ortho:()=>fi,orthoNO:()=>Ho,orthoZO:()=>Vh,perspective:()=>ui,perspectiveFromFieldOfView:()=>Nh,perspectiveNO:()=>Zo,perspectiveZO:()=>Oh,rotate:()=>si,rotateX:()=>oi,rotateY:()=>ai,rotateZ:()=>ci,scale:()=>ii,set:()=>_h,str:()=>zh,sub:()=>Zh,subtract:()=>Qo,targetTo:()=>Gh,translate:()=>ni,transpose:()=>ti});function yh(){let e=new O(16);return O!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function wh(e){let t=new O(16);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 Eh(e,t){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 Th(e,t,r,n,i,s,o,a,c,l,h,u,f,d,p,g){let m=new O(16);return m[0]=e,m[1]=t,m[2]=r,m[3]=n,m[4]=i,m[5]=s,m[6]=o,m[7]=a,m[8]=c,m[9]=l,m[10]=h,m[11]=u,m[12]=f,m[13]=d,m[14]=p,m[15]=g,m}function _h(e,t,r,n,i,s,o,a,c,l,h,u,f,d,p,g,m){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e[4]=s,e[5]=o,e[6]=a,e[7]=c,e[8]=l,e[9]=h,e[10]=u,e[11]=f,e[12]=d,e[13]=p,e[14]=g,e[15]=m,e}function jo(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function ti(e,t){if(e===t){let r=t[1],n=t[2],i=t[3],s=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=s,e[11]=t[14],e[12]=i,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function ei(e,t){let r=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],u=t[9],f=t[10],d=t[11],p=t[12],g=t[13],m=t[14],b=t[15],_=r*a-n*o,y=r*c-i*o,E=r*l-s*o,v=n*c-i*a,w=n*l-s*a,x=i*l-s*c,T=h*g-u*p,M=h*m-f*p,S=h*b-d*p,C=u*m-f*g,L=u*b-d*g,R=f*b-d*m,A=_*R-y*L+E*C+v*S-w*M+x*T;return A?(A=1/A,e[0]=(a*R-c*L+l*C)*A,e[1]=(i*L-n*R-s*C)*A,e[2]=(g*x-m*w+b*v)*A,e[3]=(f*w-u*x-d*v)*A,e[4]=(c*S-o*R-l*M)*A,e[5]=(r*R-i*S+s*M)*A,e[6]=(m*E-p*x-b*y)*A,e[7]=(h*x-f*E+d*y)*A,e[8]=(o*L-a*S+l*T)*A,e[9]=(n*S-r*L-s*T)*A,e[10]=(p*w-g*E+b*_)*A,e[11]=(u*E-h*w-d*_)*A,e[12]=(a*M-o*C-c*T)*A,e[13]=(r*C-n*M+i*T)*A,e[14]=(g*y-p*v-m*_)*A,e[15]=(h*v-u*y+f*_)*A,e):null}function vh(e,t){let r=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],u=t[9],f=t[10],d=t[11],p=t[12],g=t[13],m=t[14],b=t[15],_=r*a-n*o,y=r*c-i*o,E=r*l-s*o,v=n*c-i*a,w=n*l-s*a,x=i*l-s*c,T=h*g-u*p,M=h*m-f*p,S=h*b-d*p,C=u*m-f*g,L=u*b-d*g,R=f*b-d*m;return e[0]=a*R-c*L+l*C,e[1]=i*L-n*R-s*C,e[2]=g*x-m*w+b*v,e[3]=f*w-u*x-d*v,e[4]=c*S-o*R-l*M,e[5]=r*R-i*S+s*M,e[6]=m*E-p*x-b*y,e[7]=h*x-f*E+d*y,e[8]=o*L-a*S+l*T,e[9]=n*S-r*L-s*T,e[10]=p*w-g*E+b*_,e[11]=u*E-h*w-d*_,e[12]=a*M-o*C-c*T,e[13]=r*C-n*M+i*T,e[14]=g*y-p*v-m*_,e[15]=h*v-u*y+f*_,e}function ri(e){let t=e[0],r=e[1],n=e[2],i=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],h=e[9],u=e[10],f=e[11],d=e[12],p=e[13],g=e[14],m=e[15],b=t*o-r*s,_=t*a-n*s,y=r*a-n*o,E=l*p-h*d,v=l*g-u*d,w=h*g-u*p,x=t*w-r*v+n*E,T=s*w-o*v+a*E,M=l*y-h*_+u*b,S=d*y-p*_+g*b;return c*x-i*T+m*M-f*S}function Re(e,t,r){let n=t[0],i=t[1],s=t[2],o=t[3],a=t[4],c=t[5],l=t[6],h=t[7],u=t[8],f=t[9],d=t[10],p=t[11],g=t[12],m=t[13],b=t[14],_=t[15],y=r[0],E=r[1],v=r[2],w=r[3];return e[0]=y*n+E*a+v*u+w*g,e[1]=y*i+E*c+v*f+w*m,e[2]=y*s+E*l+v*d+w*b,e[3]=y*o+E*h+v*p+w*_,y=r[4],E=r[5],v=r[6],w=r[7],e[4]=y*n+E*a+v*u+w*g,e[5]=y*i+E*c+v*f+w*m,e[6]=y*s+E*l+v*d+w*b,e[7]=y*o+E*h+v*p+w*_,y=r[8],E=r[9],v=r[10],w=r[11],e[8]=y*n+E*a+v*u+w*g,e[9]=y*i+E*c+v*f+w*m,e[10]=y*s+E*l+v*d+w*b,e[11]=y*o+E*h+v*p+w*_,y=r[12],E=r[13],v=r[14],w=r[15],e[12]=y*n+E*a+v*u+w*g,e[13]=y*i+E*c+v*f+w*m,e[14]=y*s+E*l+v*d+w*b,e[15]=y*o+E*h+v*p+w*_,e}function ni(e,t,r){let n=r[0],i=r[1],s=r[2],o,a,c,l,h,u,f,d,p,g,m,b;return t===e?(e[12]=t[0]*n+t[4]*i+t[8]*s+t[12],e[13]=t[1]*n+t[5]*i+t[9]*s+t[13],e[14]=t[2]*n+t[6]*i+t[10]*s+t[14],e[15]=t[3]*n+t[7]*i+t[11]*s+t[15]):(o=t[0],a=t[1],c=t[2],l=t[3],h=t[4],u=t[5],f=t[6],d=t[7],p=t[8],g=t[9],m=t[10],b=t[11],e[0]=o,e[1]=a,e[2]=c,e[3]=l,e[4]=h,e[5]=u,e[6]=f,e[7]=d,e[8]=p,e[9]=g,e[10]=m,e[11]=b,e[12]=o*n+h*i+p*s+t[12],e[13]=a*n+u*i+g*s+t[13],e[14]=c*n+f*i+m*s+t[14],e[15]=l*n+d*i+b*s+t[15]),e}function ii(e,t,r){let n=r[0],i=r[1],s=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function si(e,t,r,n){let i=n[0],s=n[1],o=n[2],a=Math.sqrt(i*i+s*s+o*o),c,l,h,u,f,d,p,g,m,b,_,y,E,v,w,x,T,M,S,C,L,R,A,B;return a<1e-6?null:(a=1/a,i*=a,s*=a,o*=a,l=Math.sin(r),c=Math.cos(r),h=1-c,u=t[0],f=t[1],d=t[2],p=t[3],g=t[4],m=t[5],b=t[6],_=t[7],y=t[8],E=t[9],v=t[10],w=t[11],x=i*i*h+c,T=s*i*h+o*l,M=o*i*h-s*l,S=i*s*h-o*l,C=s*s*h+c,L=o*s*h+i*l,R=i*o*h+s*l,A=s*o*h-i*l,B=o*o*h+c,e[0]=u*x+g*T+y*M,e[1]=f*x+m*T+E*M,e[2]=d*x+b*T+v*M,e[3]=p*x+_*T+w*M,e[4]=u*S+g*C+y*L,e[5]=f*S+m*C+E*L,e[6]=d*S+b*C+v*L,e[7]=p*S+_*C+w*L,e[8]=u*R+g*A+y*B,e[9]=f*R+m*A+E*B,e[10]=d*R+b*A+v*B,e[11]=p*R+_*A+w*B,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function oi(e,t,r){let n=Math.sin(r),i=Math.cos(r),s=t[4],o=t[5],a=t[6],c=t[7],l=t[8],h=t[9],u=t[10],f=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=s*i+l*n,e[5]=o*i+h*n,e[6]=a*i+u*n,e[7]=c*i+f*n,e[8]=l*i-s*n,e[9]=h*i-o*n,e[10]=u*i-a*n,e[11]=f*i-c*n,e}function ai(e,t,r){let n=Math.sin(r),i=Math.cos(r),s=t[0],o=t[1],a=t[2],c=t[3],l=t[8],h=t[9],u=t[10],f=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i-l*n,e[1]=o*i-h*n,e[2]=a*i-u*n,e[3]=c*i-f*n,e[8]=s*n+l*i,e[9]=o*n+h*i,e[10]=a*n+u*i,e[11]=c*n+f*i,e}function ci(e,t,r){let n=Math.sin(r),i=Math.cos(r),s=t[0],o=t[1],a=t[2],c=t[3],l=t[4],h=t[5],u=t[6],f=t[7];return t!==e&&(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[0]=s*i+l*n,e[1]=o*i+h*n,e[2]=a*i+u*n,e[3]=c*i+f*n,e[4]=l*i-s*n,e[5]=h*i-o*n,e[6]=u*i-a*n,e[7]=f*i-c*n,e}function Sh(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function Mh(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ph(e,t,r){let n=r[0],i=r[1],s=r[2],o=Math.sqrt(n*n+i*i+s*s),a,c,l;return o<1e-6?null:(o=1/o,n*=o,i*=o,s*=o,c=Math.sin(t),a=Math.cos(t),l=1-a,e[0]=n*n*l+a,e[1]=i*n*l+s*c,e[2]=s*n*l-i*c,e[3]=0,e[4]=n*i*l-s*c,e[5]=i*i*l+a,e[6]=s*i*l+n*c,e[7]=0,e[8]=n*s*l+i*c,e[9]=i*s*l-n*c,e[10]=s*s*l+a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function Ch(e,t){let r=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Lh(e,t){let r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ah(e,t){let r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function qo(e,t,r){let n=t[0],i=t[1],s=t[2],o=t[3],a=n+n,c=i+i,l=s+s,h=n*a,u=n*c,f=n*l,d=i*c,p=i*l,g=s*l,m=o*a,b=o*c,_=o*l;return e[0]=1-(d+g),e[1]=u+_,e[2]=f-b,e[3]=0,e[4]=u-_,e[5]=1-(h+g),e[6]=p+m,e[7]=0,e[8]=f+b,e[9]=p-m,e[10]=1-(h+d),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function Rh(e,t){let r=new O(3),n=-t[0],i=-t[1],s=-t[2],o=t[3],a=t[4],c=t[5],l=t[6],h=t[7],u=n*n+i*i+s*s+o*o;return u>0?(r[0]=(a*o+h*n+c*s-l*i)*2/u,r[1]=(c*o+h*i+l*n-a*s)*2/u,r[2]=(l*o+h*s+a*i-c*n)*2/u):(r[0]=(a*o+h*n+c*s-l*i)*2,r[1]=(c*o+h*i+l*n-a*s)*2,r[2]=(l*o+h*s+a*i-c*n)*2),qo(e,t,r),e}function kh(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Xo(e,t){let r=t[0],n=t[1],i=t[2],s=t[4],o=t[5],a=t[6],c=t[8],l=t[9],h=t[10];return e[0]=Math.sqrt(r*r+n*n+i*i),e[1]=Math.sqrt(s*s+o*o+a*a),e[2]=Math.sqrt(c*c+l*l+h*h),e}function Dh(e,t){let r=new O(3);Xo(r,t);let n=1/r[0],i=1/r[1],s=1/r[2],o=t[0]*n,a=t[1]*i,c=t[2]*s,l=t[4]*n,h=t[5]*i,u=t[6]*s,f=t[8]*n,d=t[9]*i,p=t[10]*s,g=o+h+p,m=0;return g>0?(m=Math.sqrt(g+1)*2,e[3]=.25*m,e[0]=(u-d)/m,e[1]=(f-c)/m,e[2]=(a-l)/m):o>h&&o>p?(m=Math.sqrt(1+o-h-p)*2,e[3]=(u-d)/m,e[0]=.25*m,e[1]=(a+l)/m,e[2]=(f+c)/m):h>p?(m=Math.sqrt(1+h-o-p)*2,e[3]=(f-c)/m,e[0]=(a+l)/m,e[1]=.25*m,e[2]=(u+d)/m):(m=Math.sqrt(1+p-o-h)*2,e[3]=(a-l)/m,e[0]=(f+c)/m,e[1]=(u+d)/m,e[2]=.25*m),e}function Ih(e,t,r,n){t[0]=n[12],t[1]=n[13],t[2]=n[14];let i=n[0],s=n[1],o=n[2],a=n[4],c=n[5],l=n[6],h=n[8],u=n[9],f=n[10];r[0]=Math.sqrt(i*i+s*s+o*o),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(h*h+u*u+f*f);let d=1/r[0],p=1/r[1],g=1/r[2],m=i*d,b=s*p,_=o*g,y=a*d,E=c*p,v=l*g,w=h*d,x=u*p,T=f*g,M=m+E+T,S=0;return M>0?(S=Math.sqrt(M+1)*2,e[3]=.25*S,e[0]=(v-x)/S,e[1]=(w-_)/S,e[2]=(b-y)/S):m>E&&m>T?(S=Math.sqrt(1+m-E-T)*2,e[3]=(v-x)/S,e[0]=.25*S,e[1]=(b+y)/S,e[2]=(w+_)/S):E>T?(S=Math.sqrt(1+E-m-T)*2,e[3]=(w-_)/S,e[0]=(b+y)/S,e[1]=.25*S,e[2]=(v+x)/S):(S=Math.sqrt(1+T-m-E)*2,e[3]=(b-y)/S,e[0]=(w+_)/S,e[1]=(v+x)/S,e[2]=.25*S),e}function Bh(e,t,r,n){let i=t[0],s=t[1],o=t[2],a=t[3],c=i+i,l=s+s,h=o+o,u=i*c,f=i*l,d=i*h,p=s*l,g=s*h,m=o*h,b=a*c,_=a*l,y=a*h,E=n[0],v=n[1],w=n[2];return e[0]=(1-(p+m))*E,e[1]=(f+y)*E,e[2]=(d-_)*E,e[3]=0,e[4]=(f-y)*v,e[5]=(1-(u+m))*v,e[6]=(g+b)*v,e[7]=0,e[8]=(d+_)*w,e[9]=(g-b)*w,e[10]=(1-(u+p))*w,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function Fh(e,t,r,n,i){let s=t[0],o=t[1],a=t[2],c=t[3],l=s+s,h=o+o,u=a+a,f=s*l,d=s*h,p=s*u,g=o*h,m=o*u,b=a*u,_=c*l,y=c*h,E=c*u,v=n[0],w=n[1],x=n[2],T=i[0],M=i[1],S=i[2],C=(1-(g+b))*v,L=(d+E)*v,R=(p-y)*v,A=(d-E)*w,B=(1-(f+b))*w,ft=(m+_)*w,Q=(p+y)*x,je=(m-_)*x,Bi=(1-(f+g))*x;return e[0]=C,e[1]=L,e[2]=R,e[3]=0,e[4]=A,e[5]=B,e[6]=ft,e[7]=0,e[8]=Q,e[9]=je,e[10]=Bi,e[11]=0,e[12]=r[0]+T-(C*T+A*M+Q*S),e[13]=r[1]+M-(L*T+B*M+je*S),e[14]=r[2]+S-(R*T+ft*M+Bi*S),e[15]=1,e}function li(e,t){let r=t[0],n=t[1],i=t[2],s=t[3],o=r+r,a=n+n,c=i+i,l=r*o,h=n*o,u=n*a,f=i*o,d=i*a,p=i*c,g=s*o,m=s*a,b=s*c;return e[0]=1-u-p,e[1]=h+b,e[2]=f-m,e[3]=0,e[4]=h-b,e[5]=1-l-p,e[6]=d+g,e[7]=0,e[8]=f+m,e[9]=d-g,e[10]=1-l-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function hi(e,t,r,n,i,s,o){let a=1/(r-t),c=1/(i-n),l=1/(s-o);return e[0]=s*2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s*2*c,e[6]=0,e[7]=0,e[8]=(r+t)*a,e[9]=(i+n)*c,e[10]=(o+s)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*s*2*l,e[15]=0,e}function Zo(e,t,r,n,i){let s=1/Math.tan(t/2);if(e[0]=s/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){let o=1/(n-i);e[10]=(i+n)*o,e[14]=2*i*n*o}else e[10]=-1,e[14]=-2*n;return e}var ui=Zo;function Oh(e,t,r,n,i){let s=1/Math.tan(t/2);if(e[0]=s/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){let o=1/(n-i);e[10]=i*o,e[14]=i*n*o}else e[10]=-1,e[14]=-n;return e}function Nh(e,t,r,n){let i=Math.tan(t.upDegrees*Math.PI/180),s=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(i+s);return e[0]=c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-((o-a)*c*.5),e[9]=(i-s)*l*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e}function Ho(e,t,r,n,i,s,o){let a=1/(t-r),c=1/(n-i),l=1/(s-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*a,e[13]=(i+n)*c,e[14]=(o+s)*l,e[15]=1,e}var fi=Ho;function Vh(e,t,r,n,i,s,o){let a=1/(t-r),c=1/(n-i),l=1/(s-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=l,e[11]=0,e[12]=(t+r)*a,e[13]=(i+n)*c,e[14]=s*l,e[15]=1,e}function di(e,t,r,n){let i,s,o,a,c,l,h,u,f,d,p=t[0],g=t[1],m=t[2],b=n[0],_=n[1],y=n[2],E=r[0],v=r[1],w=r[2];return Math.abs(p-E)<1e-6&&Math.abs(g-v)<1e-6&&Math.abs(m-w)<1e-6?jo(e):(u=p-E,f=g-v,d=m-w,i=1/Math.sqrt(u*u+f*f+d*d),u*=i,f*=i,d*=i,s=_*d-y*f,o=y*u-b*d,a=b*f-_*u,i=Math.sqrt(s*s+o*o+a*a),i?(i=1/i,s*=i,o*=i,a*=i):(s=0,o=0,a=0),c=f*a-d*o,l=d*s-u*a,h=u*o-f*s,i=Math.sqrt(c*c+l*l+h*h),i?(i=1/i,c*=i,l*=i,h*=i):(c=0,l=0,h=0),e[0]=s,e[1]=c,e[2]=u,e[3]=0,e[4]=o,e[5]=l,e[6]=f,e[7]=0,e[8]=a,e[9]=h,e[10]=d,e[11]=0,e[12]=-(s*p+o*g+a*m),e[13]=-(c*p+l*g+h*m),e[14]=-(u*p+f*g+d*m),e[15]=1,e)}function Gh(e,t,r,n){let i=t[0],s=t[1],o=t[2],a=n[0],c=n[1],l=n[2],h=i-r[0],u=s-r[1],f=o-r[2],d=h*h+u*u+f*f;d>0&&(d=1/Math.sqrt(d),h*=d,u*=d,f*=d);let p=c*f-l*u,g=l*h-a*f,m=a*u-c*h;return d=p*p+g*g+m*m,d>0&&(d=1/Math.sqrt(d),p*=d,g*=d,m*=d),e[0]=p,e[1]=g,e[2]=m,e[3]=0,e[4]=u*m-f*g,e[5]=f*p-h*m,e[6]=h*g-u*p,e[7]=0,e[8]=h,e[9]=u,e[10]=f,e[11]=0,e[12]=i,e[13]=s,e[14]=o,e[15]=1,e}function zh(e){return`mat4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]}, ${e[4]}, ${e[5]}, ${e[6]}, ${e[7]}, ${e[8]}, ${e[9]}, ${e[10]}, ${e[11]}, ${e[12]}, ${e[13]}, ${e[14]}, ${e[15]})`}function Wh(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function Uh(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e}function Qo(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}function Yh(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e}function $h(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e}function jh(e,t){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]}function qh(e,t){let r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=e[9],f=e[10],d=e[11],p=e[12],g=e[13],m=e[14],b=e[15],_=t[0],y=t[1],E=t[2],v=t[3],w=t[4],x=t[5],T=t[6],M=t[7],S=t[8],C=t[9],L=t[10],R=t[11],A=t[12],B=t[13],ft=t[14],Q=t[15];return Math.abs(r-_)<=1e-6*Math.max(1,Math.abs(r),Math.abs(_))&&Math.abs(n-y)<=1e-6*Math.max(1,Math.abs(n),Math.abs(y))&&Math.abs(i-E)<=1e-6*Math.max(1,Math.abs(i),Math.abs(E))&&Math.abs(s-v)<=1e-6*Math.max(1,Math.abs(s),Math.abs(v))&&Math.abs(o-w)<=1e-6*Math.max(1,Math.abs(o),Math.abs(w))&&Math.abs(a-x)<=1e-6*Math.max(1,Math.abs(a),Math.abs(x))&&Math.abs(c-T)<=1e-6*Math.max(1,Math.abs(c),Math.abs(T))&&Math.abs(l-M)<=1e-6*Math.max(1,Math.abs(l),Math.abs(M))&&Math.abs(h-S)<=1e-6*Math.max(1,Math.abs(h),Math.abs(S))&&Math.abs(u-C)<=1e-6*Math.max(1,Math.abs(u),Math.abs(C))&&Math.abs(f-L)<=1e-6*Math.max(1,Math.abs(f),Math.abs(L))&&Math.abs(d-R)<=1e-6*Math.max(1,Math.abs(d),Math.abs(R))&&Math.abs(p-A)<=1e-6*Math.max(1,Math.abs(p),Math.abs(A))&&Math.abs(g-B)<=1e-6*Math.max(1,Math.abs(g),Math.abs(B))&&Math.abs(m-ft)<=1e-6*Math.max(1,Math.abs(m),Math.abs(ft))&&Math.abs(b-Q)<=1e-6*Math.max(1,Math.abs(b),Math.abs(Q))}var Xh=Re,Zh=Qo;var Rt={};me(Rt,{add:()=>tu,ceil:()=>eu,clone:()=>Hh,copy:()=>Kh,create:()=>Ko,cross:()=>fu,dist:()=>_u,distance:()=>ra,div:()=>Tu,divide:()=>ea,dot:()=>uu,equals:()=>yu,exactEquals:()=>xu,floor:()=>ru,forEach:()=>Pu,fromValues:()=>Qh,inverse:()=>lu,len:()=>Su,length:()=>ia,lerp:()=>du,max:()=>iu,min:()=>nu,mul:()=>Eu,multiply:()=>ta,negate:()=>cu,normalize:()=>hu,random:()=>mu,round:()=>su,scale:()=>ou,scaleAndAdd:()=>au,set:()=>Jh,sqrDist:()=>vu,sqrLen:()=>Mu,squaredDistance:()=>na,squaredLength:()=>sa,str:()=>bu,sub:()=>wu,subtract:()=>Jo,transformMat4:()=>mi,transformQuat:()=>pu,zero:()=>gu});function Ko(){let e=new O(4);return O!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Hh(e){let t=new O(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function Qh(e,t,r,n){let i=new O(4);return i[0]=e,i[1]=t,i[2]=r,i[3]=n,i}function Kh(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function Jh(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e}function tu(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function Jo(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function ta(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e}function ea(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e}function eu(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e}function ru(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e}function nu(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e}function iu(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e}function su(e,t){return e[0]=K(t[0]),e[1]=K(t[1]),e[2]=K(t[2]),e[3]=K(t[3]),e}function ou(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function au(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e}function ra(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2],s=t[3]-e[3];return Math.sqrt(r*r+n*n+i*i+s*s)}function na(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2],s=t[3]-e[3];return r*r+n*n+i*i+s*s}function ia(e){let t=e[0],r=e[1],n=e[2],i=e[3];return Math.sqrt(t*t+r*r+n*n+i*i)}function sa(e){let t=e[0],r=e[1],n=e[2],i=e[3];return t*t+r*r+n*n+i*i}function cu(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e}function lu(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e}function hu(e,t){let r=t[0],n=t[1],i=t[2],s=t[3],o=r*r+n*n+i*i+s*s;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=n*o,e[2]=i*o,e[3]=s*o,e}function uu(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function fu(e,t,r,n){let i=r[0]*n[1]-r[1]*n[0],s=r[0]*n[2]-r[2]*n[0],o=r[0]*n[3]-r[3]*n[0],a=r[1]*n[2]-r[2]*n[1],c=r[1]*n[3]-r[3]*n[1],l=r[2]*n[3]-r[3]*n[2],h=t[0],u=t[1],f=t[2],d=t[3];return e[0]=u*l-f*c+d*a,e[1]=-(h*l)+f*o-d*s,e[2]=h*c-u*o+d*i,e[3]=-(h*a)+u*s-f*i,e}function du(e,t,r,n){let i=t[0],s=t[1],o=t[2],a=t[3];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=o+n*(r[2]-o),e[3]=a+n*(r[3]-a),e}function mu(e,t){t=t===void 0?1:t;let r,n,i,s,o,a;do r=xt()*2-1,n=xt()*2-1,o=r*r+n*n;while(o>=1);do i=xt()*2-1,s=xt()*2-1,a=i*i+s*s;while(a>=1);let c=Math.sqrt((1-o)/a);return e[0]=t*r,e[1]=t*n,e[2]=t*i*c,e[3]=t*s*c,e}function mi(e,t,r){let n=t[0],i=t[1],s=t[2],o=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*s+r[12]*o,e[1]=r[1]*n+r[5]*i+r[9]*s+r[13]*o,e[2]=r[2]*n+r[6]*i+r[10]*s+r[14]*o,e[3]=r[3]*n+r[7]*i+r[11]*s+r[15]*o,e}function pu(e,t,r){let n=t[0],i=t[1],s=t[2],o=r[0],a=r[1],c=r[2],l=r[3],h=l*n+a*s-c*i,u=l*i+c*n-o*s,f=l*s+o*i-a*n,d=-o*n-a*i-c*s;return e[0]=h*l+d*-o+u*-c-f*-a,e[1]=u*l+d*-a+f*-o-h*-c,e[2]=f*l+d*-c+h*-a-u*-o,e[3]=t[3],e}function gu(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function bu(e){return`vec4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]})`}function xu(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function yu(e,t){let r=e[0],n=e[1],i=e[2],s=e[3],o=t[0],a=t[1],c=t[2],l=t[3];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-a)<=1e-6*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(i-c)<=1e-6*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(s-l)<=1e-6*Math.max(1,Math.abs(s),Math.abs(l))}var wu=Jo,Eu=ta,Tu=ea,_u=ra,vu=na,Su=ia,Mu=sa,Pu=(function(){let e=Ko();return function(t,r,n,i,s,o){let a,c;for(r||(r=4),n||(n=0),i?c=Math.min(i*r+n,t.length):c=t.length,a=n;a<c;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],e[3]=t[a+3],s(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2],t[a+3]=e[3];return t}})();var bi;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(bi||(bi={}));var Cu=45*Math.PI/180,Lu=1,pi=.1,gi=500,Au=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),q=class extends $r{static get IDENTITY(){return ku()}static get ZERO(){return Ru()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return bi}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,r,n,i,s,o,a,c,l,h,u,f,d,p,g,m){return this[0]=t,this[1]=r,this[2]=n,this[3]=i,this[4]=s,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=h,this[10]=u,this[11]=f,this[12]=d,this[13]=p,this[14]=g,this[15]=m,this.check()}setRowMajor(t,r,n,i,s,o,a,c,l,h,u,f,d,p,g,m){return this[0]=t,this[1]=s,this[2]=l,this[3]=d,this[4]=r,this[5]=o,this[6]=h,this[7]=p,this[8]=n,this[9]=a,this[10]=u,this[11]=g,this[12]=i,this[13]=c,this[14]=f,this[15]=m,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(Au)}fromObject(t){return this.check()}fromQuaternion(t){return li(this,t),this.check()}frustum(t){let{left:r,right:n,bottom:i,top:s,near:o=pi,far:a=gi}=t;return a===1/0?Du(this,r,n,i,s,o):hi(this,r,n,i,s,o,a),this.check()}lookAt(t){let{eye:r,center:n=[0,0,0],up:i=[0,1,0]}=t;return di(this,r,n,i),this.check()}ortho(t){let{left:r,right:n,bottom:i,top:s,near:o=pi,far:a=gi}=t;return fi(this,r,n,i,s,o,a),this.check()}orthographic(t){let{fovy:r=Cu,aspect:n=Lu,focalDistance:i=1,near:s=pi,far:o=gi}=t;oa(r);let a=r/2,c=i*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:s,far:o})}perspective(t){let{fovy:r=45*Math.PI/180,aspect:n=1,near:i=.1,far:s=500}=t;return oa(r),ui(this,r,n,i,s),this.check()}determinant(){return ri(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),i=1/n[0],s=1/n[1],o=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*s,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*i,t[5]=this[5]*s,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*i,t[9]=this[9]*s,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),i=1/n[0],s=1/n[1],o=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*s,t[2]=this[2]*o,t[3]=this[4]*i,t[4]=this[5]*s,t[5]=this[6]*o,t[6]=this[8]*i,t[7]=this[9]*s,t[8]=this[10]*o,t}transpose(){return ti(this,this),this.check()}invert(){return ei(this,this),this.check()}multiplyLeft(t){return Re(this,t,this),this.check()}multiplyRight(t){return Re(this,this,t),this.check()}rotateX(t){return oi(this,this,t),this.check()}rotateY(t){return ai(this,this,t),this.check()}rotateZ(t){return ci(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,r){return si(this,this,t,r),this.check()}scale(t){return ii(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return ni(this,this,t),this.check()}transform(t,r){return t.length===4?(r=mi(r||[-0,-0,-0,-0],t,this),Gr(r,4),r):this.transformAsPoint(t,r)}transformAsPoint(t,r){let{length:n}=t,i;switch(n){case 2:i=Yn(r||[-0,-0],t,this);break;case 3:i=Ae(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Gr(i,t.length),i}transformAsVector(t,r){let n;switch(t.length){case 2:n=Fo(r||[-0,-0],t,this);break;case 3:n=Ur(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Gr(n,t.length),n}transformPoint(t,r){return this.transformAsPoint(t,r)}transformVector(t,r){return this.transformAsPoint(t,r)}transformDirection(t,r){return this.transformAsVector(t,r)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,r,n){return this.identity().translate([t,r,n])}},jr,qr;function Ru(){return jr||(jr=new q([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(jr)),jr}function ku(){return qr||(qr=new q,Object.freeze(qr)),qr}function oa(e){if(e>Math.PI*2)throw Error("expected radians")}function Du(e,t,r,n,i,s){let o=2*s/(r-t),a=2*s/(i-n),c=(r+t)/(r-t),l=(i+n)/(i-n),h=-1,u=-1,f=-2*s;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=c,e[9]=l,e[10]=h,e[11]=u,e[12]=0,e[13]=0,e[14]=f,e[15]=0,e}function ne(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function xi(e,t){let r=e%t;return r<0?t+r:r}function ca(e){return[e[12],e[13],e[14]]}function la(e){return{left:re(e[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12]),right:re(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12]),bottom:re(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13]),top:re(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13]),near:re(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14]),far:re(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])}}var aa=new Mt;function re(e,t,r,n){aa.set(e,t,r);let i=aa.len();return{distance:n/i,normal:new Mt(-e/i,-t/i,-r/i)}}function yi(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function kt(e,t){let r=Rt.transformMat4([],t,e);return Rt.scale(r,r,1/r[3]),r}function ke(e,t,r){return e<t?t:e>r?r:e}function Iu(e){return Math.log(e)*Math.LOG2E}var De=Math.log2||Iu;function lt(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}var ht=Math.PI,ha=ht/4,J=ht/180,wi=180/ht,ie=512,Xr=4003e4,ut=85.051129,ua=1.5;function Ei(e){return De(e)}function tt(e){let[t,r]=e;lt(Number.isFinite(t)),lt(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let n=t*J,i=r*J,s=ie*(n+ht)/(2*ht),o=ie*(ht+Math.log(Math.tan(ha+i*.5)))/(2*ht);return[s,o]}function Z(e){let[t,r]=e,n=t/ie*(2*ht)-ht,i=2*(Math.atan(Math.exp(r/ie*(2*ht)-ht))-ha);return[n*wi,i*wi]}function Ti(e){let{latitude:t}=e;lt(Number.isFinite(t));let r=Math.cos(t*J);return Ei(Xr*r)-9}function Ie(e){let t=Math.cos(e*J);return ie/Xr/t}function se(e){let{latitude:t,longitude:r,highPrecision:n=!1}=e;lt(Number.isFinite(t)&&Number.isFinite(r));let i=ie,s=Math.cos(t*J),o=i/360,a=o/s,c=i/Xr/s,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(n){let h=J*Math.tan(t*J)/s,u=o*h/2,f=i/Xr*h,d=f/a*c;l.unitsPerDegree2=[0,u,f],l.unitsPerMeter2=[d,0,d]}return l}function _i(e,t){let[r,n,i]=e,[s,o,a]=t,{unitsPerMeter:c,unitsPerMeter2:l}=se({longitude:r,latitude:n,highPrecision:!0}),h=tt(e);h[0]+=s*(c[0]+l[0]*o),h[1]+=o*(c[1]+l[1]*o);let u=Z(h),f=(i||0)+(a||0);return Number.isFinite(i)||Number.isFinite(a)?[u[0],u[1],f]:u}function Zr(e){let{height:t,pitch:r,bearing:n,altitude:i,scale:s,center:o}=e,a=yi();W.translate(a,a,[0,0,-i]),W.rotateX(a,a,-r*J),W.rotateZ(a,a,n*J);let c=s/t;return W.scale(a,a,[c,c,c]),o&&W.translate(a,a,ct.negate([],o)),a}function vi(e){let{width:t,height:r,altitude:n,pitch:i=0,offset:s,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=e,{fovy:h=Pt(ua)}=e;n!==void 0&&(h=Pt(n));let u=h*J,f=i*J,d=Ot(h),p=d;o&&(p+=o[2]*a/Math.cos(f)/r);let g=u*(.5+(s?s[1]:0)/r),m=Math.sin(g)*p/Math.sin(ke(Math.PI/2-f-g,.01,Math.PI-.01)),b=Math.sin(f)*m+p,_=p*10,y=Math.min(b*l,_);return{fov:u,aspect:t/r,focalDistance:d,near:c,far:y}}function Pt(e){return 2*Math.atan(.5/e)*wi}function Ot(e){return .5/Math.tan(.5*e*J)}function Hr(e,t){let[r,n,i=0]=e;return lt(Number.isFinite(r)&&Number.isFinite(n)&&Number.isFinite(i)),kt(t,[r,n,i,1])}function oe(e,t,r=0){let[n,i,s]=e;if(lt(Number.isFinite(n)&&Number.isFinite(i),"invalid pixel coordinate"),Number.isFinite(s))return kt(t,[n,i,s,1]);let o=kt(t,[n,i,0,1]),a=kt(t,[n,i,1,1]),c=o[2],l=a[2],h=c===l?0:((r||0)-c)/(l-c);return at.lerp([],o,a,h)}function Qr(e){let{width:t,height:r,bounds:n,minExtent:i=0,maxZoom:s=24,offset:o=[0,0]}=e,[[a,c],[l,h]]=n,u=Bu(e.padding),f=tt([a,ke(h,-ut,ut)]),d=tt([l,ke(c,-ut,ut)]),p=[Math.max(Math.abs(d[0]-f[0]),i),Math.max(Math.abs(d[1]-f[1]),i)],g=[t-u.left-u.right-Math.abs(o[0])*2,r-u.top-u.bottom-Math.abs(o[1])*2];lt(g[0]>0&&g[1]>0);let m=g[0]/p[0],b=g[1]/p[1],_=(u.right-u.left)/2/m,y=(u.top-u.bottom)/2/b,E=[(d[0]+f[0])/2+_,(d[1]+f[1])/2+y],v=Z(E),w=Math.min(s,De(Math.abs(Math.min(m,b))));return lt(Number.isFinite(w)),{longitude:v[0],latitude:v[1],zoom:w}}function Bu(e=0){return typeof e=="number"?{top:e,bottom:e,left:e,right:e}:(lt(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e)}var fa=Math.PI/180;function Kr(e,t=0){let{width:r,height:n,unproject:i}=e,s={targetZ:t},o=i([0,n],s),a=i([r,n],s),c,l,h=e.fovy?.5*e.fovy*fa:Math.atan(.5/e.altitude),u=(90-e.pitch)*fa;return h>u-.01?(c=da(e,0,t),l=da(e,r,t)):(c=i([0,0],s),l=i([r,0],s)),[o,a,l,c]}function da(e,t,r){let{pixelUnprojectionMatrix:n}=e,i=kt(n,[t,0,1,1]),s=kt(n,[t,e.height,1,1]),a=(r*e.distanceScales.unitsPerMeter[2]-i[2])/(s[2]-i[2]),c=at.lerp([],i,s,a),l=Z(c);return l.push(r),l}var V;(function(e){e[e.Start=1]="Start",e[e.Move=2]="Move",e[e.End=4]="End",e[e.Cancel=8]="Cancel"})(V||(V={}));var Nt;(function(e){e[e.None=0]="None",e[e.Left=1]="Left",e[e.Right=2]="Right",e[e.Up=4]="Up",e[e.Down=8]="Down",e[e.Horizontal=3]="Horizontal",e[e.Vertical=12]="Vertical",e[e.All=15]="All"})(Nt||(Nt={}));var H;(function(e){e[e.Possible=1]="Possible",e[e.Began=2]="Began",e[e.Changed=4]="Changed",e[e.Ended=8]="Ended",e[e.Recognized=8]="Recognized",e[e.Cancelled=16]="Cancelled",e[e.Failed=32]="Failed"})(H||(H={}));var X0={pointerdown:V.Start,pointermove:V.Move,pointerup:V.End,pointercancel:V.Cancel,pointerout:V.Cancel};var Ta=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"";var Ex=Ta.indexOf("firefox")!==-1;var _a={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(_a,"IDENTITY",{get:()=>(te.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),_a.CARTESIAN)});var ae={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0};var Ku=Math.PI/180,Ju=ne(),va=[0,0,0],tf={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function ef({width:e,height:t,orthographic:r,fovyRadians:n,focalDistance:i,padding:s,near:o,far:a}){let c=e/t,l=r?new q().orthographic({fovy:n,aspect:c,focalDistance:i,near:o,far:a}):new q().perspective({fovy:n,aspect:c,near:o,far:a});if(s){let{left:h=0,right:u=0,top:f=0,bottom:d=0}=s,p=Y((h+e-u)/2,0,e)-e/2,g=Y((f+t-d)/2,0,t)-t/2;l[8]-=p*2/e,l[9]+=g*2/t}return l}var Jr=class Jr{constructor(t={}){this._frustumPlanes={};this.id=t.id||this.constructor.displayName||"viewport",this.x=t.x||0,this.y=t.y||0,this.width=t.width||1,this.height=t.height||1,this.zoom=t.zoom||0,this.padding=t.padding,this.distanceScales=t.distanceScales||tf,this.focalDistance=t.focalDistance||1,this.position=t.position||va,this.modelMatrix=t.modelMatrix||null;let{longitude:r,latitude:n}=t;this.isGeospatial=Number.isFinite(n)&&Number.isFinite(r),this._initProps(t),this._initMatrices(t),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?ae.WEB_MERCATOR:ae.WEB_MERCATOR_AUTO_OFFSET:ae.IDENTITY}equals(t){return t instanceof Jr?this===t?!0:t.width===this.width&&t.height===this.height&&t.scale===this.scale&&St(t.projectionMatrix,this.projectionMatrix)&&St(t.viewMatrix,this.viewMatrix):!1}project(t,{topLeft:r=!0}={}){let n=this.projectPosition(t),i=Hr(n,this.pixelProjectionMatrix),[s,o]=i,a=r?o:this.height-o;return t.length===2?[s,a]:[s,a,i[2]]}unproject(t,{topLeft:r=!0,targetZ:n}={}){let[i,s,o]=t,a=r?s:this.height-s,c=n&&n*this.distanceScales.unitsPerMeter[2],l=oe([i,a,o],this.pixelUnprojectionMatrix,c),[h,u,f]=this.unprojectPosition(l);return Number.isFinite(o)?[h,u,f]:Number.isFinite(n)?[h,u,n]:[h,u]}projectPosition(t){let[r,n]=this.projectFlat(t),i=(t[2]||0)*this.distanceScales.unitsPerMeter[2];return[r,n,i]}unprojectPosition(t){let[r,n]=this.unprojectFlat(t),i=(t[2]||0)*this.distanceScales.metersPerUnit[2];return[r,n,i]}projectFlat(t){if(this.isGeospatial){let r=tt(t);return r[1]=Y(r[1],-318,830),r}return t}unprojectFlat(t){return this.isGeospatial?Z(t):t}getBounds(t={}){let r={targetZ:t.z||0},n=this.unproject([0,0],r),i=this.unproject([this.width,0],r),s=this.unproject([0,this.height],r),o=this.unproject([this.width,this.height],r);return[Math.min(n[0],i[0],s[0],o[0]),Math.min(n[1],i[1],s[1],o[1]),Math.max(n[0],i[0],s[0],o[0]),Math.max(n[1],i[1],s[1],o[1])]}getDistanceScales(t){return t&&this.isGeospatial?se({longitude:t[0],latitude:t[1],highPrecision:!0}):this.distanceScales}containsPixel({x:t,y:r,width:n=1,height:i=1}){return t<this.x+this.width&&this.x<t+n&&r<this.y+this.height&&this.y<r+i}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,la(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(t,r,n){return null}_initProps(t){let r=t.longitude,n=t.latitude;this.isGeospatial&&(Number.isFinite(t.zoom)||(this.zoom=Ti({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=t.distanceScales||se({latitude:n,longitude:r}));let i=Math.pow(2,this.zoom);this.scale=i;let{position:s,modelMatrix:o}=t,a=va;if(s&&(a=o?new q(o).transformAsVector(s,[]):s),this.isGeospatial){let c=this.projectPosition([r,n,0]);this.center=new Mt(a).scale(this.distanceScales.unitsPerMeter).add(c)}else this.center=this.projectPosition(a)}_initMatrices(t){let{viewMatrix:r=Ju,projectionMatrix:n=null,orthographic:i=!1,fovyRadians:s,fovy:o=75,near:a=.1,far:c=1e3,padding:l=null,focalDistance:h=1}=t;this.viewMatrixUncentered=r,this.viewMatrix=new q().multiplyRight(r).translate(new Mt(this.center).negate()),this.projectionMatrix=n||ef({width:this.width,height:this.height,orthographic:i,fovyRadians:s||o*Ku,focalDistance:h,padding:l,near:a,far:c});let u=ne();W.multiply(u,u,this.projectionMatrix),W.multiply(u,u,this.viewMatrix),this.viewProjectionMatrix=u,this.viewMatrixInverse=W.invert([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=ca(this.viewMatrixInverse);let f=ne(),d=ne();W.scale(f,f,[this.width/2,-this.height/2,1]),W.translate(f,f,[1,-1,0]),W.multiply(d,f,this.viewProjectionMatrix),this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=W.invert(ne(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||te.warn("Pixel project matrix not invertible")()}};Jr.displayName="Viewport";var Vt=Jr;var Fe=class Fe extends Vt{constructor(t={}){let{latitude:r=0,longitude:n=0,zoom:i=0,pitch:s=0,bearing:o=0,nearZMultiplier:a=.1,farZMultiplier:c=1.01,nearZ:l,farZ:h,orthographic:u=!1,projectionMatrix:f,repeat:d=!1,worldOffset:p=0,position:g,padding:m,legacyMeterSizes:b=!1}=t,{width:_,height:y,altitude:E=1.5}=t,v=Math.pow(2,i);_=_||1,y=y||1;let w,x=null;if(f)E=f[5]/2,w=Pt(E);else{t.fovy?(w=t.fovy,E=Ot(w)):w=Pt(E);let M;if(m){let{top:S=0,bottom:C=0}=m;M=[0,Y((S+y-C)/2,0,y)-y/2]}x=vi({width:_,height:y,scale:v,center:g&&[0,0,g[2]*Ie(r)],offset:M,pitch:s,fovy:w,nearZMultiplier:a,farZMultiplier:c}),Number.isFinite(l)&&(x.near=l),Number.isFinite(h)&&(x.far=h)}let T=Zr({height:y,pitch:s,bearing:o,scale:v,altitude:E});p&&(T=new q().translate([512*p,0,0]).multiplyLeft(T)),super({...t,width:_,height:y,viewMatrix:T,longitude:n,latitude:r,zoom:i,...x,fovy:w,focalDistance:E}),this.latitude=r,this.longitude=n,this.zoom=i,this.pitch=s,this.bearing=o,this.altitude=E,this.fovy=w,this.orthographic=u,this._subViewports=d?[]:null,this._pseudoMeters=b,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let t=this.getBounds(),r=Math.floor((t[0]+180)/360),n=Math.ceil((t[2]-180)/360);for(let i=r;i<=n;i++){let s=i?new Fe({...this,worldOffset:i}):this;this._subViewports.push(s)}}return this._subViewports}projectPosition(t){if(this._pseudoMeters)return super.projectPosition(t);let[r,n]=this.projectFlat(t),i=(t[2]||0)*Ie(t[1]);return[r,n,i]}unprojectPosition(t){if(this._pseudoMeters)return super.unprojectPosition(t);let[r,n]=this.unprojectFlat(t),i=(t[2]||0)/Ie(n);return[r,n,i]}addMetersToLngLat(t,r){return _i(t,r)}panByPosition(t,r,n){let i=oe(r,this.pixelUnprojectionMatrix),s=this.projectFlat(t),o=at.add([],s,at.negate([],i)),a=at.add([],this.center,o),[c,l]=this.unprojectFlat(a);return{longitude:c,latitude:l}}panByPosition3D(t,r){let n=t[2]||0,i=at.sub([],t,this.unproject(r,{targetZ:n}));return{longitude:this.longitude+i[0],latitude:this.latitude+i[1]}}getBounds(t={}){let r=Kr(this,t.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(t,r={}){let{width:n,height:i}=this,{longitude:s,latitude:o,zoom:a}=Qr({width:n,height:i,bounds:t,...r});return new Fe({width:n,height:i,longitude:s,latitude:o,zoom:a})}};Fe.displayName="WebMercatorViewport";var Oe=Fe;var Ne=class{constructor(t){this._inProgress=!1;this._handle=null;this.time=0;this.settings={duration:0};this._timeline=t}get inProgress(){return this._inProgress}start(t){this.cancel(),this.settings=t,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:t,settings:r}=this;this._handle=t.addChannel({delay:t.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 Sa=()=>{},Ma={mode:"preserve"},rf={mode:"hard"},Ci={BREAK:1,SNAP_TO_END:2,IGNORE:3},nf=e=>e,sf=Ci.BREAK,Ve=class{constructor(t){this._onTransitionUpdate=t=>{let{time:r,settings:{interpolator:n,startProps:i,endProps:s,duration:o,easing:a}}=t,c=a(r/o),l=n.interpolateProps(i,s,c);this.propsInTransition=this.getControllerState({...this.props,...l},Ma).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})};this.getControllerState=t.getControllerState,this.propsInTransition=null,this.transition=new Ne(t.timeline),this.onViewStateChange=t.onViewStateChange||Sa,this.onStateChange=t.onStateChange||Sa}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(t){let r=!1,n=this.props;if(this.props=t,!n||this._shouldIgnoreViewportChange(n,t))return!1;if(this._isTransitionEnabled(t)){let i=n;if(this.transition.inProgress){let{interruption:s,endProps:o}=this.transition.settings;i={...n,...s===Ci.SNAP_TO_END?o:this.propsInTransition||n}}this._triggerTransition(i,t),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(t){let{transitionDuration:r,transitionInterpolator:n}=t;return(r>0||r==="auto")&&!!n}_isUpdateDueToCurrentTransition(t){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(t,this.propsInTransition):!1}_shouldIgnoreViewportChange(t,r){return this.transition.inProgress?this.transition.settings.interruption===Ci.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(t,r):!0}_triggerTransition(t,r){let n=this.getControllerState(t,Ma),i=this.getControllerState(r,rf).shortestPathFrom(n),s=r.transitionInterpolator,o=s.getDuration?s.getDuration(t,r):r.transitionDuration;if(o===0)return;let a=s.initializeProps(t,i);this.propsInTransition={};let c={duration:o,easing:r.transitionEasing||nf,interpolator:s,interruption:r.transitionInterruption||sf,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(t){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),t?.(r)}}};function Gt(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}var Ge=class{constructor(t){let{compare:r,extract:n,required:i}=t;this._propsToCompare=r,this._propsToExtract=n||r,this._requiredProps=i}arePropsEqual(t,r){for(let n of this._propsToCompare)if(!(n in t)||!(n in r)||!St(t[n],r[n]))return!1;return!0}initializeProps(t,r){let n={},i={};for(let s of this._propsToExtract)(s in t||s in r)&&(n[s]=t[s],i[s]=r[s]);return this._checkRequiredProps(n),this._checkRequiredProps(i),{start:n,end:i}}getDuration(t,r){return r.transitionDuration}_checkRequiredProps(t){this._requiredProps&&this._requiredProps.forEach(r=>{let n=t[r];Gt(Number.isFinite(n)||Array.isArray(n),`${r} is required for transition`)})}};var ce=Math.PI/180,Pa=180/Math.PI,en=6370972,le=256;function of(){let e=le/en,t=Math.PI/180*le;return{unitsPerMeter:[e,e,e],unitsPerMeter2:[0,0,0],metersPerUnit:[1/e,1/e,1/e],unitsPerDegree:[t,t,e],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/t,1/t,1/e]}}var he=class extends Vt{constructor(t={}){let{longitude:r=0,bearing:n=0,pitch:i=0,zoom:s=0,nearZMultiplier:o=.5,farZMultiplier:a=1,resolution:c=10}=t,{latitude:l=0,height:h,altitude:u=1.5,fovy:f}=t;l=Math.max(Math.min(l,90),-90),h=h||1,f?u=Ot(f):f=Pt(u);let d=Math.max(Math.min(l,ut),-ut),p=Math.pow(2,s-tn(d)),g=i*ce,m=t.nearZ??o,b=t.farZ??(u+le*2*p/h/Math.max(Math.cos(g),.1))*a,_=new q().lookAt({eye:[0,-u,0],up:[0,0,1]}).rotateX(-g).rotateY(-n*ce).rotateX(l*ce).rotateZ(-r*ce).scale(p/h);super({...t,height:h,viewMatrix:_,longitude:r,latitude:l,zoom:s,distanceScales:of(),fovy:f,focalDistance:u,near:m,far:b}),this.scale=p,this.latitude=l,this.longitude=r,this.bearing=n,this.pitch=i,this.fovy=f,this.resolution=c}get projectionMode(){return ae.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(t={}){let r={targetZ:t.z||0},n=this.unproject([0,this.height/2],r),i=this.unproject([this.width/2,0],r),s=this.unproject([this.width,this.height/2],r),o=this.unproject([this.width/2,this.height],r);return s[0]<this.longitude&&(s[0]+=360),n[0]>this.longitude&&(n[0]-=360),[Math.min(n[0],s[0],i[0],o[0]),Math.min(n[1],s[1],i[1],o[1]),Math.max(n[0],s[0],i[0],o[0]),Math.max(n[1],s[1],i[1],o[1])]}unproject(t,{topLeft:r=!0,targetZ:n}={}){let[i,s,o]=t,a=r?s:this.height-s,{pixelUnprojectionMatrix:c}=this,l;if(Number.isFinite(o))l=Li(c,[i,a,o,1]);else{let d=Li(c,[i,a,-1,1]),p=Li(c,[i,a,1,1]),g=((n||0)/en+1)*le,m=ct.sqrLen(ct.sub([],d,p)),b=ct.sqrLen(d),_=ct.sqrLen(p),E=4*((4*b*_-(m-b-_)**2)/16)/m,v=Math.sqrt(b-E),w=Math.sqrt(Math.max(0,g*g-E)),x=(v-w)/Math.sqrt(m);l=ct.lerp([],d,p,x)}let[h,u,f]=this.unprojectPosition(l);return Number.isFinite(o)?[h,u,f]:Number.isFinite(n)?[h,u,n]:[h,u]}projectPosition(t){let[r,n,i=0]=t,s=r*ce,o=n*ce,a=Math.cos(o),c=(i/en+1)*le;return[Math.sin(s)*a*c,-Math.cos(s)*a*c,Math.sin(o)*c]}unprojectPosition(t){let[r,n,i]=t,s=ct.len(t),o=Math.asin(i/s),c=Math.atan2(r,-n)*Pa,l=o*Pa,h=(s/le-1)*en;return[c,l,h]}projectFlat(t){return t}unprojectFlat(t){return t}panByPosition([t,r,n],i,s){let a=.25/Math.pow(2,this.zoom-tn(this.latitude)),c=t+a*(s[0]-i[0]),l=r-a*(s[1]-i[1]);l=Math.max(Math.min(l,90),-90);let h={longitude:c,latitude:l,zoom:n-tn(r)};return h.zoom+=tn(h.latitude),h}};he.displayName="GlobeViewport";function tn(e,t){t&&(e=Math.max(Math.min(e,ut),-ut));let r=Math.PI*Math.cos(e*Math.PI/180);return Math.log2(r)}function Li(e,t){let r=Rt.transformMat4([],t,e);return Rt.scale(r,r,1/r[3]),r}var af=["longitude","latitude","zoom","bearing","pitch"],cf=["longitude","latitude","zoom"],zt=class extends Ge{constructor(t={}){let r=Array.isArray(t)?t:t.transitionProps,n=Array.isArray(t)?{}:t;n.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:af,required:cf},super(n.transitionProps),this.opts=n}initializeProps(t,r){let n=super.initializeProps(t,r),{makeViewport:i,around:s}=this.opts;if(i&&s)if(i(t)instanceof he)te.warn("around not supported in GlobeView")();else{let a=i(t),c=i(r),l=a.unproject(s);n.start.around=s,Object.assign(n.end,{around:c.project(l),aroundPosition:l,width:r.width,height:r.height})}return n}interpolateProps(t,r,n){let i={};for(let s of this._propsToExtract)i[s]=Le(t[s]||0,r[s]||0,n);if(r.aroundPosition&&this.opts.makeViewport){let s=this.opts.makeViewport({...r,...i});Object.assign(i,s.panByPosition(r.aroundPosition,Le(t.around,r.around,n)))}return i}};var yt={transitionDuration:0},lf=300,hf=300,Ai=e=>1-(1-e)*(1-e),uf=e=>e===1?1:1-Math.pow(2,-10*e),Wt={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],DOUBLE_CLICK_DRAG:["dblclickdragstart","dblclickdragmove","dblclickdragend","dblclickdragcancel"],KEYBOARD:["keydown"]},Ut={},ze=class{constructor(t){this.state={};this._events={};this._interactionState={isDragging:!1};this._customEvents=[];this._eventStartBlocked=null;this._panMove=!1;this._multiPanMode=null;this._multiPanStartCenter=null;this._doubleClickDragAnchor=null;this._suppressDoubleClickUntil=0;this.invertPan=!1;this.dragMode="rotate";this.inertia=0;this.scrollZoom=!0;this.dragPan=!0;this.dragRotate=!0;this.doubleClickZoom=!0;this.doubleClickDragZoom=!0;this.touchZoom=!0;this.touchRotate=!1;this.multiTouchDrag=null;this.trackpadGesture=!1;this.keyboard=!0;this.transitionManager=new Ve({...t,getControllerState:(r,n)=>new this.ControllerState({...r,constraintContext:n,makeViewport:t.makeViewport}),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=t.eventManager,this.onViewStateChange=t.onViewStateChange||(()=>{}),this.onStateChange=t.onStateChange||(()=>{}),this.makeViewport=t.makeViewport,this.pickPosition=t.pickPosition}set events(t){this.toggleEvents(this._customEvents,!1),this.toggleEvents(t,!0),this._customEvents=t,this.props&&this.setProps(this.props)}finalize(){for(let t in this._events)this._events[t]&&this.eventManager?.off(t,this.handleEvent);this.transitionManager.finalize()}handleEvent(t){this._controllerState=void 0;let r=this._eventStartBlocked;switch(t.type){case"panstart":return r?!1:this._onPanStart(t);case"panmove":return this._onPan(t);case"panend":return this._onPanEnd(t);case"pinchstart":return r||!this._isTrackpadGestureAllowed(t)?!1:this._onPinchStart(t);case"pinchmove":return this._isTrackpadGestureAllowed(t)?this._onPinch(t):!1;case"pinchend":return this._isTrackpadGestureAllowed(t)?this._onPinchEnd(t):!1;case"multipanstart":return r?!1:this._onMultiPanStart(t);case"multipanmove":return this._onMultiPan(t);case"multipanend":return this._onMultiPanEnd(t);case"dblclick":return this._onDoubleClick(t);case"dblclickdragstart":return r?!1:this._onDoubleClickDragStart(t);case"dblclickdragmove":return this._onDoubleClickDrag(t);case"dblclickdragend":case"dblclickdragcancel":return this._onDoubleClickDragEnd(t);case"wheel":return this._onWheel(t);case"keydown":return this._onKeyDown(t);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(t){let{x:r,y:n}=this.props,{offsetCenter:i}=t;return[i.x-r,i.y-n]}isPointInBounds(t,r){let{width:n,height:i}=this.props;if(r&&r.handled)return!1;let s=t[0]>=0&&t[0]<=n&&t[1]>=0&&t[1]<=i;return s&&r&&r.stopPropagation(),s}isFunctionKeyPressed(t){let{srcEvent:r}=t;return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(t){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},t);this._eventStartBlocked=r}setProps(t){t.maxBoundsPadding===void 0&&(t.maxBoundsPadding=null),t.dragMode&&(this.dragMode=t.dragMode);let r=this.props;this.props=t,"transitionInterpolator"in t||(t.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(t);let{inertia:n}=t;this.inertia=Number.isFinite(n)?n:n===!0?lf:0;let{scrollZoom:i=!0,dragPan:s=!0,dragRotate:o=!0,doubleClickZoom:a=!0,doubleClickDragZoom:c=!1,touchZoom:l=!0,touchRotate:h=!1,multiTouchDrag:u=h?"rotate":null,trackpadGesture:f=!1,keyboard:d=!0}=t,p=!!this.onViewStateChange;if(this.toggleEvents(Wt.WHEEL,p&&i),this.toggleEvents(Wt.PAN,p),this.toggleEvents(Wt.PINCH,p&&(l||u==="rotate")),this.toggleEvents(Wt.MULTI_PAN,p&&!!u),this.toggleEvents(Wt.DOUBLE_CLICK,p&&a),this.toggleEvents(Wt.DOUBLE_CLICK_DRAG,p&&c),this.toggleEvents(Wt.KEYBOARD,p&&d),this.scrollZoom=i,this.dragPan=s,this.dragRotate=o,this.doubleClickZoom=a,this.doubleClickDragZoom=c,this.touchZoom=l,this.touchRotate=u==="rotate",this.multiTouchDrag=u,this.trackpadGesture=f,this.keyboard=d,(!r||r.height!==t.height||r.width!==t.width||r.maxBounds!==t.maxBounds||r.maxBoundsPadding!==t.maxBoundsPadding)&&t.maxBounds){let m=new this.ControllerState({...t,makeViewport:this.makeViewport}),b=m.getViewportProps();Object.keys(b).some(y=>!Bt(b[y],t[y],1))&&this.updateViewport(m)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(t,r){this.eventManager&&t.forEach(n=>{this._events[n]!==r&&(this._events[n]=r,r?this.eventManager.on(n,this.handleEvent):this.eventManager.off(n,this.handleEvent))})}updateViewport(t,r=null,n={}){let i={...t.getViewportProps(),...r},s=this.controllerState!==t;if(this.state=t.getState(),this._setInteractionState(n),s){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:i,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(t){this.onViewStateChange({...t,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(t){Object.assign(this._interactionState,t),this.onStateChange(this._interactionState)}_getConstraintContext(t,r){return this.props.rubberBand?{mode:r==="update"?"elastic":r==="end"?"rebound":"hard"}:{mode:"hard"}}_getReboundTransition(t,r){if(t.mode!=="rebound")return null;let n=r.getViewportProps();return Object.keys(n).some(s=>!Bt(this.props[s],n[s],1))?{...this._getTransitionProps(),transitionDuration:hf,transitionEasing:uf}:null}_onPanStart(t){let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;let n=this.isFunctionKeyPressed(t)||t.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(n=!n);let i=n?"pan":"rotate",s=this._getConstraintContext(i,"start"),o=n?this.controllerState.panStart({pos:r},s):this.controllerState.rotateStart({pos:r},s);return this._panMove=n,this.updateViewport(o,yt,{isDragging:!0}),!0}_onPan(t){return this.isDragging()?this._panMove?this._onPanMove(t):this._onPanRotate(t):!1}_onPanEnd(t){return this.isDragging()?this._panMove?this._onPanMoveEnd(t):this._onPanRotateEnd(t):!1}_onPanMove(t){if(!this.dragPan)return!1;let r=this.getCenter(t),n=this.controllerState.pan({pos:r},this._getConstraintContext("pan","update"));return this.updateViewport(n,yt,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(t){let{inertia:r}=this;if(this.dragPan&&r&&t.velocity){let n=this.getCenter(t),i=[n[0]+t.velocityX*r/2,n[1]+t.velocityY*r/2],s=this.controllerState.pan({pos:i}).panEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Ai},{isDragging:!1,isPanning:!0})}else{let n=this.controllerState,i=this._getConstraintContext("pan","end"),s=n.panEnd(i),o=this._getReboundTransition(i,s);this.updateViewport(s,o,{isDragging:!1,isPanning:!!o})}return!0}_onPanRotate(t){if(!this.dragRotate)return!1;let r=this.getCenter(t),n=this.controllerState.rotate({pos:r},this._getConstraintContext("rotate","update"));return this.updateViewport(n,yt,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(t){let{inertia:r}=this;if(this.dragRotate&&r&&t.velocity){let n=this.getCenter(t),i=[n[0]+t.velocityX*r/2,n[1]+t.velocityY*r/2],s=this.controllerState.rotate({pos:i}).rotateEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Ai},{isDragging:!1,isRotating:!0})}else{let n=this.controllerState,i=this._getConstraintContext("rotate","end"),s=n.rotateEnd(i),o=this._getReboundTransition(i,s);this.updateViewport(s,o,{isDragging:!1,isRotating:!!o})}return!0}_onWheel(t){if(!this.scrollZoom||this.trackpadGesture&&t.device!=="mouse")return!1;let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;t.srcEvent.preventDefault();let{speed:n=.01,smooth:i=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:s}=t,o=2/(1+Math.exp(-Math.abs(s*n)));s<0&&o!==0&&(o=1/o);let a=i?{...this._getTransitionProps({around:r}),transitionDuration:250}:yt,c=this.controllerState.zoom({pos:r,scale:o});return this.updateViewport(c,a,{isZooming:!0,isPanning:!0}),i||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(t){let{multiTouchDrag:r}=this;if(!r||!this._isMultiPanEventAllowed(t,r))return!1;let n=t.offsetCenter;if(!this.isPointInBounds(this.getCenter(t),t))return!1;let i=t.pointerType==="trackpad",s={x:n.x-(i?0:t.deltaX),y:n.y-(i?0:t.deltaY)},o={...t,offsetCenter:s},a=this.getCenter(o),c=r==="pan"?this.controllerState.panStart({pos:a},this._getConstraintContext("pan","start")):this.controllerState.rotateStart({pos:a},this._getConstraintContext("rotate","start"));return this._multiPanMode=r,this._multiPanStartCenter=s,this.updateViewport(c,yt,{isDragging:!0}),!0}_onMultiPan(t){let{mode:r,event:n}=this._getMultiPanEvent(t);return!r||!n||!this.isDragging()?!1:r==="pan"?this._onPanMove(n):this._onPanRotate(n)}_onMultiPanEnd(t){let{mode:r,event:n}=this._getMultiPanEvent(t);if(!r||!n||!this.isDragging())return this._resetMultiPan(),!1;let i=r==="pan"?this._onPanMoveEnd(n):this._onPanRotateEnd(n);return this._resetMultiPan(),i}_isTrackpadGestureAllowed(t){return t.pointerType!=="trackpad"||this.trackpadGesture}_isMultiPanEventAllowed(t,r){return t.pointerType==="trackpad"?this.trackpadGesture&&(r==="pan"?this.dragPan:this.dragRotate):t.pointerType==="touch"&&(r==="pan"?this.dragPan:this.dragRotate)}_getMultiPanEvent(t){let r=this._multiPanMode,n=this._multiPanStartCenter;return!r||!n?{mode:null,event:null}:{mode:r,event:{...t,offsetCenter:{x:n.x+t.deltaX,y:n.y+t.deltaY}}}}_resetMultiPan(){this._multiPanMode=null,this._multiPanStartCenter=null}_onPinchStart(t){this._doubleClickDragAnchor=null;let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;let n=this.controllerState.zoomStart({pos:r},this._getConstraintContext("zoom","start")).rotateStart({pos:r},this._getConstraintContext("rotate","start"));return Ut._startPinchRotation=t.rotation,Ut._lastPinchEvent=t,this.updateViewport(n,yt,{isDragging:!0}),!0}_onPinch(t){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:n}=t,i=this.getCenter(t);r=r.zoom({pos:i,scale:n},this._getConstraintContext("zoom","update"))}if(this.touchRotate){let{rotation:n}=t;r=r.rotate({deltaAngleX:Ut._startPinchRotation-n},this._getConstraintContext("rotate","update"))}return this.updateViewport(r,yt,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),Ut._lastPinchEvent=t,!0}_onPinchEnd(t){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:n}=Ut;if(this.touchZoom&&r&&n&&t.scale!==n.scale){let i=this.getCenter(t),s=this.controllerState.rotateEnd(),o=Math.log2(t.scale),a=(o-Math.log2(n.scale))/(t.deltaTime-n.deltaTime),c=Math.pow(2,o+a*r/2);s=s.zoom({pos:i,scale:c}).zoomEnd(),this.updateViewport(s,{...this._getTransitionProps({around:i}),transitionDuration:r,transitionEasing:Ai},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let i=this.controllerState,s=this._getConstraintContext("zoom","end"),o=this._getConstraintContext("rotate","end"),a=i.zoomEnd(s).rotateEnd(o),c=this._getReboundTransition(this.touchZoom?s:o,a);this.updateViewport(a,c,{isDragging:!1,isPanning:!!c&&this.touchZoom,isZooming:!!c&&this.touchZoom,isRotating:!!c&&this.touchRotate})}return Ut._startPinchRotation=null,Ut._lastPinchEvent=null,!0}_onDoubleClick(t){if(!this.doubleClickZoom||Date.now()<this._suppressDoubleClickUntil)return!1;let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;let n=this.isFunctionKeyPressed(t),i=this.controllerState.zoom({pos:r,scale:n?.5:2});return this.updateViewport(i,this._getTransitionProps({around:r}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onDoubleClickDragStart(t){if(!this.doubleClickDragZoom)return this._doubleClickDragAnchor=null,!1;let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return this._doubleClickDragAnchor=null,!1;this._doubleClickDragAnchor=r;let n=this.controllerState.zoomStart({pos:r},this._getConstraintContext("zoom","start"));return t.scale!==1&&(n=n.zoom({pos:r,scale:t.scale},this._getConstraintContext("zoom","update"))),this.updateViewport(n,yt,{isDragging:!0,isPanning:!0,isZooming:!0}),!0}_onDoubleClickDrag(t){let r=this._doubleClickDragAnchor;if(!r)return!1;let n=this.controllerState.zoom({pos:r,scale:t.scale},this._getConstraintContext("zoom","update"));return this.updateViewport(n,yt,{isDragging:!0,isPanning:!0,isZooming:!0}),!0}_onDoubleClickDragEnd(t){if(!this._doubleClickDragAnchor)return!1;this._doubleClickDragAnchor=null;let n=this.controllerState,i=this._getConstraintContext("zoom","end"),s=n.zoomEnd(i),o=this._getReboundTransition(i,s);return this.updateViewport(s,o,{isDragging:!1,isPanning:!!o,isZooming:!!o}),this._suppressDoubleClickUntil=Date.now()+100,this.blockEvents(100),!0}_onKeyDown(t){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(t),{zoomSpeed:n,moveSpeed:i,rotateSpeedX:s,rotateSpeedY:o}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(t.srcEvent.code){case"Minus":c=r?a.zoomOut(n).zoomOut(n):a.zoomOut(n),l.isZooming=!0;break;case"Equal":c=r?a.zoomIn(n).zoomIn(n):a.zoomIn(n),l.isZooming=!0;break;case"ArrowLeft":r?(c=a.rotateLeft(s),l.isRotating=!0):(c=a.moveLeft(i),l.isPanning=!0);break;case"ArrowRight":r?(c=a.rotateRight(s),l.isRotating=!0):(c=a.moveRight(i),l.isPanning=!0);break;case"ArrowUp":r?(c=a.rotateUp(o),l.isRotating=!0):(c=a.moveUp(i),l.isPanning=!0);break;case"ArrowDown":r?(c=a.rotateDown(o),l.isRotating=!0):(c=a.moveDown(i),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(t){let{transition:r}=this;return!r||!r.transitionInterpolator?yt:t?{...r,transitionInterpolator:new zt({...t,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var ue=Symbol("constraintAround"),We=class{constructor(t,r,n,i){this.makeViewport=n,this._viewportProps=this.applyConstraints(t,i),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};function rn(e,t,r){let n=e-t;return n&&Number.isFinite(n)?t+n*r/(r+Math.abs(n)):t}function Ri(e,t,r){let n=j($(r?.left??0),e),i=j($(r?.right??0),e),s=j($(r?.top??0),t),o=j($(r?.bottom??0),t);return{x:n,y:s,width:e-n-i,height:t-s-o}}function Ca(e,t,r){let[n,i]=e.project(t);return n=Number.isFinite(n)?n:e.width/2,i=Number.isFinite(i)?i:e.height/2,{left:n-r.x,right:r.x+r.width-n,top:i-r.y,bottom:r.y+r.height-i}}var La=5,ff=1.2,Aa=512,Ra=[[-1/0,-90],[1/0,90]],df=1;function Ue([e,t]){if(Math.abs(t)>90&&(t=Math.sign(t)*90),Number.isFinite(e)){let[n,i]=tt([e,t]);return[n,Y(i,0,Aa)]}let[,r]=tt([0,t]);return[e,Y(r,0,Aa)]}var ki=class extends We{constructor(t){let{width:r,height:n,latitude:i,longitude:s,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:h=[0,0,0],maxZoom:u=20,minZoom:f=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:g,startZoomLngLat:m,startRotatePos:b,startRotateLngLat:_,startBearing:y,startPitch:E,startZoom:v,normalize:w=!0,rubberBand:x=!1}=t,{[ue]:T}=t;Gt(Number.isFinite(s)),Gt(Number.isFinite(i)),Gt(Number.isFinite(o));let M=t.maxBounds||(w?Ra:null),S=t.maxBoundsPadding||null;super({width:r,height:n,latitude:i,longitude:s,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:u,minZoom:f,maxPitch:d,minPitch:p,normalize:w,position:h,maxBounds:M,maxBoundsPadding:S,rubberBand:x,[ue]:T},{startPanLngLat:g,startZoomLngLat:m,startRotatePos:b,startRotateLngLat:_,startBearing:y,startPitch:E,startZoom:v},t.makeViewport,t.constraintContext),this.getAltitude=t.getAltitude}panStart({pos:t},r){return this._getUpdatedState({startPanLngLat:this._unproject(t)},r)}pan({pos:t,startPos:r},n){let i=this.getState().startPanLngLat||this._unproject(r);if(!i)return this;let o=this.makeViewport(this.getViewportProps()).panByPosition(i,t);return this._getUpdatedState(o,n)}panEnd(t){return this._getUpdatedState({startPanLngLat:null},t)}rotateStart({pos:t}){let r=this.getAltitude?.(t);return this._getUpdatedState({startRotatePos:t,startRotateLngLat:r!==void 0?this._unproject3D(t,r):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:t,deltaAngleX:r=0,deltaAngleY:n=0}){let{startRotatePos:i,startRotateLngLat:s,startBearing:o,startPitch:a}=this.getState();if(!i||o===void 0||a===void 0)return this;let c;if(t?c=this._getNewRotation(t,i,a,o):c={bearing:o+r,pitch:a+n},s){let l=this.makeViewport({...this.getViewportProps(),...c}),h="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[h](s,i)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:t},r){return this._getUpdatedState({startZoomLngLat:this._unproject(t),startZoom:this.getViewportProps().zoom},r)}zoom({pos:t,startPos:r,scale:n},i){let{startZoom:s,startZoomLngLat:o}=this.getState();return o||(s=this.getViewportProps().zoom,o=this._unproject(r)||this._unproject(t)),o?this._getUpdatedState({zoom:s+Math.log2(n),[ue]:{position:o,screenPosition:t}},i):this}zoomEnd(t){return this._getUpdatedState({startZoomLngLat:null,startZoom:null},t)}zoomIn(t=2,r){return this._zoomFromCenter(t,r)}zoomOut(t=2,r){return this._zoomFromCenter(1/t,r)}moveLeft(t=100,r){return this._panFromCenter([t,0],r)}moveRight(t=100,r){return this._panFromCenter([-t,0],r)}moveUp(t=100,r){return this._panFromCenter([0,t],r)}moveDown(t=100,r){return this._panFromCenter([0,-t],r)}rotateLeft(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-t})}rotateRight(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+t})}rotateUp(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+t})}rotateDown(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-t})}shortestPathFrom(t){let r=t.getViewportProps(),n={...this.getViewportProps()},{bearing:i,longitude:s}=n;return Math.abs(i-r.bearing)>180&&(n.bearing=i<0?i+360:i-360),Math.abs(s-r.longitude)>180&&(n.longitude=s<0?s+360:s-360),n}applyConstraints(t,r){let n=t,i=n[ue];delete n[ue];let{maxPitch:s,minPitch:o,pitch:a,bearing:c,normalize:l,maxBounds:h,rubberBand:u}=t;l&&(c<-180||c>180)&&(t.bearing=xi(c+180,360)-180),t.pitch=Y(a,o,s);let f=this._constrainZoom(t.zoom,t),d=u&&r?.mode==="elastic";if(t.zoom=r?.mode==="preserve"?t.zoom:d?rn(t.zoom,f,df):f,i){let p=this.makeViewport(t);Object.assign(t,p.panByPosition(i.position,i.screenPosition))}if(l&&(t.longitude<-180||t.longitude>180)&&(t.longitude=xi(t.longitude+180,360)-180),h){let p=Ri(t.width,t.height,t.maxBoundsPadding),g=this.makeViewport({...t,bearing:0,pitch:0}),m=Ca(g,[t.longitude,t.latitude],p),b=Ue(h[0]),_=Ue(h[1]),y=2**t.zoom,E=[b[0]+m.left/y,b[1]+m.bottom/y],v=[_[0]-m.right/y,_[1]-m.top/y],w=Ue([t.longitude,t.latitude]),x=[Y(w[0],E[0],v[0]),Y(w[1],E[1],v[1])],T=w.slice();if(p.width>=0&&(T[0]=r?.mode==="preserve"?w[0]:d?rn(w[0],x[0],p.width/2/y):x[0]),p.height>=0&&(T[1]=r?.mode==="preserve"?w[1]:d?rn(w[1],x[1],p.height/2/y):x[1]),T[0]!==w[0]||T[1]!==w[1]){let[M,S]=Z(T);T[0]!==w[0]&&(t.longitude=M),T[1]!==w[1]&&(t.latitude=S)}}return t}_constrainZoom(t,r){r||=this.getViewportProps();let{maxZoom:n,maxBounds:i}=r,s=i!==null&&r.width>0&&r.height>0,{minZoom:o}=r;if(s){let a=Ri(r.width,r.height,r.maxBoundsPadding),c=Ue(i[0]),l=Ue(i[1]),h=l[0]-c[0],u=l[1]-c[1];a.width>0&&Number.isFinite(h)&&h>0&&(o=Math.max(o,Math.log2(a.width/h))),a.height>0&&Number.isFinite(u)&&u>0&&(o=Math.max(o,Math.log2(a.height/u))),o>n&&(o=n)}return Y(t,o,n)}_zoomFromCenter(t,r){let{width:n,height:i}=this.getViewportProps();return this.zoom({pos:[n/2,i/2],scale:t},r)}_panFromCenter(t,r){let{width:n,height:i}=this.getViewportProps();return this.pan({startPos:[n/2,i/2],pos:[n/2+t[0],i/2+t[1]]},r)}_getUpdatedState(t,r){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...t,constraintContext:r})}_unproject(t){let r=this.makeViewport(this.getViewportProps());return t&&r.unproject(t)}_unproject3D(t,r){return this.makeViewport(this.getViewportProps()).unproject(t,{targetZ:r})}_getNewRotation(t,r,n,i){let s=t[0]-r[0],o=t[1]-r[1],a=t[1],c=r[1],{width:l,height:h}=this.getViewportProps(),u=s/l,f=0;o>0?Math.abs(h-c)>La&&(f=o/(c-h)*ff):o<0&&c>La&&(f=1-a/c),f=Y(f,-1,1);let{minPitch:d,maxPitch:p}=this.getViewportProps(),g=i+180*u,m=n;return f>0?m=n+f*(p-n):f<0&&(m=n-f*(d-n)),{pitch:m,bearing:g}}},Ye=class extends ze{constructor(){super(...arguments);this.ControllerState=ki;this.transition={transitionDuration:300,transitionInterpolator:new zt({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})};this.dragMode="pan";this.rotationPivot="center";this._getAltitude=r=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:n,y:i}=this.props,s=this.pickPosition(n+r[0],i+r[1]);if(s&&s.coordinate&&s.coordinate.length>=3)return s.coordinate[2]}}}setProps(r){"rotationPivot"in r&&(this.rotationPivot=r.rotationPivot||"center"),r.getAltitude=this._getAltitude,r.position=r.position||[0,0,0],r.maxBounds=r.maxBounds||(r.normalize===!1?null:Ra),super.setProps(r)}updateViewport(r,n=null,i={}){let s=r.getState();i.isDragging&&s.startRotateLngLat?i={...i,rotationPivotPosition:s.startRotateLngLat}:i.isDragging===!1&&(i={...i,rotationPivotPosition:void 0}),super.updateViewport(r,n,i)}};var fe=class extends Ce{constructor(t={}){super(t)}getViewportType(){return Oe}get ControllerType(){return Ye}};fe.displayName="MapView";var mf=5916575505e-1,pf=78271.484,nn=111320,gf=55*Math.PI/180,bf=65,xf=80;function yf(e,t){let r=(e.latitude+t.latitude)/2*Math.PI/180,n=(e.latitude-t.latitude)*nn,i=(e.longitude-t.longitude)*nn*Math.cos(r);return Math.sqrt(n*n+i*i)}function wf(e,t,r,n,i){let s=e.toMap({x:n/2,y:i/2}),o=e.toMap({x:n/2+1,y:i/2});if(s&&o){let a=yf(s,o);if(a>0){let c=r*Math.PI/180;return Math.log2(pf*Math.cos(c)/a)}}return Math.log2(mf/e.scale)-1}function Ef(e,t,r){let n=Math.max(0,Math.min(1,(r-e)/(t-e)));return n*n*(3-2*n)}function Tf(e,t){let r=e/t;return .5/(Math.tan(gf/2)/Math.sqrt(1+r*r))}function _f(e,t,r,n){let i=Tf(r,n),s=Ef(bf,xf,e);return t*(1-s)+i*s}function vf(e,t,r,n,i,s){return{views:new fe({id:"arcgis-scene"}),viewState:{"arcgis-scene":{id:"arcgis-scene",longitude:t,latitude:r,zoom:n,pitch:e.camera.tilt,bearing:e.camera.heading,altitude:s,position:[0,0,0],resolution:i}}}}function Di(e,t){class r{constructor(i,s){if(this.resources=null,this.cancelInitialization=null,this.renderNode=null,i&&typeof i=="object"&&"view"in i){let{view:l,...h}=i;this.view=l,this.deck=new e(h)}else this.view=i,this.deck=new e(s);let o=!1,a=this,c=t.createSubclass({consumes:{required:["composite-color"]},produces:"composite-color",initialize(){},render(l){let h=this,u=l.find(B=>B.name==="composite-color");if(!a.resources&&!o){let B=h.gl;if(B){o=!0;let ft=!1;a.cancelInitialization=()=>{ft=!0},Fr.call(a,B).then(Q=>{if(o=!1,ft){Ht(Q);return}a.deck.on("change",je=>Q.deck.setProps(je)),Q.deck.setProps(a.deck.toJSON()),a.resources=Q,h.requestRender()}).catch(Q=>{o=!1,console.error("DeckRenderer: failed to initialize resources",Q)})}return u}if(!a.resources)return u;let f=h.bindRenderTarget(),d=h.gl,p=window.devicePixelRatio||1,g=d.drawingBufferWidth/p,m=d.drawingBufferHeight/p,b=a.view.camera.position,_=a.view.toMap({x:g/2,y:m/2}),y=_?_.latitude:a.view.center.latitude,E=_?_.longitude:a.view.center.longitude,v=(y+b.latitude)/2*Math.PI/180,w=(b.latitude-y)*nn,x=(b.longitude-E)*nn*Math.cos(v),T=Math.sqrt(w*w+x*x),M=Math.sqrt(T*T+b.z*b.z),S=wf(a.view,E,y,g,m),C=m*a.view.resolution,L=M/C,R=_f(a.view.camera.tilt,L,g,m),A=vf(a.view,E,y,S,a.view.resolution,R);try{A?Pe(a.resources,{width:g,height:m,latitude:y,longitude:E,altitude:R,zoom:S,bearing:a.view.camera.heading,pitch:a.view.camera.tilt,...A}):Pe(a.resources,{width:g,height:m,latitude:y,longitude:E,altitude:R,zoom:S,bearing:a.view.camera.heading,pitch:a.view.camera.tilt})}catch(B){console.error("DeckRenderer: render error",B)}return f}});this.renderNode=new c({view:this.view})}async setup(i){}dispose(){this.cancelInitialization?.(),this.resources&&(Ht(this.resources),this.resources=null),this.renderNode=null}redraw(){this.renderNode?.requestRender()}render(){this.renderNode?.requestRender()}}return r}var Ii=D(Da(),1),de;async function Sf(e,t){let r=Array.isArray(e)?null:e;return await Mf(r,t),Array.isArray(e)?(0,Ii.loadModules)(e,t).then(n=>({...de,modules:n})):de}async function Mf(e,t){if(de)return de;if(e){let o=e.layers.Layer,a=e.core.Accessor,c=e.views["2d"].layers.BaseLayerViewGL2D,l=e.views["3d"].webgl.RenderNode;return Ia(o,a,c,l)}let[r,n,i,s]=await(0,Ii.loadModules)(["esri/layers/Layer","esri/core/Accessor","esri/views/2d/layers/BaseLayerViewGL2D","esri/views/3d/webgl/RenderNode"],t);return Ia(r,n,i,s)}function Ia(e,t,r,n){let i=on(t),s=On(r),o=an(i,e,s),a=Di(i,n);return de={DeckLayer:o,DeckRenderer:a},de}return Ga($e);})();
|
|
29
|
+
`,bindings:{deckglTexture:n},parameters:{depthWriteEnabled:!1,depthCompare:"always",blendColorSrcFactor:"one",blendColorDstFactor:"one-minus-src-alpha",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one-minus-src-alpha",blendColorOperation:"add",blendAlphaOperation:"add"},geometry:new kr.Geometry({topology:"triangle-strip",attributes:{pos:{size:2,value:new Int8Array([-1,-1,1,-1,-1,1,-1,1,1,1,1,-1])}}}),vertexCount:6,disableWarnings:!0}),s=r.createFramebuffer({id:"deckfbo",width:1,height:1,colorAttachments:[n],depthStencilAttachment:"depth16unorm"});return t.setProps({_framebuffer:s,_customRender:o=>{if(o==="arcgis"){let a=r.gl;a.blendFuncSeparate(a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA),t._drawLayers(o)}else this.redraw()}}),{deck:t,texture:n,fbo:s,model:i}}function Te(e,t){let{model:r,deck:n,fbo:i}=e,s=r.device;if(s instanceof Ee){let o=s.getParametersWebGL(36006),{width:a,height:c,views:l,viewState:h,...u}=t,f=window.devicePixelRatio,d=Math.round(a*f),p=Math.round(c*f);i.resize({width:d,height:p});let g=i.colorAttachments[0].texture??i.colorAttachments[0];g!==e.texture&&(e.texture=g,r.setBindings({deckglTexture:g}));let m={width:a,height:c,viewState:h||u};l&&(m.views=l),n.setProps(m),n.redraw("arcgis");let{gl:x}=s;o?(x.bindFramebuffer(36160,o),x.drawBuffers([36064])):x.drawBuffers([1029]),x.enable(3042),x.blendFuncSeparate(1,771,1,771),x.blendEquationSeparate(32774,32774);let _={handle:o,width:d,height:p,colorAttachments:[null]},b=s.beginRenderPass({framebuffer:_,parameters:{viewport:[0,0,d,p]},clearColor:!1,clearDepth:!1});try{r.draw(b)}finally{b.end()}}}function jt(e){e.deck.finalize(),e.model.destroy(),e.fbo.destroy(),e.texture.destroy()}function Bn(e){return e.createSubclass({properties:{cancelInitialization:null,resources:null},async attach(){let t=this.context,r=!1;this.cancelInitialization=()=>r=!0;let n=await Ir.call(this,t);if(r){jt(n);return}this.resources=n,this.layer.deck.on("change",i=>n.deck.setProps(i)),n.deck.setProps(this.layer.deck.toJSON())},redraw(){this.requestRender()},detach(){this.cancelInitialization?.(),this.resources&&(jt(this.resources),this.resources=null)},render(t){if(!this.resources)return;let[r,n]=this.view.state.size,i=t.state;Te(this.resources,{width:r,height:n,latitude:this.view.center.latitude,longitude:this.view.center.longitude,zoom:this.view.featuresTilingScheme.scaleToLevel(i.scale),bearing:-i.rotation,pitch:0})}})}var Xc=/^(?:\d+\.?\d*|\.\d+)$/;function Y(e){switch(typeof e){case"number":if(!Number.isFinite(e))throw new Error(`Could not parse position string ${e}`);return{type:"literal",value:e};case"string":try{let t=Zc(e);return new Fn(t).parseExpression()}catch(t){let r=t instanceof Error?t.message:String(t);throw new Error(`Could not parse position string ${e}: ${r}`)}default:throw new Error(`Could not parse position string ${e}`)}}function Dn(e,t){switch(e.type){case"literal":return e.value;case"percentage":return Math.round(e.value*t);case"binary":let r=Dn(e.left,t),n=Dn(e.right,t);return e.operator==="+"?r+n:r-n;default:throw new Error("Unknown layout expression type")}}function j(e,t){return Dn(e,t)}function Zc(e){let t=[],r=0;for(;r<e.length;){let n=e[r];if(/\s/.test(n)){r++;continue}if(n==="+"||n==="-"||n==="("||n===")"||n==="%"){t.push({type:"symbol",value:n}),r++;continue}if(bo(n)||n==="."){let i=r,s=n===".";for(r++;r<e.length;){let a=e[r];if(bo(a)){r++;continue}if(a==="."&&!s){s=!0,r++;continue}break}let o=e.slice(i,r);if(!Xc.test(o))throw new Error("Invalid number token");t.push({type:"number",value:parseFloat(o)});continue}if(xo(n)){let i=r;for(;r<e.length&&xo(e[r]);)r++;let s=e.slice(i,r).toLowerCase();t.push({type:"word",value:s});continue}throw new Error("Invalid token in position string")}return t}var Fn=class{constructor(t){this.index=0;this.tokens=t}parseExpression(){let t=this.parseBinaryExpression();if(this.index<this.tokens.length)throw new Error("Unexpected token at end of expression");return t}parseBinaryExpression(){let t=this.parseFactor(),r=this.peek();for(;Hc(r);){this.index++;let n=this.parseFactor();t={type:"binary",operator:r.value,left:t,right:n},r=this.peek()}return t}parseFactor(){let t=this.peek();if(!t)throw new Error("Unexpected end of expression");if(t.type==="symbol"&&t.value==="+")return this.index++,this.parseFactor();if(t.type==="symbol"&&t.value==="-"){this.index++;let r=this.parseFactor();return{type:"binary",operator:"-",left:{type:"literal",value:0},right:r}}if(t.type==="symbol"&&t.value==="("){this.index++;let r=this.parseBinaryExpression();if(!this.consumeSymbol(")"))throw new Error("Missing closing parenthesis");return r}if(t.type==="word"&&t.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(t.type==="number"){this.index++;let r=t.value,n=this.peek();return n&&n.type==="symbol"&&n.value==="%"?(this.index++,{type:"percentage",value:r/100}):n&&n.type==="word"&&n.value==="px"?(this.index++,{type:"literal",value:r}):{type:"literal",value:r}}throw new Error("Unexpected token in expression")}consumeSymbol(t){let r=this.peek();return r&&r.type==="symbol"&&r.value===t?(this.index++,!0):!1}peek(){return this.tokens[this.index]||null}};function bo(e){return e>="0"&&e<="9"}function xo(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}function Hc(e){return!!(e&&e.type==="symbol"&&(e.value==="+"||e.value==="-"))}function It(e,t,r){if(e===t)return!0;if(!r||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!It(e[n],t[n],r-1))return!1;return!0}if(Array.isArray(t))return!1;if(typeof e=="object"&&typeof t=="object"){let n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!1;for(let s of n)if(!t.hasOwnProperty(s)||!It(e[s],t[s],r-1))return!1;return!0}return!1}function yo(e,t){let r={...e};for(let n in t)n!=="id"&&(Array.isArray(r[n])&&Array.isArray(t[n])?r[n]=Kc(r[n],t[n]):r[n]=t[n]);return r}function Kc(e,t){e=e.slice();for(let r=0;r<t.length;r++){let n=t[r];Number.isFinite(n)&&(e[r]=n)}return e}var _e=class{constructor(t){let{id:r,x:n=0,y:i=0,width:s="100%",height:o="100%",padding:a=null}=t;this.id=r||this.constructor.displayName||"view",this.props={...t,id:this.id},this._x=Y(n),this._y=Y(i),this._width=Y(s),this._height=Y(o),this._padding=a&&{left:Y(a.left||0),right:Y(a.right||0),top:Y(a.top||0),bottom:Y(a.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(t){return this===t?!0:this.constructor===t.constructor&&It(this.props,t.props,2)}clone(t){let r=this.constructor;return new r({...this.props,...t})}makeViewport({width:t,height:r,viewState:n}){n=this.filterViewState(n);let i=this.getDimensions({width:t,height:r});if(!i.height||!i.width)return null;let s=this.getViewportType(n);return new s({...n,...this.props,...i})}getViewStateId(){let{viewState:t}=this.props;return typeof t=="string"?t:t?.id||this.id}filterViewState(t){return this.props.viewState&&typeof this.props.viewState=="object"?this.props.viewState.id?yo(t,this.props.viewState):this.props.viewState:t}getDimensions({width:t,height:r}){let n={x:j(this._x,t),y:j(this._y,r),width:j(this._width,t),height:j(this._height,r)};return this._padding&&(n.padding={left:j(this._padding.left,t),top:j(this._padding.top,r),right:j(this._padding.right,t),bottom:j(this._padding.bottom,r)}),n}get controller(){let t=this.props.controller;return t?t===!0?{type:this.ControllerType}:typeof t=="function"?{type:t}:{type:this.ControllerType,...t}:null}};ye();function qt(e,t){if(!e)throw new Error(t||"Assertion failed")}function On(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return qt(Number.isFinite(t)&&t>=0),t}function wo(e){let{logLevel:t,message:r}=e;e.logLevel=On(t);let n=e.args?Array.from(e.args):[];for(;n.length&&n.shift()!==r;);switch(typeof t){case"string":case"function":r!==void 0&&n.unshift(r),e.message=t;break;case"object":Object.assign(e,t);break;default:}typeof e.message=="function"&&(e.message=e.message());let i=typeof e.message;return qt(i==="string"||i==="object"),Object.assign(e,{args:n},e.opts)}var Bt=()=>{},Br=class{constructor({level:t=0}={}){this.userData={},this._onceCache=new Set,this._level=t}set level(t){this.setLevel(t)}get level(){return this.getLevel()}setLevel(t){return this._level=t,this}getLevel(){return this._level}warn(t,...r){return this._log("warn",0,t,r,{once:!0})}error(t,...r){return this._log("error",0,t,r)}log(t,r,...n){return this._log("log",t,r,n)}info(t,r,...n){return this._log("info",t,r,n)}once(t,r,...n){return this._log("once",t,r,n,{once:!0})}_log(t,r,n,i,s={}){let o=wo({logLevel:r,message:n,args:this._buildArgs(r,n,i),opts:s});return this._createLogFunction(t,o,s)}_buildArgs(t,r,n){return[t,r,...n]}_createLogFunction(t,r,n){if(!this._shouldLog(r.logLevel))return Bt;let i=this._getOnceTag(n.tag??r.tag??r.message);if((n.once||r.once)&&i!==void 0){if(this._onceCache.has(i))return Bt;this._onceCache.add(i)}return this._emit(t,r)}_shouldLog(t){return this.getLevel()>=On(t)}_getOnceTag(t){if(t!==void 0)try{return typeof t=="string"?t:String(t)}catch{return}}};function Qc(e){try{let t=window[e],r="__storage_test__";return t.setItem(r,r),t.removeItem(r),t}catch{return null}}var Dr=class{constructor(t,r,n="sessionStorage"){this.storage=Qc(n),this.id=t,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let t={};if(this.storage){let r=this.storage.getItem(this.id);t=r?JSON.parse(r):{}}return Object.assign(this.config,t),this}};function Eo(e){let t;return e<10?t=`${e.toFixed(2)}ms`:e<100?t=`${e.toFixed(1)}ms`:e<1e3?t=`${e.toFixed(0)}ms`:t=`${(e/1e3).toFixed(2)}s`,t}function To(e,t=8){let r=Math.max(t-e.length,0);return`${" ".repeat(r)}${e}`}ye();var Fr;(function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Fr||(Fr={}));var Jc=10;function _o(e){return typeof e!="string"?e:(e=e.toUpperCase(),Fr[e]||Fr.WHITE)}function vo(e,t,r){return!Et&&typeof e=="string"&&(t&&(e=`\x1B[${_o(t)}m${e}\x1B[39m`),r&&(e=`\x1B[${_o(r)+Jc}m${e}\x1B[49m`)),e}function So(e,t=["constructor"]){let r=Object.getPrototypeOf(e),n=Object.getOwnPropertyNames(r),i=e;for(let s of n){let o=i[s];typeof o=="function"&&(t.find(a=>s===a)||(i[s]=o.bind(e)))}}ye();function Xt(){let e;if(Et()&&vr.performance)e=vr?.performance?.now?.();else if("hrtime"in Sr){let t=Sr?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var Zt={debug:Et()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Nn={enabled:!0,level:0},Tt=class extends Br{constructor({id:t}={id:""}){super({level:0}),this.VERSION=Rn,this._startTs=Xt(),this._deltaTs=Xt(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=t,this.userData={},this._storage=new Dr(`__probe-${this.id}__`,{[this.id]:Nn}),this.timeStamp(`${this.id} started`),So(this),Object.seal(this)}isEnabled(){return this._getConfiguration().enabled}getLevel(){return this._getConfiguration().level}getTotal(){return Number((Xt()-this._startTs).toPrecision(10))}getDelta(){return Number((Xt()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(t=!0){return this._updateConfiguration({enabled:t}),this}setLevel(t){return this._updateConfiguration({level:t}),this}get(t){return this._getConfiguration()[t]}set(t,r){this._updateConfiguration({[t]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,r){if(!t)throw new Error(r||"Assertion failed")}warn(t,...r){return this._log("warn",0,t,r,{method:Zt.warn,once:!0})}error(t,...r){return this._log("error",0,t,r,{method:Zt.error})}deprecated(t,r){return this.warn(`\`${t}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(t,r){return this.error(`\`${t}\` has been removed. Use \`${r}\` instead`)}probe(t,r,...n){return this._log("log",t,r,n,{method:Zt.log,time:!0,once:!0})}log(t,r,...n){return this._log("log",t,r,n,{method:Zt.debug})}info(t,r,...n){return this._log("info",t,r,n,{method:console.info})}once(t,r,...n){return this._log("once",t,r,n,{method:Zt.debug||Zt.info,once:!0})}table(t,r,n){return r?this._log("table",t,r,n&&[n]||[],{method:console.table||Bt,tag:el(r)}):Bt}time(t,r){return this._log("time",t,r,[],{method:console.time?console.time:console.info})}timeEnd(t,r){return this._log("time",t,r,[],{method:console.timeEnd?console.timeEnd:console.info})}timeStamp(t,r){return this._log("time",t,r,[],{method:console.timeStamp||Bt})}group(t,r,n={collapsed:!1}){let i=(n.collapsed?console.groupCollapsed:console.group)||console.info;return this._log("group",t,r,[],{method:i})}groupCollapsed(t,r,n={}){return this.group(t,r,Object.assign({},n,{collapsed:!0}))}groupEnd(t){return this._log("groupEnd",t,"",[],{method:console.groupEnd||Bt})}withGroup(t,r,n){this.group(t,r)();try{n()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&super._shouldLog(t)}_emit(t,r){let n=r.method;qt(n),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Xt();let i=tl(this.id,r.message,r);return n.bind(console,i,...r.args)}_getConfiguration(){return this._storage.config[this.id]||this._updateConfiguration(Nn),this._storage.config[this.id]}_updateConfiguration(t){let r=this._storage.config[this.id]||{...Nn};this._storage.setConfiguration({[this.id]:{...r,...t}})}};Tt.VERSION=Rn;function tl(e,t,r){if(typeof t=="string"){let n=r.time?To(Eo(r.total)):"";t=r.time?`${e}: ${n} ${t}`:`${e}: ${t}`,t=vo(t,r.color,r.background)}return t}function el(e){for(let t in e)for(let r in e[t])return r||"untitled";return"empty"}globalThis.probe={};var Up=new Tt({id:"@probe.gl/log"});var rl=new Tt({id:"deck"}),Or=rl;var Zp=1/Math.PI*180,Hp=1/180*Math.PI,nl={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...nl}};var G=globalThis.mathgl.config;function Vn(e,{precision:t=G.precision}={}){return e=il(e),`${parseFloat(e.toPrecision(t))}`}function _t(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function $(e,t,r){return ol(e,n=>Math.max(t,Math.min(r,n)))}function ve(e,t,r){return _t(e)?e.map((n,i)=>ve(n,t[i],r)):r*t+(1-r)*e}function gt(e,t,r){let n=G.EPSILON;r&&(G.EPSILON=r);try{if(e===t)return!0;if(_t(e)&&_t(t)){if(e.length!==t.length)return!1;for(let i=0;i<e.length;++i)if(!gt(e[i],t[i]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=G.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{G.EPSILON=n}}function il(e){return Math.round(e/G.EPSILON)*G.EPSILON}function sl(e){return e.clone?e.clone():new Array(e.length)}function ol(e,t,r){if(_t(e)){let n=e;r=r||sl(n);for(let i=0;i<r.length&&i<n.length;++i){let s=typeof e=="number"?e:e[i];r[i]=t(s,i,r)}return r}return t(e)}var Ht=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=t[n+r];return this.check()}toArray(t=[],r=0){for(let n=0;n<this.ELEMENTS;++n)t[r+n]=this[n];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:_t(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(G)}formatString(t){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+Vn(this[n],t);return`${t.printTypes?this.constructor.name:""}[${r}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!gt(this[r],t[r]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==t[r])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,r,n){if(n===void 0)return this.lerp(this,t,r);for(let i=0;i<this.ELEMENTS;++i){let s=t[i],o=typeof r=="number"?r:r[i];this[i]=s+n*(o-s)}return this.check()}min(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(t[r],this[r]);return this.check()}max(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(t[r],this[r]);return this.check()}clamp(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t[n]),r[n]);return this.check()}add(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(t){if(typeof t=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;else for(let r=0;r<this.ELEMENTS&&r<t.length;++r)this[r]*=t[r];return this.check()}multiplyByScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}check(){if(G.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)t=t&&Number.isFinite(this[r]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=t;return this.check()}addScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t),r);return this.check()}get elements(){return this}};function al(e,t){if(e.length!==t)return!1;for(let r=0;r<e.length;++r)if(!Number.isFinite(e[r]))return!1;return!0}function z(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function Nr(e,t,r=""){if(G.debug&&!al(e,t))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return e}function Gn(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Vr=class extends Ht{get x(){return this[0]}set x(t){this[0]=z(t)}get y(){return this[1]}set y(t){this[1]=z(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*this[r];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let r=0;for(let n=0;n<this.ELEMENTS;++n){let i=this[n]-t[n];r+=i*i}return z(r)}dot(t){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*t[n];return z(r)}normalize(){let t=this.magnitude();if(t!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=t;return this.check()}multiply(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Gn(t>=0&&t<this.ELEMENTS,"index is out of range"),z(this[t])}setComponent(t,r){return Gn(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=r,this.check()}addVectors(t,r){return this.copy(t).add(r)}subVectors(t,r){return this.copy(t).subtract(r)}multiplyVectors(t,r){return this.copy(t).multiply(r)}addScaledVector(t,r){return this.add(new this.constructor(t).multiplyScalar(r))}};var at={};ce(at,{add:()=>fl,angle:()=>Rl,ceil:()=>dl,clone:()=>cl,copy:()=>hl,create:()=>Mo,cross:()=>vl,dist:()=>Gl,distance:()=>Ao,div:()=>Vl,divide:()=>Lo,dot:()=>_l,equals:()=>Dl,exactEquals:()=>Bl,floor:()=>ml,forEach:()=>Ul,fromValues:()=>ll,inverse:()=>El,len:()=>Fl,length:()=>ko,lerp:()=>Sl,max:()=>gl,min:()=>pl,mul:()=>Nl,multiply:()=>Co,negate:()=>wl,normalize:()=>Tl,random:()=>Ml,rotate:()=>Al,round:()=>bl,scale:()=>xl,scaleAndAdd:()=>yl,set:()=>ul,sqrDist:()=>zl,sqrLen:()=>Wl,squaredDistance:()=>Ro,squaredLength:()=>Io,str:()=>Il,sub:()=>Ol,subtract:()=>Po,transformMat2:()=>Pl,transformMat2d:()=>Cl,transformMat3:()=>Ll,transformMat4:()=>zn,zero:()=>kl});var O=typeof Float32Array<"u"?Float32Array:Array,bt=Math.random;function K(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var ag=Math.PI/180;function Mo(){let e=new O(2);return O!=Float32Array&&(e[0]=0,e[1]=0),e}function cl(e){let t=new O(2);return t[0]=e[0],t[1]=e[1],t}function ll(e,t){let r=new O(2);return r[0]=e,r[1]=t,r}function hl(e,t){return e[0]=t[0],e[1]=t[1],e}function ul(e,t,r){return e[0]=t,e[1]=r,e}function fl(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e}function Po(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e}function Co(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e}function Lo(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e}function dl(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e}function ml(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e}function pl(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e}function gl(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e}function bl(e,t){return e[0]=K(t[0]),e[1]=K(t[1]),e}function xl(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e}function yl(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e}function Ao(e,t){let r=t[0]-e[0],n=t[1]-e[1];return Math.sqrt(r*r+n*n)}function Ro(e,t){let r=t[0]-e[0],n=t[1]-e[1];return r*r+n*n}function ko(e){let t=e[0],r=e[1];return Math.sqrt(t*t+r*r)}function Io(e){let t=e[0],r=e[1];return t*t+r*r}function wl(e,t){return e[0]=-t[0],e[1]=-t[1],e}function El(e,t){return e[0]=1/t[0],e[1]=1/t[1],e}function Tl(e,t){let r=t[0],n=t[1],i=r*r+n*n;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e}function _l(e,t){return e[0]*t[0]+e[1]*t[1]}function vl(e,t,r){let n=t[0]*r[1]-t[1]*r[0];return e[0]=e[1]=0,e[2]=n,e}function Sl(e,t,r,n){let i=t[0],s=t[1];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e}function Ml(e,t){t=t===void 0?1:t;let r=bt()*2*Math.PI;return e[0]=Math.cos(r)*t,e[1]=Math.sin(r)*t,e}function Pl(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e}function Cl(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5],e}function Ll(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e}function zn(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e}function Al(e,t,r,n){let i=t[0]-r[0],s=t[1]-r[1],o=Math.sin(n),a=Math.cos(n);return e[0]=i*a-s*o+r[0],e[1]=i*o+s*a+r[1],e}function Rl(e,t){let r=e[0],n=e[1],i=t[0],s=t[1],o=Math.sqrt((r*r+n*n)*(i*i+s*s)),a=o&&(r*i+n*s)/o;return Math.acos(Math.min(Math.max(a,-1),1))}function kl(e){return e[0]=0,e[1]=0,e}function Il(e){return`vec2(${e[0]}, ${e[1]})`}function Bl(e,t){return e[0]===t[0]&&e[1]===t[1]}function Dl(e,t){let r=e[0],n=e[1],i=t[0],s=t[1];return Math.abs(r-i)<=1e-6*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(n-s)<=1e-6*Math.max(1,Math.abs(n),Math.abs(s))}var Fl=ko,Ol=Po,Nl=Co,Vl=Lo,Gl=Ao,zl=Ro,Wl=Io,Ul=(function(){let e=Mo();return function(t,r,n,i,s,o){let a,c;for(r||(r=2),n||(n=0),i?c=Math.min(i*r+n,t.length):c=t.length,a=n;a<c;a+=r)e[0]=t[a],e[1]=t[a+1],s(e,e,o),t[a]=e[0],t[a+1]=e[1];return t}})();function Bo(e,t,r){let n=t[0],i=t[1],s=r[3]*n+r[7]*i||1;return e[0]=(r[0]*n+r[4]*i)/s,e[1]=(r[1]*n+r[5]*i)/s,e}function zr(e,t,r){let n=t[0],i=t[1],s=t[2],o=r[3]*n+r[7]*i+r[11]*s||1;return e[0]=(r[0]*n+r[4]*i+r[8]*s)/o,e[1]=(r[1]*n+r[5]*i+r[9]*s)/o,e[2]=(r[2]*n+r[6]*i+r[10]*s)/o,e}function Do(e,t,r){let n=t[0],i=t[1];return e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e[2]=t[2],e}var Wr={};ce(Wr,{add:()=>Xl,angle:()=>Zn,bezier:()=>ch,ceil:()=>Zl,clone:()=>$l,copy:()=>jl,create:()=>Fo,cross:()=>Un,dist:()=>bh,distance:()=>zo,div:()=>gh,divide:()=>Go,dot:()=>Wn,equals:()=>dh,exactEquals:()=>fh,floor:()=>Hl,forEach:()=>Eh,fromValues:()=>Yl,hermite:()=>ah,inverse:()=>nh,len:()=>yh,length:()=>Oo,lerp:()=>sh,max:()=>Ql,min:()=>Kl,mul:()=>ph,multiply:()=>Vo,negate:()=>rh,normalize:()=>ih,random:()=>lh,rotateX:()=>jn,rotateY:()=>qn,rotateZ:()=>Xn,round:()=>Jl,scale:()=>th,scaleAndAdd:()=>eh,set:()=>ql,slerp:()=>oh,sqrDist:()=>xh,sqrLen:()=>wh,squaredDistance:()=>Wo,squaredLength:()=>Uo,str:()=>uh,sub:()=>mh,subtract:()=>No,transformMat3:()=>$n,transformMat4:()=>Se,transformQuat:()=>Yn,zero:()=>hh});function Fo(){let e=new O(3);return O!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function $l(e){let t=new O(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Oo(e){let t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function Yl(e,t,r){let n=new O(3);return n[0]=e,n[1]=t,n[2]=r,n}function jl(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function ql(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function Xl(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function No(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function Vo(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function Go(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function Zl(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function Hl(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function Kl(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function Ql(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function Jl(e,t){return e[0]=K(t[0]),e[1]=K(t[1]),e[2]=K(t[2]),e}function th(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function eh(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e}function zo(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return Math.sqrt(r*r+n*n+i*i)}function Wo(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2];return r*r+n*n+i*i}function Uo(e){let t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function rh(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function nh(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function ih(e,t){let r=t[0],n=t[1],i=t[2],s=r*r+n*n+i*i;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function Wn(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Un(e,t,r){let n=t[0],i=t[1],s=t[2],o=r[0],a=r[1],c=r[2];return e[0]=i*c-s*a,e[1]=s*o-n*c,e[2]=n*a-i*o,e}function sh(e,t,r,n){let i=t[0],s=t[1],o=t[2];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=o+n*(r[2]-o),e}function oh(e,t,r,n){let i=Math.acos(Math.min(Math.max(Wn(t,r),-1),1)),s=Math.sin(i),o=Math.sin((1-n)*i)/s,a=Math.sin(n*i)/s;return e[0]=o*t[0]+a*r[0],e[1]=o*t[1]+a*r[1],e[2]=o*t[2]+a*r[2],e}function ah(e,t,r,n,i,s){let o=s*s,a=o*(2*s-3)+1,c=o*(s-2)+s,l=o*(s-1),h=o*(3-2*s);return e[0]=t[0]*a+r[0]*c+n[0]*l+i[0]*h,e[1]=t[1]*a+r[1]*c+n[1]*l+i[1]*h,e[2]=t[2]*a+r[2]*c+n[2]*l+i[2]*h,e}function ch(e,t,r,n,i,s){let o=1-s,a=o*o,c=s*s,l=a*o,h=3*s*a,u=3*c*o,f=c*s;return e[0]=t[0]*l+r[0]*h+n[0]*u+i[0]*f,e[1]=t[1]*l+r[1]*h+n[1]*u+i[1]*f,e[2]=t[2]*l+r[2]*h+n[2]*u+i[2]*f,e}function lh(e,t){t=t===void 0?1:t;let r=bt()*2*Math.PI,n=bt()*2-1,i=Math.sqrt(1-n*n)*t;return e[0]=Math.cos(r)*i,e[1]=Math.sin(r)*i,e[2]=n*t,e}function Se(e,t,r){let n=t[0],i=t[1],s=t[2],o=r[3]*n+r[7]*i+r[11]*s+r[15];return o=o||1,e[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/o,e[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/o,e[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/o,e}function $n(e,t,r){let n=t[0],i=t[1],s=t[2];return e[0]=n*r[0]+i*r[3]+s*r[6],e[1]=n*r[1]+i*r[4]+s*r[7],e[2]=n*r[2]+i*r[5]+s*r[8],e}function Yn(e,t,r){let n=r[0],i=r[1],s=r[2],o=r[3],a=t[0],c=t[1],l=t[2],h=i*l-s*c,u=s*a-n*l,f=n*c-i*a,d=i*f-s*u,p=s*h-n*f,g=n*u-i*h,m=o*2;return h*=m,u*=m,f*=m,d*=2,p*=2,g*=2,e[0]=a+h+d,e[1]=c+u+p,e[2]=l+f+g,e}function jn(e,t,r,n){let i=[],s=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],s[0]=i[0],s[1]=i[1]*Math.cos(n)-i[2]*Math.sin(n),s[2]=i[1]*Math.sin(n)+i[2]*Math.cos(n),e[0]=s[0]+r[0],e[1]=s[1]+r[1],e[2]=s[2]+r[2],e}function qn(e,t,r,n){let i=[],s=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],s[0]=i[2]*Math.sin(n)+i[0]*Math.cos(n),s[1]=i[1],s[2]=i[2]*Math.cos(n)-i[0]*Math.sin(n),e[0]=s[0]+r[0],e[1]=s[1]+r[1],e[2]=s[2]+r[2],e}function Xn(e,t,r,n){let i=[],s=[];return i[0]=t[0]-r[0],i[1]=t[1]-r[1],i[2]=t[2]-r[2],s[0]=i[0]*Math.cos(n)-i[1]*Math.sin(n),s[1]=i[0]*Math.sin(n)+i[1]*Math.cos(n),s[2]=i[2],e[0]=s[0]+r[0],e[1]=s[1]+r[1],e[2]=s[2]+r[2],e}function Zn(e,t){let r=e[0],n=e[1],i=e[2],s=t[0],o=t[1],a=t[2],c=Math.sqrt((r*r+n*n+i*i)*(s*s+o*o+a*a)),l=c&&Wn(e,t)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function hh(e){return e[0]=0,e[1]=0,e[2]=0,e}function uh(e){return`vec3(${e[0]}, ${e[1]}, ${e[2]})`}function fh(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function dh(e,t){let r=e[0],n=e[1],i=e[2],s=t[0],o=t[1],a=t[2];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-o)<=1e-6*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))}var mh=No,ph=Vo,gh=Go,bh=zo,xh=Wo,yh=Oo,wh=Uo,Eh=(function(){let e=Fo();return function(t,r,n,i,s,o){let a,c;for(r||(r=3),n||(n=0),i?c=Math.min(i*r+n,t.length):c=t.length,a=n;a<c;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],s(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}})();var Hn=[0,0,0],Ur,vt=class e extends Vr{static get ZERO(){return Ur||(Ur=new e(0,0,0),Object.freeze(Ur)),Ur}constructor(t=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&_t(t)?this.copy(t):(G.debug&&(z(t),z(r),z(n)),this[0]=t,this[1]=r,this[2]=n)}set(t,r,n){return this[0]=t,this[1]=r,this[2]=n,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return G.debug&&(z(t.x),z(t.y),z(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=z(t)}angle(t){return Zn(this,t)}cross(t){return Un(this,this,t),this.check()}rotateX({radians:t,origin:r=Hn}){return jn(this,this,r,t),this.check()}rotateY({radians:t,origin:r=Hn}){return qn(this,this,r,t),this.check()}rotateZ({radians:t,origin:r=Hn}){return Xn(this,this,r,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Se(this,this,t),this.check()}transformAsVector(t){return zr(this,this,t),this.check()}transformByMatrix3(t){return $n(this,this,t),this.check()}transformByMatrix2(t){return Do(this,this,t),this.check()}transformByQuaternion(t){return Yn(this,this,t),this.check()}};var $r=class extends Ht{toString(){let t="[";if(G.printRowMajor){t+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)t+=` ${this[n*this.RANK+r]}`}else{t+="column-major:";for(let r=0;r<this.ELEMENTS;++r)t+=` ${this[r]}`}return t+="]",t}getElementIndex(t,r){return r*this.RANK+t}getElement(t,r){return this[r*this.RANK+t]}setElement(t,r,n){return this[r*this.RANK+t]=z(n),this}getColumn(t,r=new Array(this.RANK).fill(-0)){let n=t*this.RANK;for(let i=0;i<this.RANK;++i)r[i]=this[n+i];return r}setColumn(t,r){let n=t*this.RANK;for(let i=0;i<this.RANK;++i)this[n+i]=r[i];return this}};var W={};ce(W,{add:()=>jh,adjoint:()=>Ph,clone:()=>_h,copy:()=>vh,create:()=>Th,decompose:()=>Oh,determinant:()=>Jn,equals:()=>Hh,exactEquals:()=>Zh,frob:()=>Yh,fromQuat:()=>oi,fromQuat2:()=>Bh,fromRotation:()=>Ah,fromRotationTranslation:()=>Yo,fromRotationTranslationScale:()=>Nh,fromRotationTranslationScaleOrigin:()=>Vh,fromScaling:()=>Lh,fromTranslation:()=>Ch,fromValues:()=>Sh,fromXRotation:()=>Rh,fromYRotation:()=>kh,fromZRotation:()=>Ih,frustum:()=>ai,getRotation:()=>Fh,getScaling:()=>jo,getTranslation:()=>Dh,identity:()=>$o,invert:()=>Qn,lookAt:()=>hi,mul:()=>Kh,multiply:()=>Me,multiplyScalar:()=>qh,multiplyScalarAndAdd:()=>Xh,ortho:()=>li,orthoNO:()=>Xo,orthoZO:()=>Wh,perspective:()=>ci,perspectiveFromFieldOfView:()=>zh,perspectiveNO:()=>qo,perspectiveZO:()=>Gh,rotate:()=>ri,rotateX:()=>ni,rotateY:()=>ii,rotateZ:()=>si,scale:()=>ei,set:()=>Mh,str:()=>$h,sub:()=>Qh,subtract:()=>Zo,targetTo:()=>Uh,translate:()=>ti,transpose:()=>Kn});function Th(){let e=new O(16);return O!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function _h(e){let t=new O(16);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 vh(e,t){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 Sh(e,t,r,n,i,s,o,a,c,l,h,u,f,d,p,g){let m=new O(16);return m[0]=e,m[1]=t,m[2]=r,m[3]=n,m[4]=i,m[5]=s,m[6]=o,m[7]=a,m[8]=c,m[9]=l,m[10]=h,m[11]=u,m[12]=f,m[13]=d,m[14]=p,m[15]=g,m}function Mh(e,t,r,n,i,s,o,a,c,l,h,u,f,d,p,g,m){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e[4]=s,e[5]=o,e[6]=a,e[7]=c,e[8]=l,e[9]=h,e[10]=u,e[11]=f,e[12]=d,e[13]=p,e[14]=g,e[15]=m,e}function $o(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Kn(e,t){if(e===t){let r=t[1],n=t[2],i=t[3],s=t[6],o=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=s,e[11]=t[14],e[12]=i,e[13]=o,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function Qn(e,t){let r=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],u=t[9],f=t[10],d=t[11],p=t[12],g=t[13],m=t[14],x=t[15],_=r*a-n*o,b=r*c-i*o,w=r*l-s*o,v=n*c-i*a,E=n*l-s*a,y=i*l-s*c,T=h*g-u*p,M=h*m-f*p,S=h*x-d*p,C=u*m-f*g,L=u*x-d*g,R=f*x-d*m,A=_*R-b*L+w*C+v*S-E*M+y*T;return A?(A=1/A,e[0]=(a*R-c*L+l*C)*A,e[1]=(i*L-n*R-s*C)*A,e[2]=(g*y-m*E+x*v)*A,e[3]=(f*E-u*y-d*v)*A,e[4]=(c*S-o*R-l*M)*A,e[5]=(r*R-i*S+s*M)*A,e[6]=(m*w-p*y-x*b)*A,e[7]=(h*y-f*w+d*b)*A,e[8]=(o*L-a*S+l*T)*A,e[9]=(n*S-r*L-s*T)*A,e[10]=(p*E-g*w+x*_)*A,e[11]=(u*w-h*E-d*_)*A,e[12]=(a*M-o*C-c*T)*A,e[13]=(r*C-n*M+i*T)*A,e[14]=(g*b-p*v-m*_)*A,e[15]=(h*v-u*b+f*_)*A,e):null}function Ph(e,t){let r=t[0],n=t[1],i=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],u=t[9],f=t[10],d=t[11],p=t[12],g=t[13],m=t[14],x=t[15],_=r*a-n*o,b=r*c-i*o,w=r*l-s*o,v=n*c-i*a,E=n*l-s*a,y=i*l-s*c,T=h*g-u*p,M=h*m-f*p,S=h*x-d*p,C=u*m-f*g,L=u*x-d*g,R=f*x-d*m;return e[0]=a*R-c*L+l*C,e[1]=i*L-n*R-s*C,e[2]=g*y-m*E+x*v,e[3]=f*E-u*y-d*v,e[4]=c*S-o*R-l*M,e[5]=r*R-i*S+s*M,e[6]=m*w-p*y-x*b,e[7]=h*y-f*w+d*b,e[8]=o*L-a*S+l*T,e[9]=n*S-r*L-s*T,e[10]=p*E-g*w+x*_,e[11]=u*w-h*E-d*_,e[12]=a*M-o*C-c*T,e[13]=r*C-n*M+i*T,e[14]=g*b-p*v-m*_,e[15]=h*v-u*b+f*_,e}function Jn(e){let t=e[0],r=e[1],n=e[2],i=e[3],s=e[4],o=e[5],a=e[6],c=e[7],l=e[8],h=e[9],u=e[10],f=e[11],d=e[12],p=e[13],g=e[14],m=e[15],x=t*o-r*s,_=t*a-n*s,b=r*a-n*o,w=l*p-h*d,v=l*g-u*d,E=h*g-u*p,y=t*E-r*v+n*w,T=s*E-o*v+a*w,M=l*b-h*_+u*x,S=d*b-p*_+g*x;return c*y-i*T+m*M-f*S}function Me(e,t,r){let n=t[0],i=t[1],s=t[2],o=t[3],a=t[4],c=t[5],l=t[6],h=t[7],u=t[8],f=t[9],d=t[10],p=t[11],g=t[12],m=t[13],x=t[14],_=t[15],b=r[0],w=r[1],v=r[2],E=r[3];return e[0]=b*n+w*a+v*u+E*g,e[1]=b*i+w*c+v*f+E*m,e[2]=b*s+w*l+v*d+E*x,e[3]=b*o+w*h+v*p+E*_,b=r[4],w=r[5],v=r[6],E=r[7],e[4]=b*n+w*a+v*u+E*g,e[5]=b*i+w*c+v*f+E*m,e[6]=b*s+w*l+v*d+E*x,e[7]=b*o+w*h+v*p+E*_,b=r[8],w=r[9],v=r[10],E=r[11],e[8]=b*n+w*a+v*u+E*g,e[9]=b*i+w*c+v*f+E*m,e[10]=b*s+w*l+v*d+E*x,e[11]=b*o+w*h+v*p+E*_,b=r[12],w=r[13],v=r[14],E=r[15],e[12]=b*n+w*a+v*u+E*g,e[13]=b*i+w*c+v*f+E*m,e[14]=b*s+w*l+v*d+E*x,e[15]=b*o+w*h+v*p+E*_,e}function ti(e,t,r){let n=r[0],i=r[1],s=r[2],o,a,c,l,h,u,f,d,p,g,m,x;return t===e?(e[12]=t[0]*n+t[4]*i+t[8]*s+t[12],e[13]=t[1]*n+t[5]*i+t[9]*s+t[13],e[14]=t[2]*n+t[6]*i+t[10]*s+t[14],e[15]=t[3]*n+t[7]*i+t[11]*s+t[15]):(o=t[0],a=t[1],c=t[2],l=t[3],h=t[4],u=t[5],f=t[6],d=t[7],p=t[8],g=t[9],m=t[10],x=t[11],e[0]=o,e[1]=a,e[2]=c,e[3]=l,e[4]=h,e[5]=u,e[6]=f,e[7]=d,e[8]=p,e[9]=g,e[10]=m,e[11]=x,e[12]=o*n+h*i+p*s+t[12],e[13]=a*n+u*i+g*s+t[13],e[14]=c*n+f*i+m*s+t[14],e[15]=l*n+d*i+x*s+t[15]),e}function ei(e,t,r){let n=r[0],i=r[1],s=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*i,e[5]=t[5]*i,e[6]=t[6]*i,e[7]=t[7]*i,e[8]=t[8]*s,e[9]=t[9]*s,e[10]=t[10]*s,e[11]=t[11]*s,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function ri(e,t,r,n){let i=n[0],s=n[1],o=n[2],a=Math.sqrt(i*i+s*s+o*o),c,l,h,u,f,d,p,g,m,x,_,b,w,v,E,y,T,M,S,C,L,R,A,D;return a<1e-6?null:(a=1/a,i*=a,s*=a,o*=a,l=Math.sin(r),c=Math.cos(r),h=1-c,u=t[0],f=t[1],d=t[2],p=t[3],g=t[4],m=t[5],x=t[6],_=t[7],b=t[8],w=t[9],v=t[10],E=t[11],y=i*i*h+c,T=s*i*h+o*l,M=o*i*h-s*l,S=i*s*h-o*l,C=s*s*h+c,L=o*s*h+i*l,R=i*o*h+s*l,A=s*o*h-i*l,D=o*o*h+c,e[0]=u*y+g*T+b*M,e[1]=f*y+m*T+w*M,e[2]=d*y+x*T+v*M,e[3]=p*y+_*T+E*M,e[4]=u*S+g*C+b*L,e[5]=f*S+m*C+w*L,e[6]=d*S+x*C+v*L,e[7]=p*S+_*C+E*L,e[8]=u*R+g*A+b*D,e[9]=f*R+m*A+w*D,e[10]=d*R+x*A+v*D,e[11]=p*R+_*A+E*D,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function ni(e,t,r){let n=Math.sin(r),i=Math.cos(r),s=t[4],o=t[5],a=t[6],c=t[7],l=t[8],h=t[9],u=t[10],f=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=s*i+l*n,e[5]=o*i+h*n,e[6]=a*i+u*n,e[7]=c*i+f*n,e[8]=l*i-s*n,e[9]=h*i-o*n,e[10]=u*i-a*n,e[11]=f*i-c*n,e}function ii(e,t,r){let n=Math.sin(r),i=Math.cos(r),s=t[0],o=t[1],a=t[2],c=t[3],l=t[8],h=t[9],u=t[10],f=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=s*i-l*n,e[1]=o*i-h*n,e[2]=a*i-u*n,e[3]=c*i-f*n,e[8]=s*n+l*i,e[9]=o*n+h*i,e[10]=a*n+u*i,e[11]=c*n+f*i,e}function si(e,t,r){let n=Math.sin(r),i=Math.cos(r),s=t[0],o=t[1],a=t[2],c=t[3],l=t[4],h=t[5],u=t[6],f=t[7];return t!==e&&(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[0]=s*i+l*n,e[1]=o*i+h*n,e[2]=a*i+u*n,e[3]=c*i+f*n,e[4]=l*i-s*n,e[5]=h*i-o*n,e[6]=u*i-a*n,e[7]=f*i-c*n,e}function Ch(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function Lh(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ah(e,t,r){let n=r[0],i=r[1],s=r[2],o=Math.sqrt(n*n+i*i+s*s),a,c,l;return o<1e-6?null:(o=1/o,n*=o,i*=o,s*=o,c=Math.sin(t),a=Math.cos(t),l=1-a,e[0]=n*n*l+a,e[1]=i*n*l+s*c,e[2]=s*n*l-i*c,e[3]=0,e[4]=n*i*l-s*c,e[5]=i*i*l+a,e[6]=s*i*l+n*c,e[7]=0,e[8]=n*s*l+i*c,e[9]=i*s*l-n*c,e[10]=s*s*l+a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function Rh(e,t){let r=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function kh(e,t){let r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Ih(e,t){let r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Yo(e,t,r){let n=t[0],i=t[1],s=t[2],o=t[3],a=n+n,c=i+i,l=s+s,h=n*a,u=n*c,f=n*l,d=i*c,p=i*l,g=s*l,m=o*a,x=o*c,_=o*l;return e[0]=1-(d+g),e[1]=u+_,e[2]=f-x,e[3]=0,e[4]=u-_,e[5]=1-(h+g),e[6]=p+m,e[7]=0,e[8]=f+x,e[9]=p-m,e[10]=1-(h+d),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function Bh(e,t){let r=new O(3),n=-t[0],i=-t[1],s=-t[2],o=t[3],a=t[4],c=t[5],l=t[6],h=t[7],u=n*n+i*i+s*s+o*o;return u>0?(r[0]=(a*o+h*n+c*s-l*i)*2/u,r[1]=(c*o+h*i+l*n-a*s)*2/u,r[2]=(l*o+h*s+a*i-c*n)*2/u):(r[0]=(a*o+h*n+c*s-l*i)*2,r[1]=(c*o+h*i+l*n-a*s)*2,r[2]=(l*o+h*s+a*i-c*n)*2),Yo(e,t,r),e}function Dh(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function jo(e,t){let r=t[0],n=t[1],i=t[2],s=t[4],o=t[5],a=t[6],c=t[8],l=t[9],h=t[10];return e[0]=Math.sqrt(r*r+n*n+i*i),e[1]=Math.sqrt(s*s+o*o+a*a),e[2]=Math.sqrt(c*c+l*l+h*h),e}function Fh(e,t){let r=new O(3);jo(r,t);let n=1/r[0],i=1/r[1],s=1/r[2],o=t[0]*n,a=t[1]*i,c=t[2]*s,l=t[4]*n,h=t[5]*i,u=t[6]*s,f=t[8]*n,d=t[9]*i,p=t[10]*s,g=o+h+p,m=0;return g>0?(m=Math.sqrt(g+1)*2,e[3]=.25*m,e[0]=(u-d)/m,e[1]=(f-c)/m,e[2]=(a-l)/m):o>h&&o>p?(m=Math.sqrt(1+o-h-p)*2,e[3]=(u-d)/m,e[0]=.25*m,e[1]=(a+l)/m,e[2]=(f+c)/m):h>p?(m=Math.sqrt(1+h-o-p)*2,e[3]=(f-c)/m,e[0]=(a+l)/m,e[1]=.25*m,e[2]=(u+d)/m):(m=Math.sqrt(1+p-o-h)*2,e[3]=(a-l)/m,e[0]=(f+c)/m,e[1]=(u+d)/m,e[2]=.25*m),e}function Oh(e,t,r,n){t[0]=n[12],t[1]=n[13],t[2]=n[14];let i=n[0],s=n[1],o=n[2],a=n[4],c=n[5],l=n[6],h=n[8],u=n[9],f=n[10];r[0]=Math.sqrt(i*i+s*s+o*o),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(h*h+u*u+f*f);let d=1/r[0],p=1/r[1],g=1/r[2],m=i*d,x=s*p,_=o*g,b=a*d,w=c*p,v=l*g,E=h*d,y=u*p,T=f*g,M=m+w+T,S=0;return M>0?(S=Math.sqrt(M+1)*2,e[3]=.25*S,e[0]=(v-y)/S,e[1]=(E-_)/S,e[2]=(x-b)/S):m>w&&m>T?(S=Math.sqrt(1+m-w-T)*2,e[3]=(v-y)/S,e[0]=.25*S,e[1]=(x+b)/S,e[2]=(E+_)/S):w>T?(S=Math.sqrt(1+w-m-T)*2,e[3]=(E-_)/S,e[0]=(x+b)/S,e[1]=.25*S,e[2]=(v+y)/S):(S=Math.sqrt(1+T-m-w)*2,e[3]=(x-b)/S,e[0]=(E+_)/S,e[1]=(v+y)/S,e[2]=.25*S),e}function Nh(e,t,r,n){let i=t[0],s=t[1],o=t[2],a=t[3],c=i+i,l=s+s,h=o+o,u=i*c,f=i*l,d=i*h,p=s*l,g=s*h,m=o*h,x=a*c,_=a*l,b=a*h,w=n[0],v=n[1],E=n[2];return e[0]=(1-(p+m))*w,e[1]=(f+b)*w,e[2]=(d-_)*w,e[3]=0,e[4]=(f-b)*v,e[5]=(1-(u+m))*v,e[6]=(g+x)*v,e[7]=0,e[8]=(d+_)*E,e[9]=(g-x)*E,e[10]=(1-(u+p))*E,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function Vh(e,t,r,n,i){let s=t[0],o=t[1],a=t[2],c=t[3],l=s+s,h=o+o,u=a+a,f=s*l,d=s*h,p=s*u,g=o*h,m=o*u,x=a*u,_=c*l,b=c*h,w=c*u,v=n[0],E=n[1],y=n[2],T=i[0],M=i[1],S=i[2],C=(1-(g+x))*v,L=(d+w)*v,R=(p-b)*v,A=(d-w)*E,D=(1-(f+x))*E,ht=(m+_)*E,H=(p+b)*y,Ue=(m-_)*y,Ri=(1-(f+g))*y;return e[0]=C,e[1]=L,e[2]=R,e[3]=0,e[4]=A,e[5]=D,e[6]=ht,e[7]=0,e[8]=H,e[9]=Ue,e[10]=Ri,e[11]=0,e[12]=r[0]+T-(C*T+A*M+H*S),e[13]=r[1]+M-(L*T+D*M+Ue*S),e[14]=r[2]+S-(R*T+ht*M+Ri*S),e[15]=1,e}function oi(e,t){let r=t[0],n=t[1],i=t[2],s=t[3],o=r+r,a=n+n,c=i+i,l=r*o,h=n*o,u=n*a,f=i*o,d=i*a,p=i*c,g=s*o,m=s*a,x=s*c;return e[0]=1-u-p,e[1]=h+x,e[2]=f-m,e[3]=0,e[4]=h-x,e[5]=1-l-p,e[6]=d+g,e[7]=0,e[8]=f+m,e[9]=d-g,e[10]=1-l-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function ai(e,t,r,n,i,s,o){let a=1/(r-t),c=1/(i-n),l=1/(s-o);return e[0]=s*2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s*2*c,e[6]=0,e[7]=0,e[8]=(r+t)*a,e[9]=(i+n)*c,e[10]=(o+s)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*s*2*l,e[15]=0,e}function qo(e,t,r,n,i){let s=1/Math.tan(t/2);if(e[0]=s/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){let o=1/(n-i);e[10]=(i+n)*o,e[14]=2*i*n*o}else e[10]=-1,e[14]=-2*n;return e}var ci=qo;function Gh(e,t,r,n,i){let s=1/Math.tan(t/2);if(e[0]=s/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,i!=null&&i!==1/0){let o=1/(n-i);e[10]=i*o,e[14]=i*n*o}else e[10]=-1,e[14]=-n;return e}function zh(e,t,r,n){let i=Math.tan(t.upDegrees*Math.PI/180),s=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),c=2/(o+a),l=2/(i+s);return e[0]=c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-((o-a)*c*.5),e[9]=(i-s)*l*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e}function Xo(e,t,r,n,i,s,o){let a=1/(t-r),c=1/(n-i),l=1/(s-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*a,e[13]=(i+n)*c,e[14]=(o+s)*l,e[15]=1,e}var li=Xo;function Wh(e,t,r,n,i,s,o){let a=1/(t-r),c=1/(n-i),l=1/(s-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=l,e[11]=0,e[12]=(t+r)*a,e[13]=(i+n)*c,e[14]=s*l,e[15]=1,e}function hi(e,t,r,n){let i,s,o,a,c,l,h,u,f,d,p=t[0],g=t[1],m=t[2],x=n[0],_=n[1],b=n[2],w=r[0],v=r[1],E=r[2];return Math.abs(p-w)<1e-6&&Math.abs(g-v)<1e-6&&Math.abs(m-E)<1e-6?$o(e):(u=p-w,f=g-v,d=m-E,i=1/Math.sqrt(u*u+f*f+d*d),u*=i,f*=i,d*=i,s=_*d-b*f,o=b*u-x*d,a=x*f-_*u,i=Math.sqrt(s*s+o*o+a*a),i?(i=1/i,s*=i,o*=i,a*=i):(s=0,o=0,a=0),c=f*a-d*o,l=d*s-u*a,h=u*o-f*s,i=Math.sqrt(c*c+l*l+h*h),i?(i=1/i,c*=i,l*=i,h*=i):(c=0,l=0,h=0),e[0]=s,e[1]=c,e[2]=u,e[3]=0,e[4]=o,e[5]=l,e[6]=f,e[7]=0,e[8]=a,e[9]=h,e[10]=d,e[11]=0,e[12]=-(s*p+o*g+a*m),e[13]=-(c*p+l*g+h*m),e[14]=-(u*p+f*g+d*m),e[15]=1,e)}function Uh(e,t,r,n){let i=t[0],s=t[1],o=t[2],a=n[0],c=n[1],l=n[2],h=i-r[0],u=s-r[1],f=o-r[2],d=h*h+u*u+f*f;d>0&&(d=1/Math.sqrt(d),h*=d,u*=d,f*=d);let p=c*f-l*u,g=l*h-a*f,m=a*u-c*h;return d=p*p+g*g+m*m,d>0&&(d=1/Math.sqrt(d),p*=d,g*=d,m*=d),e[0]=p,e[1]=g,e[2]=m,e[3]=0,e[4]=u*m-f*g,e[5]=f*p-h*m,e[6]=h*g-u*p,e[7]=0,e[8]=h,e[9]=u,e[10]=f,e[11]=0,e[12]=i,e[13]=s,e[14]=o,e[15]=1,e}function $h(e){return`mat4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]}, ${e[4]}, ${e[5]}, ${e[6]}, ${e[7]}, ${e[8]}, ${e[9]}, ${e[10]}, ${e[11]}, ${e[12]}, ${e[13]}, ${e[14]}, ${e[15]})`}function Yh(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function jh(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e}function Zo(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}function qh(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e}function Xh(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e}function Zh(e,t){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]}function Hh(e,t){let r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],h=e[8],u=e[9],f=e[10],d=e[11],p=e[12],g=e[13],m=e[14],x=e[15],_=t[0],b=t[1],w=t[2],v=t[3],E=t[4],y=t[5],T=t[6],M=t[7],S=t[8],C=t[9],L=t[10],R=t[11],A=t[12],D=t[13],ht=t[14],H=t[15];return Math.abs(r-_)<=1e-6*Math.max(1,Math.abs(r),Math.abs(_))&&Math.abs(n-b)<=1e-6*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(i-w)<=1e-6*Math.max(1,Math.abs(i),Math.abs(w))&&Math.abs(s-v)<=1e-6*Math.max(1,Math.abs(s),Math.abs(v))&&Math.abs(o-E)<=1e-6*Math.max(1,Math.abs(o),Math.abs(E))&&Math.abs(a-y)<=1e-6*Math.max(1,Math.abs(a),Math.abs(y))&&Math.abs(c-T)<=1e-6*Math.max(1,Math.abs(c),Math.abs(T))&&Math.abs(l-M)<=1e-6*Math.max(1,Math.abs(l),Math.abs(M))&&Math.abs(h-S)<=1e-6*Math.max(1,Math.abs(h),Math.abs(S))&&Math.abs(u-C)<=1e-6*Math.max(1,Math.abs(u),Math.abs(C))&&Math.abs(f-L)<=1e-6*Math.max(1,Math.abs(f),Math.abs(L))&&Math.abs(d-R)<=1e-6*Math.max(1,Math.abs(d),Math.abs(R))&&Math.abs(p-A)<=1e-6*Math.max(1,Math.abs(p),Math.abs(A))&&Math.abs(g-D)<=1e-6*Math.max(1,Math.abs(g),Math.abs(D))&&Math.abs(m-ht)<=1e-6*Math.max(1,Math.abs(m),Math.abs(ht))&&Math.abs(x-H)<=1e-6*Math.max(1,Math.abs(x),Math.abs(H))}var Kh=Me,Qh=Zo;var Pe={};ce(Pe,{add:()=>nu,ceil:()=>iu,clone:()=>Jh,copy:()=>eu,create:()=>Ho,cross:()=>pu,dist:()=>Mu,distance:()=>ta,div:()=>Su,divide:()=>Jo,dot:()=>mu,equals:()=>Tu,exactEquals:()=>Eu,floor:()=>su,forEach:()=>Au,fromValues:()=>tu,inverse:()=>fu,len:()=>Cu,length:()=>ra,lerp:()=>gu,max:()=>au,min:()=>ou,mul:()=>vu,multiply:()=>Qo,negate:()=>uu,normalize:()=>du,random:()=>bu,round:()=>cu,scale:()=>lu,scaleAndAdd:()=>hu,set:()=>ru,sqrDist:()=>Pu,sqrLen:()=>Lu,squaredDistance:()=>ea,squaredLength:()=>na,str:()=>wu,sub:()=>_u,subtract:()=>Ko,transformMat4:()=>ui,transformQuat:()=>xu,zero:()=>yu});function Ho(){let e=new O(4);return O!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Jh(e){let t=new O(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t}function tu(e,t,r,n){let i=new O(4);return i[0]=e,i[1]=t,i[2]=r,i[3]=n,i}function eu(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function ru(e,t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,e[3]=i,e}function nu(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function Ko(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e}function Qo(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e[3]=t[3]*r[3],e}function Jo(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e[3]=t[3]/r[3],e}function iu(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e[3]=Math.ceil(t[3]),e}function su(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e[3]=Math.floor(t[3]),e}function ou(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e[3]=Math.min(t[3],r[3]),e}function au(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e[3]=Math.max(t[3],r[3]),e}function cu(e,t){return e[0]=K(t[0]),e[1]=K(t[1]),e[2]=K(t[2]),e[3]=K(t[3]),e}function lu(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function hu(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e}function ta(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2],s=t[3]-e[3];return Math.sqrt(r*r+n*n+i*i+s*s)}function ea(e,t){let r=t[0]-e[0],n=t[1]-e[1],i=t[2]-e[2],s=t[3]-e[3];return r*r+n*n+i*i+s*s}function ra(e){let t=e[0],r=e[1],n=e[2],i=e[3];return Math.sqrt(t*t+r*r+n*n+i*i)}function na(e){let t=e[0],r=e[1],n=e[2],i=e[3];return t*t+r*r+n*n+i*i}function uu(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e}function fu(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e}function du(e,t){let r=t[0],n=t[1],i=t[2],s=t[3],o=r*r+n*n+i*i+s*s;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=n*o,e[2]=i*o,e[3]=s*o,e}function mu(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function pu(e,t,r,n){let i=r[0]*n[1]-r[1]*n[0],s=r[0]*n[2]-r[2]*n[0],o=r[0]*n[3]-r[3]*n[0],a=r[1]*n[2]-r[2]*n[1],c=r[1]*n[3]-r[3]*n[1],l=r[2]*n[3]-r[3]*n[2],h=t[0],u=t[1],f=t[2],d=t[3];return e[0]=u*l-f*c+d*a,e[1]=-(h*l)+f*o-d*s,e[2]=h*c-u*o+d*i,e[3]=-(h*a)+u*s-f*i,e}function gu(e,t,r,n){let i=t[0],s=t[1],o=t[2],a=t[3];return e[0]=i+n*(r[0]-i),e[1]=s+n*(r[1]-s),e[2]=o+n*(r[2]-o),e[3]=a+n*(r[3]-a),e}function bu(e,t){t=t===void 0?1:t;let r,n,i,s,o,a;do r=bt()*2-1,n=bt()*2-1,o=r*r+n*n;while(o>=1);do i=bt()*2-1,s=bt()*2-1,a=i*i+s*s;while(a>=1);let c=Math.sqrt((1-o)/a);return e[0]=t*r,e[1]=t*n,e[2]=t*i*c,e[3]=t*s*c,e}function ui(e,t,r){let n=t[0],i=t[1],s=t[2],o=t[3];return e[0]=r[0]*n+r[4]*i+r[8]*s+r[12]*o,e[1]=r[1]*n+r[5]*i+r[9]*s+r[13]*o,e[2]=r[2]*n+r[6]*i+r[10]*s+r[14]*o,e[3]=r[3]*n+r[7]*i+r[11]*s+r[15]*o,e}function xu(e,t,r){let n=t[0],i=t[1],s=t[2],o=r[0],a=r[1],c=r[2],l=r[3],h=l*n+a*s-c*i,u=l*i+c*n-o*s,f=l*s+o*i-a*n,d=-o*n-a*i-c*s;return e[0]=h*l+d*-o+u*-c-f*-a,e[1]=u*l+d*-a+f*-o-h*-c,e[2]=f*l+d*-c+h*-a-u*-o,e[3]=t[3],e}function yu(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function wu(e){return`vec4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]})`}function Eu(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function Tu(e,t){let r=e[0],n=e[1],i=e[2],s=e[3],o=t[0],a=t[1],c=t[2],l=t[3];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-a)<=1e-6*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(i-c)<=1e-6*Math.max(1,Math.abs(i),Math.abs(c))&&Math.abs(s-l)<=1e-6*Math.max(1,Math.abs(s),Math.abs(l))}var _u=Ko,vu=Qo,Su=Jo,Mu=ta,Pu=ea,Cu=ra,Lu=na,Au=(function(){let e=Ho();return function(t,r,n,i,s,o){let a,c;for(r||(r=4),n||(n=0),i?c=Math.min(i*r+n,t.length):c=t.length,a=n;a<c;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],e[3]=t[a+3],s(e,e,o),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2],t[a+3]=e[3];return t}})();var mi;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(mi||(mi={}));var Ru=45*Math.PI/180,ku=1,fi=.1,di=500,Iu=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Q=class extends $r{static get IDENTITY(){return Du()}static get ZERO(){return Bu()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return mi}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,r,n,i,s,o,a,c,l,h,u,f,d,p,g,m){return this[0]=t,this[1]=r,this[2]=n,this[3]=i,this[4]=s,this[5]=o,this[6]=a,this[7]=c,this[8]=l,this[9]=h,this[10]=u,this[11]=f,this[12]=d,this[13]=p,this[14]=g,this[15]=m,this.check()}setRowMajor(t,r,n,i,s,o,a,c,l,h,u,f,d,p,g,m){return this[0]=t,this[1]=s,this[2]=l,this[3]=d,this[4]=r,this[5]=o,this[6]=h,this[7]=p,this[8]=n,this[9]=a,this[10]=u,this[11]=g,this[12]=i,this[13]=c,this[14]=f,this[15]=m,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(Iu)}fromObject(t){return this.check()}fromQuaternion(t){return oi(this,t),this.check()}frustum(t){let{left:r,right:n,bottom:i,top:s,near:o=fi,far:a=di}=t;return a===1/0?Fu(this,r,n,i,s,o):ai(this,r,n,i,s,o,a),this.check()}lookAt(t){let{eye:r,center:n=[0,0,0],up:i=[0,1,0]}=t;return hi(this,r,n,i),this.check()}ortho(t){let{left:r,right:n,bottom:i,top:s,near:o=fi,far:a=di}=t;return li(this,r,n,i,s,o,a),this.check()}orthographic(t){let{fovy:r=Ru,aspect:n=ku,focalDistance:i=1,near:s=fi,far:o=di}=t;ia(r);let a=r/2,c=i*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:s,far:o})}perspective(t){let{fovy:r=45*Math.PI/180,aspect:n=1,near:i=.1,far:s=500}=t;return ia(r),ci(this,r,n,i,s),this.check()}determinant(){return Jn(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),i=1/n[0],s=1/n[1],o=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*s,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*i,t[5]=this[5]*s,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*i,t[9]=this[9]*s,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),i=1/n[0],s=1/n[1],o=1/n[2];return t[0]=this[0]*i,t[1]=this[1]*s,t[2]=this[2]*o,t[3]=this[4]*i,t[4]=this[5]*s,t[5]=this[6]*o,t[6]=this[8]*i,t[7]=this[9]*s,t[8]=this[10]*o,t}transpose(){return Kn(this,this),this.check()}invert(){return Qn(this,this),this.check()}multiplyLeft(t){return Me(this,t,this),this.check()}multiplyRight(t){return Me(this,this,t),this.check()}rotateX(t){return ni(this,this,t),this.check()}rotateY(t){return ii(this,this,t),this.check()}rotateZ(t){return si(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,r){return ri(this,this,t,r),this.check()}scale(t){return ei(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return ti(this,this,t),this.check()}transform(t,r){return t.length===4?(r=ui(r||[-0,-0,-0,-0],t,this),Nr(r,4),r):this.transformAsPoint(t,r)}transformAsPoint(t,r){let{length:n}=t,i;switch(n){case 2:i=zn(r||[-0,-0],t,this);break;case 3:i=Se(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Nr(i,t.length),i}transformAsVector(t,r){let n;switch(t.length){case 2:n=Bo(r||[-0,-0],t,this);break;case 3:n=zr(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Nr(n,t.length),n}transformPoint(t,r){return this.transformAsPoint(t,r)}transformVector(t,r){return this.transformAsPoint(t,r)}transformDirection(t,r){return this.transformAsVector(t,r)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,r,n){return this.identity().translate([t,r,n])}},Yr,jr;function Bu(){return Yr||(Yr=new Q([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Yr)),Yr}function Du(){return jr||(jr=new Q,Object.freeze(jr)),jr}function ia(e){if(e>Math.PI*2)throw Error("expected radians")}function Fu(e,t,r,n,i,s){let o=2*s/(r-t),a=2*s/(i-n),c=(r+t)/(r-t),l=(i+n)/(i-n),h=-1,u=-1,f=-2*s;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=c,e[9]=l,e[10]=h,e[11]=u,e[12]=0,e[13]=0,e[14]=f,e[15]=0,e}function Qt(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function pi(e,t){let r=e%t;return r<0?t+r:r}function oa(e){return[e[12],e[13],e[14]]}function aa(e){return{left:Kt(e[3]+e[0],e[7]+e[4],e[11]+e[8],e[15]+e[12]),right:Kt(e[3]-e[0],e[7]-e[4],e[11]-e[8],e[15]-e[12]),bottom:Kt(e[3]+e[1],e[7]+e[5],e[11]+e[9],e[15]+e[13]),top:Kt(e[3]-e[1],e[7]-e[5],e[11]-e[9],e[15]-e[13]),near:Kt(e[3]+e[2],e[7]+e[6],e[11]+e[10],e[15]+e[14]),far:Kt(e[3]-e[2],e[7]-e[6],e[11]-e[10],e[15]-e[14])}}var sa=new vt;function Kt(e,t,r,n){sa.set(e,t,r);let i=sa.len();return{distance:n/i,normal:new vt(-e/i,-t/i,-r/i)}}function gi(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Ct(e,t){let r=Pe.transformMat4([],t,e);return Pe.scale(r,r,1/r[3]),r}function Ce(e,t,r){return e<t?t:e>r?r:e}function Ou(e){return Math.log(e)*Math.LOG2E}var Le=Math.log2||Ou;function ct(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}var lt=Math.PI,ca=lt/4,J=lt/180,bi=180/lt,Jt=512,qr=4003e4,te=85.051129,la=1.5;function xi(e){return Le(e)}function tt(e){let[t,r]=e;ct(Number.isFinite(t)),ct(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let n=t*J,i=r*J,s=Jt*(n+lt)/(2*lt),o=Jt*(lt+Math.log(Math.tan(ca+i*.5)))/(2*lt);return[s,o]}function X(e){let[t,r]=e,n=t/Jt*(2*lt)-lt,i=2*(Math.atan(Math.exp(r/Jt*(2*lt)-lt))-ca);return[n*bi,i*bi]}function yi(e){let{latitude:t}=e;ct(Number.isFinite(t));let r=Math.cos(t*J);return xi(qr*r)-9}function Ae(e){let t=Math.cos(e*J);return Jt/qr/t}function ee(e){let{latitude:t,longitude:r,highPrecision:n=!1}=e;ct(Number.isFinite(t)&&Number.isFinite(r));let i=Jt,s=Math.cos(t*J),o=i/360,a=o/s,c=i/qr/s,l={unitsPerMeter:[c,c,c],metersPerUnit:[1/c,1/c,1/c],unitsPerDegree:[o,a,c],degreesPerUnit:[1/o,1/a,1/c]};if(n){let h=J*Math.tan(t*J)/s,u=o*h/2,f=i/qr*h,d=f/a*c;l.unitsPerDegree2=[0,u,f],l.unitsPerMeter2=[d,0,d]}return l}function wi(e,t){let[r,n,i]=e,[s,o,a]=t,{unitsPerMeter:c,unitsPerMeter2:l}=ee({longitude:r,latitude:n,highPrecision:!0}),h=tt(e);h[0]+=s*(c[0]+l[0]*o),h[1]+=o*(c[1]+l[1]*o);let u=X(h),f=(i||0)+(a||0);return Number.isFinite(i)||Number.isFinite(a)?[u[0],u[1],f]:u}function Xr(e){let{height:t,pitch:r,bearing:n,altitude:i,scale:s,center:o}=e,a=gi();W.translate(a,a,[0,0,-i]),W.rotateX(a,a,-r*J),W.rotateZ(a,a,n*J);let c=s/t;return W.scale(a,a,[c,c,c]),o&&W.translate(a,a,Wr.negate([],o)),a}function Ei(e){let{width:t,height:r,altitude:n,pitch:i=0,offset:s,center:o,scale:a,nearZMultiplier:c=1,farZMultiplier:l=1}=e,{fovy:h=Dt(la)}=e;n!==void 0&&(h=Dt(n));let u=h*J,f=i*J,d=Re(h),p=d;o&&(p+=o[2]*a/Math.cos(f)/r);let g=u*(.5+(s?s[1]:0)/r),m=Math.sin(g)*p/Math.sin(Ce(Math.PI/2-f-g,.01,Math.PI-.01)),x=Math.sin(f)*m+p,_=p*10,b=Math.min(x*l,_);return{fov:u,aspect:t/r,focalDistance:d,near:c,far:b}}function Dt(e){return 2*Math.atan(.5/e)*bi}function Re(e){return .5/Math.tan(.5*e*J)}function re(e,t){let[r,n,i=0]=e;return ct(Number.isFinite(r)&&Number.isFinite(n)&&Number.isFinite(i)),Ct(t,[r,n,i,1])}function ne(e,t,r=0){let[n,i,s]=e;if(ct(Number.isFinite(n)&&Number.isFinite(i),"invalid pixel coordinate"),Number.isFinite(s))return Ct(t,[n,i,s,1]);let o=Ct(t,[n,i,0,1]),a=Ct(t,[n,i,1,1]),c=o[2],l=a[2],h=c===l?0:((r||0)-c)/(l-c);return at.lerp([],o,a,h)}function Zr(e){let{width:t,height:r,bounds:n,minExtent:i=0,maxZoom:s=24,offset:o=[0,0]}=e,[[a,c],[l,h]]=n,u=Nu(e.padding),f=tt([a,Ce(h,-te,te)]),d=tt([l,Ce(c,-te,te)]),p=[Math.max(Math.abs(d[0]-f[0]),i),Math.max(Math.abs(d[1]-f[1]),i)],g=[t-u.left-u.right-Math.abs(o[0])*2,r-u.top-u.bottom-Math.abs(o[1])*2];ct(g[0]>0&&g[1]>0);let m=g[0]/p[0],x=g[1]/p[1],_=(u.right-u.left)/2/m,b=(u.top-u.bottom)/2/x,w=[(d[0]+f[0])/2+_,(d[1]+f[1])/2+b],v=X(w),E=Math.min(s,Le(Math.abs(Math.min(m,x))));return ct(Number.isFinite(E)),{longitude:v[0],latitude:v[1],zoom:E}}function Nu(e=0){return typeof e=="number"?{top:e,bottom:e,left:e,right:e}:(ct(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e)}var ha=Math.PI/180;function Hr(e,t=0){let{width:r,height:n,unproject:i}=e,s={targetZ:t},o=i([0,n],s),a=i([r,n],s),c,l,h=e.fovy?.5*e.fovy*ha:Math.atan(.5/e.altitude),u=(90-e.pitch)*ha;return h>u-.01?(c=ua(e,0,t),l=ua(e,r,t)):(c=i([0,0],s),l=i([r,0],s)),[o,a,l,c]}function ua(e,t,r){let{pixelUnprojectionMatrix:n}=e,i=Ct(n,[t,0,1,1]),s=Ct(n,[t,e.height,1,1]),a=(r*e.distanceScales.unitsPerMeter[2]-i[2])/(s[2]-i[2]),c=at.lerp([],i,s,a),l=X(c);return l.push(r),l}var N;(function(e){e[e.Start=1]="Start",e[e.Move=2]="Move",e[e.End=4]="End",e[e.Cancel=8]="Cancel"})(N||(N={}));var Ft;(function(e){e[e.None=0]="None",e[e.Left=1]="Left",e[e.Right=2]="Right",e[e.Up=4]="Up",e[e.Down=8]="Down",e[e.Horizontal=3]="Horizontal",e[e.Vertical=12]="Vertical",e[e.All=15]="All"})(Ft||(Ft={}));var Z;(function(e){e[e.Possible=1]="Possible",e[e.Began=2]="Began",e[e.Changed=4]="Changed",e[e.Ended=8]="Ended",e[e.Recognized=8]="Recognized",e[e.Cancelled=16]="Cancelled",e[e.Failed=32]="Failed"})(Z||(Z={}));var K0={pointerdown:N.Start,pointermove:N.Move,pointerup:N.End,pointercancel:N.Cancel,pointerout:N.Cancel};var wa=typeof navigator<"u"&&navigator.userAgent?navigator.userAgent.toLowerCase():"";var Sx=wa.indexOf("firefox")!==-1;var Ea={DEFAULT:"default",LNGLAT:"lnglat",METER_OFFSETS:"meter-offsets",LNGLAT_OFFSETS:"lnglat-offsets",CARTESIAN:"cartesian"};Object.defineProperty(Ea,"IDENTITY",{get:()=>(Or.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),Ea.CARTESIAN)});var Kr={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0};var rf=Math.PI/180,nf=Qt(),Ta=[0,0,0],sf={unitsPerMeter:[1,1,1],metersPerUnit:[1,1,1]};function of({width:e,height:t,orthographic:r,fovyRadians:n,focalDistance:i,padding:s,near:o,far:a}){let c=e/t,l=r?new Q().orthographic({fovy:n,aspect:c,focalDistance:i,near:o,far:a}):new Q().perspective({fovy:n,aspect:c,near:o,far:a});if(s){let{left:h=0,right:u=0,top:f=0,bottom:d=0}=s,p=$((h+e-u)/2,0,e)-e/2,g=$((f+t-d)/2,0,t)-t/2;l[8]-=p*2/e,l[9]+=g*2/t}return l}var Qr=class Qr{constructor(t={}){this._frustumPlanes={};this.id=t.id||this.constructor.displayName||"viewport",this.x=t.x||0,this.y=t.y||0,this.width=t.width||1,this.height=t.height||1,this.zoom=t.zoom||0,this.padding=t.padding,this.distanceScales=t.distanceScales||sf,this.focalDistance=t.focalDistance||1,this.position=t.position||Ta,this.modelMatrix=t.modelMatrix||null;let{longitude:r,latitude:n}=t;this.isGeospatial=Number.isFinite(n)&&Number.isFinite(r),this._initProps(t),this._initMatrices(t),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?Kr.WEB_MERCATOR:Kr.WEB_MERCATOR_AUTO_OFFSET:Kr.IDENTITY}equals(t){return t instanceof Qr?this===t?!0:t.width===this.width&&t.height===this.height&&t.scale===this.scale&&t.projectionMode===this.projectionMode&&t.resolution===this.resolution&>(t.distanceScales.unitsPerMeter,this.distanceScales.unitsPerMeter)&>(t.projectionMatrix,this.projectionMatrix)&>(t.viewMatrix,this.viewMatrix):!1}project(t,{topLeft:r=!0}={}){let n=this.projectPosition(t),i=re(n,this.pixelProjectionMatrix),[s,o]=i,a=r?o:this.height-o;return t.length===2?[s,a]:[s,a,i[2]]}unproject(t,{topLeft:r=!0,targetZ:n}={}){let[i,s,o]=t,a=r?s:this.height-s,c=n&&n*this.distanceScales.unitsPerMeter[2],l=ne([i,a,o],this.pixelUnprojectionMatrix,c),[h,u,f]=this.unprojectPosition(l);return Number.isFinite(o)?[h,u,f]:Number.isFinite(n)?[h,u,n]:[h,u]}projectPosition(t){let[r,n]=this.projectFlat(t),i=(t[2]||0)*this.distanceScales.unitsPerMeter[2];return[r,n,i]}unprojectPosition(t){let[r,n]=this.unprojectFlat(t),i=(t[2]||0)*this.distanceScales.metersPerUnit[2];return[r,n,i]}projectFlat(t){if(this.isGeospatial){let r=tt(t);return r[1]=$(r[1],-318,830),r}return t}unprojectFlat(t){return this.isGeospatial?X(t):t}getBounds(t={}){let r={targetZ:t.z||0},n=this.unproject([0,0],r),i=this.unproject([this.width,0],r),s=this.unproject([0,this.height],r),o=this.unproject([this.width,this.height],r);return[Math.min(n[0],i[0],s[0],o[0]),Math.min(n[1],i[1],s[1],o[1]),Math.max(n[0],i[0],s[0],o[0]),Math.max(n[1],i[1],s[1],o[1])]}getDistanceScales(t){return t&&this.isGeospatial?ee({longitude:t[0],latitude:t[1],highPrecision:!0}):this.distanceScales}containsPixel({x:t,y:r,width:n=1,height:i=1}){return t<this.x+this.width&&this.x<t+n&&r<this.y+this.height&&this.y<r+i}getFrustumPlanes(){return this._frustumPlanes.near?this._frustumPlanes:(Object.assign(this._frustumPlanes,aa(this.viewProjectionMatrix)),this._frustumPlanes)}panByPosition(t,r,n){return null}_initProps(t){let r=t.longitude,n=t.latitude;this.isGeospatial&&(Number.isFinite(t.zoom)||(this.zoom=yi({latitude:n})+Math.log2(this.focalDistance)),this.distanceScales=t.distanceScales||ee({latitude:n,longitude:r}));let i=Math.pow(2,this.zoom);this.scale=i;let{position:s,modelMatrix:o}=t,a=Ta;if(s&&(a=o?new Q(o).transformAsVector(s,[]):s),this.isGeospatial){let c=this.projectPosition([r,n,0]);this.center=new vt(a).scale(this.distanceScales.unitsPerMeter).add(c)}else this.center=this.projectPosition(a)}_initMatrices(t){let{viewMatrix:r=nf,projectionMatrix:n=null,orthographic:i=!1,fovyRadians:s,fovy:o=75,near:a=.1,far:c=1e3,padding:l=null,focalDistance:h=1}=t;this.viewMatrixUncentered=r,this.viewMatrix=new Q().multiplyRight(r).translate(new vt(this.center).negate()),this.projectionMatrix=n||of({width:this.width,height:this.height,orthographic:i,fovyRadians:s||o*rf,focalDistance:h,padding:l,near:a,far:c});let u=Qt();W.multiply(u,u,this.projectionMatrix),W.multiply(u,u,this.viewMatrix),this.viewProjectionMatrix=u,this.viewMatrixInverse=W.invert([],this.viewMatrix)||this.viewMatrix,this.cameraPosition=oa(this.viewMatrixInverse);let f=Qt(),d=Qt();W.scale(f,f,[this.width/2,-this.height/2,1]),W.translate(f,f,[1,-1,0]),W.multiply(d,f,this.viewProjectionMatrix),this.pixelProjectionMatrix=d,this.pixelUnprojectionMatrix=W.invert(Qt(),this.pixelProjectionMatrix),this.pixelUnprojectionMatrix||Or.warn("Pixel project matrix not invertible")()}};Qr.displayName="Viewport";var Ie=Qr;var ie=class ie extends Ie{constructor(t={}){let{latitude:r=0,longitude:n=0,zoom:i=0,pitch:s=0,bearing:o=0,nearZMultiplier:a=.1,farZMultiplier:c=1.01,nearZ:l,farZ:h,orthographic:u=!1,projectionMatrix:f,repeat:d=!1,worldOffset:p=0,position:g,padding:m,legacyMeterSizes:x=!1}=t,{width:_,height:b,altitude:w=1.5}=t,v=Math.pow(2,i);_=_||1,b=b||1;let E,y=null;if(f)w=f[5]/2,E=Dt(w);else{t.fovy?(E=t.fovy,w=Re(E)):E=Dt(w);let M;if(m){let{top:S=0,bottom:C=0}=m;M=[0,$((S+b-C)/2,0,b)-b/2]}y=Ei({width:_,height:b,scale:v,center:g&&[0,0,g[2]*Ae(r)],offset:M,pitch:s,fovy:E,nearZMultiplier:a,farZMultiplier:c}),Number.isFinite(l)&&(y.near=l),Number.isFinite(h)&&(y.far=h)}let T=Xr({height:b,pitch:s,bearing:o,scale:v,altitude:w});p&&(T=new Q().translate([512*p,0,0]).multiplyLeft(T)),super({...t,width:_,height:b,viewMatrix:T,longitude:n,latitude:r,zoom:i,...y,fovy:E,focalDistance:w}),this.latitude=r,this.longitude=n,this.zoom=i,this.pitch=s,this.bearing=o,this.altitude=w,this.fovy=E,this.orthographic=u,this._subViewports=d?[]:null,this._pseudoMeters=x,Object.freeze(this)}get subViewports(){if(this._subViewports&&!this._subViewports.length){let t=this.getBounds(),r=Math.floor((t[0]+180)/360),n=Math.ceil((t[2]-180)/360);for(let i=r;i<=n;i++){let s=i?new ie({...this,worldOffset:i}):this;this._subViewports.push(s)}}return this._subViewports}equals(t){return t instanceof ie&&t._pseudoMeters===this._pseudoMeters&&super.equals(t)}projectPosition(t){if(this._pseudoMeters)return super.projectPosition(t);let[r,n]=this.projectFlat(t),i=(t[2]||0)*Ae(t[1]);return[r,n,i]}unprojectPosition(t){if(this._pseudoMeters)return super.unprojectPosition(t);let[r,n]=this.unprojectFlat(t),i=(t[2]||0)/Ae(n);return[r,n,i]}addMetersToLngLat(t,r){return wi(t,r)}panByPosition(t,r,n){let i=ne(r,this.pixelUnprojectionMatrix),s=this.projectFlat(t),o=at.add([],s,at.negate([],i)),a=at.add([],this.center,o),[c,l]=this.unprojectFlat(a);return{longitude:c,latitude:l}}panByPosition3D(t,r){let n=t[2]||0,i=at.sub([],t,this.unproject(r,{targetZ:n}));return{longitude:this.longitude+i[0],latitude:this.latitude+i[1]}}getBounds(t={}){let r=Hr(this,t.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(t,r={}){let{width:n,height:i}=this,{longitude:s,latitude:o,zoom:a}=Zr({width:n,height:i,bounds:t,...r});return new ie({width:n,height:i,longitude:s,latitude:o,zoom:a})}};ie.displayName="WebMercatorViewport";var Be=ie;var De=class{constructor(t){this._inProgress=!1;this._handle=null;this.time=0;this.settings={duration:0};this._timeline=t}get inProgress(){return this._inProgress}start(t){this.cancel(),this.settings=t,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:t,settings:r}=this;this._handle=t.addChannel({delay:t.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 _a=()=>{},va={mode:"preserve"},af={mode:"hard"},Si={BREAK:1,SNAP_TO_END:2,IGNORE:3},cf=e=>e,lf=Si.BREAK,Fe=class{constructor(t){this._onTransitionUpdate=t=>{let{time:r,settings:{interpolator:n,startProps:i,endProps:s,duration:o,easing:a}}=t,c=a(r/o),l=n.interpolateProps(i,s,c);this.propsInTransition=this.getControllerState({...this.props,...l},va).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})};this.getControllerState=t.getControllerState,this.propsInTransition=null,this.transition=new De(t.timeline),this.onViewStateChange=t.onViewStateChange||_a,this.onStateChange=t.onStateChange||_a}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(t){let r=!1,n=this.props;if(this.props=t,!n||this._shouldIgnoreViewportChange(n,t))return!1;if(this._isTransitionEnabled(t)){let i=n;if(this.transition.inProgress){let{interruption:s,endProps:o}=this.transition.settings;i={...n,...s===Si.SNAP_TO_END?o:this.propsInTransition||n}}this._triggerTransition(i,t),r=!0}else this.transition.cancel();return r}updateTransition(){this.transition.update()}_isTransitionEnabled(t){let{transitionDuration:r,transitionInterpolator:n}=t;return(r>0||r==="auto")&&!!n}_isUpdateDueToCurrentTransition(t){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(t,this.propsInTransition):!1}_shouldIgnoreViewportChange(t,r){return this.transition.inProgress?this.transition.settings.interruption===Si.IGNORE||this._isUpdateDueToCurrentTransition(r):this._isTransitionEnabled(r)?r.transitionInterpolator.arePropsEqual(t,r):!0}_triggerTransition(t,r){let n=this.getControllerState(t,va),i=this.getControllerState(r,af).shortestPathFrom(n),s=r.transitionInterpolator,o=s.getDuration?s.getDuration(t,r):r.transitionDuration;if(o===0)return;let a=s.initializeProps(t,i);this.propsInTransition={};let c={duration:o,easing:r.transitionEasing||cf,interpolator:s,interruption:r.transitionInterruption||lf,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(t){return r=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),t?.(r)}}};function Ot(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}var Oe=class{constructor(t){let{compare:r,extract:n,required:i}=t;this._propsToCompare=r,this._propsToExtract=n||r,this._requiredProps=i}arePropsEqual(t,r){for(let n of this._propsToCompare)if(!(n in t)||!(n in r)||!gt(t[n],r[n]))return!1;return!0}initializeProps(t,r){let n={},i={};for(let s of this._propsToExtract)(s in t||s in r)&&(n[s]=t[s],i[s]=r[s]);return this._checkRequiredProps(n),this._checkRequiredProps(i),{start:n,end:i}}getDuration(t,r){return r.transitionDuration}_checkRequiredProps(t){this._requiredProps&&this._requiredProps.forEach(r=>{let n=t[r];Ot(Number.isFinite(n)||Array.isArray(n),`${r} is required for transition`)})}};var hf=["longitude","latitude","zoom","bearing","pitch"],uf=["longitude","latitude","zoom"],Nt=class extends Oe{constructor(t={}){let r=Array.isArray(t)?t:t.transitionProps,n=Array.isArray(t)?{}:t;n.transitionProps=Array.isArray(r)?{compare:r,required:r}:r||{compare:hf,required:uf},super(n.transitionProps),this.opts=n}initializeProps(t,r){let n=super.initializeProps(t,r),{makeViewport:i,around:s}=this.opts;if(i&&s){let o=i(t),a=i(r),c=o.unproject(s);n.start.around=s,Object.assign(n.end,{around:a.project(c),aroundPosition:c,width:r.width,height:r.height})}return n}interpolateProps(t,r,n){let i={};for(let s of this._propsToExtract)i[s]=ve(t[s]||0,r[s]||0,n);if(r.aroundPosition&&this.opts.makeViewport){let s=this.opts.makeViewport({...r,...i});Object.assign(i,s.panByPosition(r.aroundPosition,ve(t.around,r.around,n)))}return i}};var xt={transitionDuration:0},ff=300,df=300,Mi=e=>1-(1-e)*(1-e),mf=e=>e===1?1:1-Math.pow(2,-10*e),Vt={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],MULTI_PAN:["multipanstart","multipanmove","multipanend"],DOUBLE_CLICK:["dblclick"],DOUBLE_CLICK_DRAG:["dblclickdragstart","dblclickdragmove","dblclickdragend","dblclickdragcancel"],KEYBOARD:["keydown"]},Gt={},Ne=class{constructor(t){this.state={};this._events={};this._interactionState={isDragging:!1};this._customEvents=[];this._eventStartBlocked=null;this._panMove=!1;this._multiPanMode=null;this._multiPanStartCenter=null;this._doubleClickDragAnchor=null;this._suppressDoubleClickUntil=0;this.invertPan=!1;this.dragMode="rotate";this.inertia=0;this.scrollZoom=!0;this.dragPan=!0;this.dragRotate=!0;this.doubleClickZoom=!0;this.doubleClickDragZoom=!0;this.touchZoom=!0;this.touchRotate=!1;this.multiTouchDrag=null;this.trackpadGesture=!1;this.zoomAround="pointer";this.keyboard=!0;this.transitionManager=new Fe({...t,getControllerState:(r,n)=>new this.ControllerState({...r,constraintContext:n,makeViewport:t.makeViewport}),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=t.eventManager,this.onViewStateChange=t.onViewStateChange||(()=>{}),this.onStateChange=t.onStateChange||(()=>{}),this.makeViewport=t.makeViewport,this.pickPosition=t.pickPosition}set events(t){this.toggleEvents(this._customEvents,!1),this.toggleEvents(t,!0),this._customEvents=t,this.props&&this.setProps(this.props)}finalize(){for(let t in this._events)this._events[t]&&this.eventManager?.off(t,this.handleEvent);this.transitionManager.finalize()}handleEvent(t){this._controllerState=void 0;let r=this._eventStartBlocked;switch(t.type){case"panstart":return r?!1:this._onPanStart(t);case"panmove":return this._onPan(t);case"panend":return this._onPanEnd(t);case"pinchstart":return r||!this._isTrackpadGestureAllowed(t)?!1:this._onPinchStart(t);case"pinchmove":return this._isTrackpadGestureAllowed(t)?this._onPinch(t):!1;case"pinchend":return this._isTrackpadGestureAllowed(t)?this._onPinchEnd(t):!1;case"multipanstart":return r?!1:this._onMultiPanStart(t);case"multipanmove":return this._onMultiPan(t);case"multipanend":return this._onMultiPanEnd(t);case"dblclick":return this._onDoubleClick(t);case"dblclickdragstart":return r?!1:this._onDoubleClickDragStart(t);case"dblclickdragmove":return this._onDoubleClickDrag(t);case"dblclickdragend":case"dblclickdragcancel":return this._onDoubleClickDragEnd(t);case"wheel":return this._onWheel(t);case"keydown":return this._onKeyDown(t);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(t){let{x:r,y:n}=this.props,{offsetCenter:i}=t;return[i.x-r,i.y-n]}getZoomPosition(t){if(this.zoomAround==="pointer")return t;let r=this.makeViewport(this.controllerState.getViewportProps()),[n,i]=re(r.center,r.pixelProjectionMatrix);return[n,i]}isPointInBounds(t,r){let{width:n,height:i}=this.props;if(r&&r.handled)return!1;let s=t[0]>=0&&t[0]<=n&&t[1]>=0&&t[1]<=i;return s&&r&&r.stopPropagation(),s}isFunctionKeyPressed(t){let{srcEvent:r}=t;return!!(r.metaKey||r.altKey||r.ctrlKey||r.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(t){let r=setTimeout(()=>{this._eventStartBlocked===r&&(this._eventStartBlocked=null)},t);this._eventStartBlocked=r}setProps(t){t.maxBoundsPadding===void 0&&(t.maxBoundsPadding=null),t.dragMode&&(this.dragMode=t.dragMode);let r=this.props;this.props=t,"transitionInterpolator"in t||(t.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(t);let{inertia:n}=t;this.inertia=Number.isFinite(n)?n:n===!0?ff:0;let{scrollZoom:i=!0,dragPan:s=!0,dragRotate:o=!0,doubleClickZoom:a=!0,doubleClickDragZoom:c=!1,touchZoom:l=!0,touchRotate:h=!1,multiTouchDrag:u=h?"rotate":null,trackpadGesture:f=!1,zoomAround:d="pointer",keyboard:p=!0}=t,g=!!this.onViewStateChange;if(this.toggleEvents(Vt.WHEEL,g&&i),this.toggleEvents(Vt.PAN,g),this.toggleEvents(Vt.PINCH,g&&(l||u==="rotate")),this.toggleEvents(Vt.MULTI_PAN,g&&!!u),this.toggleEvents(Vt.DOUBLE_CLICK,g&&a),this.toggleEvents(Vt.DOUBLE_CLICK_DRAG,g&&c),this.toggleEvents(Vt.KEYBOARD,g&&p),this.scrollZoom=i,this.dragPan=s,this.dragRotate=o,this.doubleClickZoom=a,this.doubleClickDragZoom=c,this.touchZoom=l,this.touchRotate=u==="rotate",this.multiTouchDrag=u,this.trackpadGesture=f,this.zoomAround=d,this.keyboard=p,(!r||r.height!==t.height||r.width!==t.width||r.maxBounds!==t.maxBounds||r.maxBoundsPadding!==t.maxBoundsPadding)&&t.maxBounds){let x=new this.ControllerState({...t,makeViewport:this.makeViewport}),_=x.getViewportProps();Object.keys(_).some(w=>!It(_[w],t[w],1))&&this.updateViewport(x)}}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(t,r){this.eventManager&&t.forEach(n=>{this._events[n]!==r&&(this._events[n]=r,r?this.eventManager.on(n,this.handleEvent):this.eventManager.off(n,this.handleEvent))})}updateViewport(t,r=null,n={}){let i={...t.getViewportProps(),...r},s=this.controllerState!==t;if(this.state=t.getState(),this._setInteractionState(n),s){let o=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:i,interactionState:this._interactionState,oldViewState:o,viewId:this.props.id})}}_onTransition(t){this.onViewStateChange({...t,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(t){Object.assign(this._interactionState,t),this.onStateChange(this._interactionState)}_getConstraintContext(t,r){return this.props.rubberBand?{mode:r==="update"?"elastic":r==="end"?"rebound":"hard"}:{mode:"hard"}}_getReboundTransition(t,r){if(t.mode!=="rebound")return null;let n=r.getViewportProps();return Object.keys(n).some(s=>!It(this.props[s],n[s],1))?{...this._getTransitionProps(),transitionDuration:df,transitionEasing:mf}:null}_onPanStart(t){let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;let n=this.isFunctionKeyPressed(t)||t.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(n=!n);let i=n?"pan":"rotate",s=this._getConstraintContext(i,"start"),o=n?this.controllerState.panStart({pos:r},s):this.controllerState.rotateStart({pos:r},s);return this._panMove=n,this.updateViewport(o,xt,{isDragging:!0}),!0}_onPan(t){return this.isDragging()?this._panMove?this._onPanMove(t):this._onPanRotate(t):!1}_onPanEnd(t){return this.isDragging()?this._panMove?this._onPanMoveEnd(t):this._onPanRotateEnd(t):!1}_onPanMove(t){if(!this.dragPan)return!1;let r=this.getCenter(t),n=this.controllerState.pan({pos:r},this._getConstraintContext("pan","update"));return this.updateViewport(n,xt,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(t){let{inertia:r}=this;if(this.dragPan&&r&&t.velocity){let n=this.getCenter(t),i=[n[0]+t.velocityX*r/2,n[1]+t.velocityY*r/2],s=this.controllerState.pan({pos:i}).panEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Mi},{isDragging:!1,isPanning:!0})}else{let n=this.controllerState,i=this._getConstraintContext("pan","end"),s=n.panEnd(i),o=this._getReboundTransition(i,s);this.updateViewport(s,o,{isDragging:!1,isPanning:!!o})}return!0}_onPanRotate(t){if(!this.dragRotate)return!1;let r=this.getCenter(t),n=this.controllerState.rotate({pos:r},this._getConstraintContext("rotate","update"));return this.updateViewport(n,xt,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(t){let{inertia:r}=this;if(this.dragRotate&&r&&t.velocity){let n=this.getCenter(t),i=[n[0]+t.velocityX*r/2,n[1]+t.velocityY*r/2],s=this.controllerState.rotate({pos:i}).rotateEnd();this.updateViewport(s,{...this._getTransitionProps(),transitionDuration:r,transitionEasing:Mi},{isDragging:!1,isRotating:!0})}else{let n=this.controllerState,i=this._getConstraintContext("rotate","end"),s=n.rotateEnd(i),o=this._getReboundTransition(i,s);this.updateViewport(s,o,{isDragging:!1,isRotating:!!o})}return!0}_onWheel(t){if(!this.scrollZoom||this.trackpadGesture&&t.device!=="mouse")return!1;let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;t.srcEvent.preventDefault();let{speed:n=.01,smooth:i=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:s}=t,o=2/(1+Math.exp(-Math.abs(s*n)));s<0&&o!==0&&(o=1/o);let a=this.getZoomPosition(r),c=i?{...this._getTransitionProps({around:a}),transitionDuration:250}:xt,l=this.controllerState.zoom({pos:a,scale:o});return this.updateViewport(l,c,{isZooming:!0,isPanning:!0}),i||this._setInteractionState({isZooming:!1,isPanning:!1}),!0}_onMultiPanStart(t){let{multiTouchDrag:r}=this;if(!r||!this._isMultiPanEventAllowed(t,r))return!1;let n=t.offsetCenter;if(!this.isPointInBounds(this.getCenter(t),t))return!1;let i=t.pointerType==="trackpad",s={x:n.x-(i?0:t.deltaX),y:n.y-(i?0:t.deltaY)},o={...t,offsetCenter:s},a=this.getCenter(o),c=r==="pan"?this.controllerState.panStart({pos:a},this._getConstraintContext("pan","start")):this.controllerState.rotateStart({pos:a},this._getConstraintContext("rotate","start"));return this._multiPanMode=r,this._multiPanStartCenter=s,this.updateViewport(c,xt,{isDragging:!0}),!0}_onMultiPan(t){let{mode:r,event:n}=this._getMultiPanEvent(t);return!r||!n||!this.isDragging()?!1:r==="pan"?this._onPanMove(n):this._onPanRotate(n)}_onMultiPanEnd(t){let{mode:r,event:n}=this._getMultiPanEvent(t);if(!r||!n||!this.isDragging())return this._resetMultiPan(),!1;let i=r==="pan"?this._onPanMoveEnd(n):this._onPanRotateEnd(n);return this._resetMultiPan(),i}_isTrackpadGestureAllowed(t){return t.pointerType!=="trackpad"||this.trackpadGesture}_isMultiPanEventAllowed(t,r){return t.pointerType==="trackpad"?this.trackpadGesture&&(r==="pan"?this.dragPan:this.dragRotate):t.pointerType==="touch"&&(r==="pan"?this.dragPan:this.dragRotate)}_getMultiPanEvent(t){let r=this._multiPanMode,n=this._multiPanStartCenter;return!r||!n?{mode:null,event:null}:{mode:r,event:{...t,offsetCenter:{x:n.x+t.deltaX,y:n.y+t.deltaY}}}}_resetMultiPan(){this._multiPanMode=null,this._multiPanStartCenter=null}_onPinchStart(t){this._doubleClickDragAnchor=null;let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;let n=this.controllerState.zoomStart({pos:this.getZoomPosition(r)},this._getConstraintContext("zoom","start")).rotateStart({pos:r},this._getConstraintContext("rotate","start"));return Gt._startPinchRotation=t.rotation,Gt._lastPinchEvent=t,this.updateViewport(n,xt,{isDragging:!0}),!0}_onPinch(t){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let r=this.controllerState;if(this.touchZoom){let{scale:n}=t,i=this.getCenter(t);r=r.zoom({pos:this.getZoomPosition(i),scale:n},this._getConstraintContext("zoom","update"))}if(this.touchRotate){let{rotation:n}=t;r=r.rotate({deltaAngleX:Gt._startPinchRotation-n},this._getConstraintContext("rotate","update"))}return this.updateViewport(r,xt,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),Gt._lastPinchEvent=t,!0}_onPinchEnd(t){if(!this.isDragging())return!1;let{inertia:r}=this,{_lastPinchEvent:n}=Gt;if(this.touchZoom&&r&&n&&t.scale!==n.scale){let i=this.getCenter(t),s=this.getZoomPosition(i),o=this.controllerState.rotateEnd(),a=Math.log2(t.scale),c=(a-Math.log2(n.scale))/(t.deltaTime-n.deltaTime),l=Math.pow(2,a+c*r/2);o=o.zoom({pos:s,scale:l}).zoomEnd(),this.updateViewport(o,{...this._getTransitionProps({around:s}),transitionDuration:r,transitionEasing:Mi},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(r)}else{let i=this.controllerState,s=this._getConstraintContext("zoom","end"),o=this._getConstraintContext("rotate","end"),a=i.zoomEnd(s).rotateEnd(o),c=this._getReboundTransition(this.touchZoom?s:o,a);this.updateViewport(a,c,{isDragging:!1,isPanning:!!c&&this.touchZoom,isZooming:!!c&&this.touchZoom,isRotating:!!c&&this.touchRotate})}return Gt._startPinchRotation=null,Gt._lastPinchEvent=null,!0}_onDoubleClick(t){if(!this.doubleClickZoom||Date.now()<this._suppressDoubleClickUntil)return!1;let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return!1;let n=this.isFunctionKeyPressed(t),i=this.getZoomPosition(r),s=this.controllerState.zoom({pos:i,scale:n?.5:2});return this.updateViewport(s,this._getTransitionProps({around:i}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onDoubleClickDragStart(t){if(!this.doubleClickDragZoom)return this._doubleClickDragAnchor=null,!1;let r=this.getCenter(t);if(!this.isPointInBounds(r,t))return this._doubleClickDragAnchor=null,!1;this._doubleClickDragAnchor=this.getZoomPosition(r);let n=this.controllerState.zoomStart({pos:this._doubleClickDragAnchor},this._getConstraintContext("zoom","start"));return t.scale!==1&&(n=n.zoom({pos:this._doubleClickDragAnchor,scale:t.scale},this._getConstraintContext("zoom","update"))),this.updateViewport(n,xt,{isDragging:!0,isPanning:!0,isZooming:!0}),!0}_onDoubleClickDrag(t){let r=this._doubleClickDragAnchor;if(!r)return!1;let n=this.controllerState.zoom({pos:r,scale:t.scale},this._getConstraintContext("zoom","update"));return this.updateViewport(n,xt,{isDragging:!0,isPanning:!0,isZooming:!0}),!0}_onDoubleClickDragEnd(t){if(!this._doubleClickDragAnchor)return!1;this._doubleClickDragAnchor=null;let n=this.controllerState,i=this._getConstraintContext("zoom","end"),s=n.zoomEnd(i),o=this._getReboundTransition(i,s);return this.updateViewport(s,o,{isDragging:!1,isPanning:!!o,isZooming:!!o}),this._suppressDoubleClickUntil=Date.now()+100,this.blockEvents(100),!0}_onKeyDown(t){if(!this.keyboard)return!1;let r=this.isFunctionKeyPressed(t),{zoomSpeed:n,moveSpeed:i,rotateSpeedX:s,rotateSpeedY:o}=this.keyboard===!0?{}:this.keyboard,{controllerState:a}=this,c,l={};switch(t.srcEvent.code){case"Minus":c=r?a.zoomOut(n).zoomOut(n):a.zoomOut(n),l.isZooming=!0;break;case"Equal":c=r?a.zoomIn(n).zoomIn(n):a.zoomIn(n),l.isZooming=!0;break;case"ArrowLeft":r?(c=a.rotateLeft(s),l.isRotating=!0):(c=a.moveLeft(i),l.isPanning=!0);break;case"ArrowRight":r?(c=a.rotateRight(s),l.isRotating=!0):(c=a.moveRight(i),l.isPanning=!0);break;case"ArrowUp":r?(c=a.rotateUp(o),l.isRotating=!0):(c=a.moveUp(i),l.isPanning=!0);break;case"ArrowDown":r?(c=a.rotateDown(o),l.isRotating=!0):(c=a.moveDown(i),l.isPanning=!0);break;default:return!1}return this.updateViewport(c,this._getTransitionProps(),l),!0}_getTransitionProps(t){let{transition:r}=this;return!r||!r.transitionInterpolator?xt:t?{...r,transitionInterpolator:new Nt({...t,...r.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:r}};var se=Symbol("constraintAround"),Ve=class{constructor(t,r,n,i){this.makeViewport=n,this._viewportProps=this.applyConstraints(t,i),this._state=r}getViewportProps(){return this._viewportProps}getState(){return this._state}};function Jr(e,t,r){let n=e-t;return n&&Number.isFinite(n)?t+n*r/(r+Math.abs(n)):t}function Pi(e,t,r){let n=j(Y(r?.left??0),e),i=j(Y(r?.right??0),e),s=j(Y(r?.top??0),t),o=j(Y(r?.bottom??0),t);return{x:n,y:s,width:e-n-i,height:t-s-o}}function Sa(e,t,r){let[n,i]=e.project(t);return n=Number.isFinite(n)?n:e.width/2,i=Number.isFinite(i)?i:e.height/2,{left:n-r.x,right:r.x+r.width-n,top:i-r.y,bottom:r.y+r.height-i}}var Ma=5,pf=1.2,Pa=512,Ca=[[-1/0,-90],[1/0,90]],gf=1;function Ge([e,t]){if(Math.abs(t)>90&&(t=Math.sign(t)*90),Number.isFinite(e)){let[n,i]=tt([e,t]);return[n,$(i,0,Pa)]}let[,r]=tt([0,t]);return[e,$(r,0,Pa)]}var Ci=class extends Ve{constructor(t){let{width:r,height:n,latitude:i,longitude:s,zoom:o,bearing:a=0,pitch:c=0,altitude:l=1.5,position:h=[0,0,0],maxZoom:u=20,minZoom:f=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:g,startZoomLngLat:m,startRotatePos:x,startRotateLngLat:_,startBearing:b,startPitch:w,startZoom:v,normalize:E=!0,rubberBand:y=!1}=t,{[se]:T}=t;Ot(Number.isFinite(s)),Ot(Number.isFinite(i)),Ot(Number.isFinite(o));let M=t.maxBounds||(E?Ca:null),S=t.maxBoundsPadding||null;super({width:r,height:n,latitude:i,longitude:s,zoom:o,bearing:a,pitch:c,altitude:l,maxZoom:u,minZoom:f,maxPitch:d,minPitch:p,normalize:E,position:h,maxBounds:M,maxBoundsPadding:S,rubberBand:y,[se]:T},{startPanLngLat:g,startZoomLngLat:m,startRotatePos:x,startRotateLngLat:_,startBearing:b,startPitch:w,startZoom:v},t.makeViewport,t.constraintContext),this.getAltitude=t.getAltitude}panStart({pos:t},r){return this._getUpdatedState({startPanLngLat:this._unproject(t)},r)}pan({pos:t,startPos:r},n){let i=this.getState().startPanLngLat||this._unproject(r);if(!i)return this;let o=this.makeViewport(this.getViewportProps()).panByPosition(i,t);return this._getUpdatedState(o,n)}panEnd(t){return this._getUpdatedState({startPanLngLat:null},t)}rotateStart({pos:t}){let r=this.getAltitude?.(t);return this._getUpdatedState({startRotatePos:t,startRotateLngLat:r!==void 0?this._unproject3D(t,r):void 0,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:t,deltaAngleX:r=0,deltaAngleY:n=0}){let{startRotatePos:i,startRotateLngLat:s,startBearing:o,startPitch:a}=this.getState();if(!i||o===void 0||a===void 0)return this;let c;if(t?c=this._getNewRotation(t,i,a,o):c={bearing:o+r,pitch:a+n},s){let l=this.makeViewport({...this.getViewportProps(),...c}),h="panByPosition3D"in l?"panByPosition3D":"panByPosition";return this._getUpdatedState({...c,...l[h](s,i)})}return this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startRotatePos:null,startRotateLngLat:null,startBearing:null,startPitch:null})}zoomStart({pos:t},r){return this._getUpdatedState({startZoomLngLat:this._unproject(t),startZoom:this.getViewportProps().zoom},r)}zoom({pos:t,startPos:r,scale:n},i){let{startZoom:s,startZoomLngLat:o}=this.getState();return o||(s=this.getViewportProps().zoom,o=this._unproject(r)||this._unproject(t)),o?this._getUpdatedState({zoom:s+Math.log2(n),[se]:{position:o,screenPosition:t}},i):this}zoomEnd(t){return this._getUpdatedState({startZoomLngLat:null,startZoom:null},t)}zoomIn(t=2,r){return this._zoomFromCenter(t,r)}zoomOut(t=2,r){return this._zoomFromCenter(1/t,r)}moveLeft(t=100,r){return this._panFromCenter([t,0],r)}moveRight(t=100,r){return this._panFromCenter([-t,0],r)}moveUp(t=100,r){return this._panFromCenter([0,t],r)}moveDown(t=100,r){return this._panFromCenter([0,-t],r)}rotateLeft(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-t})}rotateRight(t=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+t})}rotateUp(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+t})}rotateDown(t=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-t})}shortestPathFrom(t){let r=t.getViewportProps(),n={...this.getViewportProps()},{bearing:i,longitude:s}=n;return Math.abs(i-r.bearing)>180&&(n.bearing=i<0?i+360:i-360),Math.abs(s-r.longitude)>180&&(n.longitude=s<0?s+360:s-360),n}applyConstraints(t,r){let n=t,i=n[se];delete n[se];let{maxPitch:s,minPitch:o,pitch:a,bearing:c,normalize:l,maxBounds:h,rubberBand:u}=t;l&&(c<-180||c>180)&&(t.bearing=pi(c+180,360)-180),t.pitch=$(a,o,s);let f=this._constrainZoom(t.zoom,t),d=u&&r?.mode==="elastic";if(t.zoom=r?.mode==="preserve"?t.zoom:d?Jr(t.zoom,f,gf):f,i){let p=this.makeViewport(t);Object.assign(t,p.panByPosition(i.position,i.screenPosition))}if(l&&(t.longitude<-180||t.longitude>180)&&(t.longitude=pi(t.longitude+180,360)-180),h){let p=Pi(t.width,t.height,t.maxBoundsPadding),g=this.makeViewport({...t,bearing:0,pitch:0}),m=Sa(g,[t.longitude,t.latitude],p),x=Ge(h[0]),_=Ge(h[1]),b=2**t.zoom,w=[x[0]+m.left/b,x[1]+m.bottom/b],v=[_[0]-m.right/b,_[1]-m.top/b],E=Ge([t.longitude,t.latitude]),y=[$(E[0],w[0],v[0]),$(E[1],w[1],v[1])],T=E.slice();if(p.width>=0&&(T[0]=r?.mode==="preserve"?E[0]:d?Jr(E[0],y[0],p.width/2/b):y[0]),p.height>=0&&(T[1]=r?.mode==="preserve"?E[1]:d?Jr(E[1],y[1],p.height/2/b):y[1]),T[0]!==E[0]||T[1]!==E[1]){let[M,S]=X(T);T[0]!==E[0]&&(t.longitude=M),T[1]!==E[1]&&(t.latitude=S)}}return t}_constrainZoom(t,r){r||=this.getViewportProps();let{maxZoom:n,maxBounds:i}=r,s=i!==null&&r.width>0&&r.height>0,{minZoom:o}=r;if(s){let a=Pi(r.width,r.height,r.maxBoundsPadding),c=Ge(i[0]),l=Ge(i[1]),h=l[0]-c[0],u=l[1]-c[1];a.width>0&&Number.isFinite(h)&&h>0&&(o=Math.max(o,Math.log2(a.width/h))),a.height>0&&Number.isFinite(u)&&u>0&&(o=Math.max(o,Math.log2(a.height/u))),o>n&&(o=n)}return $(t,o,n)}_zoomFromCenter(t,r){let{width:n,height:i}=this.getViewportProps();return this.zoom({pos:[n/2,i/2],scale:t},r)}_panFromCenter(t,r){let{width:n,height:i}=this.getViewportProps();return this.pan({startPos:[n/2,i/2],pos:[n/2+t[0],i/2+t[1]]},r)}_getUpdatedState(t,r){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...t,constraintContext:r})}_unproject(t){let r=this.makeViewport(this.getViewportProps());return t&&r.unproject(t)}_unproject3D(t,r){return this.makeViewport(this.getViewportProps()).unproject(t,{targetZ:r})}_getNewRotation(t,r,n,i){let s=t[0]-r[0],o=t[1]-r[1],a=t[1],c=r[1],{width:l,height:h}=this.getViewportProps(),u=s/l,f=0;o>0?Math.abs(h-c)>Ma&&(f=o/(c-h)*pf):o<0&&c>Ma&&(f=1-a/c),f=$(f,-1,1);let{minPitch:d,maxPitch:p}=this.getViewportProps(),g=i+180*u,m=n;return f>0?m=n+f*(p-n):f<0&&(m=n-f*(d-n)),{pitch:m,bearing:g}}},ze=class extends Ne{constructor(){super(...arguments);this.ControllerState=Ci;this.transition={transitionDuration:300,transitionInterpolator:new Nt({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})};this.dragMode="pan";this.rotationPivot="center";this._getAltitude=r=>{if(this.rotationPivot==="2d")return 0;if(this.rotationPivot==="3d"&&this.pickPosition){let{x:n,y:i}=this.props,s=this.pickPosition(n+r[0],i+r[1]);if(s&&s.coordinate&&s.coordinate.length>=3)return s.coordinate[2]}}}setProps(r){"rotationPivot"in r&&(this.rotationPivot=r.rotationPivot||"center"),r.getAltitude=this._getAltitude,r.position=r.position||[0,0,0],r.maxBounds=r.maxBounds||(r.normalize===!1?null:Ca),super.setProps(r)}updateViewport(r,n=null,i={}){let s=r.getState();i.isDragging&&s.startRotateLngLat?i={...i,rotationPivotPosition:s.startRotateLngLat}:i.isDragging===!1&&(i={...i,rotationPivotPosition:void 0}),super.updateViewport(r,n,i)}};var oe=class extends _e{constructor(t={}){super(t)}getViewportType(){return Be}get ControllerType(){return ze}};oe.displayName="MapView";var bf=5916575505e-1,xf=78271.484,tn=111320,yf=55*Math.PI/180,wf=65,Ef=80;function Tf(e,t){let r=(e.latitude+t.latitude)/2*Math.PI/180,n=(e.latitude-t.latitude)*tn,i=(e.longitude-t.longitude)*tn*Math.cos(r);return Math.sqrt(n*n+i*i)}function _f(e,t,r,n,i){let s=e.toMap({x:n/2,y:i/2}),o=e.toMap({x:n/2+1,y:i/2});if(s&&o){let a=Tf(s,o);if(a>0){let c=r*Math.PI/180;return Math.log2(xf*Math.cos(c)/a)}}return Math.log2(bf/e.scale)-1}function vf(e,t,r){let n=Math.max(0,Math.min(1,(r-e)/(t-e)));return n*n*(3-2*n)}function Sf(e,t){let r=e/t;return .5/(Math.tan(yf/2)/Math.sqrt(1+r*r))}function Mf(e,t,r,n){let i=Sf(r,n),s=vf(wf,Ef,e);return t*(1-s)+i*s}function Pf(e,t,r,n,i,s){return{views:new oe({id:"arcgis-scene"}),viewState:{"arcgis-scene":{id:"arcgis-scene",longitude:t,latitude:r,zoom:n,pitch:e.camera.tilt,bearing:e.camera.heading,altitude:s,position:[0,0,0],resolution:i}}}}function Li(e,t){class r{constructor(i,s){if(this.resources=null,this.cancelInitialization=null,this.renderNode=null,i&&typeof i=="object"&&"view"in i){let{view:l,...h}=i;this.view=l,this.deck=new e(h)}else this.view=i,this.deck=new e(s);let o=!1,a=this,c=t.createSubclass({consumes:{required:["composite-color"]},produces:"composite-color",initialize(){},render(l){let h=this,u=l.find(D=>D.name==="composite-color");if(!a.resources&&!o){let D=h.gl;if(D){o=!0;let ht=!1;a.cancelInitialization=()=>{ht=!0},Ir.call(a,D).then(H=>{if(o=!1,ht){jt(H);return}a.deck.on("change",Ue=>H.deck.setProps(Ue)),H.deck.setProps(a.deck.toJSON()),a.resources=H,h.requestRender()}).catch(H=>{o=!1,console.error("DeckRenderer: failed to initialize resources",H)})}return u}if(!a.resources)return u;let f=h.bindRenderTarget(),d=h.gl,p=window.devicePixelRatio||1,g=d.drawingBufferWidth/p,m=d.drawingBufferHeight/p,x=a.view.camera.position,_=a.view.toMap({x:g/2,y:m/2}),b=_?_.latitude:a.view.center.latitude,w=_?_.longitude:a.view.center.longitude,v=(b+x.latitude)/2*Math.PI/180,E=(x.latitude-b)*tn,y=(x.longitude-w)*tn*Math.cos(v),T=Math.sqrt(E*E+y*y),M=Math.sqrt(T*T+x.z*x.z),S=_f(a.view,w,b,g,m),C=m*a.view.resolution,L=M/C,R=Mf(a.view.camera.tilt,L,g,m),A=Pf(a.view,w,b,S,a.view.resolution,R);try{A?Te(a.resources,{width:g,height:m,latitude:b,longitude:w,altitude:R,zoom:S,bearing:a.view.camera.heading,pitch:a.view.camera.tilt,...A}):Te(a.resources,{width:g,height:m,latitude:b,longitude:w,altitude:R,zoom:S,bearing:a.view.camera.heading,pitch:a.view.camera.tilt})}catch(D){console.error("DeckRenderer: render error",D)}return f}});this.renderNode=new c({view:this.view})}async setup(i){}dispose(){this.cancelInitialization?.(),this.resources&&(jt(this.resources),this.resources=null),this.renderNode=null}redraw(){this.renderNode?.requestRender()}render(){this.renderNode?.requestRender()}}return r}var Ai=I(Aa(),1),ae;async function Cf(e,t){let r=Array.isArray(e)?null:e;return await Lf(r,t),Array.isArray(e)?(0,Ai.loadModules)(e,t).then(n=>({...ae,modules:n})):ae}async function Lf(e,t){if(ae)return ae;if(e){let o=e.layers.Layer,a=e.core.Accessor,c=e.views["2d"].layers.BaseLayerViewGL2D,l=e.views["3d"].webgl.RenderNode;return Ra(o,a,c,l)}let[r,n,i,s]=await(0,Ai.loadModules)(["esri/layers/Layer","esri/core/Accessor","esri/views/2d/layers/BaseLayerViewGL2D","esri/views/3d/webgl/RenderNode"],t);return Ra(r,n,i,s)}function Ra(e,t,r,n){let i=rn(t),s=Bn(r),o=nn(i,e,s),a=Li(i,n);return ae={DeckLayer:o,DeckRenderer:a},ae}return Oa(We);})();
|
|
30
30
|
return __exports__;
|
|
31
31
|
});
|