@maptalks/3dtiles 0.98.0 → 0.100.0
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.
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @maptalks/3dtiles v0.
|
|
2
|
+
* @maptalks/3dtiles v0.100.0
|
|
3
3
|
* LICENSE : UNLICENSED
|
|
4
4
|
* (c) 2016-2024 maptalks.org
|
|
5
5
|
*/
|
|
6
|
-
import*as t from"maptalks";import*as e from"@maptalks/gl";import{reshader as n,mat4 as r,HighlightUtil as s,ContextUtil as i,quat as o,vec3 as a,mat3 as c,vec4 as h,MaskRendererMixin as l,createREGL as u,MaskLayerMixin as f,ClipOutsideMask as d,vec2 as m}from"@maptalks/gl";import{intersectsBox as p,intersectsOrientedBox as b,intersectsSphere as g}from"frustum-intersects";import{GLTFLoader as y,Ajax as w}from"@maptalks/gltf-loader";import{quat as v,mat4 as T,vec3 as _,mat3 as O}from"gl-matrix";const M="${",x=`function(t){var e="undefined"!=typeof Float32Array?Float32Array:Array;function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function r(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],u=e[6],l=e[7],f=e[8],h=e[9],d=e[10],y=e[11],m=e[12],b=e[13],p=e[14],g=e[15],w=n[0],v=n[1],M=n[2],T=n[3];return t[0]=w*r+v*a+M*f+T*m,t[1]=w*s+v*c+M*h+T*b,t[2]=w*i+v*u+M*d+T*p,t[3]=w*o+v*l+M*y+T*g,w=n[4],v=n[5],M=n[6],T=n[7],t[4]=w*r+v*a+M*f+T*m,t[5]=w*s+v*c+M*h+T*b,t[6]=w*i+v*u+M*d+T*p,t[7]=w*o+v*l+M*y+T*g,w=n[8],v=n[9],M=n[10],T=n[11],t[8]=w*r+v*a+M*f+T*m,t[9]=w*s+v*c+M*h+T*b,t[10]=w*i+v*u+M*d+T*p,t[11]=w*o+v*l+M*y+T*g,w=n[12],v=n[13],M=n[14],T=n[15],t[12]=w*r+v*a+M*f+T*m,t[13]=w*s+v*c+M*h+T*b,t[14]=w*i+v*u+M*d+T*p,t[15]=w*o+v*l+M*y+T*g,t}function s(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function i(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function o(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,u=n*o,l=r*o,f=r*a,h=s*o,d=s*a,y=s*c,m=i*o,b=i*a,p=i*c;return t[0]=1-f-y,t[1]=l+p,t[2]=h-b,t[3]=0,t[4]=l-p,t[5]=1-u-y,t[6]=d+m,t[7]=0,t[8]=h+b,t[9]=d-m,t[10]=1-u-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function a(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function c(){var t=new e(3);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function u(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function l(t,n,r){var s=new e(3);return s[0]=t,s[1]=n,s[2]=r,s}function f(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function h(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function d(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function y(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function m(t,e){var n=e[0],r=e[1],s=e[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function b(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function p(t,e,n){var r=e[0],s=e[1],i=e[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,t[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,t[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var g=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},w=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},v=u;function M(t,e,n,r,s){return t[0]=e,t[1]=n,t[2]=r,t[3]=s,t}function T(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3];return t[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,t[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,t[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,t[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,t}function A(){var t=new e(4);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function _(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function O(t,e,n,r){var s,i,o,a,c,u=e[0],l=e[1],f=e[2],h=e[3],d=n[0],y=n[1],m=n[2],b=n[3];return(i=u*d+l*y+f*m+h*b)<0&&(i=-i,d=-d,y=-y,m=-m,b=-b),1-i>1e-6?(s=Math.acos(i),o=Math.sin(s),a=Math.sin((1-r)*s)/o,c=Math.sin(r*s)/o):(a=1-r,c=r),t[0]=a*u+c*d,t[1]=a*l+c*y,t[2]=a*f+c*m,t[3]=a*h+c*b,t}c(),function(){var t,n=(t=new e(4),e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var k,x=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};c(),l(1,0,0),l(0,1,0),A(),A(),k=new e(9),e!=Float32Array&&(k[1]=0,k[2]=0,k[3]=0,k[5]=0,k[6]=0,k[7]=0),k[0]=1,k[4]=1,k[8]=1;\n/*!\n * @maptalks/gltf-loader v0.98.0\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.org\n */\nlet S=0;function I(t){return null==t}function E(t){return!I(t)}function C(t){return!I(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function U(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function F(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView's component type: "+t)}function N(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function P(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=e.charCodeAt(t);return r.buffer}const B=[],D=[],R=[],L=[0,0,0],j=_([]),z=[1,1,1];function q(t,e,n,r,s,i,o){const a=F(o),c=a.BYTES_PER_ELEMENT;if((0===s||s===r*c)&&i%c==0){const s=new a(e,i,n*r);return t.set(s),t}0===s&&(s=r*c);const u=new Uint8Array(r*c);for(let o=0;o<n;o++){let n=null;const l=new Uint8Array(e,s*o+i,r*c);u.set(l),n=new a(u.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const V="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function G(t,e,n){const r=new Uint8Array(t,e,n);return V.decode(r)}const $={get:function(t,e={},n){e||(e={});const r=new AbortController,s=r.signal,i=U({},e);i.signal=s,i.method||(i.method="GET"),i.referrerPolicy=i.referrerPolicy||"origin","undefined"==typeof window||i.referrer||(i.referrer=window.location.href),n&&(t=n(t));const o=fetch(t,i).then((t=>{const n=this.t(t,e.responseType);return n.message?n:n.then((n=>"arraybuffer"===e.responseType?{data:n,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:n)).catch((t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t}))})).catch((t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t}));return o.xhr=r,o},t:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:\`incorrect http request with status code(${M}t.status}): ${M}t.statusText}\`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={},n)=>(e||(e={}),e.responseType="arraybuffer",$.get(t,e,n)),getJSON:function(t,e={},n){return e&&e.jsonp?$.jsonp(t):((e=e||{}).responseType="json",$.get(t,e,n))},jsonp:function(t){const e="_maptalks_jsonp_"+S++;t.match(/\\?/)?t+="&callback="+e:t+="?callback="+e;let n=document.createElement("script");return n.type="text/javascript",n.src=t,new Promise((t=>{window[e]=function(r){document.getElementsByTagName("head")[0].removeChild(n),n=null,delete window[e],t(r)},document.getElementsByTagName("head")[0].appendChild(n)}))}};class X{constructor(t,e,n,r,s){this.i=t,this.decoders=e,this.o=n,this.images={},this.u={},this.h=r||{},this.m=s}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],s=this.p(e,r);return this.getImageByBuffer(s,n)}if(this.u[t.id])return this.u[t.id].then((()=>{const r=this.buffers[t.id],s=this.p(e,r);return this.getImageByBuffer(s,n)}));if(N(t.uri)){const r=this.buffers[t.id]=P(t.uri),s=this.p(e,r);return this.getImageByBuffer(s,n)}let r;const s=t.uri.indexOf("blob:")>=0;return r=t.uri.indexOf("://")>0||s?t.uri:this.rootPath+"/"+t.uri,this.u[t.id]=$.getArrayBuffer(r,this.h,this.m).then((r=>{const s=this.buffers[t.id]=r.data,i=this.p(e,s);return this.getImageByBuffer(i,n)}))}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const n=this.decoders;return n[e.mimeType]?n[e.mimeType](t,{supportedFormats:this.o}):"image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType?(console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null)):this.v(e.id,t)}requestExternalImage(t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const e=0===t.uri.indexOf("data:image/")?t.uri:this.rootPath+"/"+t.uri;return this.u[t.id]?this.u[t.id].then((()=>this.images[t.id])):this.u[t.id]=this.v(t.id,e)}v(t,e){return new Promise(((n,r)=>{let s=e;this.m&&(s=this.m(e)),this.i(s,this.h,((s,i)=>{s?r(s):(URL.revokeObjectURL(e),this.images[t]=i,n(this.images[t]))}))}))}}const H=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],J=[];class K{constructor(t,e,n,r,s){this.rootPath=t,this.gltf=e,this.M=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.T(),this.h=r,this.m=s}A(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this._(t,e,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const s=n.bufferViews[r.bufferView];return this.O(s).then((n=>{const{buffer:s,byteOffset:i}=n;return this.accessors[r.id]=this._(t,e,s,i)}))}O(t){const e=this.gltf.buffers[t.buffer];if(this.buffers[e.id]){const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}if(this.requests[e.id])return this.requests[e.id].then((()=>{const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}));if("binary_glTF"!==t.buffer&&"KHR_binary_glTF"!==t.buffer&&e.uri){if(N(e.uri)){const t=this.buffers[e.id]=P(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const n=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=$.getArrayBuffer(t,this.h,!n&&this.m).then((r=>(n&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=r.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}_(t,e,n,r=0){const s=this.gltf,i=s.accessors[e],o=void 0!==i.bufferView?s.bufferViews[i.bufferView]:{},a=(o.byteOffset||0)+r,c=this.k(i.type),u=F(i.componentType),l=o.byteStride||0,f={array:void 0,name:t,accessorName:e,byteLength:i.count*c*u.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:c,max:i.max,min:i.min,extensions:i.extensions};if(i.min&&(f.min=i.min),i.max&&(f.max=i.max),n)if(this.M)f.byteStride=l,f.byteOffset=a+(i.byteOffset||0),!l||l===c*u.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(f.array=this.S(n,i.count,c,a+(i.byteOffset||0),u),f.array.buffer.byteLength===f.byteLength&&(f.byteOffset=0)):f.array=new Uint8Array(n,a,o.byteLength);else if(i.interleaved){f.byteStride=0,f.byteOffset=0;const t=new u(i.count*c);if(f.array=q(t,n,i.count,c,l,a+(i.byteOffset||0),i.componentType),f.extensions&&f.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(f.array.length),{decodeMatrix:e}=f.extensions.WEB3D_quantized_attributes;for(let n=0;n<f.array.length;n+=c){J[0]=f.array[n],J[1]=f.array[n+1],J[2]=f.array[n+2],J[3]=1;const r=T(J,J,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}f.componentType=5126,f.array=t}}else f.byteStride=0,f.array=this.S(n,i.count,c,a+(i.byteOffset||0),u),f.byteOffset=f.array.byteOffset;else{f.array=new u(i.count);const t=f.min||f.max;t&&(f.array[0]=t[0],f.array[1]=t[1],f.array[2]=t[2])}return f}T(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let n=0;n<t.length;n++)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0);else for(const e in t)for(const n in t)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0)}S(t,e,n,r,s){return r%s.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*s.BYTES_PER_ELEMENT),r=0),new s(t,r,n*e)}k(t){const e=H.indexOf(t);return H[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,n=e.map((t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:n}=e;return this.O(e).then((r=>{const{buffer:s,byteOffset:i}=r,o=G(s,i+(e.byteOffset||0),n);return t.content=o,t}))}if(t.uri){if(N(t.uri)){const e=P(t.uri),n=G(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return $.get(e,this.h,this.m).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(n).then((()=>t))}}class Y extends X{constructor(t,e,n,r,s,i,o,a){super(r,s,i,o,a),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new K(t,e,n,o,a)}iterate(t,e){const n=this.gltf[e];if(!n)return;let r=0;for(const e in n)t(e,n[e],r++)}createNode(t){const e={};if(E(t.name)&&(e.name=t.name),E(t.children)&&(e.children=t.children),E(t.jointName)&&(e.jointName=t.jointName),E(t.matrix)&&(e.matrix=t.matrix),E(t.rotation)&&(e.rotation=t.rotation),E(t.scale)&&(e.scale=t.scale),E(t.translation)&&(e.translation=t.translation),E(t.extras)&&(e.extras=t.extras),E(t.meshes)&&(e.mesh=t.meshes[0]),e.translation||e.rotation||e.scale){const t=function(t,e){if(e.matrix)return e.matrix;if(e.translation||e.scale||e.rotation){const n=s(B,e.translation||L),a=o(D,e.rotation||j),c=i(R,e.scale||z);return r(c,a,c),r(t,n,c)}return n(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}I(t){const e={};for(const n in t){const r=t[n];let s,i;r.instanceTechnique&&r.instanceTechnique.values?(s=r.instanceTechnique,i=s.values.diffuse):(s=r,i=s.values.tex||s.values.diffuseTex||s.values.diffuse);const o={baseColorTexture:{index:i}};r.name&&(o.name=r.name),r.extensions&&(o.extensions=r.extensions),r.extras&&(o.extras=r.extras),e[n]=o}return e}C(t){if(t.bufferView||t.extensions&&(t.extensions.KHR_binary_glTF||t.extensions.binary_glTF)){const e=t.bufferView?t:t.extensions.KHR_binary_glTF||t.extensions.binary_glTF;t.extensions&&(t.mimeType=e.mimeType,t.width=e.width,t.height=e.height);const n=this.gltf.bufferViews[e.bufferView],r=(n.byteOffset||0)+this.glbBuffer.byteOffset,s=n.byteLength,i=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,s);return this.getImageByBuffer(i,t)}return this.requestExternalImage(t)}U(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.C(n).then((t=>{const r=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:n.mimeType,name:n.name,extras:n.extras},sampler:r}}))}getBaseColorTexture(t){const e=this.gltf.materials[t];let n,r;if(e.instanceTechnique&&e.instanceTechnique.values?(n=e.instanceTechnique,r=n.values.diffuse):(n=e,r=n.values.tex||n.values.diffuseTex||n.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const s=this.gltf.textures[r];if(!s)return null;const i=this.gltf.samplers[s.sampler];return{format:s.format||6408,internalFormat:s.internalFormat||6408,type:s.type||5121,sampler:i,source:this.gltf.images[s.source]}}getMaterial(){return null}getAnimations(){return null}}const Q=9729;class W extends X{constructor(t,e,n,r,s,i,o,a){super(r,s,i,o,a),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new K(t,e,n,o,a)}iterate(t,e){const n=this.gltf[e];if(n)for(let e=0;e<n.length;e++)t(e,n[e],e)}createNode(t){const e={};return U(e,t),!E(t.weights)&&this.gltf.meshes&&E(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}U(t){const e=this.gltf.textures[t];if(!e)return null;let n=e.source;if(e.extensions&&e.extensions.EXT_texture_webp&&(n=e.extensions.EXT_texture_webp.source),!E(n))return null;const r=this.gltf.images[n];return this.C(r).then((t=>{if(!t)return null;const n={image:{array:t.data,mipmap:t.mipmap,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};U(n,e);const s=E(e.sampler)?this.gltf.samplers[e.sampler]:void 0;if(s&&(n.sampler=s,n.sampler.magFilter=s.magFilter||Q,n.sampler.minFilter=s.minFilter||Q,n.sampler.wrapS=s.wrapS||10497,n.sampler.wrapT=s.wrapT||10497),!n.mipmap&&n.sampler.minFilter!==Q&&9728!==n.sampler.minFilter){const t=n.sampler.minFilter;n.sampler.minFilter=9984===t||9986===t?9728:Q}return t.format&&(n.format=t.format),n}))}C(t){if(!E(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],n=this.gltf.buffers[e.buffer];if(n.uri)return this.requestImageFromBufferURI(n,e,t);if(this.glbBuffer)return this.F(e,t)}return null}F(t,e){const n=this.p(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}p(t,e,n){n=n||0;const r=(t.byteOffset||0)+n,s=t.byteLength;return new Uint8Array(e,r,s)}N(t,e){const n=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)n[e]=String.fromCharCode(t[e]);n.join("");const r="data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(n)));return r}getAnimations(t){const e=[];return t.forEach((t=>{e.push(this.getSamplers(t.samplers))})),Promise.all(e).then((e=>{for(let n=0;n<e.length;n++)t[n].samplers=e[n];return t}))}getSamplers(t){const e=[];for(let n=0;n<t.length;n++)(E(t[n].input)||E(t[n].output))&&(e.push(this.accessor.A("input",t[n].input)),e.push(this.accessor.A("output",t[n].output)));return Promise.all(e).then((e=>{for(let n=0;n<e.length/2;n++)t[n].input=e[2*n],t[n].output=e[2*n+1],t[n].interpolation||(t[n].interpolation="LINEAR");return t}))}}const Z="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class tt{static read(t,e=0,n=0){n||(n=t.byteLength);const r=new DataView(t,e,n),s=r.getUint32(4,!0);if(1===s)return tt.readV1(r,e);if(2===s)return tt.readV2(t,e);throw new Error("Unsupported glb version : "+s)}static readV1(t,e){const n=t.getUint32(8,!0),r=t.getUint32(12,!0);if(n!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const s=et(t.buffer,20+e,r);return{json:JSON.parse(s),glbBuffer:{byteOffset:20+e+r,buffer:t.buffer,byteLength:n}}}static readV2(t,e){let n,r,s;const i=new DataView(t,e+12);let o=0;for(;o<i.byteLength;){const a=i.getUint32(o,!0);o+=4;const c=i.getUint32(o,!0);if(o+=4,1313821514===c)n=et(t,e+12+o,a);else if(5130562===c){s=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:s,buffer:t,byteLength:r}}}}function et(t,e,n){if(Z){const r=new Uint8Array(t,e,n);return Z.decode(r)}return function(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=nt[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}(new Uint8Array(t,e,n))}const nt=[1,1,1,1,2,2,3,0],rt=[0,0,0],st=[0,0,0,1],it=[1,1,1],ot={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},at={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},ct={P(t,e,n,r,s,i,o,a){const c=E(t)?e.animations:[e.animations[0]],u={};for(let e=0;e<c.length;e++){const l=c[e],h=l.name||e;if(E(t)&&h!==t)continue;const d=l.channelsMap[n];if(d)for(let t=0;t<d.length;t++){const e=d[t];"translation"===e.target.path?(this.B(s,l.samplers[e.sampler],r,1),u.translation=f(rt,s)):"rotation"===e.target.path?(this.D(i,l.samplers[e.sampler],r,1),u.rotation=x(st,i)):"scale"===e.target.path?(this.B(o,l.samplers[e.sampler],r,1),u.scale=f(it,o)):"weights"===e.target.path&&a&&(this.B(a,l.samplers[e.sampler],r,a.length),u.weights=a)}}return u},B(t,e,n,r){switch(e.interpolation){case"LINEAR":{const s=this.R(at,e,n,1*r);s&&(t=function(t,e,n,r){for(let s=0;s<t.length;s++)t[s]=e[s]+r*(n[s]-e[s]);return t}(t,s.PREVIOUS,s.NEXT,s.INTERPOLATION));break}case"STEP":{const s=this.R(at,e,n,1*r);s&&(t=function(t,e){for(let n=0;n<t.length;n++)t[n]=e[n];return t}(t,...s.PREVIOUS));break}case"CUBICSPLINE":{const s=this.R(at,e,n,3*r);s&&(t=this.L(t,s,e.input.array,3*r));break}}return t},D(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.R(at,e,n,1);r&&O(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.R(at,e,n,1);r&&(t=M(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.R(at,e,n,3);if(r){for(let t=0;t<r.PREVIOUS.length;t++)r.PREVIOUS[t]=Math.acos(r.PREVIOUS[t]),r.NEXT[t]=Math.acos(r.NEXT[t]);t=this.L(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},j(t,e){const n=t.length;let r,s,i,o=0,a=n-1,c=Math.floor((o+a)/2);for(;o<=n-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const n=t[c];return r=c,s=c+1,i=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:s,interpolation:i}}e<t[c]?(a=c,c=Math.floor((o+a)/2)):t[c+1]<e&&(o=c,c=Math.floor((o+a)/2))}return null},R(t,e,n,r){const s=e.input.array,i=e.output.array,o=e.output.itemSize;(n<s[0]||n>s[s.length-1])&&(n=Math.max(s[0],Math.min(s[s.length-1],n))),n===s[s.length-1]&&(n=s[0]);const a=this.j(s,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:u,interpolation:l}=a;t.PREINDEX=c,t.NEXTINDEX=u,t.INTERPOLATION=l;const f=o*r;return t.PREVIOUS=i.subarray(t.PREINDEX*f,(t.PREINDEX+1)*f),t.NEXT=i.subarray(t.NEXTINDEX*f,(t.NEXTINDEX+1)*f),t},L(t,e,n,r){const s=e.INTERPOLATION,i=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-i)*e.PREVIOUS[2*r+n],u=e.NEXT[3+n],l=(o-i)*e.NEXT[n],f=(2*Math.pow(s,3)-3*Math.pow(s,2)+1)*a+(Math.pow(s,3)-2*Math.pow(s,2)+s)*c+(2*-Math.pow(s,3)+3*Math.pow(s,2))*u+(Math.pow(s,3)-Math.pow(s,2))*l;t[n]=f}return t},getAnimationClip(t,e,n,r){const s=t.nodes[e]&&t.nodes[e].weights;return h(rt,...ot.TRANSLATION),M(st,...ot.ROTATION),h(it,...ot.SCALE),this.P(r,t,e,n,rt,st,it,s)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach(((e,n)=>{let r=-1/0,s=1/0;const i=e.channels;for(let t=0;t<i.length;t++){const n=i[t],o=e.samplers[n.sampler].input.array;o[o.length-1]>r&&(r=o[o.length-1]),o[0]<s&&(s=o[0])}const o=e.name||n;t.timeSpan[o]={max:r,min:s}})),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?E(e)?n[e]:n[Object.keys(n)[0]]:null}};let ut=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Ge){}t&&"undefined"!=typeof createImageBitmap&&(ut=!0)}const lt="undefined"==typeof document?null:document.createElement("canvas");class ft{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),this.h=this.options.fetchOptions||{},e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=tt.read(e.buffer,e.byteOffset,e.byteLength);this.q(t,n,r)}else this.q(t,e);this.V=new K(this.rootPath,this.gltf,this.glbBuffer,this.h,this.options.urlModifier),this.G()}G(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders["image/ktx2"])throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded");if(t.indexOf("EXT_meshopt_compression")>=0)throw new Error("EXT_meshopt_compression extension is not supported yet.")}}$(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.V.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.X(t),n=this.H(),r=this.J(),s=this.$();return Promise.all([e,n,r,s]).then((t=>(t[0].animations=t[1],t[0].textures=t[2],t[0].extensions=t[3],t[0].transferables=this.transferables||[],this.createChannelsMap(t[0]),t[0])))}createChannelsMap(t){const e=t.animations;if(e)for(let t=0;t<e.length;t++){const n=e[t];n.channelsMap={};for(let t=0;t<n.channels.length;t++){const e=n.channels[t];n.channelsMap[e.target.node]||(n.channelsMap[e.target.node]=[]),n.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:n}=this.gltf;for(let n=0;n<e.length;n++)e[n].uri&&e[n].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[n].uri});for(let e=0;e<n.length;e++)n[e].uri&&n[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:n[e].uri})}return t}static getAnimationClip(t,e,n,r){return ct.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return ct.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return F(t)}static readInterleavedArray(t,e,n,r,s,i,o){return q(t,e,n,r,s,i,o)}q(t,e,n){this.gltf=e,this.glbBuffer=n,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=ut?gt.bind(this):this.options.requestImage||ht,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new W(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.h,this.options.urlModifier),this.adapter.iterate(((t,e,n)=>{e.id="buffer_"+n}),"buffers"),this.adapter.iterate(((t,e,n)=>{e.id="image_"+n}),"images"),this.adapter.iterate(((t,e,n)=>{e.id="accessor_"+n}),"accessors")):(this.adapter=new Y(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.h,this.options.urlModifier),this.adapter.iterate(((t,e,n)=>{e.id="accessor_"+n}),"accessors"),this.adapter.iterate(((t,e,n)=>{e.id="image_"+n}),"images"))}K(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(n=t.children[0])&&isFinite(n)||C(t.children[0])))return t;const r=t.children.map((t=>{const n=e[t];return n.nodeIndex=t,this.K(n,e)}));t.children=r}var n;return t}X(t){return this.Y(t).then((t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.K(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate(((r,s,i)=>{const o={};s.name&&(o.name=s.name),s.nodes&&(o.nodes=s.nodes.map((e=>t[e]))),this.gltf.scene===r&&(n=i),e.push(o)}),"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:n,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.I(this.gltf.materials);r.materials=t}return delete this.gltf.buffers,r.json=this.gltf,r}))}Y(t){return this.W(t).then((()=>{const t=this.nodes={};return this.adapter.iterate(((e,n)=>{const r=this.adapter.createNode(n,this.meshes,this.skins);t[e]=r}),"nodes"),t}))}Z(){this.skins=[];const t=[];return this.adapter.iterate(((e,n,r)=>{t.push(this.tt(n).then((t=>{t.index=r,this.skins.push(t)})))}),"skins"),t}tt(t){const e=t.inverseBindMatrices;return this.adapter.accessor.A("inverseBindMatrices",e).then((e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t)))}H(){const t=this.gltf.animations;return E(t)?this.adapter.getAnimations(t):null}W(t){this.meshes={};let e=[];return this.adapter.iterate(((n,r,s)=>{e.push(this.et(r,t).then((t=>{t.index=s,this.meshes[n]=t})))}),"meshes"),e=e.concat(this.Z()),Promise.all(e)}et(t,e){const n=t.primitives.map((t=>this.nt(t,e))).filter((t=>!!t));return Promise.all(n).then((e=>{const n={};return U(n,t),n.primitives=e,n}))}J(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.U(n));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image.array;if(n){let t;t=n instanceof ImageBitmap?n:n.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const n={},r=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(n[r[t]]=e[t]);return n}return e}))}nt(t,e){let n;const r=[],s=t.extensions;if(E(t.targets))for(let e=0;e<t.targets.length;e++){const n=t.targets[e];for(const t in n){const s=this.adapter.accessor.A(\`morphTargets_${M}t}_${M}e}\`,n[t]);s&&r.push(s)}}if(s&&s.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const t=this.options.decoders.draco,{bufferView:i,attributes:o}=s.KHR_draco_mesh_compression,a=this.gltf.bufferViews[i],c=this.V.O(a).then((n=>{const{buffer:r,byteOffset:s}=n;let{byteOffset:i}=a;const c=a.byteLength;i||(i=0);const u=new DataView(r,s+i,c),l={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(u,l).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));r.push(c),n=Promise.all(r)}else{const e=t.attributes;for(const t in e){const n=this.adapter.accessor.A(t,e[t]);n&&r.push(n)}if(E(t.indices)){const e=this.adapter.accessor.A("indices",t.indices);e&&r.push(e)}n=Promise.all(r)}return n.then((e=>{if(s&&s.KHR_draco_mesh_compression){const n=t.targets?t.targets.length:0;e[n]=e[n].concat(e.slice(0,n)),e=e[n]}let n,r;const i={attributes:e.reduce(((t,e)=>{if("indices"===e.name)n=e;else if(e.name.indexOf("morphTargets_")>-1)r=r||{},r[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],{itemSize:r,array:s}=e,i=s.length/r;for(let e=0;e<i;e++)for(let i=0;i<r;i++){const o=e*r+i;s[o]<t[i]&&(t[i]=s[o]),s[o]>n[i]&&(n[i]=s[o])}if(e.quantization){const r=e.quantization,s=r.range/(1<<r.quantizationBits),i=r.minValues;y(t,t,s),d(t,t,i),y(n,n,s),d(n,n,i)}e.min=t,e.max=n}t[e.name]=e}return this.transferables&&e.array.buffer&&this.transferables.indexOf(e.array.buffer)<0&&this.transferables.push(e.array.buffer),t}),{}),material:t.material};return n&&(i.indices=n),r&&(i.morphTargets=r),i.mode=E(t.mode)?t.mode:4,E(t.extras)&&(i.extras=t.extras),i}))}}function ht(t,e,n){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!lt)return void n(new Error("There is no canvas to draw image!"));lt.width=r.width,lt.height=r.height;const t=lt.getContext("2d",{willReadFrequently:!0});t.drawImage(r,0,0,r.width,r.height);const e=t.getImageData(0,0,r.width,r.height),s={width:r.width,height:r.height,data:new Uint8Array(e.data)};n(null,s)},r.onerror=function(t){n(t)},r.src=t}const dt=[],yt=[],mt=10;let bt,pt;function gt(t,e,n){bt||(bt=new OffscreenCanvas(2,2),pt=bt.getContext("2d",{willReadFrequently:!0}));let r=null;if(C(t))this.options.urlModifier&&(t=this.options.urlModifier(t)),dt.push([t,e,n,this]),wt();else{const e=new Blob([t]);r=createImageBitmap(e),r.then(vt.bind(this)).then((t=>{n(null,t)})).catch((t=>{console.warn(t),n(t)}))}}function wt(){if(!dt.length||yt.length>mt)return;const t=dt.shift(),[e,n,r,s]=t;yt.push(t),fetch(e,n).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then(vt.bind(s)).then((e=>{r.call(s,null,e);const n=yt.indexOf(t);yt.splice(n,1),wt()})).catch((e=>{console.warn(e),r.call(s,e);const n=yt.indexOf(t);yt.splice(n,1),wt()}))}function vt(t){let{width:e,height:n}=t;Mt(e)||(e=Tt(e)),Mt(n)||(n=Tt(n));const r=this.options.maxTextureSize;r&&(e=Math.min(r,e),n=Math.min(r,n)),bt.width=e,bt.height=n,pt.drawImage(t,0,0,e,n),t.close();const s=pt.getImageData(0,0,e,n);return{width:e,height:n,data:new Uint8Array(s.data)}}function Mt(t){return!(t&t-1)&&0!==t}function Tt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function At(t){return t&&t.rt&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var _t={exports:{}},Ot={exports:{}},kt=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},xt=Array.prototype.concat,St=Array.prototype.slice,It=Ot.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var s=t[n];kt(s)?e=xt.call(e,St.call(s)):e.push(s)}return e};It.wrap=function(t){return function(){return t(It(arguments))}};var Et=Ot.exports,Ct={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},Ut=Et,Ft=Object.hasOwnProperty,Nt=Object.create(null);for(var Pt in Ct)Ft.call(Ct,Pt)&&(Nt[Ct[Pt]]=Pt);var Bt=_t.exports={to:{},get:{}};function Dt(t,e,n){return Math.min(Math.max(e,t),n)}function Rt(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}Bt.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=Bt.get.hsl(t),n="hsl";break;case"hwb":e=Bt.get.hwb(t),n="hwb";break;default:e=Bt.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},Bt.get.rgb=function(t){if(!t)return null;var e,n,r,s=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var i=2*n;s[n]=parseInt(e.slice(i,i+2),16)}r&&(s[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)s[n]=parseInt(e[n]+e[n],16);r&&(s[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(n=0;n<3;n++)s[n]=parseInt(e[n+1],0);e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(e=t.match(/^(\\w+)$/))?"transparent"===e[1]?[0,0,0,0]:Ft.call(Ct,e[1])?((s=Ct[e[1]])[3]=1,s):null:null;for(n=0;n<3;n++)s[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}for(n=0;n<3;n++)s[n]=Dt(s[n],0,255);return s[3]=Dt(s[3],0,1),s},Bt.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,Dt(parseFloat(e[2]),0,100),Dt(parseFloat(e[3]),0,100),Dt(isNaN(n)?1:n,0,1)]}return null},Bt.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,Dt(parseFloat(e[2]),0,100),Dt(parseFloat(e[3]),0,100),Dt(isNaN(n)?1:n,0,1)]}return null},Bt.to.hex=function(){var t=Ut(arguments);return"#"+Rt(t[0])+Rt(t[1])+Rt(t[2])+(t[3]<1?Rt(Math.round(255*t[3])):"")},Bt.to.rgb=function(){var t=Ut(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},Bt.to.rgb.percent=function(){var t=Ut(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},Bt.to.hsl=function(){var t=Ut(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},Bt.to.hwb=function(){var t=Ut(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},Bt.to.keyword=function(t){return Nt[t.slice(0,3)]};var Lt=_t.exports,jt={exports:{}},zt={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},qt={};for(var Vt in zt)zt.hasOwnProperty(Vt)&&(qt[zt[Vt]]=Vt);var Gt=jt.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var $t in Gt)if(Gt.hasOwnProperty($t)){if(!("channels"in Gt[$t]))throw new Error("missing channels property: "+$t);if(!("labels"in Gt[$t]))throw new Error("missing channel labels property: "+$t);if(Gt[$t].labels.length!==Gt[$t].channels)throw new Error("channel and label counts mismatch: "+$t);var Xt=Gt[$t].channels,Ht=Gt[$t].labels;delete Gt[$t].channels,delete Gt[$t].labels,Object.defineProperty(Gt[$t],"channels",{value:Xt}),Object.defineProperty(Gt[$t],"labels",{value:Ht})}function Jt(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}Gt.rgb.hsl=function(t){var e,n,r=t[0]/255,s=t[1]/255,i=t[2]/255,o=Math.min(r,s,i),a=Math.max(r,s,i),c=a-o;return a===o?e=0:r===a?e=(s-i)/c:s===a?e=2+(i-r)/c:i===a&&(e=4+(r-s)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},Gt.rgb.hsv=function(t){var e,n,r,s,i,o=t[0]/255,a=t[1]/255,c=t[2]/255,u=Math.max(o,a,c),l=u-Math.min(o,a,c),f=function(t){return(u-t)/6/l+.5};return 0===l?s=i=0:(i=l/u,e=f(o),n=f(a),r=f(c),o===u?s=r-n:a===u?s=1/3+e-r:c===u&&(s=2/3+n-e),s<0?s+=1:s>1&&(s-=1)),[360*s,100*i,100*u]},Gt.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[Gt.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},Gt.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-s)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-s-e)/(1-e)||0),100*e]},Gt.rgb.keyword=function(t){var e=qt[t];if(e)return e;var n,r=1/0;for(var s in zt)if(zt.hasOwnProperty(s)){var i=Jt(t,zt[s]);i<r&&(r=i,n=s)}return n},Gt.keyword.rgb=function(t){return zt[t]},Gt.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},Gt.rgb.lab=function(t){var e=Gt.rgb.xyz(t),n=e[0],r=e[1],s=e[2];return r/=100,s/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116))]},Gt.hsl.rgb=function(t){var e,n,r,s,i,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[i=255*c,i,i];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),s=[0,0,0];for(var u=0;u<3;u++)(r=o+1/3*-(u-1))<0&&r++,r>1&&r--,i=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,s[u]=255*i;return s},Gt.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,s=n,i=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,s*=i<=1?i:2-i,[e,100*(0===r?2*s/(i+s):2*n/(r+n)),100*((r+n)/2)]},Gt.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,s=Math.floor(e)%6,i=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*i),c=255*r*(1-n*(1-i));switch(r*=255,s){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},Gt.hsv.hsl=function(t){var e,n,r,s=t[0],i=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-i)*o,n=i*a,[s,100*(n=(n/=(e=(2-i)*a)<=1?e:2-e)||0),100*(r/=2)]},Gt.hwb.rgb=function(t){var e,n,r,s,i,o,a,c=t[0]/360,u=t[1]/100,l=t[2]/100,f=u+l;switch(f>1&&(u/=f,l/=f),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),s=u+r*((n=1-l)-u),e){default:case 6:case 0:i=n,o=s,a=u;break;case 1:i=s,o=n,a=u;break;case 2:i=u,o=n,a=s;break;case 3:i=u,o=s,a=n;break;case 4:i=s,o=u,a=n;break;case 5:i=n,o=u,a=s}return[255*i,255*o,255*a]},Gt.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,s=t[3]/100;return[255*(1-Math.min(1,e*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s)),255*(1-Math.min(1,r*(1-s)+s))]},Gt.xyz.rgb=function(t){var e,n,r,s=t[0]/100,i=t[1]/100,o=t[2]/100;return n=-.9689*s+1.8758*i+.0415*o,r=.0557*s+-.204*i+1.057*o,e=(e=3.2406*s+-1.5372*i+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},Gt.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},Gt.lab.xyz=function(t){var e,n,r,s=t[0];e=t[1]/500+(n=(s+16)/116),r=n-t[2]/200;var i=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},Gt.lab.lch=function(t){var e,n=t[0],r=t[1],s=t[2];return(e=360*Math.atan2(s,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+s*s),e]},Gt.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},Gt.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],s=1 in arguments?arguments[1]:Gt.rgb.hsv(t)[2];if(0===(s=Math.round(s/50)))return 30;var i=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===s&&(i+=60),i},Gt.hsv.ansi16=function(t){return Gt.rgb.ansi16(Gt.hsv.rgb(t),t[2])},Gt.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},Gt.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},Gt.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},Gt.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},Gt.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},Gt.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.max(Math.max(n,r),s),o=Math.min(Math.min(n,r),s),a=i-o;return e=a<=0?0:i===n?(r-s)/a%6:i===r?2+(s-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},Gt.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,s=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(s=(n-.5*r)/(1-r)),[t[0],100*r,100*s]},Gt.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},Gt.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var s,i=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=c,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=c,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=c}return s=(1-n)*r,[255*(n*i[0]+s),255*(n*i[1]+s),255*(n*i[2]+s)]},Gt.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},Gt.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},Gt.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},Gt.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},Gt.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},Gt.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},Gt.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},Gt.gray.hsl=Gt.gray.hsv=function(t){return[0,0,t[0]]},Gt.gray.hwb=function(t){return[0,100,t[0]]},Gt.gray.cmyk=function(t){return[0,0,0,t[0]]},Gt.gray.lab=function(t){return[t[0],0,0]},Gt.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},Gt.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var Kt=jt.exports,Yt=Kt;function Qt(t){var e=function(){for(var t={},e=Object.keys(Yt),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),s=Object.keys(Yt[r]),i=s.length,o=0;o<i;o++){var a=s[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function Wt(t,e){return function(n){return e(t(n))}}function Zt(t,e){for(var n=[e[t].parent,t],r=Yt[e[t].parent][t],s=e[t].parent;e[s].parent;)n.unshift(e[s].parent),r=Wt(Yt[e[s].parent][s],r),s=e[s].parent;return r.conversion=n,r}var te=Kt,ee=function(t){for(var e=Qt(t),n={},r=Object.keys(e),s=r.length,i=0;i<s;i++){var o=r[i];null!==e[o].parent&&(n[o]=Zt(o,e))}return n},ne={};Object.keys(te).forEach((function(t){ne[t]={},Object.defineProperty(ne[t],"channels",{value:te[t].channels}),Object.defineProperty(ne[t],"labels",{value:te[t].labels});var e=ee(t);Object.keys(e).forEach((function(n){var r=e[n];ne[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,s=0;s<r;s++)n[s]=Math.round(n[s]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),ne[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var re=Lt,se=ne,ie=[].slice,oe=["keyword","gray","hex"],ae={};Object.keys(se).forEach((function(t){ae[ie.call(se[t].labels).sort().join("")]=t}));var ce={};function ue(t,e){if(!(this instanceof ue))return new ue(t,e);if(e&&e in oe&&(e=null),e&&!(e in se))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ue)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var s=re.get(t);if(null===s)throw new Error("Unable to parse color from string: "+t);this.model=s.model,r=se[this.model].channels,this.color=s.value.slice(0,r),this.valpha="number"==typeof s.value[r]?s.value[r]:1}else if(t.length){this.model=e||"rgb",r=se[this.model].channels;var i=ie.call(t,0,r);this.color=he(i,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in ae))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ae[a];var c=se[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=he(u)}if(ce[this.model])for(r=se[this.model].channels,n=0;n<r;n++){var l=ce[this.model][n];l&&(this.color[n]=l(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function le(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(ce[t]||(ce[t]=[]))[e]=n})),t=t[0],function(r){var s;return arguments.length?(n&&(r=n(r)),(s=this[t]()).color[e]=r,s):(s=this[t]().color[e],n&&(s=n(s)),s)}}function fe(t){return function(e){return Math.max(0,Math.min(t,e))}}function he(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function de(t){return null==t}function ye(t){return"object"==typeof t&&!!t}function me(t){return t/Math.PI*180}ue.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in re.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return re.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return re.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=se[this.model].channels,n=se[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ue(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ue(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:le("rgb",0,fe(255)),green:le("rgb",1,fe(255)),blue:le("rgb",2,fe(255)),hue:le(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:le("hsl",1,fe(100)),lightness:le("hsl",2,fe(100)),saturationv:le("hsv",1,fe(100)),value:le("hsv",2,fe(100)),chroma:le("hcg",1,fe(100)),gray:le("hcg",2,fe(100)),white:le("hwb",1,fe(100)),wblack:le("hwb",2,fe(100)),cyan:le("cmyk",0,fe(100)),magenta:le("cmyk",1,fe(100)),yellow:le("cmyk",2,fe(100)),black:le("cmyk",3,fe(100)),x:le("xyz",0,fe(100)),y:le("xyz",1,fe(100)),z:le("xyz",2,fe(100)),l:le("lab",0,fe(100)),a:le("lab",1),b:le("lab",2),keyword:function(t){return arguments.length?new ue(t):se[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ue(t):re.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ue.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),s=void 0===e?.5:e,i=2*s-1,o=n.alpha()-r.alpha(),a=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,c=1-a;return ue.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*s+r.alpha()*(1-s))}},Object.keys(se).forEach((function(t){if(-1===oe.indexOf(t)){var e=se[t].channels;ue.prototype[t]=function(){if(this.model===t)return new ue(this);if(arguments.length)return new ue(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ue((n=se[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ue[t]=function(n){return"number"==typeof n&&(n=he(ie.call(arguments),e)),new ue(n,t)}}}));const be=[1,1,1,1,2,2,3,0];function pe(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=be[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}new Array(3),new Array(3);const ge=[1/6378137,1/6378137,1/6356752.314245179],we=[1/40680631590769,1/40680631590769,1/40408299984661.445],ve=new Array(3),Me=new Array(3),Te=new Array(3);function Ae(t,e){const n=we,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],u=n[1],l=n[2],f=i*i*c*c,h=o*o*u*u,d=a*a*l*l,m=f+h+d,b=Math.sqrt(1/m),p=y(_e,e,b);if(m<s)return isFinite(b)?p:void 0;const g=r[0],w=r[1],v=r[2],M=Oe;M[0]=p[0]*g*2,M[1]=p[1]*w*2,M[2]=p[2]*v*2;let T,A,_,O,k,x,S,I,E,C,U,F=(1-b)*xe(e)/(.5*xe(M)),N=0;do{F-=N,_=1/(1+F*g),O=1/(1+F*w),k=1/(1+F*v),x=_*_,S=O*O,I=k*k,E=x*_,C=S*O,U=I*k,T=f*x+h*S+d*I-1,A=f*E*g+h*C*w+d*U*v;N=T/(-2*A)}while(Math.abs(T)>ke);return t[0]=i*_,t[1]=o*O,t[2]=a*k,t}(ve,e,ge,n,.1);let s=w(Me,r,n);s=function(t,e){const n=e[0],r=e[1],s=e[2];let i=n*n+r*r+s*s;i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i);return t}(s,s);const i=g(Te,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=function(t){return Math.sign?Math.sign(t):0==(t=+t)||isNaN(t)?Number(t):t>0?1:-1}(b(i,e))*xe(i);return t[0]=me(o),t[1]=me(a),t[2]=c,t}const _e=new Array(3),Oe=new Array(3),ke=1e-12;function xe(t){return u(t)}function Se(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const Ie="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ee(t,e,n){const r=new Uint8Array(t,e,n);return Ie?JSON.parse(Ie.decode(r)):JSON.parse(pe(r))}function Ce(t,e,n){const r=new Uint8Array(t,e,n);return Ie?JSON.parse(Ie.decode(r)):JSON.parse(pe(r))}function Ue(t,e,n){return{offset:e,byteLength:n}}function Fe(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=function(t){return Be[t]}(i||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Pe[t]}(o);return{byteStride:0,byteOffset:s+n,itemSize:u,count:r*u,componentType:c,array:new a(e,n+s,r*u)}}function Ne(t,e,n,r){const s=Fe(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}const Pe={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Be={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function De(t){for(const e in Be)if(t===Be[e].ctor)return Be[e].type;throw new Error("unrecognized ctor:"+t)}function Re(t,e,n,r){const s=t,i=e.length/3;for(let t=0;t<i;t++)s[3*t]=e[3*t]/65535*r[0]+n[0],s[3*t+1]=e[3*t+1]/65535*r[1]+n[1],s[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return s}function Le(t,e,n){const r=t.getUint32(12,!0),s=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,u={},l={},f=null;r>0&&(u=Ee(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(l=Ce(a,e,i),e+=i);const h=Ue(0,e,o);return f=a.slice(h.offset,h.offset+h.byteLength),n.push(f),{featureTable:u,featureTableBin:c,batchTable:l,batchTableBin:f}}const je={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function ze(t){for(const e in je)if(t===je[e])return+e;throw new Error("unrecognized ctor:"+t)}\n/*!\n * @maptalks/gl v0.98.0\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.com\n */const qe=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof undefined)return global;throw new Error("unable to locate global object")},Ve=qe(),Ge=Ve.gl_trans__coders=Ve.gl_trans__coders||{};Ge.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=Ve.gl_trans__coders=Ve.gl_trans__coders||{};let i=\`${M}r}\\n const _____getGlobal = ${M}qe.toString()};\\n const g___lobals = _____getGlobal()\\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};\`;for(const t in s)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+='tran_____scoders["'+t+'"] ='+s[t].toString()+"\\n;");return i+="\\n"+e.substring(r.length),i},Ge.registerTranscoder=function(t,e){Ge[t]=e},Ge.getTranscoder=function(t){return Ge[t]};let $e=null;function Xe(){return $e||($e={"image/crn":Ge.crn&&Ge.crn(),"image/ktx2":Ge.ktx2&&Ge.ktx2(),"image/cttf":Ge.ktx2&&Ge.ktx2(),"draco":Ge.draco&&Ge.draco()}),$e}class He{constructor(t,e,n){this.i=t,this.st=e||ft,this.o=n,this.it=Xe()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,s)):$.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.ot(t,s,n,r)}))}ot(t,e,n,r,s){const i=s&&s.maxTextureSize,o=this.ct(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.st(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.it,supportedFormats:this.o,maxTextureSize:i});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${M}t}-${M}n}-${M}r}\`;const s=c.transferables;for(let t=0;t<o.transferables.length;t++)s.indexOf(o.transferables[t])<0&&s.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:s,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}ct(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=s.getUint32(12,!0),c=s.getUint32(16,!0),u=s.getUint32(20,!0),l=s.getUint32(24,!0),f=28+e;u>=570425344?(f-=8,o=a,u=c,l=0,a=0,c=0):l>=570425344&&(f-=4,o=u,u=a,l=c,a=0,c=0);const h=[t];let d,y,m;if(a>0?(d=Ee(t,f,a),f+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(f+=c),u>0&&(y=Ce(t,f,u),f+=u,l>0)){const e=Ue(0,f,l);m=t.slice(e.offset,e.offset+e.byteLength),f+=l,h.push(m)}const b=d.BATCH_LENGTH,p={};if(d&&d.BATCH_ID){p.BATCH_ID=Ne(d.BATCH_ID,t,undefined.offset,b);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:o,transferables:h,featureTable:d,batchTable:y,batchTableBin:m,b3dm:p,glb:{buffer:t,byteOffset:f,byteLength:s.byteLength+s.byteOffset-f}}}ut(){return null}}class Je{constructor(t,e,n,r){this.i=t,this.st=e||ft,this.o=n,this.it=Xe(),this.lt=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,s)):$.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.ot(t,s,n,r)}))}ot(t,e,n,r,s){return this.ft(t,e,n,r,s).then((({gltf:s,transferables:i})=>{const o=this.ht(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete s.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:s})}))}ft(t,e,n,r,s){const i=s&&s.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.it,supportedFormats:this.o,maxTextureSize:i},a=new DataView(e,n,r),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let r=pe(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?$.getArrayBuffer(r,{}).then((t=>this.dt(r,{buffer:t.data,byteOffset:0},o))):$.getJSON(r,{}).then((t=>this.dt(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.dt(t,r,o)}}dt(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.st(r,e,n);return s.load({skipAttributeTransform:!0}).then((n=>{let r=0,i=0;return e.buffer&&(r=e.byteOffset||0,i=e.byteLength||0),n.url=\`${M}t}-${M}r}-${M}i}\`,{transferables:s.transferables,gltf:n}}))}ht(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:l}=Le(s,32+e,o),f={},h=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(f.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.yt(new Uint16Array(t,r+c.offset,3*h),e,n)},o.push(f.POSITION.array.buffer)}if(a.BATCH_ID){f.BATCH_ID=Ne(a.BATCH_ID,t,c.offset,h);const e=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(f.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(f.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.bt(new Uint16Array(t,e+c.offset,2*h))},o.push(f.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.bt(new Uint16Array(t,e+c.offset,2*h))},o.push(f.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},o.push(f.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;f.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(f.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:l,featureTable:a,i3dm:f,transferables:o}}bt(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)Ke(r,t[2*s],t[2*s+1],65535),n[3*s]=r[0],n[3*s+1]=r[1],n[3*s+2]=r[2];return n}yt(t,e,n){return Re(new Float32Array(t.length),t,e,n)}ut(){return null}}function Ke(t,e,n,r){if(t[0]=Ye(e,r),t[1]=Ye(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*Qe(e),t[1]=(1-Math.abs(e))*Qe(t[1])}return m(t,t)}function Ye(t,e){return e=function(t,e){if(null!=t)return t;return e}(e,255),function(t,e,n){return t<e?e:t>n?n:t}(t,0,e)/e*2-1}function Qe(t){return t<0?-1:1}class We{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.ot(t,e,n,r)):$.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.ot(t,s,n,r)}))}ot(t,e,n,r){return this.gt(e,n,r,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}gt(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:l}=Le(s,e+28,o),f=a.QUANTIZED_VOLUME_OFFSET,h=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let y,m={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){m=a.extensions["3DTILES_draco_point_compression"],y=new DataView(t,m.byteOffset+c.offset,m.byteLength);const e={attributes:m.properties,useUniqueIDs:!1};return this.wt||(this.wt=Xe().draco),this.wt(y,e).then((e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.vt(t,e.attributes,c.offset,d,o,f,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:De(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?r.BATCH_ID=Ne(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=Ze(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:u,batchTableBin:l,featureTable:a,pnts:r,transferables:o}}))}const b=this.vt(t,a,c.offset,d,o,f,h);if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?b.BATCH_ID=Ne(a.BATCH_ID,t,c.offset,d):b.BATCH_ID=Ze(d);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:u,batchTableBin:l,featureTable:a,pnts:b,transferables:o})}vt(t,e,n,r,s,i,o){const a={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:u}=e.POSITION_QUANTIZED;c=c||0;const l=u?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.yt(u||new Uint16Array(t,c+l,3*r),i,o)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},s.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},s.push(o.buffer)}return a}yt(t,e,n){return Re(new Float32Array(t.length),t,e,n)}ut(){return null}}function Ze(t){const e=(n=t)<256?Uint8Array:n<65536?Uint16Array:Uint32Array;var n;const r=new e(t);for(let e=0;e<t;e++)r[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:De(e),array:r}}class tn{constructor(t,e,n,r){this.o=n,this.i=t,this.st=e||ft,this.lt=r}load(t,e,n=0,r=0,s){return e?this.ot(t,e,n,r,s):$.getArrayBuffer(t,{}).then((e=>{const s=e.data;return this.ot(t,s,n,r)}))}ot(t,e,n,r,s){r||(r=e.byteLength);const i=this.Mt(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new He(this.i,this.st,this.o);else if("i3dm"===i[n].magic)r=new Je(this.i,this.st,this.o,this.lt);else if("pnts"===i[n].magic)r=new We;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new tn(this.i,this.st,this.o,this.lt)}o.push(r.load(t,e,i[n].offset,i[n].byteLength,s).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}Mt(t,e,n,r){const s=new DataView(t,n,r),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===s.byteLength)return[];const o=[],a=s.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=Se(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}function en(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,s=r.length;n<s;n++){const s=[];un(r[n],s,t,e)}}}const nn=[],rn=[],sn=[],on=[0,0,0],an=_([]),cn=[1,1,1];function un(t,e,n,a){const c=e.slice(0);if(t.matrix)c.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=s(nn,t.translation||on),n=o(rn,t.rotation||an),a=i(sn,t.scale||cn);r(a,n,a);const u=r([],e,a);c.push(u)}if(t.children&&t.children.length)for(let e=0,r=t.children.length;e<r;e++)un(t.children[e],c,n,a);if(void 0!==t.mesh){const e=t.mesh,r=n.meshes[e];if(r){const t=c.slice(0),s=r.primitives;for(let r=0,i=s.length;r<i;r++){const i=s[r];i&&(i.matrices=t,a(i,e,r,n))}}}}function ln(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?ft.getTypedArrayCtor(i):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,s=s||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*o);for(let r=0;r<s*o;r+=o){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o)}return}const u=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const s=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);u.set(s);e(new c(u.buffer),t),s.set(u)}}var fn=bn("DXT1"),hn=bn("DXT3"),dn=bn("DXT5"),yn=bn("DX10"),mn=function(t){var e,n,r=new Int32Array(t,0,31);if(542327876!==r[0])throw new Error("Invalid magic number in DDS header");if(4&!r[20])throw new Error("Unsupported format, must contain a FourCC code");var s=r[21];switch(s){case fn:e=8,n="dxt1";break;case hn:e=16,n="dxt3";break;case dn:e=16,n="dxt5";break;case 116:n="rgba32f";break;case yn:var i=new Uint32Array(t.slice(128,148));n=i[0];var o=i[1];if(i[2],i[3],i[4],3!==o||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(a=s,String.fromCharCode(255&a,a>>8&255,a>>16&255,a>>24&255)))}var a;var c=r[2],u=1;131072&c&&(u=Math.max(1,r[7]));var l=!1;512&r[28]&&(l=!0);var f,h=r[4],d=r[3],y=r[1]+4,m=h,b=d,p=[];s===yn&&(y+=20);if(l)for(var g=0;g<6;g++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");h=m,d=b;for(var w=Math.log(h)/Math.log(2)+1,v=0;v<w;v++)f=h*d*16,p.push({offset:y,length:f,shape:[h,d]}),v<u&&(y+=f),h=Math.floor(h/2),d=Math.floor(d/2)}else for(v=0;v<u;v++)f=Math.max(4,h)/4*Math.max(4,d)/4*e,p.push({offset:y,length:f,shape:[h,d]}),y+=f,h=Math.floor(h/2),d=Math.floor(d/2);return{shape:[m,b],images:p,format:n,flags:c,cubemap:l}};function bn(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var pn=At(mn),gn=Math.abs,wn=Math.sin,vn=Math.cos,Mn=Math.tan,Tn=Math.atan,An=Math.atan2,_n=Math.sqrt,On=Math.log,kn=Math.hypot,xn=Math.sinh,Sn=Math.cosh,In=1/0;function En(t){var e,n,r,s,i,o,a=[],c=[],u=[],l=[];function f(t,e){for(var n,r=2*vn(2*e),s=t.length-1,i=t[s],o=0;--s>=0;)n=r*i-o+t[s],o=i,i=n;return e+n*wn(2*e)}function h(t,e,n){for(var r,s,i=wn(e),o=vn(e),a=xn(n),c=Sn(n),u=2*o*c,l=-2*i*a,f=t.length-1,h=t[f],d=0,y=0,m=0;--f>=0;)r=y,s=d,h=u*(y=h)-r-l*(d=m)+t[f],m=l*y-s+u*d;return[(u=i*c)*h-(l=o*a)*m,u*m+l*h]}t.es,i=s=(r=t.es/(1+_n(1-t.es)))/(2-r),a[0]=s*(2+s*(-2/3+s*(s*(116/45+s*(26/45+s*(-2854/675)))-2))),c[0]=s*(s*(2/3+s*(4/3+s*(-82/45+s*(32/45+s*(4642/4725)))))-2),i*=s,a[1]=i*(7/3+s*(s*(-227/45+s*(2704/315+s*(2323/945)))-1.6)),c[1]=i*(5/3+s*(-16/15+s*(-13/9+s*(904/315+s*(-1522/945))))),i*=s,a[2]=i*(56/15+s*(-136/35+s*(-1262/105+s*(73814/2835)))),c[2]=i*(-26/15+s*(34/21+s*(1.6+s*(-12686/2835)))),i*=s,a[3]=i*(4279/630+s*(-332/35+s*(-399572/14175))),c[3]=i*(1237/630+s*(s*(-24832/14175)-2.4)),i*=s,a[4]=i*(4174/315+s*(-144838/6237)),c[4]=i*(-734/315+s*(109598/31185)),i*=s,a[5]=i*(601676/22275),c[5]=i*(444337/155925),i=s*s,e=t.k0/(1+s)*(1+i*(1/4+i*(1/64+i/256))),u[0]=s*(s*(2/3+s*(-37/96+s*(1/360+s*(81/512+s*(-96199/604800)))))-.5),l[0]=s*(.5+s*(-2/3+s*(5/16+s*(41/180+s*(-127/288+s*(7891/37800)))))),u[1]=i*(-1/48+s*(-1/15+s*(437/1440+s*(-46/105+s*(1118711/3870720))))),l[1]=i*(13/48+s*(s*(557/1440+s*(281/630+s*(-1983433/1935360)))-.6)),i*=s,u[2]=i*(-17/480+s*(37/840+s*(209/4480+s*(-5569/90720)))),l[2]=i*(61/240+s*(-103/140+s*(15061/26880+s*(167603/181440)))),i*=s,u[3]=i*(-4397/161280+s*(11/504+s*(830251/7257600))),l[3]=i*(49561/161280+s*(-179/168+s*(6601661/7257600))),i*=s,u[4]=i*(-4583/161280+s*(108847/3991680)),l[4]=i*(34729/80640+s*(-3418889/1995840)),i*=s,u[5]=i*(-20648693/638668800),l[5]=.6650675310896665*i,o=f(c,t.phi0),n=-e*(o+function(t,e){var n,r=2*vn(e),s=t.length-1,i=t[s],o=0;for(;--s>=0;)n=r*i-o+t[s],o=i,i=n;return wn(e)*n}(l,2*o)),t.fwd=function(t,r){var s,i,o,a,u,d=t.phi,y=t.lam;d=f(c,d),s=wn(d),i=vn(d),a=wn(y),o=vn(y),d=An(s,o*i),y=An(a*i,kn(s,i*o)),y=function(t){var e=gn(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*On(e)/n}(e*(1+e/(kn(1,e)+1))),t<0?-e:e}(Mn(y)),u=h(l,2*d,2*y),d+=u[0],y+=u[1],gn(y)<=2.623395162778?(r.y=e*d+n,r.x=e*y):r.x=r.y=In},t.inv=function(t,r){var s,i,o,c,l,d=t.y,y=t.x;d=(d-n)/e,gn(y/=e)<=2.623395162778?(d+=(l=h(u,2*d,2*y))[0],y+=l[1],y=Tn(xn(y)),s=wn(d),i=vn(d),c=wn(y),o=vn(y),y=An(c,o*i),d=An(s*o,kn(c,o*i)),r.phi=f(a,d),r.lam=y):r.phi=r.lam=In}}const Cn=Math.PI/180,Un=6378137*Math.PI/180,Fn=85.0511287798,Nn={};function Pn(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=Fn,r=e[0],s=Math.max(Math.min(n,e[1]),-n);let i;i=0===s?0:Math.log(Math.tan((90+s)*Cn/2))/Cn;return t[0]=r*Un,t[1]=i*Un,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return Bn(t,e);if("baidu"===n)return Bn(t,e);throw new Error("unsupported projection:"+n)}{if(!(!r||4326===r.wkid))return function(t,e){return t[0]=e[0],t[1]=e[1],t}(t,e);const s=JSON.stringify(n);let i=Nn[s];return i||(i=Nn[s]=function(t){const e={a:Rn,es:Ln,x0:de(t.falseEasting)?5e5:t.falseEasting,y0:de(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*Dn,phi0:(t.latitudeOfOrigin||0)*Dn,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};En(e);const n={lam:0,phi:0},r={};let s=0,i=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*Dn-e.lam0,n.phi=e.originPhi0*Dn,e.fwd(n,r),s=e.a*r.x+e.x0,i=e.a*r.y+e.y0);return{project:function(t,o){n.lam=t[0]*Dn-e.lam0,n.phi=t[1]*Dn,e.fwd(n,r);const a=e.a*r.x+e.x0-s,c=e.a*r.y+e.y0-i;return o[0]=a,o[1]=c,o}}}(n)),i.project(e,t)}}function Bn(t,e){return t[0]=e[0],t[1]=e[1],t}const Dn=.017453292519943295,Rn=6378137,Ln=.0066943799901413165;const jn=n([]),zn=Xe().draco,qn=Xe().ktx2,Vn={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},Gn={"position":{name:"POSITION",accessor:{"componentType":5126,"type":"VEC3"}},"normal":{name:"NORMAL",accessor:{"componentType":5126,"type":"VEC3"}},"uv0":{name:"TEXCOORD_0",accessor:{"componentType":5126,"type":"VEC2"}},"color":{name:"COLOR_0",accessor:{"componentType":5121,"type":"VEC4"}},"uv-region":{name:"uvRegion",accessor:{"componentType":5123,"type":"VEC4"}},"feature-index":{name:"_BATCHID",accessor:{"componentType":5125,"type":"SCALAR"}},"faceRange":{name:"faceRange",accessor:{"componentType":5125,"type":"VEC2"}}};function $n(t,e,r,s,i,o){const a=[],c=[],u=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],s=$.getArrayBuffer(n.url,o);s.xhr.url=n.url,u.push(s.xhr);const i=s.then((t=>({buffer:t})));a.push(i);const l=[];if(Zn(r,l),l.length){const t=l.map((t=>{const e=$.getArrayBuffer(t.url,o);return e.xhr.url=t.url,u.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));a.push(...t)}c[e]=l.length}const l=Promise.all(a).then((o=>{for(let t=0;t<o.length;t++)if(!o[t]||!o[t].buffer)return Promise.resolve(null);const a=[];let u=0;for(let t=0;t<c.length;t++){const e=c[t];a.push({geoBuffer:{data:o[u].buffer.data},textureBuffers:o.slice(u+1,e+u+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),u+=1+e}const l=function(t,e,r,s,i,o){const a={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},c=[];for(let u=0;u<t.meshes.length;u++){let{material:l}=t.meshes[u];const{geometry:f}=t.meshes[u];let h;const d=e[u].geoBuffer.data;if(!d)continue;h=ir(d)?Hn(a,u,f,d,t.transform,t.center,i,o):Kn(a,u,f,d,t.transform,t.center,i,o),c.push(h),a.nodes[u]={mesh:u,nodeIndex:u,matrix:n([])},a.scenes[0].nodes[u]=a.nodes[u],l||(l=Vn);const y=Qn(u,a,l,e[u].textureBuffers,r,s);c.push(y)}return Promise.all(c).then((()=>({gltf:a,featureTable:{BATCH_LENGTH:0},transferables:a.transferables})))}(t,a,e,i,r,s);return l}));return l.xhr=u,l}const Xn={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Hn(t,e,n,r,s,i,o,a){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=Gn[e];if(!r)return t;return t[r.name||e]=n,t}),{});return zn(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>Yn(n,t,e,s,i,o,a)))}const Jn={position:function(t,e,n){const r=3*t.vertexCount,s=new Float32Array(e,n,r);return t.position={array:s,componentType:5126,itemSize:3,count:r/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},n+=4*r},normal:function(t,e,n){const r=3*t.vertexCount,s=new Float32Array(e,n,r);return t.normal={array:s,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,s=new Float32Array(e,n,r);return t.uv0={array:s,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,s=new Uint8Array(e,n,r);return t.color={array:s,componentType:5121,itemSize:4,count:r/4,type:"VEC4"},n+=r},featureId:function(t,e,n){return n+=8*t.featureCount},id:function(t,e,n){return n+=8*t.featureCount},faceRange:function(t,e,n){const r=2*t.featureCount,s=new Uint32Array(e,n,r);return t.faceRange={array:s,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,s=new Uint16Array(e,n,r);return t["uv-region"]={array:s,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,s=new Uint16Array(e,n,r);return t["uv-region"]={array:s,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Kn(t,e,n,r,s,i,o,a){const c={vertexCount:0},u=new DataView(r);try{let t=0;c.vertexCount=u.getUint32(t,1),t+=4,c.featureCount=u.getUint32(t,1),t+=4;const e=n.info.ordering?null:n.info;if(e){const n=[];for(const t in e)"offset"!==t&&""!==t&&n.push(t);for(let e=0;e<n.length;e++)Jn[n[e]]?t=Jn[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let s=e.ordering,i=e.featureAttributeOrder;const o=null;o&&o.geometryData&&o.geometryData[0]&&o.geometryData[0].params;for(let e=0;e<s.length;e++){const n=Jn[s[e]];n||console.log(s[e]),t=n(c,r,t)}for(let e=0;e<i.length;e++){const n=Jn[i[e]];n||console.log(i[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const l={};for(const t in c){const e=Gn[t]&&Gn[t].name;e&&(l[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(f=e)<=255?Uint8Array:f<=65535?Uint16Array:Uint32Array,r=new n(l.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,s=t[e],i=t[e+1];for(let t=s;t<=i;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}l._BATCHID={componentType:ze(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var f;return Yn({attributes:l},t,e,s,i,o,a)}function Yn(t,e,n,r,s,i,o){const c={attributes:t.attributes,material:n,indices:t.indices,mode:4};!function(t){const e=t.array,n=t.meta&&t.meta["i3s-scale_x"],r=t.meta&&t.meta["i3s-scale_y"];if(n&&r&&(1!==n||1!==r))for(let t=0;t<e.length;t+=3)e[t]*=n.value,e[t+1]*=r.value}(t.attributes.POSITION);const u=function(t,e,n,r,s){let i,o=[0,0,0,1];const c=[0,0],u=Pn([],n,r,s);u[2]=n[2];const l=e&&a(jn,e);return ln(t,(t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],l||(o=p(o,o,e)),n&&d(o,o,n),Pn(c,o,r,s),i=o[2],t[0]=c[0]-u[0],t[1]=c[1]-u[1],t[2]=i-u[2],t))),u}(t.attributes.POSITION,r,s,i,o);e.meshes[n]={primitives:[c],index:n},e.extensions.MAPTALKS_RTC={projCenter:u},e.extensions.CESIUM_RTC={rtcCoord:s};for(const n in t.attributes)sr(e.transferables,t.attributes[n].array.buffer);return t.indices&&sr(e.transferables,t.indices.array.buffer),c}function Qn(t,e,n,r,s,i){const o=r.map((t=>function(t,e,n,r,s){if("dds"===e){const e=pn(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),s="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Xn,format:s})}if("png"===e||"jpg"===e)return function(t,e){tr||(tr=new OffscreenCanvas(2,2),er=tr.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;nr(n)||(n=rr(n)),nr(r)||(r=rr(r));const s=e;s&&(n=Math.min(s,n),r=Math.min(s,r)),tr.width=n,tr.height=r,er.drawImage(t,0,0,n,r),t.close();const i=er.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(i.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,s).then((t=>{t.mimeType=n;return{image:t,sampler:Xn,format:6408}}));if("ktx2"===e)return qn(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Xn,format:t.format})));return null}(t.data,t.format,t.mimeType,s,i).then((t=>{if(t.image)if(t.image.array)sr(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)sr(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(o).then((r=>{Wn(t,e,n,r)}))}function Wn(t,e,n,r){const s=JSON.parse(JSON.stringify(n)),i=e.textures;r.ptr||(r.ptr=0);for(const t in n)n[t]&&n[t].url?(i.push(r[r.ptr++]),s[t]={index:i.length-1},void 0!==n[t].factor&&(s[t].scale=n[t].factor)):ye(n[t])&&(s[t]=Wn(-1,e,n[t],r));return t>=0&&(e.materials[t]=s),s}function Zn(t,e){for(const n in t)t[n]&&t[n].url?e.push({url:t[n].url,mimeType:t[n].mimeType,format:t[n].format}):ye(t[n])&&Zn(t[n],e)}let tr,er;function nr(t){return!(t&t-1)&&0!==t}function rr(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function sr(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function ir(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}var or="undefined"!=typeof Float32Array?Float32Array:Array;function ar(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var cr=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t};!function(){var t=function(){var t=new or(3);return or!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const ur=[];const lr=[],fr=[],hr=[],dr=[],yr=[],mr=[],br=[];function pr(t,e,n,r,s,i){ar(dr,t[3*e],t[3*e+1],t[3*e+2]),ar(yr,t[3*n],t[3*n+1],t[3*n+2]),ar(mr,t[3*r],t[3*r+1],t[3*r+2]);const o=cr(lr,mr,yr),a=cr(fr,dr,yr),c=function(t,e,n){var r=e[0],s=e[1],i=e[2],o=n[0],a=n[1],c=n[2];return t[0]=s*c-i*a,t[1]=i*o-r*c,t[2]=r*a-s*o,t}(hr,o,a);!function(t,e){var n=e[0],r=e[1],s=e[2],i=n*n+r*r+s*s;i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i)}(br,c),s[3*e]=s[3*e]||0,s[3*n]=s[3*n]||0,s[3*r]=s[3*r]||0,s[3*e+1]=s[3*e+1]||0,s[3*n+1]=s[3*n+1]||0,s[3*r+1]=s[3*r+1]||0,s[3*e+2]=s[3*e+2]||0,s[3*n+2]=s[3*n+2]||0,s[3*r+2]=s[3*r+2]||0,s[3*e]+=br[0],s[3*n]+=br[0],s[3*r]+=br[0],s[3*e+1]+=br[1],s[3*n+1]+=br[1],s[3*r+1]+=br[1],s[3*e+2]+=br[2],s[3*n+2]+=br[2],s[3*r+2]+=br[2],i[e]+=1,i[n]+=1,i[r]+=1}const gr=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],wr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],vr=2*Math.PI*6378137/360,Mr="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let Tr,Ar,_r=!1;if("undefined"!=typeof OffscreenCanvas){try{Ar=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}Ar&&"undefined"!=typeof createImageBitmap&&(_r=!0)}const Or=n([]),kr=[0,0,0],xr=[],Sr=[],Ir=[],Er=[],Cr={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Ur={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Fr;class Nr{constructor(t,e,n,r){this.id=t,this.options=e,this.Tt=this.requestImage.bind(this),this.At=n,this._t={},r(null,{},[])}Ot(t){this.kt||(this.o=t,this.xt=new We,this.kt=new He(this.Tt,ft,t),this.St=new Je(this.Tt,ft,t))}requestImage(t,e){_r?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{Tr.width=t.width,Tr.height=t.height,Ar.drawImage(t,0,0);const n=Ar.getImageData(0,0,Tr.width,Tr.height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.At("requestImage",{url:t},null,e)}loadTile(t,e){this.Ot(t.supportedFormats);const{service:n,url:r,arraybuffer:s}=t,i=n.fetchOptions||{};if(i.referrer=t.referrer,i.referrerPolicy=i.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const s=t.i3sInfo,o=n.maxTextureSize||0,a=$n(s,t.supportedFormats,this.options.projection,t.projection,o,i);return a.then((t=>{if(delete this._t[r],!t)return void e({status:404,url:r,i3sInfo:s});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:s});t.gltf.url=r;const{transferables:i}=t;t.magic="b3dm",this.It(t.gltf),n.compressGeometry&&this.Et(t.gltf),e(null,t,i)})),void(this._t[r]=a.xhr)}if(s){delete this._t[r];const n=Se(new DataView(s),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(Mr){const r=new Uint8Array(t,e,n);return Mr.decode(r)}return pe(new Uint8Array(t,e,n))}(s,0,s.byteLength),i=JSON.parse(n);i.accessors?this.Ct(i,r,t,"gltf",e):this.Ut(t.rootIdx,i,s,r,e)}else this.Ct(s,r,t,n,e)}else{let s=n.urlParams;s&&(s=(r.indexOf("?")>0?"&":"?")+s);const o=r.replace(/\\+/g,"%2B");let a=$.getArrayBuffer(o+(s||""),i);const c=a.xhr;a=a.then((n=>{delete this._t[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this._t[r],e(t)})),this._t[r]=c}}Ct(t,e,n,r,s){r=r&&r.toLowerCase();const{service:i}=n;if("b3dm"===r){this.kt.load(e,t,0,0,{maxTextureSize:i.maxTextureSize||0}).then((t=>{if(t.error)return void s(t);const{content:e,transferables:r}=this.Ft(t,n);this.It(e.gltf),i.compressGeometry&&this.Et(e.gltf),s(null,e,r)})).catch((t=>{s(t)}))}else if("pnts"===r){const r=n.transform||Or;this.xt.load(e,t).then((t=>{const{content:e,transferables:i}=this.Nt(t,r,n.rootIdx);this.Pt(e),s(null,e,i)}))}else if("i3dm"===r){const r=n.transform||Or;this.St.load(e,t,0,0,{maxTextureSize:i.maxTextureSize||0}).then((t=>{const{content:e,transferables:o}=this.Bt(t,r,n.rootIdx);this.It(e.gltf),i.compressGeometry&&this.Et(e.gltf),s(null,e,o)}))}else if("cmpt"===r){new tn(this.Tt,ft,this.o,i.maxTextureSize||0).load(e,t,0,0,{maxTextureSize:i.maxTextureSize||0}).then((t=>{const{content:e,transferables:r}=this.Dt(t,n);this.Rt(e),i.compressGeometry&&this.Lt(e),s(null,e,r)})).catch((t=>{s(t)}))}else if("gltf"===r){this.it||(this.it=Xe());const r=e.substring(0,e.lastIndexOf("/")),o=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t,a=new ft(r,o,{transferable:!0,requestImage:this.Tt,decoders:this.it,supportedFormats:this.o,maxTextureSize:i.maxTextureSize||0});a.load({skipAttributeTransform:!1}).then((t=>{t.url=e,this.jt(t,null,n),this.It(t),i.compressGeometry&&this.Et(t),s(null,{magic:"gltf",gltf:t},a.transferables)}))}else s(new Error("unsupported tile format: "+r))}Rt(t){t.content?t.content.forEach((t=>{this.Rt(t)})):this.It(t.gltf)}Lt(t){t.content?t.content.forEach((t=>{this.Lt(t)})):this.Et(t.gltf)}zt(t,e){if(this.qt(t,e)&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=e.length,r=this.Vt()?Fr.subarray(0,n):e,s=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const s=ur;s.length<t.length/3&&(s.length=t.length/3),s.fill(0,0,t.length/3);const i=void 0===e.length?e:e.length;for(let n=0;n<i/3;n++)void 0===e.length?pr(t,3*n,3*n+1,3*n+2,r,s):pr(t,e[3*n],e[3*n+1],e[3*n+2],r,s);const o=r.getLength?r.getLength():r.length;for(let t=0;t<o;t+=3){const e=s[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(r,t.indices.array,new Float32Array(r.length));t.attributes.NORMAL={array:s,byteLength:s.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:s.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}Et(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const t in e){e[t].primitives.forEach((t=>{t.compressed_int16_params={};const e=t.attributes;for(const n in e)if(Cr[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=vr,t.compressed_int16_params.compressed_ratio=r);const s=jr(e[n].array,r,e[n].min,e[n].max,n);if(!s)continue;const{array:i,range:o}=s;e[n].componentType=5124,e[n].array=i,t.compressed_int16_params[n]=o}}))}}It(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const n in e){e[n].primitives.forEach((e=>{this.zt(e,t)}))}}Pt(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(Cr[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=vr,t.compressed_int16_params.compressed_ratio=r);const{array:s,range:i}=jr(e[n].array,r,e[n].min,e[n].max,n);e[n].array=s,t.compressed_int16_params[n]=i}}Gt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const s={boundingVolume:{sphere:[r.boundingSphere.center.x,r.boundingSphere.center.y,r.boundingSphere.center.z,r.boundingSphere.radius]},content:{uri:r.childTile},geometricError:r.boundingSphere.radius/r.rangeList*16,refine:"REPLACE"};e.push(s)}return e}Ut(t,e,n,r,s){return e.capabilities,void s(null,e)}Dt(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},s=[];for(let t=0;t<n.length;t++){const{magic:i}=n[t];if("b3dm"===i){const{content:i,transferables:o}=this.Ft(n[t],e);Rr(s,o),r.content.push(i)}else if("i3dm"===i){const{transform:i,rootIdx:o}=e,{content:a,transferables:c}=this.Bt(n[t],i,o);Rr(s,c),r.content.push(a)}else if("pnts"===i){const{transform:i,rootIdx:o}=e,{content:a,transferables:c}=this.Nt(n[t],i,o);Rr(s,c),r.content.push(a)}else if("cmpt"===i){const{content:i,transferables:o}=this.Dt(n[t],e);Rr(s,o),r.content.push(i)}}return{content:r,transferables:s}}Ft(t,e){const{gltf:n,transferables:r,featureTable:s}=t;return this.jt(n,s,e),delete t.transferables,{content:t,transferables:r}}jt(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;const e="visited";let n=1;const r=[];for(const s in t.meshes){const i=t.meshes[s],{primitives:o}=i;if(o)for(let t=0;t<o.length;t++){const s=o[t].attributes&&o[t].attributes.POSITION;if(!s||!s.array)continue;s.array.buffer[e]||(s.array.buffer[e]=n++);const i=n-1+"-"+(s.byteOffset||0);if(r.indexOf(i)>=0)return!0;r.push(i)}}return!1}(t);this.$t(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.Xt(t,e,n.upAxis,n.transform)):this.Ht(t,e,n.upAxis,n.transform)}Bt(t,e,n){const{featureTable:r}=t,s=t.i3dm,i=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,c=e&&a(Or,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Br(s.POSITION.array,3,i,Or,u);const l=Dr(u);e&&!c&&p(l,l,e);const d=this.Jt(l),y=[];Pn(y,d,o),y[2]=d[2];const m=f([],l),b=[0,0,0],g=[0,0,0],w=[0,0],M=[1/0,1/0,1/0],T=[-1/0,-1/0,-1/0];ln(s.POSITION,(t=>{b[0]=t[0]+i[0],b[1]=t[1]+i[1],b[2]=t[2]+i[2],e&&!c&&p(b,b,e),0===v(b)?h(g,0,0,-6378137):Ae(g,b),Pn(w,g,o),t[0]=w[0]-y[0],t[1]=w[1]-y[1],t[2]=g[2]-y[2],t[0]<M[0]&&(M[0]=t[0]),t[1]<M[1]&&(M[1]=t[1]),t[2]<M[2]&&(M[2]=t[2]),t[0]>T[0]&&(T[0]=t[0]),t[1]>T[1]&&(T[1]=t[1]),t[2]>T[2]&&(T[2]=t[2])})),s.POSITION.min=M,s.POSITION.max=T,e&&p(l,l,e),t.rtcCenter=m,t.rtcCoord=d,t.projCenter=y,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}Nt(t,e,n){const{featureTable:r}=t,s=t.pnts,i=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,c=e&&a(Or,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Br(s.POSITION.array,3,i,e,u);const l=Dr(u),d=this.Kt(l),y=f([],l),m=[1/0,1/0,1/0],b=[-1/0,-1/0,-1/0];let g=[0,0,0,1];const w=[0,0,0],M=[0,0];ln(s.POSITION,(t=>(g[0]=t[0]+i[0],g[1]=t[1]+i[1],g[2]=t[2]+i[2],e&&!c&&(g=p(g,g,e)),0===v(g)?h(w,0,0,-6378137):Ae(w,g),Pn(M,w,o),t[0]=M[0]-d[0],t[1]=M[1]-d[1],t[2]=w[2]-d[2],t[0]<m[0]&&(m[0]=t[0]),t[1]<m[1]&&(m[1]=t[1]),t[2]<m[2]&&(m[2]=t[2]),t[0]>b[0]&&(b[0]=t[0]),t[1]>b[1]&&(b[1]=t[1]),t[2]>b[2]&&(b[2]=t[2]),t))),s.POSITION.min=m,s.POSITION.max=b,e&&p(l,l,e);const T=this.Jt(l);t.rtcCenter=y,t.projCenter=d,t.rtcCoord=T,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}$t(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image&&e[t].image.array;if(n&&n.length){const r=n[0],s=n[1],i=n[2],o=n[3];let a=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==s||n[t+2]!==i||n[t+3]!==o){a=!1;break}a&&(e[t].image.color=[r/255,s/255,i/255,o/255],delete e[t].image.array)}}}abortTileLoading(t,e){const n=this._t[t.url];if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t].abort();else n&&n.abort&&n.abort();delete this._t[t.url],e(null)}Yt(t,e,s,i){const o=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let a=gr;"X"===(s=s&&s.toUpperCase())?a=wr:"Z"===s&&(a=Or),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),o&&(t.extensions.CESIUM_RTC.center=o),t.extensions.MAPTALKS_RTC={};const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};en(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=n(xr);t.matrices&&Lr(e,t.matrices);const s=t.attributes.POSITION.array,u=t.attributes.POSITION.itemSize;r(e,a,e),i&&r(e,i,e),Br(s,u,o||kr,e,c,t.compressUniforms)}));const u=Dr(c);return{rtcCenter:o,modelCenter:u,upAxisTransform:a}}Xt(t,e,s,i){const{modelCenter:o,upAxisTransform:a,rtcCenter:c}=this.Yt(t,e,s),u=this.Kt(o);t.extensions.MAPTALKS_RTC.projCenter=u,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Jt(o);const l=f([],o);i&&p(o,o,i),t.extensions.CESIUM_RTC.rtcCoord=this.Jt(o),c||(en(t,(t=>{if(t.attributes&&t.attributes.POSITION){const e=t.attributes.POSITION;if(e.array.buffer.projected&&e.array.buffer.projected[e.byteOffset])return;const s=n(xr);t.matrices&&Lr(s,t.matrices),r(s,a,s);const i=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],u=e[7],l=e[8],f=e[9],h=e[10],d=e[11],y=e[12],m=e[13],b=e[14],p=e[15],g=n*a-r*o,w=n*c-s*o,v=n*u-i*o,M=r*c-s*a,T=r*u-i*a,A=s*u-i*c,_=l*m-f*y,O=l*b-h*y,k=l*p-d*y,x=f*b-h*m,S=f*p-d*m,I=h*p-d*b,E=g*I-w*S+v*x+M*k-T*O+A*_;return E?(E=1/E,t[0]=(a*I-c*S+u*x)*E,t[1]=(s*S-r*I-i*x)*E,t[2]=(m*A-b*T+p*M)*E,t[3]=(h*T-f*A-d*M)*E,t[4]=(c*k-o*I-u*O)*E,t[5]=(n*I-s*k+i*O)*E,t[6]=(b*v-y*A-p*w)*E,t[7]=(l*A-h*v+d*w)*E,t[8]=(o*S-a*k+u*_)*E,t[9]=(r*k-n*S-i*_)*E,t[10]=(y*T-m*v+p*g)*E,t[11]=(f*v-l*T-d*g)*E,t[12]=(a*O-o*x-c*_)*E,t[13]=(n*x-r*O+s*_)*E,t[14]=(m*w-y*M-b*g)*E,t[15]=(l*M-f*w+h*g)*E,t):null}(Sr,s),o=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];ln(e,(t=>{p(t,t,s),t[0]=t[0]-l[0],t[1]=t[1]-l[1],t[2]=t[2]-l[2],p(t,t,i),t[0]<o[0]&&(o[0]=t[0]),t[1]<o[1]&&(o[1]=t[1]),t[2]<o[2]&&(o[2]=t[2]),t[0]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])})),e.min=o,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=l)}Ht(t,e,n,r){const{modelCenter:s,rtcCenter:i}=this.Yt(t,e,n,r),o=this.Kt(s);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Jt(s),en(t,(e=>{if(e.attributes&&e.attributes.POSITION){const s=this.qt(e,t);if(s){const t=e.attributes.POSITION.array.length;(!Fr||Fr.length<t)&&(Fr=new Float32Array(t))}e.attributes.NORMAL&&this.Qt(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.Qt(e.attributes.TANGENT,e.matrices,n);const{newPositions:o}=this.Wt(e.attributes.POSITION,e.matrices,i,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,s),{componentType:a}=e.attributes.POSITION;5126!==a&&(e.attributes.POSITION.array=new Float32Array(o))}}));for(const e in t.nodes){t.nodes[e].matrix=Or}}Kt(t){const e=this.options.projection;"identity"===e?f(Ir,t):0===v(t)?h(Ir,0,0,-6378137):Ae(Ir,t),Pn(Er,Ir,e);const n=Ir[2],r=[];return r[0]=Er[0],r[1]=Er[1],r[2]=n,r}Qt(t,e,n){let r;r="Y"===n?gr:"X"===n?wr:Or;const s=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}([],r);if(Lr(s,e),a(s,Or))return;const i=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}([],s),o=[];ln(t,(t=>(function(t,e,n){var r=e[0],s=e[1],i=e[2];t[0]=r*n[0]+s*n[3]+i*n[6],t[1]=r*n[1]+s*n[4]+i*n[7],t[2]=r*n[2]+s*n[5]+i*n[8]}(o,t,i),m(o,o),f(t,o),o)))}Wt(t,e,r,s,i,o,c,u){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const l=n([]);Lr(l,e);const f=this.options.projection;i=i&&i.toUpperCase();const y=r;let m=null;"Y"===i?m=gr:"X"===i&&(m=wr);let b=[0,0,0,1];const g=[0,0,0],w=[0,0],M=s.projCenter,T=Pn([],s.rtcCoord,"EPSG:3857"),A=o&&a(Or,o),_=t.min=t.min||[],O=t.max=t.max||[];h(_,1/0,1/0,1/0),h(O,-1/0,-1/0,-1/0);const k=c||{},{decode_position_min:x,decode_position_normConstant:S}=k;let I=[0,0,0,0],E=1;x&&(I=x),S&&(E=S);const C=[];return ln(t,((e,n)=>{if(b[0]=e[0]*E+I[0],b[1]=e[1]*E+I[1],b[2]=e[2]*E+I[2],b=p(b,b,l),m&&(b=p(b,b,m)),y&&d(b,b,y),o&&!A&&(b=p(b,b,o)),0===v(b)?h(g,0,0,-6378137):Ae(g,b),u){const t=Fr;Pn(w,g,f),t[3*n]=w[0]-T[0],t[3*n+1]=w[0]-T[1],t[3*n+2]=w[0]-T[2]}if(Pn(w,g,f),e instanceof Float32Array)e[0]=w[0]-M[0],e[1]=w[1]-M[1],e[2]=g[2]-M[2];else{const n=w[0]-M[0],r=w[1]-M[1],s=g[2]-M[2];5126!==t.componentType&&(C.push(n),C.push(r),C.push(s),C.push(e[3]))}return e[0]<_[0]&&(_[0]=e[0]),e[1]<_[1]&&(_[1]=e[1]),e[2]<_[2]&&(_[2]=e[2]),e[0]>O[0]&&(O[0]=e[0]),e[1]>O[1]&&(O[1]=e[1]),e[2]>O[2]&&(O[2]=e[2]),e})),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:M,newPositions:C}}Jt(t){return 0===v(t)?h([],0,0,-6378137):Ae([],t)}onRemove(){}Vt(){return"EPSG:4326"===this.options.projection||"EPSG:4490"===this.options.projection}qt(t,e){if(!t.attributes.POSITION||function(t,e){const n=e.materials[t.material],r=n&&n.extensions&&n.extensions.KHR_materials_unlit;return r}(t,e))return!1;if(t.attributes.TANGENT)return!1;return!!t.attributes.TEXCOORD_0}}const Pr=[];function Br(t,e,n,r,s,i){const o=i||{},{decode_position_min:a,decode_position_normConstant:c}=o;let u=[0,0,0,0],l=1;a&&(u=a),c&&(l=c);for(let i=0,o=t.length;i<o;i+=e){const{xmin:o,ymin:a,xmax:c,ymax:f,hmin:y,hmax:m}=s;h(Pr,t[i]*l+u[0],t[i+1]*l+u[1],t[i+2]*l+u[2]),p(Pr,Pr,r);const b=d(Pr,n,Pr);b[0]<o&&(s.xmin=b[0]),b[0]>c&&(s.xmax=b[0]),b[1]<a&&(s.ymin=b[1]),b[1]>f&&(s.ymax=b[1]),e>2&&(b[2]<y&&(s.hmin=b[2]),b[2]>m&&(s.hmax=b[2]))}}function Dr(t){const{xmax:e,ymax:n,xmin:r,ymin:s,hmin:i,hmax:o}=t,a=[(r+e)/2,(s+n)/2,(i+o)/2];return e===-1/0&&(a[0]=0),n===-1/0&&(a[1]=0),o===-1/0&&(a[2]=0),isNaN(a[2])&&(a[2]=0),a}function Rr(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function Lr(t,e){const n=t;for(let t=e.length-1;t>=0;t--)r(n,e[t],n);return n}function jr(t,e,n,r,s){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let i,o;if(n&&r&&1===e)i=Math.min(...n),o=Math.max(...r);else{const{min:e,max:n}=function(t){let e=1/0,n=-1/0;for(let r=0;r<t.length;r++)t[r]>n&&(n=t[r]),t[r]<e&&(e=t[r]);return{min:e,max:n}}(t);i=e,o=n}return!function(t,e,n,r){for(let s=0;s<t.length;s++){const i=zr(qr(t[s],e,n),e,n);if(Math.abs(i-t[s])>Ur[r])return!1}return!0}(t,i,o,s)&&Ur[s]?null:function(t,e,n){const r=new Int16Array(t.length);for(let s=0;s<t.length;s++)r[s]=qr(t[s],e,n);return{array:r,range:[e,n]}}(t,i,o)}function zr(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function qr(t,e,n){const r=2*(t-e)/(n-e)-1,s=Math.max(-1,Math.min(1,r));return s<0?32768*s:32767*s}let Vr=0;class Gr{constructor(t){this.workerId=t,this.workers={},this.Zt={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},s){if(this.te(e,n))return;const i=this.ee(e,n),o=r.options,a=this.send.bind(this,t);this.workers[i]=new Nr(n,o,a,s)}removeLayer({mapId:t,layerId:e},n){const r=this.te(t,e),s=this.ee(t,e);delete this.workers[s],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const s=this.te(t,e);s&&s.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const s=this.te(t,e);s&&s.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.Zt[e];delete this.Zt[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,s){const i=s?\`${M}t}-${M}Vr++}\`:null;s&&(this.Zt[i]=s),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(i)},r||[])}ee(t,e){return\`${M}t}-${M}e}\`}te(t,e){const n=this.ee(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new Gr(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[n.command]({actorId:n.actorId,mapId:n.mapId,layerId:n.layerId,params:n.params},((t,n,r)=>{t&&404!==t.status&&204!==t.status&&console.error(t),t instanceof Error&&(t={message:t.message}),e(t,n,r)}))}}`;function A(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var I={exports:{}},S={exports:{}},E=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},C=Array.prototype.concat,N=Array.prototype.slice,k=S.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var s=t[n];E(s)?e=C.call(e,N.call(s)):e.push(s)}return e};k.wrap=function(t){return function(){return t(k(arguments))}};var R=S.exports,P={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},L=R,B=Object.hasOwnProperty,U=Object.create(null);for(var D in P)B.call(P,D)&&(U[P[D]]=D);var G=I.exports={to:{},get:{}};function F(t,e,n){return Math.min(Math.max(e,t),n)}function j(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}G.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=G.get.hsl(t),n="hsl";break;case"hwb":e=G.get.hwb(t),n="hwb";break;default:e=G.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},G.get.rgb=function(t){if(!t)return null;var e,n,r,s=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var i=2*n;s[n]=parseInt(e.slice(i,i+2),16)}r&&(s[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)s[n]=parseInt(e[n]+e[n],16);r&&(s[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)s[n]=parseInt(e[n+1],0);e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:B.call(P,e[1])?((s=P[e[1]])[3]=1,s):null:null;for(n=0;n<3;n++)s[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}for(n=0;n<3;n++)s[n]=F(s[n],0,255);return s[3]=F(s[3],0,1),s},G.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,F(parseFloat(e[2]),0,100),F(parseFloat(e[3]),0,100),F(isNaN(n)?1:n,0,1)]}return null},G.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,F(parseFloat(e[2]),0,100),F(parseFloat(e[3]),0,100),F(isNaN(n)?1:n,0,1)]}return null},G.to.hex=function(){var t=L(arguments);return"#"+j(t[0])+j(t[1])+j(t[2])+(t[3]<1?j(Math.round(255*t[3])):"")},G.to.rgb=function(){var t=L(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},G.to.rgb.percent=function(){var t=L(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},G.to.hsl=function(){var t=L(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},G.to.hwb=function(){var t=L(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},G.to.keyword=function(t){return U[t.slice(0,3)]};var z=I.exports,q={exports:{}},H={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},V={};for(var $ in H)H.hasOwnProperty($)&&(V[H[$]]=$);var X=q.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var J in X)if(X.hasOwnProperty(J)){if(!("channels"in X[J]))throw new Error("missing channels property: "+J);if(!("labels"in X[J]))throw new Error("missing channel labels property: "+J);if(X[J].labels.length!==X[J].channels)throw new Error("channel and label counts mismatch: "+J);var K=X[J].channels,Z=X[J].labels;delete X[J].channels,delete X[J].labels,Object.defineProperty(X[J],"channels",{value:K}),Object.defineProperty(X[J],"labels",{value:Z})}X.rgb.hsl=function(t){var e,n,r=t[0]/255,s=t[1]/255,i=t[2]/255,o=Math.min(r,s,i),a=Math.max(r,s,i),c=a-o;return a===o?e=0:r===a?e=(s-i)/c:s===a?e=2+(i-r)/c:i===a&&(e=4+(r-s)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},X.rgb.hsv=function(t){var e,n,r,s,i,o=t[0]/255,a=t[1]/255,c=t[2]/255,h=Math.max(o,a,c),l=h-Math.min(o,a,c),u=function(t){return(h-t)/6/l+.5};return 0===l?s=i=0:(i=l/h,e=u(o),n=u(a),r=u(c),o===h?s=r-n:a===h?s=1/3+e-r:c===h&&(s=2/3+n-e),s<0?s+=1:s>1&&(s-=1)),[360*s,100*i,100*h]},X.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[X.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},X.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-s)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-s-e)/(1-e)||0),100*e]},X.rgb.keyword=function(t){var e=V[t];if(e)return e;var n,r,s,i=1/0;for(var o in H)if(H.hasOwnProperty(o)){var a=H[o],c=(r=t,s=a,Math.pow(r[0]-s[0],2)+Math.pow(r[1]-s[1],2)+Math.pow(r[2]-s[2],2));c<i&&(i=c,n=o)}return n},X.keyword.rgb=function(t){return H[t]},X.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},X.rgb.lab=function(t){var e=X.rgb.xyz(t),n=e[0],r=e[1],s=e[2];return r/=100,s/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116))]},X.hsl.rgb=function(t){var e,n,r,s,i,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[i=255*c,i,i];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),s=[0,0,0];for(var h=0;h<3;h++)(r=o+1/3*-(h-1))<0&&r++,r>1&&r--,i=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,s[h]=255*i;return s},X.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,s=n,i=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,s*=i<=1?i:2-i,[e,100*(0===r?2*s/(i+s):2*n/(r+n)),100*((r+n)/2)]},X.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,s=Math.floor(e)%6,i=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*i),c=255*r*(1-n*(1-i));switch(r*=255,s){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},X.hsv.hsl=function(t){var e,n,r,s=t[0],i=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-i)*o,n=i*a,[s,100*(n=(n/=(e=(2-i)*a)<=1?e:2-e)||0),100*(r/=2)]},X.hwb.rgb=function(t){var e,n,r,s,i,o,a,c=t[0]/360,h=t[1]/100,l=t[2]/100,u=h+l;switch(u>1&&(h/=u,l/=u),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),s=h+r*((n=1-l)-h),e){default:case 6:case 0:i=n,o=s,a=h;break;case 1:i=s,o=n,a=h;break;case 2:i=h,o=n,a=s;break;case 3:i=h,o=s,a=n;break;case 4:i=s,o=h,a=n;break;case 5:i=n,o=h,a=s}return[255*i,255*o,255*a]},X.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,s=t[3]/100;return[255*(1-Math.min(1,e*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s)),255*(1-Math.min(1,r*(1-s)+s))]},X.xyz.rgb=function(t){var e,n,r,s=t[0]/100,i=t[1]/100,o=t[2]/100;return n=-.9689*s+1.8758*i+.0415*o,r=.0557*s+-.204*i+1.057*o,e=(e=3.2406*s+-1.5372*i+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},X.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},X.lab.xyz=function(t){var e,n,r,s=t[0];e=t[1]/500+(n=(s+16)/116),r=n-t[2]/200;var i=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},X.lab.lch=function(t){var e,n=t[0],r=t[1],s=t[2];return(e=360*Math.atan2(s,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+s*s),e]},X.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},X.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],s=1 in arguments?arguments[1]:X.rgb.hsv(t)[2];if(0===(s=Math.round(s/50)))return 30;var i=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===s&&(i+=60),i},X.hsv.ansi16=function(t){return X.rgb.ansi16(X.hsv.rgb(t),t[2])},X.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},X.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},X.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},X.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},X.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},X.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.max(Math.max(n,r),s),o=Math.min(Math.min(n,r),s),a=i-o;return e=a<=0?0:i===n?(r-s)/a%6:i===r?2+(s-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},X.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,s=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(s=(n-.5*r)/(1-r)),[t[0],100*r,100*s]},X.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},X.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var s,i=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=c,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=c,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=c}return s=(1-n)*r,[255*(n*i[0]+s),255*(n*i[1]+s),255*(n*i[2]+s)]},X.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},X.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},X.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},X.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},X.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},X.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},X.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},X.gray.hsl=X.gray.hsv=function(t){return[0,0,t[0]]},X.gray.hwb=function(t){return[0,100,t[0]]},X.gray.cmyk=function(t){return[0,0,0,t[0]]},X.gray.lab=function(t){return[t[0],0,0]},X.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},X.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var Y=q.exports,W=Y;function Q(t){var e=function(){for(var t={},e=Object.keys(W),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),s=Object.keys(W[r]),i=s.length,o=0;o<i;o++){var a=s[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function tt(t,e){return function(n){return e(t(n))}}function et(t,e){for(var n=[e[t].parent,t],r=W[e[t].parent][t],s=e[t].parent;e[s].parent;)n.unshift(e[s].parent),r=tt(W[e[s].parent][s],r),s=e[s].parent;return r.conversion=n,r}var nt=Y,rt=function(t){for(var e=Q(t),n={},r=Object.keys(e),s=r.length,i=0;i<s;i++){var o=r[i];null!==e[o].parent&&(n[o]=et(o,e))}return n},st={};Object.keys(nt).forEach((function(t){st[t]={},Object.defineProperty(st[t],"channels",{value:nt[t].channels}),Object.defineProperty(st[t],"labels",{value:nt[t].labels});var e=rt(t);Object.keys(e).forEach((function(n){var r=e[n];st[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,s=0;s<r;s++)n[s]=Math.round(n[s]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),st[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var it=z,ot=st,at=[].slice,ct=["keyword","gray","hex"],ht={};Object.keys(ot).forEach((function(t){ht[at.call(ot[t].labels).sort().join("")]=t}));var lt={};function ut(t,e){if(!(this instanceof ut))return new ut(t,e);if(e&&e in ct&&(e=null),e&&!(e in ot))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ut)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var s=it.get(t);if(null===s)throw new Error("Unable to parse color from string: "+t);this.model=s.model,r=ot[this.model].channels,this.color=s.value.slice(0,r),this.valpha="number"==typeof s.value[r]?s.value[r]:1}else if(t.length){this.model=e||"rgb",r=ot[this.model].channels;var i=at.call(t,0,r);this.color=mt(i,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in ht))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ht[a];var c=ot[this.model].labels,h=[];for(n=0;n<c.length;n++)h.push(t[c[n]]);this.color=mt(h)}if(lt[this.model])for(r=ot[this.model].channels,n=0;n<r;n++){var l=lt[this.model][n];l&&(this.color[n]=l(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ft(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(lt[t]||(lt[t]=[]))[e]=n})),t=t[0],function(r){var s;return arguments.length?(n&&(r=n(r)),(s=this[t]()).color[e]=r,s):(s=this[t]().color[e],n&&(s=n(s)),s)}}function dt(t){return function(e){return Math.max(0,Math.min(t,e))}}function mt(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}ut.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in it.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return it.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return it.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=ot[this.model].channels,n=ot[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ut(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ut(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ft("rgb",0,dt(255)),green:ft("rgb",1,dt(255)),blue:ft("rgb",2,dt(255)),hue:ft(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ft("hsl",1,dt(100)),lightness:ft("hsl",2,dt(100)),saturationv:ft("hsv",1,dt(100)),value:ft("hsv",2,dt(100)),chroma:ft("hcg",1,dt(100)),gray:ft("hcg",2,dt(100)),white:ft("hwb",1,dt(100)),wblack:ft("hwb",2,dt(100)),cyan:ft("cmyk",0,dt(100)),magenta:ft("cmyk",1,dt(100)),yellow:ft("cmyk",2,dt(100)),black:ft("cmyk",3,dt(100)),x:ft("xyz",0,dt(100)),y:ft("xyz",1,dt(100)),z:ft("xyz",2,dt(100)),l:ft("lab",0,dt(100)),a:ft("lab",1),b:ft("lab",2),keyword:function(t){return arguments.length?new ut(t):ot[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ut(t):it.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ut.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),s=void 0===e?.5:e,i=2*s-1,o=n.alpha()-r.alpha(),a=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,c=1-a;return ut.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*s+r.alpha()*(1-s))}},Object.keys(ot).forEach((function(t){if(-1===ct.indexOf(t)){var e=ot[t].channels;ut.prototype[t]=function(){if(this.model===t)return new ut(this);if(arguments.length)return new ut(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ut((n=ot[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ut[t]=function(n){return"number"==typeof n&&(n=mt(at.call(arguments),e)),new ut(n,t)}}}));var pt=A(ut);function bt(t){return null==t}function gt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function yt(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function wt(t){return"object"==typeof t&&!!t}function vt(t){return"number"==typeof t&&!isNaN(t)}function Tt(t){return t*Math.PI/180}function _t(t){return t/Math.PI*180}function Ot(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function Mt(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const xt=[1,1,1,1,2,2,3,0];function At(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=xt[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}function It(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function St(t){return t.flat?t.flat(1/0):t.reduce(((t,e)=>t.concat(e)),[])}function Et(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function Ct(t){return 0===t.indexOf("data:")}function Nt(t){const e=t.indexOf("base64,"),n=t.substring(e+7),r=window.atob(n),s=r.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=r.charCodeAt(t);return i.buffer}function kt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return t.length}const Rt={};function Pt(t,e){if(!Array.isArray(e)){const t=e;e=Rt[t]=Rt[t]||pt(e).array().map((t=>t/255))}for(let n=0;n<e.length;n++)t[n]=e[n];return 3===e.length&&(t[3]=1),t}var Lt=Object.freeze({__proto__:null,base64URLToArrayBuffer:Nt,extend:gt,flatArr:St,getAbsoluteURL:Ot,getBatchIdArrayType:Et,isBase64:Ct,isFunction:yt,isNil:bt,isNumber:vt,isObject:wt,normalizeColor:Pt,pushIn:kt,setColumn3:It,sign:Mt,stringFromUTF8Array:At,toDegree:_t,toRadian:Tt});function Bt(t){return-1===t.indexOf("http://")&&-1===t.indexOf("https://")&&-1===t.indexOf("file://")}function Ut(t){return(t=t||{}).referrerPolicy=t.referrerPolicy||"origin",t.referrer=window&&window.location.href,t}const Dt="undefined"==typeof document?null:document.createElement("canvas");class Gt extends t.worker.Actor{constructor(t,e){super(t),this.mapId=e}initialize(t){t(null)}loadTile(t,e,n){let r=null;e&&e.arraybuffer&&(r=[e.arraybuffer]);const s={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(s,r,n)}abortTileLoading(t,e,n){const r={mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}};this.broadcast(r,null,n)}addLayer(t,e,n){const r={actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}};this.broadcast(r,null,n)}removeLayer(t,e){const n={mapId:this.mapId,layerId:t,command:"removeLayer"};this.broadcast(n,null,e)}requestImage({url:t},e){const n=new Image;n.onload=()=>{if(!this.isActive())return;if(!Dt)return void e(new Error("There is no canvas to draw image!"));const t=function(t){if(Ft(t.width)&&Ft(t.height))return t;let e=t.width,n=t.height;Ft(e)||(e=jt(e));Ft(n)||(n=jt(n));const r=document.createElement("canvas");r.width=e,r.height=n,r.getContext("2d").drawImage(t,0,0,e,n);const s=t.src,i=s.lastIndexOf("/")+1,o=s.substring(i);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);Dt.width=t.width,Dt.height=t.height;const r=Dt.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const s=r.getImageData(0,0,t.width,t.height),i={width:t.width,height:t.height,data:new Uint8Array(s.data)};e(null,i,[i.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function Ft(t){return!(t&t-1)&&0!==t}function jt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function zt(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,s=r.length;n<s;n++){const s=[];Kt(r[n],s,t,e)}}}const qt=[],Ht=[],Vt=[],$t=[0,0,0],Xt=v.identity([]),Jt=[1,1,1];function Kt(t,e,n,r){const s=e.slice(0);if(t.matrix)s.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=T.fromTranslation(qt,t.translation||$t),n=T.fromQuat(Ht,t.rotation||Xt),r=T.fromScaling(Vt,t.scale||Jt);T.multiply(r,n,r);const i=T.multiply([],e,r);s.push(i)}if(t.children&&t.children.length)for(let e=0,i=t.children.length;e<i;e++)Kt(t.children[e],s,n,r);if(void 0!==t.mesh){const e=t.mesh,i=n.meshes[e];if(i){const t=s.slice(0),o=i.primitives;for(let s=0,i=o.length;s<i;s++){const i=o[s];i&&(i.matrices=t,r(i,e,s,n))}}}}function Zt(t,e,n){let{byteOffset:r,byteStride:s}=e;const{componentType:i,itemSize:o}=e,a=e.array.buffer,c=i?y.getTypedArrayCtor(i):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,s=s||0,!s||s===o*c.BYTES_PER_ELEMENT&&r%c.BYTES_PER_ELEMENT==0){const e=new c(a,r+n*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}s||(s=o*c.BYTES_PER_ELEMENT);const h=new Uint8Array(a,s*n+r,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(h),t}function Yt(t,e,n,r){t[4*e]=n[r],t[4*e+1]=n[r+4],t[4*e+2]=n[r+8],t[4*e+3]=n[r+12]}var Wt="#include <gl2_vert>\n\nconst float SHIFT_RIGHT_11 = 1.0 / 2048.0;\n\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\n\nconst float SHIFT_LEFT_11 = 2048.0;\n\nconst float SHIFT_LEFT_5 = 32.0;\n\nconst float NORMALIZE_6 = 1.0 / 64.0;\n\nconst float NORMALIZE_5 = 1.0 / 32.0;\n\n\n\n#ifdef HAS_POSITION\n\n attribute vec3 POSITION;\n\n#endif\n\n\n\n#if defined(HAS_RGB)\n\n attribute vec3 RGB;\n\n#elif defined(HAS_RGBA)\n\n attribute vec4 RGBA;\n\n#elif defined(HAS_RGB565)\n\n attribute float RGB565;\n\n#endif\n\n\n\nuniform vec4 pointColor;\n\nuniform float pointSize;\n\n\n\nuniform mat4 projViewModelMatrix;\n\nuniform float pointOpacity;\n\n\n\nvarying vec4 vColor;\n\n\n\n#ifdef HAS_NORMAL\n\n #ifdef HAS_NORMAL_OCT16P\n\n attribute vec2 NORMAL_OCT16P;\n\n float signNotZero(float value) {\n\n return value >= 0.0 ? 1.0 : -1.0;\n\n }\n\n vec2 signNotZero(vec2 value) {\n\n return vec2(signNotZero(value.x), signNotZero(value.y));\n\n }\n\n vec3 octDecode(vec2 encoded, float range) {\n\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n\n return vec3(0.0, 0.0, 0.0);\n\n }\n\n encoded = encoded / range * 2.0 - 1.0;\n\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n\n if (v.z < 0.0) {\n\n v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n\n }\n\n return normalize(v);\n\n }\n\n vec3 octDecode(vec2 encoded) {\n\n return octDecode(encoded, 255.0);\n\n }\n\n #else\n\n attribute vec3 NORMAL;\n\n #endif\n\n uniform vec3 lightDir;\n\n uniform mat3 modelNormalMatrix;\n\n uniform mat4 positionMatrix;\n\n float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n\n return max(dot(-lightDir, normal), 0.0);\n\n }\n\n#endif\n\n#ifdef PICKING_MODE\n\n #include <fbo_picking_vert>\n\n#endif\n\n#include <draco_decode_vert>\n\nvoid main() {\n\n #ifdef HAS_POSITION\n\n vec3 localPos = decode_getPosition(POSITION);\n\n #endif\n\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n gl_PointSize = pointSize;\n\n\n\n #ifdef PICKING_MODE\n\n fbo_picking_setData(gl_Position.w, true);\n\n #else\n\n #if defined(HAS_RGB)\n\n vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n\n #elif defined(HAS_RGBA)\n\n vColor = RGBA / 255.0 * pointOpacity;\n\n #elif defined(HAS_RGB565)\n\n float compressed = RGB565;\n\n float r = floor(compressed * SHIFT_RIGHT_11);\n\n compressed -= r * SHIFT_LEFT_11;\n\n float g = floor(compressed * SHIFT_RIGHT_5);\n\n compressed -= g * SHIFT_LEFT_5;\n\n float b = compressed;\n\n vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n\n vColor = vec4(rgb, 1.0);\n\n #else\n\n vColor = pointColor;\n\n #endif\n\n\n\n #ifdef HAS_NORMAL\n\n mat3 positionNormalMatrix = mat3(positionMatrix);\n\n mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n\n #ifdef HAS_NORMAL_OCT16P\n\n vec3 localNormal = octDecode(NORMAL_OCT16P);\n\n #else\n\n vec3 localNormal = NORMAL;\n\n #endif\n\n vec3 normal = normalize(normalMatrix * localNormal);\n\n float colorStrength = getLambertDiffuse(lightDir, normal);\n\n colorStrength = max(colorStrength, 0.5);\n\n vColor *= colorStrength;\n\n #endif\n\n #endif\n\n\n\n\n\n\n\n\n\n}\n\n";const Qt=new Array(3),te=new Array(3),ee=[40680631590769,40680631590769,40408299984661.445];function ne(t,e,n,r){const s=ee,i=Math.cos(n);Qt[0]=i*Math.cos(e),Qt[1]=i*Math.sin(e),Qt[2]=Math.sin(n),de(Qt,Qt),_.multiply(te,s,Qt);const o=Math.sqrt(_.dot(Qt,te));var a,c,h;return c=te,h=o,(a=te)[0]=c[0]/h,a[1]=c[1]/h,a[2]=c[2]/h,_.scale(Qt,Qt,r),_.add(t,te,Qt)}const re=[1/6378137,1/6378137,1/6356752.314245179],se=[1/40680631590769,1/40680631590769,1/40408299984661.445],ie=new Array(3),oe=new Array(3),ae=new Array(3);function ce(t,e){const n=se,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],h=n[1],l=n[2],u=i*i*c*c,f=o*o*h*h,d=a*a*l*l,m=u+f+d,p=Math.sqrt(1/m),b=_.scale(he,e,p);if(m<s)return isFinite(p)?b:void 0;const g=r[0],y=r[1],w=r[2],v=le;v[0]=b[0]*g*2,v[1]=b[1]*y*2,v[2]=b[2]*w*2;let T,O,M,x,A,I,S,E,C,N,k,R=(1-p)*fe(e)/(.5*fe(v)),P=0;do{R-=P,M=1/(1+R*g),x=1/(1+R*y),A=1/(1+R*w),I=M*M,S=x*x,E=A*A,C=I*M,N=S*x,k=E*A,T=u*I+f*S+d*E-1,O=u*C*g+f*N*y+d*k*w;P=T/(-2*O)}while(Math.abs(T)>ue);return t[0]=i*M,t[1]=o*x,t[2]=a*A,t}(ie,e,re,n,.1);let s=_.mul(oe,r,n);s=de(s,s);const i=_.sub(ae,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=Mt(_.dot(i,e))*fe(i);return t[0]=_t(o),t[1]=_t(a),t[2]=c,t}const he=new Array(3),le=new Array(3),ue=1e-12;function fe(t){return _.length(t)}function de(t,e){const n=e[0],r=e[1],s=e[2];let i=n*n+r*r+s*s;return i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i),t}function me(t,e){return _.multiply(e,t,se),_.normalize(e,e)}function pe(t,e){const n=t[0],r=t[1],s=Math.cos(r),i=s*Math.cos(n),o=s*Math.sin(n),a=Math.sin(r);return e.x=i,e.y=o,e.z=a,_.normalize(e,e)}var be=Object.freeze({__proto__:null,cartesian3ToDegree:ce,geodeticSurfaceNormal:me,geodeticSurfaceNormalCartographic:pe,normalizeCartesian:de,radianToCartesian3:ne});function ge(t,e,n,r){n=n||0,r=r||n;const s=Math.abs(t-e);return s<=r||s<=n*Math.max(Math.abs(t),Math.abs(e))}function ye(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const we="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function ve(t,e,n){const r=new Uint8Array(t,e,n);return we?JSON.parse(we.decode(r)):JSON.parse(At(r))}function Te(t,e,n){const r=new Uint8Array(t,e,n);return we?JSON.parse(we.decode(r)):JSON.parse(At(r))}function _e(t,e,n){return{offset:e,byteLength:n}}function Oe(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=Ee(i||"UNSIGNED_SHORT"),h=Ie(o);return{byteStride:0,byteOffset:s+n,itemSize:h,count:r*h,componentType:c,array:new a(e,n+s,r*h)}}function Me(t,e,n,r){const s=Oe(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}function xe(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a}=Ee(i||"UNSIGNED_SHORT"),c=Ie(o),h=new a(e,s,n*c);return 1===c?h[r]:h.subarray(r*c,r*c+c)}const Ae={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Ie(t){return t?Ae[t]:1}const Se={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function Ee(t){return Se[t]}function Ce(t){for(const e in Se)if(t===Se[e].ctor)return Se[e].type;throw new Error("unrecognized ctor:"+t)}function Ne(t,e,n,r){const s=t,i=e.length/3;for(let t=0;t<i;t++)s[3*t]=e[3*t]/65535*r[0]+n[0],s[3*t+1]=e[3*t+1]/65535*r[1]+n[1],s[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return s}function ke(t,e,n){const r=t.getUint32(12,!0),s=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,h={},l={},u=null;r>0&&(h=ve(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(l=Te(a,e,i),e+=i);const f=_e(0,e,o);return u=a.slice(f.offset,f.offset+f.byteLength),n.push(u),{featureTable:h,featureTableBin:c,batchTable:l,batchTableBin:u}}const Re={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},Pe={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Le={},Be={east:[],north:[],up:[],west:[],south:[],down:[]};let Ue=[],De=[],Ge=[];const Fe=[0,0,0];function je(t,e,n){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=t[15],n}const ze=function(t,e){const n=Re[t][e];let r;const s=t+e;return Le[s]?r=Le[s]:(r=function(r,s,i){if(_.equals(r,Fe))_.copy(Ue,Pe[t]),_.copy(De,Pe[e]),_.copy(Ge,Pe[n]);else if(ge(r[0],0,1e-14)&&ge(r[1],0,1e-14)){const s=Mt(r[2]);_.copy(Ue,Pe[t]),_.copy(De,Pe[e]),_.scale(De,De,s),_.copy(Ge,Pe[n]),_.scale(Ge,Ge,s)}else{me(r,Be.up);const s=Be.up,i=Be.east;i[0]=-r[1],i[1]=r[0],i[2]=0,_.normalize(Be.east,i),_.cross(Be.north,s,i),_.scale(Be.down,Be.up,-1),_.scale(Be.west,Be.east,-1),_.scale(Be.south,Be.north,-1),Ue=Be[t],De=Be[e],Ge=Be[n]}return i[0]=Ue[0],i[1]=Ue[1],i[2]=Ue[2],i[3]=0,i[4]=De[0],i[5]=De[1],i[6]=De[2],i[7]=0,i[8]=Ge[0],i[9]=Ge[1],i[10]=Ge[2],i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i},Le[s]=r),r}("east","north"),qe=[],He=[],Ve=[],$e=[],Xe=[],Je=[],Ke=[],Ze={x:0,y:0},Ye={x:0,y:0},We=Math.PI/180;let Qe;const tn={width:100,height:10};function en(){if(!Qe){const{width:t,height:e}=tn;OffscreenCanvas?Qe=new OffscreenCanvas(t,e):(Qe=document.createElement("canvas"),Qe.width=t,Qe.height=e)}return Qe}class nn{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let n=1/0,r=-1/0;for(let e=0,s=t.length;e<s;e++){const s=t[e][0];n=Math.min(s,n),r=Math.max(s,r)}this.min=n,this.max=r,this.valueOffset=this.max-this.min,this.options=Object.assign({},tn,e),this.i()}getImageData(){return this.imgData}i(){const t=en(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const s=r.createLinearGradient(0,0,t.width,0),{colors:i,valueOffset:o}=this;for(let t=0,e=i.length;t<e;t++){const[e,n]=i[t],r=(e-this.min)/o;s.addColorStop(r,n)}r.fillStyle=s,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var rn;function sn(t,e){var n,r,s;if(mn(t)){var i,o=t.stops&&"object"==typeof t.stops[0][0],a=o||void 0!==t.property,c=o||!a,h=t.type||e||"exponential";if("exponential"===h)i=cn;else if("interval"===h)i=an;else if("categorical"===h)i=on;else if("identity"===h)i=un;else{if("color-interpolate"!==h)throw new Error('Unknown function type "'+h+'"');i=ln}if(o){var l={},u=[];for(let e=0;e<t.stops.length;e++){var f=t.stops[e];void 0===l[f[0].zoom]&&(l[f[0].zoom]={zoom:f[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),l[f[0].zoom].stops.push([f[0].value,f[1]])}for(let t in l)u.push([l[t].zoom,sn(l[t])]);n=function(e,n){const r=cn({stops:u,base:t.base},e)(e,n);return"function"==typeof r?r(e,n):r},r=!1,s=!1}else c?(n=function(e){const n=i(t,e);return"function"==typeof n?n(e):n},r=!0,s=!1):(n=function(e,n){const r=i(t,n?n[t.property]:null);return"function"==typeof r?r(e,n):r},r=!1,s=!0)}else n=function(){return t},r=!0,s=!0;return n.isZoomConstant=s,n.isFeatureConstant=r,n}function on(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function an(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function cn(t,e){for(var n=void 0!==t.base?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:fn(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(rn=new Map);const hn={width:100,height:1};function ln(t,e){const n=t.stops;if(n&&n.length>1){let t;if(rn){const e=JSON.stringify(n);if(!rn.has(e)){const t=new nn(n,hn);rn.set(e,t)}t=rn.get(e)}else t=new nn(n,hn);const[r,s,i,o]=t.getColor(e);return[r/255,s/255,i/255,o/255]}return n&&1===n.length?n[0][1]:null}function un(t,e){return n=e,r=t.default,void 0!==n?n:void 0!==r?r:null;var n,r}function fn(t,e,n,r,s,i){return"function"==typeof s?function(){var o=s.apply(void 0,arguments),a=i.apply(void 0,arguments);return fn(t,e,n,r,o,a)}:s.length?function(t,e,n,r,s,i){var o=[];for(let a=0;a<s.length;a++)o[a]=dn(t,e,n,r,s[a],i[a]);return o}(t,e,n,r,s,i):dn(t,e,n,r,s,i)}function dn(t,e,n,r,s,i){var o,a=r-n,c=t-n;return s*(1-(o=1===e?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)))+i*o}function mn(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type)}function pn(t){return bn(t,"exponential")}function bn(t,e){if(!mn(t))return function(){return t};let n=!0,r=!0;const s=(t=JSON.parse(JSON.stringify(t))).stops;if(s)for(let t=0;t<s.length;t++)if(mn(s[t][1])){const i=bn(s[t][1],e);n=n&&i.isZoomConstant,r=r&&i.isFeatureConstant,s[t]=[s[t][0],i]}const i=sn(t,e);return i.isZoomConstant=n&&i.isZoomConstant,i.isFeatureConstant=r&&i.isFeatureConstant,i}const{getTextureMagFilter:gn,getTextureMinFilter:yn,getTextureWrap:wn,getMaterialType:vn,getMaterialFormat:Tn,getPrimitive:_n,getUniqueREGLBuffer:On}=n.REGLHelper,Mn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],xn=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:An,logoutIBLResOnCanvas:In,getIBLResOnCanvas:Sn,getPBRUniforms:En}=n.pbr.PBRUtils,Cn={factor:0,units:0},Nn=[1,1,1,1],kn=[0,0,0],Rn={specularStrength:0,materialShininess:1},Pn=[1,1,1],Ln=r.identity([]),Bn=[0,0,0],Un=[0,0],Dn=[],Gn=t=>t.material instanceof n.PhongMaterial,Fn=t=>t.material instanceof n.pbr.StandardMaterial,jn=[],zn=new t.Coordinate(0,0),qn=new t.Point(0,0),Hn=new t.Point(0,0),Vn=new t.Point(0,0),$n=[],Xn=[],Jn=[],Kn=[],Zn=[],Yn=[],Wn=[],Qn=[],tr=[],er=[],nr=[],rr=[],sr=[],ir=[],or={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},ar=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],cr=function(t,e){const n=2*Math.PI/t,r=[],s=[];for(let s=0;s<=t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=t,r[3*s+1]=i,r[3*s+2]=o}for(let s=t;s<=2*t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=o,r[3*s+1]=t,r[3*s+2]=i}for(let s=2*t;s<=3*t;s++){const t=Math.cos(n*s)*e,i=Math.sin(n*s)*e,o=0;r[3*s]=t,r[3*s+1]=o,r[3*s+2]=i}const i=r.length/3-1;for(let e=0;e<i;e++)e!==t-1&&e!==2*t-1&&(s[2*e]=e,s[2*e+1]=e+1);return r.push(0,0,0),r.push(e,0,0),r.push(0,e,0),r.push(0,0,e),s.push(i+1,i+2),s.push(i+1,i+3),s.push(i+1,i+4),{vertices:r,indices:s}}
|
|
6
|
+
import*as t from"maptalks";import*as e from"@maptalks/gl";import{reshader as n,mat4 as r,HighlightUtil as i,ContextUtil as s,quat as o,vec3 as a,mat3 as c,vec4 as h,MaskRendererMixin as l,createREGL as u,MaskLayerMixin as f,ClipOutsideMask as d,vec2 as m}from"@maptalks/gl";import{intersectsBox as p,intersectsOrientedBox as y,intersectsSphere as b}from"frustum-intersects";import{GLTFLoader as g,Ajax as w}from"@maptalks/gltf-loader";import{quat as v,mat4 as T,vec3 as M,mat3 as O}from"gl-matrix";const _="${",A=`function(t,e,n){var r="undefined"!=typeof Float32Array?Float32Array:Array;function a(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function i(t,e,n){var r=e[0],a=e[1],i=e[2],o=e[3],s=e[4],c=e[5],u=e[6],l=e[7],f=e[8],h=e[9],y=e[10],d=e[11],b=e[12],m=e[13],p=e[14],g=e[15],v=n[0],w=n[1],M=n[2],T=n[3];return t[0]=v*r+w*s+M*f+T*b,t[1]=v*a+w*c+M*h+T*m,t[2]=v*i+w*u+M*y+T*p,t[3]=v*o+w*l+M*d+T*g,v=n[4],w=n[5],M=n[6],T=n[7],t[4]=v*r+w*s+M*f+T*b,t[5]=v*a+w*c+M*h+T*m,t[6]=v*i+w*u+M*y+T*p,t[7]=v*o+w*l+M*d+T*g,v=n[8],w=n[9],M=n[10],T=n[11],t[8]=v*r+w*s+M*f+T*b,t[9]=v*a+w*c+M*h+T*m,t[10]=v*i+w*u+M*y+T*p,t[11]=v*o+w*l+M*d+T*g,v=n[12],w=n[13],M=n[14],T=n[15],t[12]=v*r+w*s+M*f+T*b,t[13]=v*a+w*c+M*h+T*m,t[14]=v*i+w*u+M*y+T*p,t[15]=v*o+w*l+M*d+T*g,t}function o(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function s(){var t=new r(3);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function c(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function u(t,e,n){var a=new r(3);return a[0]=t,a[1]=e,a[2]=n,a}function l(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function f(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function h(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function y(t,e){var n=e[0],r=e[1],a=e[2],i=n*n+r*r+a*a;return i>0&&(i=1/Math.sqrt(i)),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i,t}function d(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function b(t,e,n){var r=e[0],a=e[1],i=e[2],o=n[3]*r+n[7]*a+n[11]*i+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*a+n[8]*i+n[12])/o,t[1]=(n[1]*r+n[5]*a+n[9]*i+n[13])/o,t[2]=(n[2]*r+n[6]*a+n[10]*i+n[14])/o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var m=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},p=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},g=c;function v(){var t=new r(4);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}s(),function(){var t,e=(t=new r(4),r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var w;function M(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}s(),u(1,0,0),u(0,1,0),v(),v(),w=new r(9),r!=Float32Array&&(w[1]=0,w[2]=0,w[3]=0,w[5]=0,w[6]=0,w[7]=0),w[0]=1,w[4]=1,w[8]=1;var T={exports:{}},A={exports:{}},k=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},O=Array.prototype.concat,S=Array.prototype.slice,x=A.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var a=t[n];k(a)?e=O.call(e,S.call(a)):e.push(a)}return e};x.wrap=function(t){return function(){return t(x(arguments))}};var _=A.exports,I={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},F=_,C=Object.hasOwnProperty,E=Object.create(null);for(var U in I)C.call(I,U)&&(E[I[U]]=U);var N=T.exports={to:{},get:{}};function z(t,e,n){return Math.min(Math.max(e,t),n)}function D(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}N.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=N.get.hsl(t),n="hsl";break;case"hwb":e=N.get.hwb(t),n="hwb";break;default:e=N.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},N.get.rgb=function(t){if(!t)return null;var e,n,r,a=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var i=2*n;a[n]=parseInt(e.slice(i,i+2),16)}r&&(a[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)a[n]=parseInt(e[n]+e[n],16);r&&(a[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(n=0;n<3;n++)a[n]=parseInt(e[n+1],0);e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(e=t.match(/^(\\w+)$/))?"transparent"===e[1]?[0,0,0,0]:C.call(I,e[1])?((a=I[e[1]])[3]=1,a):null:null;for(n=0;n<3;n++)a[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[3]=parseFloat(e[4]))}for(n=0;n<3;n++)a[n]=z(a[n],0,255);return a[3]=z(a[3],0,1),a},N.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,z(parseFloat(e[2]),0,100),z(parseFloat(e[3]),0,100),z(isNaN(n)?1:n,0,1)]}return null},N.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,z(parseFloat(e[2]),0,100),z(parseFloat(e[3]),0,100),z(isNaN(n)?1:n,0,1)]}return null},N.to.hex=function(){var t=F(arguments);return"#"+D(t[0])+D(t[1])+D(t[2])+(t[3]<1?D(Math.round(255*t[3])):"")},N.to.rgb=function(){var t=F(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},N.to.rgb.percent=function(){var t=F(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},N.to.hsl=function(){var t=F(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},N.to.hwb=function(){var t=F(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},N.to.keyword=function(t){return E[t.slice(0,3)]};var P=T.exports,L={exports:{}},j={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},B={};for(var q in j)j.hasOwnProperty(q)&&(B[j[q]]=q);var R=L.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var V in R)if(R.hasOwnProperty(V)){if(!("channels"in R[V]))throw new Error("missing channels property: "+V);if(!("labels"in R[V]))throw new Error("missing channel labels property: "+V);if(R[V].labels.length!==R[V].channels)throw new Error("channel and label counts mismatch: "+V);var G=R[V].channels,$=R[V].labels;delete R[V].channels,delete R[V].labels,Object.defineProperty(R[V],"channels",{value:G}),Object.defineProperty(R[V],"labels",{value:$})}R.rgb.hsl=function(t){var e,n,r=t[0]/255,a=t[1]/255,i=t[2]/255,o=Math.min(r,a,i),s=Math.max(r,a,i),c=s-o;return s===o?e=0:r===s?e=(a-i)/c:a===s?e=2+(i-r)/c:i===s&&(e=4+(r-a)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+s)/2,[e,100*(s===o?0:n<=.5?c/(s+o):c/(2-s-o)),100*n]},R.rgb.hsv=function(t){var e,n,r,a,i,o=t[0]/255,s=t[1]/255,c=t[2]/255,u=Math.max(o,s,c),l=u-Math.min(o,s,c),f=function(t){return(u-t)/6/l+.5};return 0===l?a=i=0:(i=l/u,e=f(o),n=f(s),r=f(c),o===u?a=r-n:s===u?a=1/3+e-r:c===u&&(a=2/3+n-e),a<0?a+=1:a>1&&(a-=1)),[360*a,100*i,100*u]},R.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[R.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},R.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-a)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-a-e)/(1-e)||0),100*e]},R.rgb.keyword=function(t){var e=B[t];if(e)return e;var n,r,a,i=1/0;for(var o in j)if(j.hasOwnProperty(o)){var s=j[o],c=(r=t,a=s,Math.pow(r[0]-a[0],2)+Math.pow(r[1]-a[1],2)+Math.pow(r[2]-a[2],2));c<i&&(i=c,n=o)}return n},R.keyword.rgb=function(t){return j[t]},R.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},R.rgb.lab=function(t){var e=R.rgb.xyz(t),n=e[0],r=e[1],a=e[2];return r/=100,a/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(a=a>.008856?Math.pow(a,1/3):7.787*a+16/116))]},R.hsl.rgb=function(t){var e,n,r,a,i,o=t[0]/360,s=t[1]/100,c=t[2]/100;if(0===s)return[i=255*c,i,i];e=2*c-(n=c<.5?c*(1+s):c+s-c*s),a=[0,0,0];for(var u=0;u<3;u++)(r=o+1/3*-(u-1))<0&&r++,r>1&&r--,i=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,a[u]=255*i;return a},R.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,a=n,i=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,a*=i<=1?i:2-i,[e,100*(0===r?2*a/(i+a):2*n/(r+n)),100*((r+n)/2)]},R.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,a=Math.floor(e)%6,i=e-Math.floor(e),o=255*r*(1-n),s=255*r*(1-n*i),c=255*r*(1-n*(1-i));switch(r*=255,a){case 0:return[r,c,o];case 1:return[s,r,o];case 2:return[o,r,c];case 3:return[o,s,r];case 4:return[c,o,r];case 5:return[r,o,s]}},R.hsv.hsl=function(t){var e,n,r,a=t[0],i=t[1]/100,o=t[2]/100,s=Math.max(o,.01);return r=(2-i)*o,n=i*s,[a,100*(n=(n/=(e=(2-i)*s)<=1?e:2-e)||0),100*(r/=2)]},R.hwb.rgb=function(t){var e,n,r,a,i,o,s,c=t[0]/360,u=t[1]/100,l=t[2]/100,f=u+l;switch(f>1&&(u/=f,l/=f),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),a=u+r*((n=1-l)-u),e){default:case 6:case 0:i=n,o=a,s=u;break;case 1:i=a,o=n,s=u;break;case 2:i=u,o=n,s=a;break;case 3:i=u,o=a,s=n;break;case 4:i=a,o=u,s=n;break;case 5:i=n,o=u,s=a}return[255*i,255*o,255*s]},R.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,a=t[3]/100;return[255*(1-Math.min(1,e*(1-a)+a)),255*(1-Math.min(1,n*(1-a)+a)),255*(1-Math.min(1,r*(1-a)+a))]},R.xyz.rgb=function(t){var e,n,r,a=t[0]/100,i=t[1]/100,o=t[2]/100;return n=-.9689*a+1.8758*i+.0415*o,r=.0557*a+-.204*i+1.057*o,e=(e=3.2406*a+-1.5372*i+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},R.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},R.lab.xyz=function(t){var e,n,r,a=t[0];e=t[1]/500+(n=(a+16)/116),r=n-t[2]/200;var i=Math.pow(n,3),o=Math.pow(e,3),s=Math.pow(r,3);return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=s>.008856?s:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},R.lab.lch=function(t){var e,n=t[0],r=t[1],a=t[2];return(e=360*Math.atan2(a,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+a*a),e]},R.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},R.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],a=1 in arguments?arguments[1]:R.rgb.hsv(t)[2];if(0===(a=Math.round(a/50)))return 30;var i=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===a&&(i+=60),i},R.hsv.ansi16=function(t){return R.rgb.ansi16(R.hsv.rgb(t),t[2])},R.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},R.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},R.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},R.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},R.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},R.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255,i=Math.max(Math.max(n,r),a),o=Math.min(Math.min(n,r),a),s=i-o;return e=s<=0?0:i===n?(r-a)/s%6:i===r?2+(a-n)/s:4+(n-r)/s+4,e/=6,[360*(e%=1),100*s,100*(s<1?o/(1-s):0)]},R.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,a=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(a=(n-.5*r)/(1-r)),[t[0],100*r,100*a]},R.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},R.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var a,i=[0,0,0],o=e%1*6,s=o%1,c=1-s;switch(Math.floor(o)){case 0:i[0]=1,i[1]=s,i[2]=0;break;case 1:i[0]=c,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=s;break;case 3:i[0]=0,i[1]=c,i[2]=1;break;case 4:i[0]=s,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=c}return a=(1-n)*r,[255*(n*i[0]+a),255*(n*i[1]+a),255*(n*i[2]+a)]},R.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},R.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},R.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},R.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},R.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},R.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},R.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},R.gray.hsl=R.gray.hsv=function(t){return[0,0,t[0]]},R.gray.hwb=function(t){return[0,100,t[0]]},R.gray.cmyk=function(t){return[0,0,0,t[0]]},R.gray.lab=function(t){return[t[0],0,0]},R.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},R.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var X=L.exports,H=X;function J(t){var e=function(){for(var t={},e=Object.keys(H),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),a=Object.keys(H[r]),i=a.length,o=0;o<i;o++){var s=a[o],c=e[s];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(s))}return e}function Y(t,e){return function(n){return e(t(n))}}function K(t,e){for(var n=[e[t].parent,t],r=H[e[t].parent][t],a=e[t].parent;e[a].parent;)n.unshift(e[a].parent),r=Y(H[e[a].parent][a],r),a=e[a].parent;return r.conversion=n,r}var Q=X,Z=function(t){for(var e=J(t),n={},r=Object.keys(e),a=r.length,i=0;i<a;i++){var o=r[i];null!==e[o].parent&&(n[o]=K(o,e))}return n},W={};Object.keys(Q).forEach((function(t){W[t]={},Object.defineProperty(W[t],"channels",{value:Q[t].channels}),Object.defineProperty(W[t],"labels",{value:Q[t].labels});var e=Z(t);Object.keys(e).forEach((function(n){var r=e[n];W[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,a=0;a<r;a++)n[a]=Math.round(n[a]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),W[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var tt=P,et=W,nt=[].slice,rt=["keyword","gray","hex"],at={};Object.keys(et).forEach((function(t){at[nt.call(et[t].labels).sort().join("")]=t}));var it={};function ot(t,e){if(!(this instanceof ot))return new ot(t,e);if(e&&e in rt&&(e=null),e&&!(e in et))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ot)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var a=tt.get(t);if(null===a)throw new Error("Unable to parse color from string: "+t);this.model=a.model,r=et[this.model].channels,this.color=a.value.slice(0,r),this.valpha="number"==typeof a.value[r]?a.value[r]:1}else if(t.length){this.model=e||"rgb",r=et[this.model].channels;var i=nt.call(t,0,r);this.color=ut(i,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var s=o.sort().join("");if(!(s in at))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=at[s];var c=et[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=ut(u)}if(it[this.model])for(r=et[this.model].channels,n=0;n<r;n++){var l=it[this.model][n];l&&(this.color[n]=l(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function st(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(it[t]||(it[t]=[]))[e]=n})),t=t[0],function(r){var a;return arguments.length?(n&&(r=n(r)),(a=this[t]()).color[e]=r,a):(a=this[t]().color[e],n&&(a=n(a)),a)}}function ct(t){return function(e){return Math.max(0,Math.min(t,e))}}function ut(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function lt(t){return null==t}function ft(t){return"object"==typeof t&&!!t}function ht(t){return t/Math.PI*180}ot.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in tt.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return tt.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return tt.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=et[this.model].channels,n=et[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ot(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ot(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:st("rgb",0,ct(255)),green:st("rgb",1,ct(255)),blue:st("rgb",2,ct(255)),hue:st(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:st("hsl",1,ct(100)),lightness:st("hsl",2,ct(100)),saturationv:st("hsv",1,ct(100)),value:st("hsv",2,ct(100)),chroma:st("hcg",1,ct(100)),gray:st("hcg",2,ct(100)),white:st("hwb",1,ct(100)),wblack:st("hwb",2,ct(100)),cyan:st("cmyk",0,ct(100)),magenta:st("cmyk",1,ct(100)),yellow:st("cmyk",2,ct(100)),black:st("cmyk",3,ct(100)),x:st("xyz",0,ct(100)),y:st("xyz",1,ct(100)),z:st("xyz",2,ct(100)),l:st("lab",0,ct(100)),a:st("lab",1),b:st("lab",2),keyword:function(t){return arguments.length?new ot(t):et[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ot(t):tt.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ot.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),a=void 0===e?.5:e,i=2*a-1,o=n.alpha()-r.alpha(),s=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,c=1-s;return ot.rgb(s*n.red()+c*r.red(),s*n.green()+c*r.green(),s*n.blue()+c*r.blue(),n.alpha()*a+r.alpha()*(1-a))}},Object.keys(et).forEach((function(t){if(-1===rt.indexOf(t)){var e=et[t].channels;ot.prototype[t]=function(){if(this.model===t)return new ot(this);if(arguments.length)return new ot(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ot((n=et[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ot[t]=function(n){return"number"==typeof n&&(n=ut(nt.call(arguments),e)),new ot(n,t)}}}));const yt=[1,1,1,1,2,2,3,0];function dt(t){const e=t.length;let n="";for(let r=0;r<e;){let a=t[r++];if(128&a){let n=yt[a>>3&7];if(!(64&a)||!n||r+n>e)return null;for(a&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;a=a<<6|63&e}}n+=String.fromCharCode(a)}return n}new Array(3),new Array(3);const bt=[1/6378137,1/6378137,1/6356752.314245179],mt=[1/40680631590769,1/40680631590769,1/40408299984661.445],pt=new Array(3),gt=new Array(3),vt=new Array(3);function wt(t,e){const n=mt,r=function(t,e,n,r,a){const i=e[0],o=e[1],s=e[2],c=n[0],u=n[1],l=n[2],f=i*i*c*c,h=o*o*u*u,y=s*s*l*l,d=f+h+y,b=Math.sqrt(1/d),m=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(Mt,e,b);if(d<a)return isFinite(b)?m:void 0;const p=r[0],g=r[1],v=r[2],w=Tt;w[0]=m[0]*p*2,w[1]=m[1]*g*2,w[2]=m[2]*v*2;let M,T,A,k,O,S,x,_,I,F,C,E=(1-b)*kt(e)/(.5*kt(w)),U=0;do{E-=U,A=1/(1+E*p),k=1/(1+E*g),O=1/(1+E*v),S=A*A,x=k*k,_=O*O,I=S*A,F=x*k,C=_*O,M=f*S+h*x+y*_-1,T=f*I*p+h*F*g+y*C*v;U=M/(-2*T)}while(Math.abs(M)>At);return t[0]=i*A,t[1]=o*k,t[2]=s*O,t}(pt,e,bt,n,.1);let a=p(gt,r,n);a=function(t,e){const n=e[0],r=e[1],a=e[2];let i=n*n+r*r+a*a;i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i);return t}(a,a);const i=m(vt,e,r),o=Math.atan2(a[1],a[0]),s=Math.asin(a[2]),c=(u=d(i,e),(Math.sign?Math.sign(u):0==(u=+u)||isNaN(u)?Number(u):u>0?1:-1)*kt(i));var u;return t[0]=ht(o),t[1]=ht(s),t[2]=c,t}const Mt=new Array(3),Tt=new Array(3),At=1e-12;function kt(t){return c(t)}function Ot(t,e){let n="";for(let r=0;r<4;r++){const a=t.getUint8(e+r);n+=String.fromCharCode(a)}return n}const St="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function xt(t,e,n){const r=new Uint8Array(t,e,n);return St?JSON.parse(St.decode(r)):JSON.parse(dt(r))}function _t(t,e,n){const r=new Uint8Array(t,e,n);return St?JSON.parse(St.decode(r)):JSON.parse(dt(r))}function It(t,e,n){return{offset:e,byteLength:n}}function Ft(t,e,n,r){const{byteOffset:a,componentType:i,type:o}=t,{ctor:s,type:c}=function(t){return Ut[t]}(i||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Et[t]}(o);return{byteStride:0,byteOffset:a+n,itemSize:u,count:r*u,componentType:c,array:new s(e,n+a,r*u)}}function Ct(t,e,n,r){const a=Ft(t,e,n,r);return a.array.buffer.byteLength!==e.byteLength&&(a.array=a.array.slice()),a}const Et={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Ut={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function Nt(t){for(const e in Ut)if(t===Ut[e].ctor)return Ut[e].type;throw new Error("unrecognized ctor:"+t)}function zt(t,e,n,r){const a=t,i=e.length/3;for(let t=0;t<i;t++)a[3*t]=e[3*t]/65535*r[0]+n[0],a[3*t+1]=e[3*t+1]/65535*r[1]+n[1],a[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return a}function Dt(t,e,n){const r=t.getUint32(12,!0),a=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),s=t.buffer;let c,u={},l={},f=null;r>0&&(u=xt(s,e,r),e+=r),a>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,a),e+=a),i>0&&(l=_t(s,e,i),e+=i);const h=It(0,e,o);return f=s.slice(h.offset,h.offset+h.byteLength),n.push(f),{featureTable:u,featureTableBin:c,batchTable:l,batchTableBin:f}}const Pt={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Lt(t){for(const e in Pt)if(t===Pt[e])return+e;throw new Error("unrecognized ctor:"+t)}let jt=null;function Bt(){return jt||(jt={"image/crn":n.crn&&n.crn(),"image/ktx2":n.ktx2&&n.ktx2(),"image/cttf":n.ktx2&&n.ktx2(),"draco":n.draco&&n.draco()}),jt}class qt{constructor(t,n,r){this.i=t,this.o=n||e.GLTFLoader,this.u=r,this.h=Bt()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,n,r=0,a=0,i){return n?(a||(a=n.byteLength),this.m(t,n,r,a,i)):e.Ajax.getArrayBuffer(t,{}).then((e=>{const n=e.data;return a||(a=n.byteLength),this.m(t,n,r,a)}))}m(t,e,n,r,a){const i=a&&a.maxTextureSize,o=this.p(e,n,r,t);if(o.error)return Promise.resolve(o);const s=t.substring(0,t.lastIndexOf("/")),c=new this.o(s,o.glb,{transferable:!0,requestImage:this.i,decoders:this.h,supportedFormats:this.u,maxTextureSize:i});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${_}t}-${_}n}-${_}r}\`;const a=c.transferables;for(let t=0;t<o.transferables.length;t++)a.indexOf(o.transferables[t])<0&&a.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:a,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}p(t,e,n,r){const a=new DataView(t,e,n),i=a.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,s=a.getUint32(12,!0),c=a.getUint32(16,!0),u=a.getUint32(20,!0),l=a.getUint32(24,!0),f=28+e;u>=570425344?(f-=8,o=s,u=c,l=0,s=0,c=0):l>=570425344&&(f-=4,o=u,u=s,l=c,s=0,c=0);const h=[t];let y,d,b;if(s>0?(y=xt(t,f,s),f+=s,o=y.BATCH_LENGTH):y={"BATCH_LENGTH":o},c>0&&(f+=c),u>0&&(d=_t(t,f,u),f+=u,l>0)){const e=It(0,f,l);b=t.slice(e.offset,e.offset+e.byteLength),f+=l,h.push(b)}const m=y.BATCH_LENGTH,p={};if(y&&y.BATCH_ID){p.BATCH_ID=Ct(y.BATCH_ID,t,undefined.offset,m);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:o,transferables:h,featureTable:y,batchTable:d,batchTableBin:b,b3dm:p,glb:{buffer:t,byteOffset:f,byteLength:a.byteLength+a.byteOffset-f}}}v(){return null}}class Rt{constructor(t,n,r,a){this.i=t,this.o=n||e.GLTFLoader,this.u=r,this.h=Bt(),this.M=a}load(t,n,r=0,a=0,i){return n?(a||(a=n.byteLength),this.m(t,n,r,a,i)):e.Ajax.getArrayBuffer(t,{}).then((e=>{const n=e.data;return a||(a=n.byteLength),this.m(t,n,r,a)}))}m(t,e,n,r,a){return this.T(t,e,n,r,a).then((({gltf:a,transferables:i})=>{const o=this.A(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete a.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:a})}))}T(t,n,r,a,i){const o=i&&i.maxTextureSize,s={transferable:!0,requestImage:this.i,decoders:this.h,supportedFormats:this.u,maxTextureSize:o},c=new DataView(n,r,a),u=32+c.getUint32(12,!0)+c.getUint32(16,!0)+c.getUint32(20,!0)+c.getUint32(24,!0);if(0===c.getUint32(28,!0)){let a=dt(new Uint8Array(n,u+r,c.byteLength-u));-1==a.indexOf("://")&&(a=t.substring(0,t.lastIndexOf("/"))+"/"+a);return a.indexOf(".glb")>0?e.Ajax.getArrayBuffer(a,{}).then((t=>this.k(a,{buffer:t.data,byteOffset:0},s))):e.Ajax.getJSON(a,{}).then((t=>this.k(a,t,s)))}{const e={buffer:n,byteOffset:u+r,byteLength:c.byteLength-u};return this.k(t,e,s)}}k(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),a=new this.o(r,e,n);return a.load({skipAttributeTransform:!0}).then((n=>{let r=0,i=0;return e.buffer&&(r=e.byteOffset||0,i=e.byteLength||0),n.url=\`${_}t}-${_}r}-${_}i}\`,{transferables:a.transferables,gltf:n}}))}A(t,e,n,r){const a=new DataView(t,e,n),i=a.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,32+e,o),f={},h=s.INSTANCES_LENGTH;if(s.POSITION){const{byteOffset:e}=s.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(f.POSITION.array.buffer)}else if(s.POSITION_QUANTIZED){const e=s.QUANTIZED_VOLUME_OFFSET,n=s.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=s.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.O(new Uint16Array(t,r+c.offset,3*h),e,n)},o.push(f.POSITION.array.buffer)}if(s.BATCH_ID){f.BATCH_ID=Ct(s.BATCH_ID,t,c.offset,h);const e=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(s.NORMAL_UP){let{byteOffset:e}=s.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(f.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(f.NORMAL_RIGHT.array.buffer)}else if(s.NORMAL_UP_OCT32P){let{byteOffset:e}=s.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.S(new Uint16Array(t,e+c.offset,2*h))},o.push(f.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.S(new Uint16Array(t,e+c.offset,2*h))},o.push(f.NORMAL_RIGHT.array.buffer)}if(s.SCALE){const{byteOffset:e}=s.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},o.push(f.SCALE.array.buffer)}else if(s.SCALE_NON_UNIFORM){const{byteOffset:e}=s.SCALE_NON_UNIFORM;f.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(f.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:l,featureTable:s,i3dm:f,transferables:o}}S(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let a=0;a<e;a++)Vt(r,t[2*a],t[2*a+1],65535),n[3*a]=r[0],n[3*a+1]=r[1],n[3*a+2]=r[2];return n}O(t,e,n){return zt(new Float32Array(t.length),t,e,n)}v(){return null}}function Vt(t,e,n,r){if(t[0]=Gt(e,r),t[1]=Gt(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*$t(e),t[1]=(1-Math.abs(e))*$t(t[1])}return y(t,t)}function Gt(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function $t(t){return t<0?-1:1}class Xt{constructor(){}load(t,n,r=0,a=0){return n?(a||(a=n.byteLength),this.m(t,n,r,a)):e.Ajax.getArrayBuffer(t,{}).then((e=>{const n=e.data;return a||(a=n.byteLength),this.m(t,n,r,a)}))}m(t,e,n,r){return this._(e,n,r,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}_(t,e,n,r){const a=new DataView(t,e,n),i=a.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,e+28,o),f=s.QUANTIZED_VOLUME_OFFSET,h=s.QUANTIZED_VOLUME_SCALE,y=s.POINTS_LENGTH;let d,b={};if(s.extensions&&s.extensions["3DTILES_draco_point_compression"]){b=s.extensions["3DTILES_draco_point_compression"],d=new DataView(t,b.byteOffset+c.offset,b.byteLength);const e={attributes:b.properties,useUniqueIDs:!1};return this.I||(this.I=Bt().draco),this.I(d,e).then((e=>{const n=e.attributes;!s.POSITION&&!s.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=s.POSITION,n.POSITION_QUANTIZED=s.POSITION_QUANTIZED),!(s.RGB||s.RGBA||s.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=s.RGB,n.RGBA=s.RGBA,n.RGB565=s.RGB565),!s.NORMAL&&!s.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=s.NORMAL,n.NORMAL_OCT16P=s.NORMAL_OCT16P);const r=this.F(t,e.attributes,c.offset,y,o,f,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Nt(t.constructor),array:t},o.push(t.buffer)}else if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?r.BATCH_ID=Ct(s.BATCH_ID,t,c.offset,y):r.BATCH_ID=Ht(y);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:r,transferables:o}}))}const m=this.F(t,s,c.offset,y,o,f,h);if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?m.BATCH_ID=Ct(s.BATCH_ID,t,c.offset,y):m.BATCH_ID=Ht(y);const e=m.BATCH_ID.array&&m.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:m,transferables:o})}F(t,e,n,r,a,i,o){const s={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},a.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:u}=e.POSITION_QUANTIZED;c=c||0;const l=u?0:n;s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.O(u||new Uint16Array(t,c+l,3*r),i,o)},a.push(s.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}s.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},a.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}s.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},a.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}s.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},a.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}s.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},a.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}s.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},a.push(o.buffer)}return s}O(t,e,n){return zt(new Float32Array(t.length),t,e,n)}v(){return null}}function Ht(t){const e=(n=t)<256?Uint8Array:n<65536?Uint16Array:Uint32Array;var n;const r=new e(t);for(let e=0;e<t;e++)r[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Nt(e),array:r}}class Jt{constructor(t,n,r,a){this.u=r,this.i=t,this.o=n||e.GLTFLoader,this.M=a}load(t,n,r=0,a=0,i){return n?this.m(t,n,r,a,i):e.Ajax.getArrayBuffer(t,{}).then((e=>{const n=e.data;return this.m(t,n,r,a)}))}m(t,e,n,r,a){r||(r=e.byteLength);const i=this.C(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new qt(this.i,this.o,this.u);else if("i3dm"===i[n].magic)r=new Rt(this.i,this.o,this.u,this.M);else if("pnts"===i[n].magic)r=new Xt;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new Jt(this.i,this.o,this.u,this.M)}o.push(r.load(t,e,i[n].offset,i[n].byteLength,a).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}C(t,e,n,r){const a=new DataView(t,n,r),i=a.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===a.byteLength)return[];const o=[],s=a.getUint32(12,!0);let c=16;for(let e=0;e<s;e++){const e=Ot(a,c),r=a.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}function Yt(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,a=r.length;n<a;n++){const a=[];ne(r[n],a,t,e)}}}const Kt=[],Qt=[],Zt=[],Wt=[0,0,0],te=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),ee=[1,1,1];function ne(t,e,n,r){const a=e.slice(0);if(t.matrix)a.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(Kt,t.translation||Wt),n=function(t,e){var n=e[0],r=e[1],a=e[2],i=e[3],o=n+n,s=r+r,c=a+a,u=n*o,l=r*o,f=r*s,h=a*o,y=a*s,d=a*c,b=i*o,m=i*s,p=i*c;return t[0]=1-f-d,t[1]=l+p,t[2]=h-m,t[3]=0,t[4]=l-p,t[5]=1-u-d,t[6]=y+b,t[7]=0,t[8]=h+m,t[9]=y-b,t[10]=1-u-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(Qt,t.rotation||te),r=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(Zt,t.scale||ee);i(r,n,r);const o=i([],e,r);a.push(o)}if(t.children&&t.children.length)for(let e=0,i=t.children.length;e<i;e++)ne(t.children[e],a,n,r);if(void 0!==t.mesh){const e=t.mesh,i=n.meshes[e];if(i){const t=a.slice(0),o=i.primitives;for(let a=0,i=o.length;a<i;a++){const i=o[a];i&&(i.matrices=t,r(i,e,a,n))}}}}function re(t,n){let{byteOffset:r,byteStride:a,count:i}=t;const{componentType:o,itemSize:s}=t,c=t.array.buffer,u=o?e.GLTFLoader.getTypedArrayCtor(o):t.array.constructor;if(r=void 0===r?t.array.byteOffset:r,a=a||0,i=i||t.array.length/s,(!a||a===s*u.BYTES_PER_ELEMENT)&&r%u.BYTES_PER_ELEMENT==0){const t=new u(c,r,i*s);for(let e=0;e<i*s;e+=s){n(new u(t.buffer,r+e*u.BYTES_PER_ELEMENT,s),e/s)}return}const l=new Uint8Array(s*u.BYTES_PER_ELEMENT);a||(a=s*u.BYTES_PER_ELEMENT);for(let t=0;t<i;t++){const e=new Uint8Array(c,a*t+r,s*u.BYTES_PER_ELEMENT);l.set(e);n(new u(l.buffer),t),e.set(l)}}var ae=ce("DXT1"),ie=ce("DXT3"),oe=ce("DXT5"),se=ce("DX10");function ce(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var ue=M((function(t){var e,n,r=new Int32Array(t,0,31);if(542327876!==r[0])throw new Error("Invalid magic number in DDS header");if(4&!r[20])throw new Error("Unsupported format, must contain a FourCC code");var a=r[21];switch(a){case ae:e=8,n="dxt1";break;case ie:e=16,n="dxt3";break;case oe:e=16,n="dxt5";break;case 116:n="rgba32f";break;case se:var i=new Uint32Array(t.slice(128,148));n=i[0];var o=i[1];if(i[2],i[3],i[4],3!==o||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(s=a,String.fromCharCode(255&s,s>>8&255,s>>16&255,s>>24&255)))}var s;var c=r[2],u=1;131072&c&&(u=Math.max(1,r[7]));var l=!1;512&r[28]&&(l=!0);var f,h=r[4],y=r[3],d=r[1]+4,b=h,m=y,p=[];a===se&&(d+=20);if(l)for(var g=0;g<6;g++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");h=b,y=m;for(var v=Math.log(h)/Math.log(2)+1,w=0;w<v;w++)f=h*y*16,p.push({offset:d,length:f,shape:[h,y]}),w<u&&(d+=f),h=Math.floor(h/2),y=Math.floor(y/2)}else for(w=0;w<u;w++)f=Math.max(4,h)/4*Math.max(4,y)/4*e,p.push({offset:d,length:f,shape:[h,y]}),d+=f,h=Math.floor(h/2),y=Math.floor(y/2);return{shape:[b,m],images:p,format:n,flags:c,cubemap:l}})),le=Math.abs,fe=Math.sin,he=Math.cos,ye=Math.tan,de=Math.atan,be=Math.atan2,me=Math.sqrt,pe=Math.log,ge=Math.hypot,ve=Math.sinh,we=Math.cosh,Me=1/0;function Te(t){var e,n,r,a,i,o,s=[],c=[],u=[],l=[];function f(t,e){for(var n,r=2*he(2*e),a=t.length-1,i=t[a],o=0;--a>=0;)n=r*i-o+t[a],o=i,i=n;return e+n*fe(2*e)}function h(t,e,n){for(var r,a,i=fe(e),o=he(e),s=ve(n),c=we(n),u=2*o*c,l=-2*i*s,f=t.length-1,h=t[f],y=0,d=0,b=0;--f>=0;)r=d,a=y,h=u*(d=h)-r-l*(y=b)+t[f],b=l*d-a+u*y;return[(u=i*c)*h-(l=o*s)*b,u*b+l*h]}t.es,i=a=(r=t.es/(1+me(1-t.es)))/(2-r),s[0]=a*(2+a*(-2/3+a*(a*(116/45+a*(26/45+a*(-2854/675)))-2))),c[0]=a*(a*(2/3+a*(4/3+a*(-82/45+a*(32/45+a*(4642/4725)))))-2),i*=a,s[1]=i*(7/3+a*(a*(-227/45+a*(2704/315+a*(2323/945)))-1.6)),c[1]=i*(5/3+a*(-16/15+a*(-13/9+a*(904/315+a*(-1522/945))))),i*=a,s[2]=i*(56/15+a*(-136/35+a*(-1262/105+a*(73814/2835)))),c[2]=i*(-26/15+a*(34/21+a*(1.6+a*(-12686/2835)))),i*=a,s[3]=i*(4279/630+a*(-332/35+a*(-399572/14175))),c[3]=i*(1237/630+a*(a*(-24832/14175)-2.4)),i*=a,s[4]=i*(4174/315+a*(-144838/6237)),c[4]=i*(-734/315+a*(109598/31185)),i*=a,s[5]=i*(601676/22275),c[5]=i*(444337/155925),i=a*a,e=t.k0/(1+a)*(1+i*(1/4+i*(1/64+i/256))),u[0]=a*(a*(2/3+a*(-37/96+a*(1/360+a*(81/512+a*(-96199/604800)))))-.5),l[0]=a*(.5+a*(-2/3+a*(5/16+a*(41/180+a*(-127/288+a*(7891/37800)))))),u[1]=i*(-1/48+a*(-1/15+a*(437/1440+a*(-46/105+a*(1118711/3870720))))),l[1]=i*(13/48+a*(a*(557/1440+a*(281/630+a*(-1983433/1935360)))-.6)),i*=a,u[2]=i*(-17/480+a*(37/840+a*(209/4480+a*(-5569/90720)))),l[2]=i*(61/240+a*(-103/140+a*(15061/26880+a*(167603/181440)))),i*=a,u[3]=i*(-4397/161280+a*(11/504+a*(830251/7257600))),l[3]=i*(49561/161280+a*(-179/168+a*(6601661/7257600))),i*=a,u[4]=i*(-4583/161280+a*(108847/3991680)),l[4]=i*(34729/80640+a*(-3418889/1995840)),i*=a,u[5]=i*(-20648693/638668800),l[5]=.6650675310896665*i,o=f(c,t.phi0),n=-e*(o+function(t,e){var n,r=2*he(e),a=t.length-1,i=t[a],o=0;for(;--a>=0;)n=r*i-o+t[a],o=i,i=n;return fe(e)*n}(l,2*o)),t.fwd=function(t,r){var a,i,o,s,u,y=t.phi,d=t.lam;y=f(c,y),a=fe(y),i=he(y),s=fe(d),o=he(d),y=be(a,o*i),d=be(s*i,ge(a,i*o)),d=function(t){var e=le(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*pe(e)/n}(e*(1+e/(ge(1,e)+1))),t<0?-e:e}(ye(d)),u=h(l,2*y,2*d),y+=u[0],d+=u[1],le(d)<=2.623395162778?(r.y=e*y+n,r.x=e*d):r.x=r.y=Me},t.inv=function(t,r){var a,i,o,c,l,y=t.y,d=t.x;y=(y-n)/e,le(d/=e)<=2.623395162778?(y+=(l=h(u,2*y,2*d))[0],d+=l[1],d=de(ve(d)),a=fe(y),i=he(y),c=fe(d),o=he(d),d=be(c,o*i),y=be(a*o,ge(c,o*i)),r.phi=f(s,y),r.lam=d):r.phi=r.lam=Me}}const Ae=Math.PI/180,ke=6378137*Math.PI/180,Oe=85.0511287798,Se={};function xe(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=Oe,r=e[0],a=Math.max(Math.min(n,e[1]),-n);let i;i=0===a?0:Math.log(Math.tan((90+a)*Ae/2))/Ae;return t[0]=r*ke,t[1]=i*ke,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return _e(t,e);if("baidu"===n)return _e(t,e);throw new Error("unsupported projection:"+n)}{if(!(!r||4326===r.wkid))return function(t,e){return t[0]=e[0],t[1]=e[1],t}(t,e);const a=JSON.stringify(n);let i=Se[a];return i||(i=Se[a]=function(t){const e={a:Fe,es:Ce,x0:lt(t.falseEasting)?5e5:t.falseEasting,y0:lt(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*Ie,phi0:(t.latitudeOfOrigin||0)*Ie,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Te(e);const n={lam:0,phi:0},r={};let a=0,i=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*Ie-e.lam0,n.phi=e.originPhi0*Ie,e.fwd(n,r),a=e.a*r.x+e.x0,i=e.a*r.y+e.y0);return{project:function(t,o){n.lam=t[0]*Ie-e.lam0,n.phi=t[1]*Ie,e.fwd(n,r);const s=e.a*r.x+e.x0-a,c=e.a*r.y+e.y0-i;return o[0]=s,o[1]=c,o}}}(n)),i.project(e,t)}}function _e(t,e){return t[0]=e[0],t[1]=e[1],t}const Ie=.017453292519943295,Fe=6378137,Ce=.0066943799901413165;const Ee=a([]),Ue=Bt().draco,Ne=Bt().ktx2,ze={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},De={"position":{name:"POSITION",accessor:{"componentType":5126,"type":"VEC3"}},"normal":{name:"NORMAL",accessor:{"componentType":5126,"type":"VEC3"}},"uv0":{name:"TEXCOORD_0",accessor:{"componentType":5126,"type":"VEC2"}},"color":{name:"COLOR_0",accessor:{"componentType":5121,"type":"VEC4"}},"uv-region":{name:"uvRegion",accessor:{"componentType":5123,"type":"VEC4"}},"feature-index":{name:"_BATCHID",accessor:{"componentType":5125,"type":"SCALAR"}},"faceRange":{name:"faceRange",accessor:{"componentType":5125,"type":"VEC2"}}};function Pe(t,n,r,i,o,s){const c=[],u=[],l=[];for(let n=0;n<t.meshes.length;n++){const{geometry:r,material:a}=t.meshes[n],i=e.Ajax.getArrayBuffer(r.url,s);i.xhr.url=r.url,l.push(i.xhr);const o=i.then((t=>({buffer:t})));c.push(o);const f=[];if($e(a,f),f.length){const t=f.map((t=>{const n=e.Ajax.getArrayBuffer(t.url,s);return n.xhr.url=t.url,l.push(n.xhr),n.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));c.push(...t)}u[n]=f.length}const f=Promise.all(c).then((e=>{for(let t=0;t<e.length;t++)if(!e[t]||!e[t].buffer)return Promise.resolve(null);const s=[];let c=0;for(let t=0;t<u.length;t++){const n=u[t];s.push({geoBuffer:{data:e[c].buffer.data},textureBuffers:e.slice(c+1,n+c+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),c+=1+n}const l=function(t,e,n,r,i,o){const s={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},c=[];for(let u=0;u<t.meshes.length;u++){let{material:l}=t.meshes[u];const{geometry:f}=t.meshes[u];let h;const y=e[u].geoBuffer.data;if(!y)continue;h=Qe(y)?je(s,u,f,y,t.transform,t.center,i,o):qe(s,u,f,y,t.transform,t.center,i,o),c.push(h),s.nodes[u]={mesh:u,nodeIndex:u,matrix:a([])},s.scenes[0].nodes[u]=s.nodes[u],l||(l=ze);const d=Ve(u,s,l,e[u].textureBuffers,n,r);c.push(d)}return Promise.all(c).then((()=>({gltf:s,featureTable:{BATCH_LENGTH:0},transferables:s.transferables})))}(t,s,n,o,r,i);return l}));return f.xhr=l,f}const Le={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function je(t,e,n,r,a,i,o,s){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=De[e];if(!r)return t;return t[r.name||e]=n,t}),{});return Ue(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>Re(n,t,e,a,i,o,s)))}const Be={position:function(t,e,n){const r=3*t.vertexCount,a=new Float32Array(e,n,r);return t.position={array:a,componentType:5126,itemSize:3,count:r/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},n+=4*r},normal:function(t,e,n){const r=3*t.vertexCount,a=new Float32Array(e,n,r);return t.normal={array:a,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,a=new Float32Array(e,n,r);return t.uv0={array:a,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,a=new Uint8Array(e,n,r);return t.color={array:a,componentType:5121,itemSize:4,count:r/4,type:"VEC4"},n+=r},featureId:function(t,e,n){return n+=8*t.featureCount},id:function(t,e,n){return n+=8*t.featureCount},faceRange:function(t,e,n){const r=2*t.featureCount,a=new Uint32Array(e,n,r);return t.faceRange={array:a,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function qe(t,e,n,r,a,i,o,s){const c={vertexCount:0},u=new DataView(r);try{let t=0;c.vertexCount=u.getUint32(t,1),t+=4,c.featureCount=u.getUint32(t,1),t+=4;const e=n.info.ordering?null:n.info;if(e){const n=[];for(const t in e)"offset"!==t&&""!==t&&n.push(t);for(let e=0;e<n.length;e++)Be[n[e]]?t=Be[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let a=e.ordering,i=e.featureAttributeOrder;const o=null;o&&o.geometryData&&o.geometryData[0]&&o.geometryData[0].params;for(let e=0;e<a.length;e++){const n=Be[a[e]];n||console.log(a[e]),t=n(c,r,t)}for(let e=0;e<i.length;e++){const n=Be[i[e]];n||console.log(i[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const l={};for(const t in c){const e=De[t]&&De[t].name;e&&(l[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(f=e)<=255?Uint8Array:f<=65535?Uint16Array:Uint32Array,r=new n(l.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,a=t[e],i=t[e+1];for(let t=a;t<=i;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}l._BATCHID={componentType:Lt(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var f;return Re({attributes:l},t,e,a,i,o,s)}function Re(t,e,n,r,a,i,s){const c={attributes:t.attributes,material:n,indices:t.indices,mode:4};!function(t){const e=t.array,n=t.meta&&t.meta["i3s-scale_x"],r=t.meta&&t.meta["i3s-scale_y"];if(n&&r&&(1!==n||1!==r))for(let t=0;t<e.length;t+=3)e[t]*=n.value,e[t+1]*=r.value}(t.attributes.POSITION);const u=function(t,e,n,r,a){let i,s=[0,0,0,1];const c=[0,0],u=xe([],n,r,a);u[2]=n[2];const l=e&&o(Ee,e);return re(t,(t=>(s[0]=t[0],s[1]=t[1],s[2]=t[2],l||(s=b(s,s,e)),n&&h(s,s,n),xe(c,s,r,a),i=s[2],t[0]=c[0]-u[0],t[1]=c[1]-u[1],t[2]=i-u[2],t))),u}(t.attributes.POSITION,r,a,i,s);e.meshes[n]={primitives:[c],index:n},e.extensions.MAPTALKS_RTC={projCenter:u},e.extensions.CESIUM_RTC={rtcCoord:a};for(const n in t.attributes)Ke(e.transferables,t.attributes[n].array.buffer);return t.indices&&Ke(e.transferables,t.indices.array.buffer),c}function Ve(t,e,n,r,a,i){const o=r.map((t=>function(t,e,n,r,a){if("dds"===e){const e=ue(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),a="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Le,format:a})}if("png"===e||"jpg"===e)return function(t,e){Xe||(Xe=new OffscreenCanvas(2,2),He=Xe.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;Je(n)||(n=Ye(n)),Je(r)||(r=Ye(r));const a=e;a&&(n=Math.min(a,n),r=Math.min(a,r)),Xe.width=n,Xe.height=r,He.drawImage(t,0,0,n,r),t.close();const i=He.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(i.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,a).then((t=>{t.mimeType=n;return{image:t,sampler:Le,format:6408}}));if("ktx2"===e)return Ne(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Le,format:t.format})));return null}(t.data,t.format,t.mimeType,a,i).then((t=>{if(t.image)if(t.image.array)Ke(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)Ke(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(o).then((r=>{Ge(t,e,n,r)}))}function Ge(t,e,n,r){const a=JSON.parse(JSON.stringify(n)),i=e.textures;r.ptr||(r.ptr=0);for(const t in n)n[t]&&n[t].url?(i.push(r[r.ptr++]),a[t]={index:i.length-1},void 0!==n[t].factor&&(a[t].scale=n[t].factor)):ft(n[t])&&(a[t]=Ge(-1,e,n[t],r));return t>=0&&(e.materials[t]=a),a}function $e(t,e){for(const n in t)t[n]&&t[n].url?e.push({url:t[n].url,mimeType:t[n].mimeType,format:t[n].format}):ft(t[n])&&$e(t[n],e)}let Xe,He;function Je(t){return!(t&t-1)&&0!==t}function Ye(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Ke(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function Qe(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}var Ze="undefined"!=typeof Float32Array?Float32Array:Array;function We(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var tn=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t};!function(){var t=function(){var t=new Ze(3);return Ze!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const en=[];const nn=[],rn=[],an=[],on=[],sn=[],cn=[],un=[];function ln(t,e,n,r,a,i){We(on,t[3*e],t[3*e+1],t[3*e+2]),We(sn,t[3*n],t[3*n+1],t[3*n+2]),We(cn,t[3*r],t[3*r+1],t[3*r+2]);const o=tn(nn,cn,sn),s=tn(rn,on,sn),c=function(t,e,n){var r=e[0],a=e[1],i=e[2],o=n[0],s=n[1],c=n[2];return t[0]=a*c-i*s,t[1]=i*o-r*c,t[2]=r*s-a*o,t}(an,o,s);!function(t,e){var n=e[0],r=e[1],a=e[2],i=n*n+r*r+a*a;i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i)}(un,c),a[3*e]=a[3*e]||0,a[3*n]=a[3*n]||0,a[3*r]=a[3*r]||0,a[3*e+1]=a[3*e+1]||0,a[3*n+1]=a[3*n+1]||0,a[3*r+1]=a[3*r+1]||0,a[3*e+2]=a[3*e+2]||0,a[3*n+2]=a[3*n+2]||0,a[3*r+2]=a[3*r+2]||0,a[3*e]+=un[0],a[3*n]+=un[0],a[3*r]+=un[0],a[3*e+1]+=un[1],a[3*n+1]+=un[1],a[3*r+1]+=un[1],a[3*e+2]+=un[2],a[3*n+2]+=un[2],a[3*r+2]+=un[2],i[e]+=1,i[n]+=1,i[r]+=1}const fn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],hn=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],yn=2*Math.PI*6378137/360,dn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let bn,mn,pn=!1;if("undefined"!=typeof OffscreenCanvas){try{mn=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}mn&&"undefined"!=typeof createImageBitmap&&(pn=!0)}const gn=a([]),vn=[0,0,0],wn=[],Mn=[],Tn=[],An=[],kn={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},On={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Sn;class xn{constructor(t,e,n,r){this.id=t,this.options=e,this.U=this.requestImage.bind(this),this.N=n,this.D={},r(null,{},[])}P(t){this.L||(this.u=t,this.j=new Xt,this.L=new qt(this.U,e.GLTFLoader,t),this.B=new Rt(this.U,e.GLTFLoader,t))}requestImage(t,e){pn?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{bn.width=t.width,bn.height=t.height,mn.drawImage(t,0,0);const n=mn.getImageData(0,0,bn.width,bn.height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.N("requestImage",{url:t},null,e)}loadTile(t,n){this.P(t.supportedFormats);const{service:r,url:a,arraybuffer:i}=t,o=r.fetchOptions||{};if(o.referrer=t.referrer,o.referrerPolicy=o.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(a)){const e=t.i3sInfo,i=r.maxTextureSize||0,s=Pe(e,t.supportedFormats,this.options.projection,t.projection,i,o);return s.then((t=>{if(delete this.D[a],!t)return void n({status:404,url:a,i3sInfo:e});if(!Object.keys(t.gltf.meshes).length)return void n({status:404,url:a,i3sInfo:e});t.gltf.url=a;const{transferables:i}=t;t.magic="b3dm",this.q(t.gltf),r.compressGeometry&&this.R(t.gltf),n(null,t,i)})),void(this.D[a]=s.xhr)}if(i){delete this.D[a];const e=Ot(new DataView(i),0);if("{"===e[0]||" "===e[0]||"<"===e[0]){const e=function(t,e,n){if(dn){const r=new Uint8Array(t,e,n);return dn.decode(r)}return dt(new Uint8Array(t,e,n))}(i,0,i.byteLength),r=JSON.parse(e);r.accessors?this.V(r,a,t,"gltf",n):this.G(t.rootIdx,r,i,a,n)}else this.V(i,a,t,e,n)}else{let i=r.urlParams;i&&(i=(a.indexOf("?")>0?"&":"?")+i);const s=a.replace(/\\+/g,"%2B");let c=e.Ajax.getArrayBuffer(s+(i||""),o);const u=c.xhr;c=c.then((e=>{delete this.D[a],e&&e.status?n(e):(t.arraybuffer=e&&e.data,this.loadTile(t,n))})).catch((t=>{delete this.D[a],n(t)})),this.D[a]=u}}V(t,n,r,a,i){a=a&&a.toLowerCase();const{service:o}=r;if("b3dm"===a){this.L.load(n,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{if(t.error)return void i(t);const{content:e,transferables:n}=this.$(t,r);this.q(e.gltf),o.compressGeometry&&this.R(e.gltf),i(null,e,n)})).catch((t=>{i(t)}))}else if("pnts"===a){const e=r.transform||gn;this.j.load(n,t).then((t=>{const{content:n,transferables:a}=this.X(t,e,r.rootIdx);this.H(n),i(null,n,a)}))}else if("i3dm"===a){const e=r.transform||gn;this.B.load(n,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:n,transferables:a}=this.J(t,e,r.rootIdx);this.q(n.gltf),o.compressGeometry&&this.R(n.gltf),i(null,n,a)}))}else if("cmpt"===a){new Jt(this.U,e.GLTFLoader,this.u,o.maxTextureSize||0).load(n,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:e,transferables:n}=this.Y(t,r);this.K(e),o.compressGeometry&&this.Z(e),i(null,e,n)})).catch((t=>{i(t)}))}else if("gltf"===a){this.h||(this.h=Bt());const a=n.substring(0,n.lastIndexOf("/")),s=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t,c=new e.GLTFLoader(a,s,{transferable:!0,requestImage:this.U,decoders:this.h,supportedFormats:this.u,maxTextureSize:o.maxTextureSize||0});c.load({skipAttributeTransform:!1}).then((t=>{t.url=n,this.W(t,null,r),this.q(t),o.compressGeometry&&this.R(t),i(null,{magic:"gltf",gltf:t},c.transferables)}))}else i(new Error("unsupported tile format: "+a))}K(t){t.content?t.content.forEach((t=>{this.K(t)})):this.q(t.gltf)}Z(t){t.content?t.content.forEach((t=>{this.Z(t)})):this.R(t.gltf)}tt(t,e){if(this.et(t,e)&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=e.length,r=this.nt()?Sn.subarray(0,n):e,a=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const a=en;a.length<t.length/3&&(a.length=t.length/3),a.fill(0,0,t.length/3);const i=void 0===e.length?e:e.length;for(let n=0;n<i/3;n++)void 0===e.length?ln(t,3*n,3*n+1,3*n+2,r,a):ln(t,e[3*n],e[3*n+1],e[3*n+2],r,a);const o=r.getLength?r.getLength():r.length;for(let t=0;t<o;t+=3){const e=a[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(r,t.indices.array,new Float32Array(r.length));t.attributes.NORMAL={array:a,byteLength:a.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:a.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}R(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const t in e){e[t].primitives.forEach((t=>{t.compressed_int16_params={};const e=t.attributes;for(const n in e)if(kn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=yn,t.compressed_int16_params.compressed_ratio=r);const a=Un(e[n].array,r,e[n].min,e[n].max,n);if(!a)continue;const{array:i,range:o}=a;e[n].componentType=5124,e[n].array=i,t.compressed_int16_params[n]=o}}))}}q(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const n in e){e[n].primitives.forEach((e=>{this.tt(e,t)}))}}H(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(kn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=yn,t.compressed_int16_params.compressed_ratio=r);const{array:a,range:i}=Un(e[n].array,r,e[n].min,e[n].max,n);e[n].array=a,t.compressed_int16_params[n]=i}}rt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const a={boundingVolume:{sphere:[r.boundingSphere.center.x,r.boundingSphere.center.y,r.boundingSphere.center.z,r.boundingSphere.radius]},content:{uri:r.childTile},geometricError:r.boundingSphere.radius/r.rangeList*16,refine:"REPLACE"};e.push(a)}return e}G(t,e,n,r,a){return e.capabilities,void a(null,e)}Y(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},a=[];for(let t=0;t<n.length;t++){const{magic:i}=n[t];if("b3dm"===i){const{content:i,transferables:o}=this.$(n[t],e);Cn(a,o),r.content.push(i)}else if("i3dm"===i){const{transform:i,rootIdx:o}=e,{content:s,transferables:c}=this.J(n[t],i,o);Cn(a,c),r.content.push(s)}else if("pnts"===i){const{transform:i,rootIdx:o}=e,{content:s,transferables:c}=this.X(n[t],i,o);Cn(a,c),r.content.push(s)}else if("cmpt"===i){const{content:i,transferables:o}=this.Y(n[t],e);Cn(a,o),r.content.push(i)}}return{content:r,transferables:a}}$(t,e){const{gltf:n,transferables:r,featureTable:a}=t;return this.W(n,a,e),delete t.transferables,{content:t,transferables:r}}W(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;const e="visited";let n=1;const r=[];for(const a in t.meshes){const i=t.meshes[a],{primitives:o}=i;if(o)for(let t=0;t<o.length;t++){const a=o[t].attributes&&o[t].attributes.POSITION;if(!a||!a.array)continue;a.array.buffer[e]||(a.array.buffer[e]=n++);const i=n-1+"-"+(a.byteOffset||0);if(r.indexOf(i)>=0)return!0;r.push(i)}}return!1}(t);this.it(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.ot(t,e,n.upAxis,n.transform)):this.st(t,e,n.upAxis,n.transform)}J(t,e,n){const{featureTable:r}=t,a=t.i3dm,i=r&&r.RTC_CENTER||[0,0,0],s=this.options.projection,c=e&&o(gn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};In(a.POSITION.array,3,i,gn,u);const h=Fn(u);e&&!c&&b(h,h,e);const y=this.ct(h),d=[];xe(d,y,s),d[2]=y[2];const m=l([],h),p=[0,0,0],v=[0,0,0],w=[0,0],M=[1/0,1/0,1/0],T=[-1/0,-1/0,-1/0];re(a.POSITION,(t=>{p[0]=t[0]+i[0],p[1]=t[1]+i[1],p[2]=t[2]+i[2],e&&!c&&b(p,p,e),0===g(p)?f(v,0,0,-6378137):wt(v,p),xe(w,v,s),t[0]=w[0]-d[0],t[1]=w[1]-d[1],t[2]=v[2]-d[2],t[0]<M[0]&&(M[0]=t[0]),t[1]<M[1]&&(M[1]=t[1]),t[2]<M[2]&&(M[2]=t[2]),t[0]>T[0]&&(T[0]=t[0]),t[1]>T[1]&&(T[1]=t[1]),t[2]>T[2]&&(T[2]=t[2])})),a.POSITION.min=M,a.POSITION.max=T,e&&b(h,h,e),t.rtcCenter=m,t.rtcCoord=y,t.projCenter=d,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}X(t,e,n){const{featureTable:r}=t,a=t.pnts,i=r&&r.RTC_CENTER||[0,0,0],s=this.options.projection,c=e&&o(gn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};In(a.POSITION.array,3,i,e,u);const h=Fn(u),y=this.ut(h),d=l([],h),m=[1/0,1/0,1/0],p=[-1/0,-1/0,-1/0];let v=[0,0,0,1];const w=[0,0,0],M=[0,0];re(a.POSITION,(t=>(v[0]=t[0]+i[0],v[1]=t[1]+i[1],v[2]=t[2]+i[2],e&&!c&&(v=b(v,v,e)),0===g(v)?f(w,0,0,-6378137):wt(w,v),xe(M,w,s),t[0]=M[0]-y[0],t[1]=M[1]-y[1],t[2]=w[2]-y[2],t[0]<m[0]&&(m[0]=t[0]),t[1]<m[1]&&(m[1]=t[1]),t[2]<m[2]&&(m[2]=t[2]),t[0]>p[0]&&(p[0]=t[0]),t[1]>p[1]&&(p[1]=t[1]),t[2]>p[2]&&(p[2]=t[2]),t))),a.POSITION.min=m,a.POSITION.max=p,e&&b(h,h,e);const T=this.ct(h);t.rtcCenter=d,t.projCenter=y,t.rtcCoord=T,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}it(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image&&e[t].image.array;if(n&&n.length){const r=n[0],a=n[1],i=n[2],o=n[3];let s=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==a||n[t+2]!==i||n[t+3]!==o){s=!1;break}s&&(e[t].image.color=[r/255,a/255,i/255,o/255],delete e[t].image.array)}}}abortTileLoading(t,e){const n=this.D[t.url];if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t].abort();else n&&n.abort&&n.abort();delete this.D[t.url],e(null)}lt(t,e,n,r){const o=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let s=fn;"X"===(n=n&&n.toUpperCase())?s=hn:"Z"===n&&(s=gn),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),o&&(t.extensions.CESIUM_RTC.center=o),t.extensions.MAPTALKS_RTC={};const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Yt(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=a(wn);t.matrices&&En(e,t.matrices);const n=t.attributes.POSITION.array,u=t.attributes.POSITION.itemSize;i(e,s,e),r&&i(e,r,e),In(n,u,o||vn,e,c,t.compressUniforms)}));const u=Fn(c);return{rtcCenter:o,modelCenter:u,upAxisTransform:s}}ot(t,e,n,r){const{modelCenter:o,upAxisTransform:s,rtcCenter:c}=this.lt(t,e,n),u=this.ut(o);t.extensions.MAPTALKS_RTC.projCenter=u,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ct(o);const f=l([],o);r&&b(o,o,r),t.extensions.CESIUM_RTC.rtcCoord=this.ct(o),c||(Yt(t,(t=>{if(t.attributes&&t.attributes.POSITION){const e=t.attributes.POSITION;if(e.array.buffer.projected&&e.array.buffer.projected[e.byteOffset])return;const n=a(wn);t.matrices&&En(n,t.matrices),i(n,s,n);const r=function(t,e){var n=e[0],r=e[1],a=e[2],i=e[3],o=e[4],s=e[5],c=e[6],u=e[7],l=e[8],f=e[9],h=e[10],y=e[11],d=e[12],b=e[13],m=e[14],p=e[15],g=n*s-r*o,v=n*c-a*o,w=n*u-i*o,M=r*c-a*s,T=r*u-i*s,A=a*u-i*c,k=l*b-f*d,O=l*m-h*d,S=l*p-y*d,x=f*m-h*b,_=f*p-y*b,I=h*p-y*m,F=g*I-v*_+w*x+M*S-T*O+A*k;return F?(F=1/F,t[0]=(s*I-c*_+u*x)*F,t[1]=(a*_-r*I-i*x)*F,t[2]=(b*A-m*T+p*M)*F,t[3]=(h*T-f*A-y*M)*F,t[4]=(c*S-o*I-u*O)*F,t[5]=(n*I-a*S+i*O)*F,t[6]=(m*w-d*A-p*v)*F,t[7]=(l*A-h*w+y*v)*F,t[8]=(o*_-s*S+u*k)*F,t[9]=(r*S-n*_-i*k)*F,t[10]=(d*T-b*w+p*g)*F,t[11]=(f*w-l*T-y*g)*F,t[12]=(s*O-o*x-c*k)*F,t[13]=(n*x-r*O+a*k)*F,t[14]=(b*v-d*M-m*g)*F,t[15]=(l*M-f*v+h*g)*F,t):null}(Mn,n),o=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];re(e,(t=>{b(t,t,n),t[0]=t[0]-f[0],t[1]=t[1]-f[1],t[2]=t[2]-f[2],b(t,t,r),t[0]<o[0]&&(o[0]=t[0]),t[1]<o[1]&&(o[1]=t[1]),t[2]<o[2]&&(o[2]=t[2]),t[0]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])})),e.min=o,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=f)}st(t,e,n,r){const{modelCenter:a,rtcCenter:i}=this.lt(t,e,n,r),o=this.ut(a);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ct(a),Yt(t,(e=>{if(e.attributes&&e.attributes.POSITION){const a=this.et(e,t);if(a){const t=e.attributes.POSITION.array.length;(!Sn||Sn.length<t)&&(Sn=new Float32Array(t))}e.attributes.NORMAL&&this.ft(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.ft(e.attributes.TANGENT,e.matrices,n);const{newPositions:o}=this.ht(e.attributes.POSITION,e.matrices,i,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,a),{componentType:s}=e.attributes.POSITION;5126!==s&&(e.attributes.POSITION.array=new Float32Array(o))}}));for(const e in t.nodes){t.nodes[e].matrix=gn}}ut(t){const e=this.options.projection;"identity"===e?l(Tn,t):0===g(t)?f(Tn,0,0,-6378137):wt(Tn,t),xe(An,Tn,e);const n=Tn[2],r=[];return r[0]=An[0],r[1]=An[1],r[2]=n,r}ft(t,e,n){let r;r="Y"===n?fn:"X"===n?hn:gn;const a=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}([],r);if(En(a,e),o(a,gn))return;const i=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}([],a),s=[];re(t,(t=>(function(t,e,n){var r=e[0],a=e[1],i=e[2];t[0]=r*n[0]+a*n[3]+i*n[6],t[1]=r*n[1]+a*n[4]+i*n[7],t[2]=r*n[2]+a*n[5]+i*n[8]}(s,t,i),y(s,s),l(t,s),s)))}ht(t,e,n,r,i,s,c,u){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const l=a([]);En(l,e);const y=this.options.projection;i=i&&i.toUpperCase();const d=n;let m=null;"Y"===i?m=fn:"X"===i&&(m=hn);let p=[0,0,0,1];const v=[0,0,0],w=[0,0],M=r.projCenter,T=xe([],r.rtcCoord,"EPSG:3857"),A=s&&o(gn,s),k=t.min=t.min||[],O=t.max=t.max||[];f(k,1/0,1/0,1/0),f(O,-1/0,-1/0,-1/0);const S=c||{},{decode_position_min:x,decode_position_normConstant:_}=S;let I=[0,0,0,0],F=1;x&&(I=x),_&&(F=_);const C=[];return re(t,((e,n)=>{if(p[0]=e[0]*F+I[0],p[1]=e[1]*F+I[1],p[2]=e[2]*F+I[2],p=b(p,p,l),m&&(p=b(p,p,m)),d&&h(p,p,d),s&&!A&&(p=b(p,p,s)),0===g(p)?f(v,0,0,-6378137):wt(v,p),u){const t=Sn;xe(w,v,y),t[3*n]=w[0]-T[0],t[3*n+1]=w[0]-T[1],t[3*n+2]=w[0]-T[2]}if(xe(w,v,y),e instanceof Float32Array)e[0]=w[0]-M[0],e[1]=w[1]-M[1],e[2]=v[2]-M[2];else{const n=w[0]-M[0],r=w[1]-M[1],a=v[2]-M[2];5126!==t.componentType&&(C.push(n),C.push(r),C.push(a),C.push(e[3]))}return e[0]<k[0]&&(k[0]=e[0]),e[1]<k[1]&&(k[1]=e[1]),e[2]<k[2]&&(k[2]=e[2]),e[0]>O[0]&&(O[0]=e[0]),e[1]>O[1]&&(O[1]=e[1]),e[2]>O[2]&&(O[2]=e[2]),e})),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:M,newPositions:C}}ct(t){return 0===g(t)?f([],0,0,-6378137):wt([],t)}onRemove(){}nt(){return"EPSG:4326"===this.options.projection||"EPSG:4490"===this.options.projection}et(t,e){if(!t.attributes.POSITION||function(t,e){const n=e.materials[t.material],r=n&&n.extensions&&n.extensions.KHR_materials_unlit;return r}(t,e))return!1;if(t.attributes.TANGENT)return!1;return!!t.attributes.TEXCOORD_0}}const _n=[];function In(t,e,n,r,a,i){const o=i||{},{decode_position_min:s,decode_position_normConstant:c}=o;let u=[0,0,0,0],l=1;s&&(u=s),c&&(l=c);for(let i=0,o=t.length;i<o;i+=e){const{xmin:o,ymin:s,xmax:c,ymax:y,hmin:d,hmax:m}=a;f(_n,t[i]*l+u[0],t[i+1]*l+u[1],t[i+2]*l+u[2]),b(_n,_n,r);const p=h(_n,n,_n);p[0]<o&&(a.xmin=p[0]),p[0]>c&&(a.xmax=p[0]),p[1]<s&&(a.ymin=p[1]),p[1]>y&&(a.ymax=p[1]),e>2&&(p[2]<d&&(a.hmin=p[2]),p[2]>m&&(a.hmax=p[2]))}}function Fn(t){const{xmax:e,ymax:n,xmin:r,ymin:a,hmin:i,hmax:o}=t,s=[(r+e)/2,(a+n)/2,(i+o)/2];return e===-1/0&&(s[0]=0),n===-1/0&&(s[1]=0),o===-1/0&&(s[2]=0),isNaN(s[2])&&(s[2]=0),s}function Cn(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function En(t,e){const n=t;for(let t=e.length-1;t>=0;t--)i(n,e[t],n);return n}function Un(t,e,n,r,a){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let i,o;if(n&&r&&1===e)i=Math.min(...n),o=Math.max(...r);else{const{min:e,max:n}=function(t){let e=1/0,n=-1/0;for(let r=0;r<t.length;r++)t[r]>n&&(n=t[r]),t[r]<e&&(e=t[r]);return{min:e,max:n}}(t);i=e,o=n}return!function(t,e,n,r){for(let a=0;a<t.length;a++){const i=Nn(zn(t[a],e,n),e,n);if(Math.abs(i-t[a])>On[r])return!1}return!0}(t,i,o,a)&&On[a]?null:function(t,e,n){const r=new Int16Array(t.length);for(let a=0;a<t.length;a++)r[a]=zn(t[a],e,n);return{array:r,range:[e,n]}}(t,i,o)}function Nn(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function zn(t,e,n){const r=2*(t-e)/(n-e)-1,a=Math.max(-1,Math.min(1,r));return a<0?32768*a:32767*a}let Dn=0;class Pn{constructor(t){this.workerId=t,this.workers={},this.yt={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},a){if(this.dt(e,n))return;const i=this.bt(e,n),o=r.options,s=this.send.bind(this,t);this.workers[i]=new xn(n,o,s,a)}removeLayer({mapId:t,layerId:e},n){const r=this.dt(t,e),a=this.bt(t,e);delete this.workers[a],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const a=this.dt(t,e);a&&a.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const a=this.dt(t,e);a&&a.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.yt[e];delete this.yt[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,a){const i=a?\`${_}t}-${_}Dn++}\`:null;a&&(this.yt[i]=a),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(i)},r||[])}bt(t,e){return\`${_}t}-${_}e}\`}dt(t,e){const n=this.bt(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new Pn(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[n.command]({actorId:n.actorId,mapId:n.mapId,layerId:n.layerId,params:n.params},((t,n,r)=>{t&&404!==t.status&&204!==t.status&&console.error(t),t instanceof Error&&(t={message:t.message}),e(t,n,r)}))}}(this.exports=this.exports||{},gltfLoader,transcoders));`;function x(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var I={exports:{}},S={exports:{}},C=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},k=Array.prototype.concat,N=Array.prototype.slice,R=S.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];C(i)?e=k.call(e,N.call(i)):e.push(i)}return e};R.wrap=function(t){return function(){return t(R(arguments))}};var E=S.exports,L={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},P=E,U=Object.hasOwnProperty,B=Object.create(null);for(var F in L)U.call(L,F)&&(B[L[F]]=F);var D=I.exports={to:{},get:{}};function j(t,e,n){return Math.min(Math.max(e,t),n)}function z(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}D.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=D.get.hsl(t),n="hsl";break;case"hwb":e=D.get.hwb(t),n="hwb";break;default:e=D.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},D.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var s=2*n;i[n]=parseInt(e.slice(s,s+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:U.call(L,e[1])?((i=L[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=j(i[n],0,255);return i[3]=j(i[3],0,1),i},D.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},D.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},D.to.hex=function(){var t=P(arguments);return"#"+z(t[0])+z(t[1])+z(t[2])+(t[3]<1?z(Math.round(255*t[3])):"")},D.to.rgb=function(){var t=P(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},D.to.rgb.percent=function(){var t=P(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},D.to.hsl=function(){var t=P(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},D.to.hwb=function(){var t=P(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},D.to.keyword=function(t){return B[t.slice(0,3)]};var G=I.exports,H={exports:{}},q={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},V={};for(var $ in q)q.hasOwnProperty($)&&(V[q[$]]=$);var J=H.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var Z in J)if(J.hasOwnProperty(Z)){if(!("channels"in J[Z]))throw new Error("missing channels property: "+Z);if(!("labels"in J[Z]))throw new Error("missing channel labels property: "+Z);if(J[Z].labels.length!==J[Z].channels)throw new Error("channel and label counts mismatch: "+Z);var X=J[Z].channels,W=J[Z].labels;delete J[Z].channels,delete J[Z].labels,Object.defineProperty(J[Z],"channels",{value:X}),Object.defineProperty(J[Z],"labels",{value:W})}J.rgb.hsl=function(t){var e,n,r=t[0]/255,i=t[1]/255,s=t[2]/255,o=Math.min(r,i,s),a=Math.max(r,i,s),c=a-o;return a===o?e=0:r===a?e=(i-s)/c:i===a?e=2+(s-r)/c:s===a&&(e=4+(r-i)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},J.rgb.hsv=function(t){var e,n,r,i,s,o=t[0]/255,a=t[1]/255,c=t[2]/255,h=Math.max(o,a,c),l=h-Math.min(o,a,c),u=function(t){return(h-t)/6/l+.5};return 0===l?i=s=0:(s=l/h,e=u(o),n=u(a),r=u(c),o===h?i=r-n:a===h?i=1/3+e-r:c===h&&(i=2/3+n-e),i<0?i+=1:i>1&&(i-=1)),[360*i,100*s,100*h]},J.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[J.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},J.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-i)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-i-e)/(1-e)||0),100*e]},J.rgb.keyword=function(t){var e=V[t];if(e)return e;var n,r,i,s=1/0;for(var o in q)if(q.hasOwnProperty(o)){var a=q[o],c=(r=t,i=a,Math.pow(r[0]-i[0],2)+Math.pow(r[1]-i[1],2)+Math.pow(r[2]-i[2],2));c<s&&(s=c,n=o)}return n},J.keyword.rgb=function(t){return q[t]},J.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},J.rgb.lab=function(t){var e=J.rgb.xyz(t),n=e[0],r=e[1],i=e[2];return r/=100,i/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(i=i>.008856?Math.pow(i,1/3):7.787*i+16/116))]},J.hsl.rgb=function(t){var e,n,r,i,s,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[s=255*c,s,s];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),i=[0,0,0];for(var h=0;h<3;h++)(r=o+1/3*-(h-1))<0&&r++,r>1&&r--,s=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,i[h]=255*s;return i},J.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,i=n,s=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,i*=s<=1?s:2-s,[e,100*(0===r?2*i/(s+i):2*n/(r+n)),100*((r+n)/2)]},J.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,i=Math.floor(e)%6,s=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*s),c=255*r*(1-n*(1-s));switch(r*=255,i){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},J.hsv.hsl=function(t){var e,n,r,i=t[0],s=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-s)*o,n=s*a,[i,100*(n=(n/=(e=(2-s)*a)<=1?e:2-e)||0),100*(r/=2)]},J.hwb.rgb=function(t){var e,n,r,i,s,o,a,c=t[0]/360,h=t[1]/100,l=t[2]/100,u=h+l;switch(u>1&&(h/=u,l/=u),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),i=h+r*((n=1-l)-h),e){default:case 6:case 0:s=n,o=i,a=h;break;case 1:s=i,o=n,a=h;break;case 2:s=h,o=n,a=i;break;case 3:s=h,o=i,a=n;break;case 4:s=i,o=h,a=n;break;case 5:s=n,o=h,a=i}return[255*s,255*o,255*a]},J.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,i=t[3]/100;return[255*(1-Math.min(1,e*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},J.xyz.rgb=function(t){var e,n,r,i=t[0]/100,s=t[1]/100,o=t[2]/100;return n=-.9689*i+1.8758*s+.0415*o,r=.0557*i+-.204*s+1.057*o,e=(e=3.2406*i+-1.5372*s+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},J.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},J.lab.xyz=function(t){var e,n,r,i=t[0];e=t[1]/500+(n=(i+16)/116),r=n-t[2]/200;var s=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=s>.008856?s:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},J.lab.lch=function(t){var e,n=t[0],r=t[1],i=t[2];return(e=360*Math.atan2(i,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+i*i),e]},J.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},J.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],i=1 in arguments?arguments[1]:J.rgb.hsv(t)[2];if(0===(i=Math.round(i/50)))return 30;var s=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===i&&(s+=60),s},J.hsv.ansi16=function(t){return J.rgb.ansi16(J.hsv.rgb(t),t[2])},J.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},J.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},J.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},J.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},J.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},J.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255,s=Math.max(Math.max(n,r),i),o=Math.min(Math.min(n,r),i),a=s-o;return e=a<=0?0:s===n?(r-i)/a%6:s===r?2+(i-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},J.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,i=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(i=(n-.5*r)/(1-r)),[t[0],100*r,100*i]},J.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},J.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var i,s=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:s[0]=1,s[1]=a,s[2]=0;break;case 1:s[0]=c,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=a;break;case 3:s[0]=0,s[1]=c,s[2]=1;break;case 4:s[0]=a,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=c}return i=(1-n)*r,[255*(n*s[0]+i),255*(n*s[1]+i),255*(n*s[2]+i)]},J.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},J.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},J.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},J.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},J.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},J.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},J.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},J.gray.hsl=J.gray.hsv=function(t){return[0,0,t[0]]},J.gray.hwb=function(t){return[0,100,t[0]]},J.gray.cmyk=function(t){return[0,0,0,t[0]]},J.gray.lab=function(t){return[t[0],0,0]},J.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},J.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var K=H.exports,Y=K;function Q(t){var e=function(){for(var t={},e=Object.keys(Y),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),i=Object.keys(Y[r]),s=i.length,o=0;o<s;o++){var a=i[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function tt(t,e){return function(n){return e(t(n))}}function et(t,e){for(var n=[e[t].parent,t],r=Y[e[t].parent][t],i=e[t].parent;e[i].parent;)n.unshift(e[i].parent),r=tt(Y[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}var nt=K,rt=function(t){for(var e=Q(t),n={},r=Object.keys(e),i=r.length,s=0;s<i;s++){var o=r[s];null!==e[o].parent&&(n[o]=et(o,e))}return n},it={};Object.keys(nt).forEach((function(t){it[t]={},Object.defineProperty(it[t],"channels",{value:nt[t].channels}),Object.defineProperty(it[t],"labels",{value:nt[t].labels});var e=rt(t);Object.keys(e).forEach((function(n){var r=e[n];it[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,i=0;i<r;i++)n[i]=Math.round(n[i]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),it[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var st=G,ot=it,at=[].slice,ct=["keyword","gray","hex"],ht={};Object.keys(ot).forEach((function(t){ht[at.call(ot[t].labels).sort().join("")]=t}));var lt={};function ut(t,e){if(!(this instanceof ut))return new ut(t,e);if(e&&e in ct&&(e=null),e&&!(e in ot))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ut)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var i=st.get(t);if(null===i)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=ot[this.model].channels,this.color=i.value.slice(0,r),this.valpha="number"==typeof i.value[r]?i.value[r]:1}else if(t.length){this.model=e||"rgb",r=ot[this.model].channels;var s=at.call(t,0,r);this.color=mt(s,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in ht))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ht[a];var c=ot[this.model].labels,h=[];for(n=0;n<c.length;n++)h.push(t[c[n]]);this.color=mt(h)}if(lt[this.model])for(r=ot[this.model].channels,n=0;n<r;n++){var l=lt[this.model][n];l&&(this.color[n]=l(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ft(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(lt[t]||(lt[t]=[]))[e]=n})),t=t[0],function(r){var i;return arguments.length?(n&&(r=n(r)),(i=this[t]()).color[e]=r,i):(i=this[t]().color[e],n&&(i=n(i)),i)}}function dt(t){return function(e){return Math.max(0,Math.min(t,e))}}function mt(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}ut.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in st.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return st.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return st.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=ot[this.model].channels,n=ot[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ut(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ut(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ft("rgb",0,dt(255)),green:ft("rgb",1,dt(255)),blue:ft("rgb",2,dt(255)),hue:ft(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ft("hsl",1,dt(100)),lightness:ft("hsl",2,dt(100)),saturationv:ft("hsv",1,dt(100)),value:ft("hsv",2,dt(100)),chroma:ft("hcg",1,dt(100)),gray:ft("hcg",2,dt(100)),white:ft("hwb",1,dt(100)),wblack:ft("hwb",2,dt(100)),cyan:ft("cmyk",0,dt(100)),magenta:ft("cmyk",1,dt(100)),yellow:ft("cmyk",2,dt(100)),black:ft("cmyk",3,dt(100)),x:ft("xyz",0,dt(100)),y:ft("xyz",1,dt(100)),z:ft("xyz",2,dt(100)),l:ft("lab",0,dt(100)),a:ft("lab",1),b:ft("lab",2),keyword:function(t){return arguments.length?new ut(t):ot[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ut(t):st.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ut.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),i=void 0===e?.5:e,s=2*i-1,o=n.alpha()-r.alpha(),a=((s*o==-1?s:(s+o)/(1+s*o))+1)/2,c=1-a;return ut.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*i+r.alpha()*(1-i))}},Object.keys(ot).forEach((function(t){if(-1===ct.indexOf(t)){var e=ot[t].channels;ut.prototype[t]=function(){if(this.model===t)return new ut(this);if(arguments.length)return new ut(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ut((n=ot[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ut[t]=function(n){return"number"==typeof n&&(n=mt(at.call(arguments),e)),new ut(n,t)}}}));var pt=x(ut);function yt(t){return null==t}function bt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function gt(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function wt(t){return"object"==typeof t&&!!t}function vt(t){return"number"==typeof t&&!isNaN(t)}function Tt(t){return t*Math.PI/180}function Mt(t){return t/Math.PI*180}function Ot(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function _t(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const At=[1,1,1,1,2,2,3,0];function xt(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=At[i>>3&7];if(!(64&i)||!n||r+n>e)return null;for(i&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;i=i<<6|63&e}}n+=String.fromCharCode(i)}return n}function It(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function St(t){return t.flat?t.flat(1/0):t.reduce(((t,e)=>t.concat(e)),[])}function Ct(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function kt(t){return 0===t.indexOf("data:")}function Nt(t){const e=t.indexOf("base64,"),n=t.substring(e+7),r=window.atob(n),i=r.length,s=new Uint8Array(i);for(let t=0;t<i;t++)s[t]=r.charCodeAt(t);return s.buffer}function Rt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return t.length}const Et={};function Lt(t,e){if(!Array.isArray(e)){const t=e;e=Et[t]=Et[t]||pt(e).array().map((t=>t/255))}for(let n=0;n<e.length;n++)t[n]=e[n];return 3===e.length&&(t[3]=1),t}var Pt=Object.freeze({__proto__:null,base64URLToArrayBuffer:Nt,extend:bt,flatArr:St,getAbsoluteURL:Ot,getBatchIdArrayType:Ct,isBase64:kt,isFunction:gt,isNil:yt,isNumber:vt,isObject:wt,normalizeColor:Lt,pushIn:Rt,setColumn3:It,sign:_t,stringFromUTF8Array:xt,toDegree:Mt,toRadian:Tt});function Ut(t){return-1===t.indexOf("http://")&&-1===t.indexOf("https://")&&-1===t.indexOf("file://")}function Bt(t){return(t=t||{}).referrerPolicy=t.referrerPolicy||"origin",t.referrer=window&&window.location.href,t}const Ft="undefined"==typeof document?null:document.createElement("canvas");class Dt extends t.worker.Actor{constructor(t,e){super(t),this.mapId=e}initialize(t){t(null)}loadTile(t,e,n){let r=null;e&&e.arraybuffer&&(r=[e.arraybuffer]);const i={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(i,r,n)}abortTileLoading(t,e,n){const r={mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}};this.broadcast(r,null,n)}addLayer(t,e,n){const r={actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}};this.broadcast(r,null,n)}removeLayer(t,e){const n={mapId:this.mapId,layerId:t,command:"removeLayer"};this.broadcast(n,null,e)}requestImage({url:t},e){const n=new Image;n.onload=()=>{if(!this.isActive())return;if(!Ft)return void e(new Error("There is no canvas to draw image!"));const t=function(t){if(jt(t.width)&&jt(t.height))return t;let e=t.width,n=t.height;jt(e)||(e=zt(e));jt(n)||(n=zt(n));const r=document.createElement("canvas");r.width=e,r.height=n,r.getContext("2d").drawImage(t,0,0,e,n);const i=t.src,s=i.lastIndexOf("/")+1,o=i.substring(s);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);Ft.width=t.width,Ft.height=t.height;const r=Ft.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const i=r.getImageData(0,0,t.width,t.height),s={width:t.width,height:t.height,data:new Uint8Array(i.data)};e(null,s,[s.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function jt(t){return!(t&t-1)&&0!==t}function zt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Gt(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,i=r.length;n<i;n++){const i=[];Xt(r[n],i,t,e)}}}const Ht=[],qt=[],Vt=[],$t=[0,0,0],Jt=v.identity([]),Zt=[1,1,1];function Xt(t,e,n,r){const i=e.slice(0);if(t.matrix)i.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=T.fromTranslation(Ht,t.translation||$t),n=T.fromQuat(qt,t.rotation||Jt),r=T.fromScaling(Vt,t.scale||Zt);T.multiply(r,n,r);const s=T.multiply([],e,r);i.push(s)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)Xt(t.children[e],i,n,r);if(void 0!==t.mesh){const e=t.mesh,s=n.meshes[e];if(s){const t=i.slice(0),o=s.primitives;for(let i=0,s=o.length;i<s;i++){const s=o[i];s&&(s.matrices=t,r(s,e,i,n))}}}}function Wt(t,e,n){let{byteOffset:r,byteStride:i}=e;const{componentType:s,itemSize:o}=e,a=e.array.buffer,c=s?g.getTypedArrayCtor(s):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,i=i||0,!i||i===o*c.BYTES_PER_ELEMENT&&r%c.BYTES_PER_ELEMENT==0){const e=new c(a,r+n*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}i||(i=o*c.BYTES_PER_ELEMENT);const h=new Uint8Array(a,i*n+r,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(h),t}function Kt(t,e,n,r){t[4*e]=n[r],t[4*e+1]=n[r+4],t[4*e+2]=n[r+8],t[4*e+3]=n[r+12]}var Yt="#include <gl2_vert>\n\nconst float SHIFT_RIGHT_11 = 1.0 / 2048.0;\n\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\n\nconst float SHIFT_LEFT_11 = 2048.0;\n\nconst float SHIFT_LEFT_5 = 32.0;\n\nconst float NORMALIZE_6 = 1.0 / 64.0;\n\nconst float NORMALIZE_5 = 1.0 / 32.0;\n\n\n\n#ifdef HAS_POSITION\n\n attribute vec3 POSITION;\n\n#endif\n\n\n\n#if defined(HAS_RGB)\n\n attribute vec3 RGB;\n\n#elif defined(HAS_RGBA)\n\n attribute vec4 RGBA;\n\n#elif defined(HAS_RGB565)\n\n attribute float RGB565;\n\n#endif\n\n\n\nuniform vec4 pointColor;\n\nuniform float pointSize;\n\n\n\nuniform mat4 projViewModelMatrix;\n\nuniform float pointOpacity;\n\n\n\nvarying vec4 vColor;\n\n\n\n#ifdef HAS_NORMAL\n\n #ifdef HAS_NORMAL_OCT16P\n\n attribute vec2 NORMAL_OCT16P;\n\n float signNotZero(float value) {\n\n return value >= 0.0 ? 1.0 : -1.0;\n\n }\n\n vec2 signNotZero(vec2 value) {\n\n return vec2(signNotZero(value.x), signNotZero(value.y));\n\n }\n\n vec3 octDecode(vec2 encoded, float range) {\n\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n\n return vec3(0.0, 0.0, 0.0);\n\n }\n\n encoded = encoded / range * 2.0 - 1.0;\n\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n\n if (v.z < 0.0) {\n\n v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n\n }\n\n return normalize(v);\n\n }\n\n vec3 octDecode(vec2 encoded) {\n\n return octDecode(encoded, 255.0);\n\n }\n\n #else\n\n attribute vec3 NORMAL;\n\n #endif\n\n uniform vec3 lightDir;\n\n uniform mat3 modelNormalMatrix;\n\n uniform mat4 positionMatrix;\n\n float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n\n return max(dot(-lightDir, normal), 0.0);\n\n }\n\n#endif\n\n#ifdef PICKING_MODE\n\n #include <fbo_picking_vert>\n\n#endif\n\n#include <draco_decode_vert>\n\nvoid main() {\n\n #ifdef HAS_POSITION\n\n vec3 localPos = decode_getPosition(POSITION);\n\n #endif\n\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n gl_PointSize = pointSize;\n\n\n\n #ifdef PICKING_MODE\n\n fbo_picking_setData(gl_Position.w, true);\n\n #else\n\n #if defined(HAS_RGB)\n\n vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n\n #elif defined(HAS_RGBA)\n\n vColor = RGBA / 255.0 * pointOpacity;\n\n #elif defined(HAS_RGB565)\n\n float compressed = RGB565;\n\n float r = floor(compressed * SHIFT_RIGHT_11);\n\n compressed -= r * SHIFT_LEFT_11;\n\n float g = floor(compressed * SHIFT_RIGHT_5);\n\n compressed -= g * SHIFT_LEFT_5;\n\n float b = compressed;\n\n vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n\n vColor = vec4(rgb, 1.0);\n\n #else\n\n vColor = pointColor;\n\n #endif\n\n\n\n #ifdef HAS_NORMAL\n\n mat3 positionNormalMatrix = mat3(positionMatrix);\n\n mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n\n #ifdef HAS_NORMAL_OCT16P\n\n vec3 localNormal = octDecode(NORMAL_OCT16P);\n\n #else\n\n vec3 localNormal = NORMAL;\n\n #endif\n\n vec3 normal = normalize(normalMatrix * localNormal);\n\n float colorStrength = getLambertDiffuse(lightDir, normal);\n\n colorStrength = max(colorStrength, 0.5);\n\n vColor *= colorStrength;\n\n #endif\n\n #endif\n\n\n\n\n\n\n\n\n\n}\n\n";const Qt=new Array(3),te=new Array(3),ee=[40680631590769,40680631590769,40408299984661.445];function ne(t,e,n,r){const i=ee,s=Math.cos(n);Qt[0]=s*Math.cos(e),Qt[1]=s*Math.sin(e),Qt[2]=Math.sin(n),de(Qt,Qt),M.multiply(te,i,Qt);const o=Math.sqrt(M.dot(Qt,te));var a,c,h;return c=te,h=o,(a=te)[0]=c[0]/h,a[1]=c[1]/h,a[2]=c[2]/h,M.scale(Qt,Qt,r),M.add(t,te,Qt)}const re=[1/6378137,1/6378137,1/6356752.314245179],ie=[1/40680631590769,1/40680631590769,1/40408299984661.445],se=new Array(3),oe=new Array(3),ae=new Array(3);function ce(t,e){const n=ie,r=function(t,e,n,r,i){const s=e[0],o=e[1],a=e[2],c=n[0],h=n[1],l=n[2],u=s*s*c*c,f=o*o*h*h,d=a*a*l*l,m=u+f+d,p=Math.sqrt(1/m),y=M.scale(he,e,p);if(m<i)return isFinite(p)?y:void 0;const b=r[0],g=r[1],w=r[2],v=le;v[0]=y[0]*b*2,v[1]=y[1]*g*2,v[2]=y[2]*w*2;let T,O,_,A,x,I,S,C,k,N,R,E=(1-p)*fe(e)/(.5*fe(v)),L=0;do{E-=L,_=1/(1+E*b),A=1/(1+E*g),x=1/(1+E*w),I=_*_,S=A*A,C=x*x,k=I*_,N=S*A,R=C*x,T=u*I+f*S+d*C-1,O=u*k*b+f*N*g+d*R*w;L=T/(-2*O)}while(Math.abs(T)>ue);return t[0]=s*_,t[1]=o*A,t[2]=a*x,t}(se,e,re,n,.1);let i=M.mul(oe,r,n);i=de(i,i);const s=M.sub(ae,e,r),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=_t(M.dot(s,e))*fe(s);return t[0]=Mt(o),t[1]=Mt(a),t[2]=c,t}const he=new Array(3),le=new Array(3),ue=1e-12;function fe(t){return M.length(t)}function de(t,e){const n=e[0],r=e[1],i=e[2];let s=n*n+r*r+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function me(t,e){return M.multiply(e,t,ie),M.normalize(e,e)}function pe(t,e){const n=t[0],r=t[1],i=Math.cos(r),s=i*Math.cos(n),o=i*Math.sin(n),a=Math.sin(r);return e.x=s,e.y=o,e.z=a,M.normalize(e,e)}var ye=Object.freeze({__proto__:null,cartesian3ToDegree:ce,geodeticSurfaceNormal:me,geodeticSurfaceNormalCartographic:pe,normalizeCartesian:de,radianToCartesian3:ne});function be(t,e,n,r){n=n||0,r=r||n;const i=Math.abs(t-e);return i<=r||i<=n*Math.max(Math.abs(t),Math.abs(e))}function ge(t,e){let n="";for(let r=0;r<4;r++){const i=t.getUint8(e+r);n+=String.fromCharCode(i)}return n}const we="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function ve(t,e,n){const r=new Uint8Array(t,e,n);return we?JSON.parse(we.decode(r)):JSON.parse(xt(r))}function Te(t,e,n){const r=new Uint8Array(t,e,n);return we?JSON.parse(we.decode(r)):JSON.parse(xt(r))}function Me(t,e,n){return{offset:e,byteLength:n}}function Oe(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=Ce(s||"UNSIGNED_SHORT"),h=Ie(o);return{byteStride:0,byteOffset:i+n,itemSize:h,count:r*h,componentType:c,array:new a(e,n+i,r*h)}}function _e(t,e,n,r){const i=Oe(t,e,n,r);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}function Ae(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a}=Ce(s||"UNSIGNED_SHORT"),c=Ie(o),h=new a(e,i,n*c);return 1===c?h[r]:h.subarray(r*c,r*c+c)}const xe={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Ie(t){return t?xe[t]:1}const Se={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function Ce(t){return Se[t]}function ke(t){for(const e in Se)if(t===Se[e].ctor)return Se[e].type;throw new Error("unrecognized ctor:"+t)}function Ne(t,e,n,r){const i=t,s=e.length/3;for(let t=0;t<s;t++)i[3*t]=e[3*t]/65535*r[0]+n[0],i[3*t+1]=e[3*t+1]/65535*r[1]+n[1],i[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return i}function Re(t,e,n){const r=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,h={},l={},u=null;r>0&&(h=ve(a,e,r),e+=r),i>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,i),e+=i),s>0&&(l=Te(a,e,s),e+=s);const f=Me(0,e,o);return u=a.slice(f.offset,f.offset+f.byteLength),n.push(u),{featureTable:h,featureTableBin:c,batchTable:l,batchTableBin:u}}const Ee={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},Le={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Pe={},Ue={east:[],north:[],up:[],west:[],south:[],down:[]};let Be=[],Fe=[],De=[];const je=[0,0,0];function ze(t,e,n){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=t[15],n}const Ge=function(t,e){const n=Ee[t][e];let r;const i=t+e;return Pe[i]?r=Pe[i]:(r=function(r,i,s){if(M.equals(r,je))M.copy(Be,Le[t]),M.copy(Fe,Le[e]),M.copy(De,Le[n]);else if(be(r[0],0,1e-14)&&be(r[1],0,1e-14)){const i=_t(r[2]);M.copy(Be,Le[t]),M.copy(Fe,Le[e]),M.scale(Fe,Fe,i),M.copy(De,Le[n]),M.scale(De,De,i)}else{me(r,Ue.up);const i=Ue.up,s=Ue.east;s[0]=-r[1],s[1]=r[0],s[2]=0,M.normalize(Ue.east,s),M.cross(Ue.north,i,s),M.scale(Ue.down,Ue.up,-1),M.scale(Ue.west,Ue.east,-1),M.scale(Ue.south,Ue.north,-1),Be=Ue[t],Fe=Ue[e],De=Ue[n]}return s[0]=Be[0],s[1]=Be[1],s[2]=Be[2],s[3]=0,s[4]=Fe[0],s[5]=Fe[1],s[6]=Fe[2],s[7]=0,s[8]=De[0],s[9]=De[1],s[10]=De[2],s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s},Pe[i]=r),r}("east","north"),He=[],qe=[],Ve=[],$e=[],Je=[],Ze=[],Xe=[],We={x:0,y:0},Ke={x:0,y:0},Ye=Math.PI/180;let Qe;const tn={width:100,height:10};function en(){if(!Qe){const{width:t,height:e}=tn;OffscreenCanvas?Qe=new OffscreenCanvas(t,e):(Qe=document.createElement("canvas"),Qe.width=t,Qe.height=e)}return Qe}class nn{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let n=1/0,r=-1/0;for(let e=0,i=t.length;e<i;e++){const i=t[e][0];n=Math.min(i,n),r=Math.max(i,r)}this.min=n,this.max=r,this.valueOffset=this.max-this.min,this.options=Object.assign({},tn,e),this.i()}getImageData(){return this.imgData}i(){const t=en(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const i=r.createLinearGradient(0,0,t.width,0),{colors:s,valueOffset:o}=this;for(let t=0,e=s.length;t<e;t++){const[e,n]=s[t],r=(e-this.min)/o;i.addColorStop(r,n)}r.fillStyle=i,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var rn;function sn(t,e){var n,r,i;if(mn(t)){var s,o=t.stops&&"object"==typeof t.stops[0][0],a=o||void 0!==t.property,c=o||!a,h=t.type||e||"exponential";if("exponential"===h)s=cn;else if("interval"===h)s=an;else if("categorical"===h)s=on;else if("identity"===h)s=un;else{if("color-interpolate"!==h)throw new Error('Unknown function type "'+h+'"');s=ln}if(o){var l={},u=[];for(let e=0;e<t.stops.length;e++){var f=t.stops[e];void 0===l[f[0].zoom]&&(l[f[0].zoom]={zoom:f[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),l[f[0].zoom].stops.push([f[0].value,f[1]])}for(let t in l)u.push([l[t].zoom,sn(l[t])]);n=function(e,n){const r=cn({stops:u,base:t.base},e)(e,n);return"function"==typeof r?r(e,n):r},r=!1,i=!1}else c?(n=function(e){const n=s(t,e);return"function"==typeof n?n(e):n},r=!0,i=!1):(n=function(e,n){const r=s(t,n?n[t.property]:null);return"function"==typeof r?r(e,n):r},r=!1,i=!0)}else n=function(){return t},r=!0,i=!0;return n.isZoomConstant=i,n.isFeatureConstant=r,n}function on(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function an(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function cn(t,e){for(var n=void 0!==t.base?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:fn(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(rn=new Map);const hn={width:100,height:1};function ln(t,e){const n=t.stops;if(n&&n.length>1){let t;if(rn){const e=JSON.stringify(n);if(!rn.has(e)){const t=new nn(n,hn);rn.set(e,t)}t=rn.get(e)}else t=new nn(n,hn);const[r,i,s,o]=t.getColor(e);return[r/255,i/255,s/255,o/255]}return n&&1===n.length?n[0][1]:null}function un(t,e){return n=e,r=t.default,void 0!==n?n:void 0!==r?r:null;var n,r}function fn(t,e,n,r,i,s){return"function"==typeof i?function(){var o=i.apply(void 0,arguments),a=s.apply(void 0,arguments);return fn(t,e,n,r,o,a)}:i.length?function(t,e,n,r,i,s){var o=[];for(let a=0;a<i.length;a++)o[a]=dn(t,e,n,r,i[a],s[a]);return o}(t,e,n,r,i,s):dn(t,e,n,r,i,s)}function dn(t,e,n,r,i,s){var o,a=r-n,c=t-n;return i*(1-(o=1===e?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)))+s*o}function mn(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type)}function pn(t){return yn(t,"exponential")}function yn(t,e){if(!mn(t))return function(){return t};let n=!0,r=!0;const i=(t=JSON.parse(JSON.stringify(t))).stops;if(i)for(let t=0;t<i.length;t++)if(mn(i[t][1])){const s=yn(i[t][1],e);n=n&&s.isZoomConstant,r=r&&s.isFeatureConstant,i[t]=[i[t][0],s]}const s=sn(t,e);return s.isZoomConstant=n&&s.isZoomConstant,s.isFeatureConstant=r&&s.isFeatureConstant,s}const{getTextureMagFilter:bn,getTextureMinFilter:gn,getTextureWrap:wn,getMaterialType:vn,getMaterialFormat:Tn,getPrimitive:Mn,getUniqueREGLBuffer:On}=n.REGLHelper,_n=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],An=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:xn,logoutIBLResOnCanvas:In,getIBLResOnCanvas:Sn,getPBRUniforms:Cn}=n.pbr.PBRUtils,kn={factor:0,units:0},Nn=[1,1,1,1],Rn=[0,0,0],En={specularStrength:0,materialShininess:1},Ln=[1,1,1],Pn=r.identity([]),Un=[0,0,0],Bn=[0,0],Fn=[],Dn=t=>t.material instanceof n.PhongMaterial,jn=t=>t.material instanceof n.pbr.StandardMaterial,zn=[],Gn=new t.Coordinate(0,0),Hn=new t.Point(0,0),qn=new t.Point(0,0),Vn=new t.Point(0,0),$n=[],Jn=[],Zn=[],Xn=[],Wn=[],Kn=[],Yn=[],Qn=[],tr=[],er=[],nr=[],rr=[],ir=[],sr=[],or={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},ar=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],cr=function(t,e){const n=2*Math.PI/t,r=[],i=[];for(let i=0;i<=t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=t,r[3*i+1]=s,r[3*i+2]=o}for(let i=t;i<=2*t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=o,r[3*i+1]=t,r[3*i+2]=s}for(let i=2*t;i<=3*t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=t,r[3*i+1]=o,r[3*i+2]=s}const s=r.length/3-1;for(let e=0;e<s;e++)e!==t-1&&e!==2*t-1&&(i[2*e]=e,i[2*e+1]=e+1);return r.push(0,0,0),r.push(e,0,0),r.push(0,e,0),r.push(0,0,e),i.push(s+1,s+2),i.push(s+1,s+3),i.push(s+1,s+4),{vertices:r,indices:i}}
|
|
7
7
|
/*!
|
|
8
|
-
* @maptalks/gl v0.
|
|
8
|
+
* @maptalks/gl v0.100.0
|
|
9
9
|
* LICENSE : UNLICENSED
|
|
10
10
|
* (c) 2016-2024 maptalks.com
|
|
11
|
-
*/(100,1),hr=[0,0,0,1],lr=[1,1,1];class ur{constructor(t,e){this.o=e,this.h=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.u=t,this.m=new n.Renderer(t),this.p={},this.v={},this.T={},this._={},this.O={},this.M={},this.A=new n.Scene,this.I=new n.Scene,this.S=new n.Scene,this.C=new n.Scene,this.N=new n.ResourceLoader(t.texture(2)),this.k=this.R.bind(this),this.P=new n.KHRTechniquesWebglManager(this.u,this.L(),this.N);const r=this.getMap();this.B=r.altitudeToPoint(100,r.getGLRes())/100}getI3DMMeshes(){return this._}getPNTSMeshes(){return this.T}getB3DMMeshes(){return this.v}getPaintedMeshes(){return this.U}getMap(){return this.o.getMap()}paint(t,e,n,o){const a=o&&o.renderTarget,c=o&&o.sceneFilter,h=this.getMap();if(!t.length||!h)return null;const l=this.D(),u=h.projViewMatrix,f=[],d=[],m=[],b=[],g=[];for(let n=0,i=t.length;n<i;n++){const i=t[n].data.node;let a=this.G(i);if(!a)continue;const c=this.o.F(i.j),h=c.debugNodes,l=c.heightOffset||0,y=c.coordOffset||Un;this.O[i.id]&&(a=this.O[i.id],a=St(a));let w=c.polygonOffset||Cn;yt(w)&&(w=w()),Array.isArray(a)||(f[0]=a,a=f);for(let c=0,f=a.length;c<f;c++){const f=a[c].properties.magic;if(a[c].properties.heightOffset===l&&a[c].properties.coordOffset[0]===y[0]&&a[c].properties.coordOffset[1]===y[1]||(this.q(a[c]),a[c].H=r.copy([],a[c].localTransform)),a[c].V=i,"b3dm"===f){if(a[c].getBoundingBox&&!p(u,a[c].getBoundingBox()))continue;const{batchIdData:t,batchIdMap:e}=a[c].geometry.properties;if(t&&e){const t=a[c].properties.node.j;this.$&&this.$[t]?s.highlightMesh(this.u,a[c],this.$[t],this.X,e):this.$&&this.$[t]||s.highlightMesh(this.u,a[c],null,this.X,e),s.showOnly(this.u,a[c],this.J&&this.J[t],this.K,e)}if(h&&h.length&&h.indexOf(a[c].V.id)<0)continue;o&&o.bloom&&a[c].properties.hlBloomMesh&&(a[c].properties.hlBloomMesh.properties.depthFunc="always",a[c].properties.hlBloomMesh.properties.polygonOffset=w,m.push(a[c].properties.hlBloomMesh)),m.push(a[c])}else"pnts"===f?b.push(a[c]):"i3dm"===f&&g.push(a[c]);a[c].properties.isLeaf=!!e[i.id],a[c].properties.selectionDepth=255-t[n].selectionDepth,a[c].properties.polygonOffset=w,e[i.id]||d.push(a[c]),this.Z(a[c]),this.Y(a[c],i)}}let y=0;const w=this.P.getExcludeFilter();i.setIncludeUniformValues(l,o),y+=this.W(this.tt,l,[c,Gn,w],a,d,m,g),y+=this.W(this.et,l,[c,Fn,w],a,d,m,g),this.P.forEachShader(((t,e,n)=>{const r=this.D(n);y+=this.W(t,r,[c,e],a,d,m,g)})),this.I.setMeshes(b);const v=this.nt();return y+=this.m.render(this.rt,v,this.I,a&&a.fbo),this.U={pntsMeshes:b,i3dmMeshes:g,b3dmMeshes:m},this.C.setMeshes(n),this.m.render(this.st,l,this.C,a&&a.fbo),y}prepareRender(t){this.it(t)}it(t){t&&t.states&&t.states.includesChanged&&(this.et.dispose(),delete this.et,this.tt.dispose(),delete this.tt),this.ot(t)}W(t,e,n,r,s,i,o){t.filter=n.filter((t=>!!t)),e.stencilEnable=!1;const a=r&&r.fbo;let c=0;const h=[];for(let n=0;n<i.length;n++){const{isLeaf:r,selectionDepth:s}=i[n].properties;r&&255===s?(e.stencilEnable&&(this.ct(a),this.A.setMeshes(h),c+=this.m.render(t,e,this.A,a),h.length=0,e.stencilEnable=!1),h.push(i[n])):(e.stencilEnable||(this.A.setMeshes(h),c+=this.m.render(t,e,this.A,a),h.length=0,e.stencilEnable=!0),h.push(i[n])),n===i.length-1&&(e.stencilEnable&&this.ct(a),this.A.setMeshes(h),c+=this.m.render(t,e,this.A,a))}return this.A.setMeshes(i.filter((t=>t.properties.isLeaf))),this.S.setMeshes(o),c+=this.m.render(t,e,this.S,r&&r.fbo),c}ct(t){this.u.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.A.getMeshes()}getCurrentI3DMMeshes(){return this.S.getMeshes()}ht(t,e){return e.V.lt-t.V.lt}deleteTile(t){const e=t.node;e.ut&&(e.ut.geometry.dispose(),e.ut.dispose(),delete e.ut);const n=e.id;this.ft(n)}ft(t){const e=this.v[t]||this.T[t]||this._[t]||this.O[t]||this.p[t];this.O[t]?this.dt(t):e&&(this.bt(e),delete this.v[t],delete this.T[t],delete this._[t],delete this.p[t])}dt(t){let e=this.O[t];e=St(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.ft(n)}delete this.O[t]}bt(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.bt(t[e]);else{s.showOnly(this.u,t),s.highlightMesh(this.u,t);const e=t.geometry.properties.url;if(e){const n=this.M[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this.M[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.o;In(t.getRenderer().canvas,t.getMap());for(const t in this.O)this.dt(t);this.O={};for(const t in this.v)this.ft(t);this.v={};for(const t in this.T)this.ft(t);this.T={};for(const t in this._)this.ft(t);this._={};for(const t in this.p)this.ft(t);this.p={},this.tt&&(this.tt.dispose(),delete this.tt),this.et&&(this.et.dispose(),delete this.et),this.rt&&(this.rt.dispose(),delete this.rt),this.st&&(this.st.dispose(),delete this.st),this.P.dispose(),this.picking&&this.picking.dispose()}G(t){return this.v[t.id]||this.T[t.id]||this._[t.id]||this.O[t.id]}has(t){return this.G(t)||this.p[t.id]}q(t){const e=t.properties.magic;"b3dm"===e?this.gt(t):"i3dm"===e?this.yt(t):"pnts"===e&&this.wt(t)}createPntsMesh(t,e,s,i){if(this.T[e]){const t=this.T[e];return console.warn(`pnts mesh with id(${e}) was already created.`),i(null,{id:e,mesh:t}),t}const{pnts:o,featureTable:a,rootIdx:c,compressed_int16_params:h}=t,l=a.POINTS_LENGTH;o.BATCH_ID||(o.BATCH_ID=new Uint8Array(l),o.BATCH_ID.fill(0));const u=new n.Geometry(o,null,l,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});u.generateBuffers(this.u);const f={};o.POSITION?f.HAS_POSITION=1:o.POSITION_QUANTIZED&&(f.HAS_POSITION_QUANTIZED=1),o.RGB?f.HAS_RGB=1:o.RGBA?f.HAS_RGBA=1:o.RGB565&&(f.HAS_RGB565=1),(o.NORMAL||o.NORMAL_OCT16P)&&(f.HAS_NORMAL=1,o.NORMAL_OCT16P&&(f.HAS_NORMAL_OCT16P=1)),this.vt(f,h),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:d,rtcCoord:m,projCenter:p}=t,b=this.o.F(c),g=new n.Mesh(u);g.properties.magic="pnts",g.properties.id=e,g.properties.node=s,g.properties.count=l,g.properties.batchTable=t.batchTable,g.properties.batchTableBin=t.batchTableBin,g.properties.serviceIndex=c,g.properties.rtcCoord=m,g.properties.rtcCenter=d,g.properties.projCenter=p,g.setDefines(f),g.setFunctionUniform("pointColor",(function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:b&&b.pointColor||[1,1,1,1]}));const y=this.getMap();let w=null,v=null;g.setFunctionUniform("pointSize",(function(){if(!b)return 2;if(mn(b.pointSize)){const t=JSON.stringify(b.pointSize);t!==w&&(v=pn(b.pointSize),w=t);return v(y.getZoom())}return b.pointSize||2}));let T=null,_=null;return g.setFunctionUniform("pointOpacity",(function(){if(!b)return 1;if(mn(b.pointOpacity)){const t=JSON.stringify(b.pointOpacity);t!==T&&(_=pn(b.pointOpacity),T=t);return _(y.getZoom())}return b.pointOpacity||1})),this.Tt(g,h),this.wt(g),g.H=r.copy([],g.localTransform),this.T[e]=g,i(null,{id:e,mesh:[g]}),[g]}wt(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:s}=t.properties;this._t(e,n,s,r.j),t.setLocalTransform(e)}createI3DMMesh(t,e,s,i){if(this._[e]){const t=this._[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.p[e]||i(null,{id:e,mesh:t}),t}const c=this.o.F(s.j),h=this.Ot(s.Mt),{i3dm:l,featureTable:u,gltf:f,batchTable:d,batchTableBin:m,count:p}=t,b=u.INSTANCES_LENGTH,{rtcCenter:g,rtcCoord:w,projCenter:v}=t,T=this.xt(Kn,s,g,w);je(T,Bn,T);const _=r.getRotation(Zn,T);o.normalize(_,_);const O=r.getScaling(Yn,T),M=r.fromScaling(Wn,O),x=this.At(Qn,v,s),A=this.It(nr),I=this.St(rr,w),S=a.div(sr,I,A),E=r.fromScaling(ir,S),{POSITION:C,NORMAL_UP:N,NORMAL_RIGHT:k,SCALE:R,SCALE_NON_UNIFORM:P}=l,L={"instance_vectorA":new Float32Array(4*b),"instance_vectorB":new Float32Array(4*b),"instance_vectorC":new Float32Array(4*b),"aPickingId":new Uint16Array(b)};for(let t=0;t<b;t++)L.aPickingId[t]=t;const B=new Float32Array(3),U=new Float32Array(3),D=[],G=new Float32Array(1),F=new Float32Array(3),j=[],z=[],q=[],H=[];!function(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?y.getTypedArrayCtor(i):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,s=s||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*o);for(let r=0;r<s*o;r+=o)e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o);return}const h=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const s=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);h.set(s),e(new c(h.buffer),t),s.set(h)}}(C,((t,e)=>{N?(Zt(U,k,e),Zt(B,N,e),a.cross(D,U,B),a.normalize(D,D),It(j,U,0),It(j,B,1),It(j,D,2),o.fromMat3(z,j),o.normalize(z,z),o.multiply(z,_,z)):o.identity(z),R?(Zt(G,R,e),a.set(q,G[0],G[0],G[0])):P?(Zt(F,P,e),a.set(q,...F)):a.set(q,1,1,1),r.fromRotationTranslationScale(H,z,t,q),Yt(L.instance_vectorA,e,H,0),Yt(L.instance_vectorB,e,H,1),Yt(L.instance_vectorC,e,H,2)}));const V={};for(const t in L)V[t]={buffer:this.u.buffer({dimension:L[t].length/b,data:L[t]}),divisor:1};const $=c.shader||"pbr";let X=0,J=!0;const K=[],Z=[];return zt(f,((t,i,o,a)=>{const c=this.Et(t,i,o,a,s,!0,$,Z),{geometry:l,material:f}=c;f&&!f.isReady()&&(J=!1,X++);const y=new n.InstancedMesh(V,b,l,f);c.refMeshes||(c.refMeshes=new Set,c.refMeshes.add(y.uuid)),y.properties.magic="i3dm",y.properties.id=e,y.properties.count=p,y.properties.batchTable=d,y.properties.batchTableBin=m,y.properties.serviceIndex=s.j,y.properties.rtcCoord=w,y.properties.rtcCenter=g,y.properties.projCenter=v,y.properties.node=s;const _=this.Ct(t,l,f,s.j,a);t.compressed_int16_params&&this.Tt(y,t.compressed_int16_params),this.Nt(y,t.attributes);const O=r.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(O,O,t.matrices[e]);r.multiply(O,h,O),r.multiply(O,E,O),u.EAST_NORTH_UP||N?r.multiply(O,M,O):r.multiply(O,T,O),y.setPositionMatrix(O),this.yt(y,x),y.setDefines(_),y.properties.polygonOffset={offset:0,factor:0},K.push(y),delete t.attributes,y.H=r.copy([],y.localTransform)})),fr(Z),J?(this._[e]=K,i(null,{id:e,mesh:K})):(this.p[e]={meshes:K,count:X},K.kt=i),K}yt(t,e){const{rtcCoord:n,node:s,projCenter:i}=t.properties;e||(e=this.At(Qn,i,s));const o=this.o.F(s.j),a=t.localTransform||[];if(o.coordOffset){const t=this.Rt(Kn,s.j,n);r.multiply(a,t,e)}else r.copy(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||Un}At(t,e,n){r.fromScaling(t,this.It(nr));const s=this.Pt(Xn,e,n.j);return r.multiply(t,r.fromTranslation(tr,s),t),t}createB3DMMesh(e,s,i,o){if(e.gltf&&(e.gltf.transferables=null),this.v[s]||this.p[s]){const t=this.v[s];return console.warn(`mesh with id(${s}) was already created.`),this.p[s]||o(null,{id:s,mesh:t}),t}let a;if(i.maxExtent){const e=new t.Extent(i.maxExtent).convertTo((t=>this._pointToPrj(t)));a=[e.xmin,e.ymin,e.xmax,e.ymax]}const c=e.gltf,{projCenter:h}=c.extensions.MAPTALKS_RTC,{rtcCoord:l,center:u}=c.extensions.CESIUM_RTC,f=c.asset.sharePosition,d=this.Ot(i.Mt),m=this.Lt(Qn,f,l,u,h,i),p=this.o.F(i.j);let b=p.shader||"pbr";if(p.unlit)b="phong";else if(c.materials)for(let t=0;t<c.materials.length;t++)if(c.materials[t]&&c.materials[t].extensions&&c.materials[t].extensions.KHR_materials_unlit){b="phong";break}const g=[],y=[];let w=0,v=!0;return zt(c,((t,o,c,T)=>{const _=this.Et(t,o,c,T,i,!1,b,g),{geometry:O,material:M}=_;M&&!M.isReady()&&(v=!1,w++);const x=new n.Mesh(O,M);_.refMeshes||(_.refMeshes=new Set,_.refMeshes.add(x.uuid)),x.properties.magic="b3dm",x.properties.id=s,x.properties.node=i,e.batchTable&&(x.properties.batchTable=e.batchTable,x.properties.batchTableBin=e.batchTableBin),x.properties.count=e.featureTable&&e.featureTable.BATCH_LENGTH||0,x.properties.serviceIndex=i.j;const A=this.Ct(t,O,M,i.j,T);x.setDefines(A);const I=t.compressUniforms;if(I)for(const t in I)x.setUniform(t,I[t]);t.compressed_int16_params&&this.Tt(x,t.compressed_int16_params),this.Nt(x,t.attributes),a&&(A.USE_MAX_EXTENT=1,x.setUniform("maxPrjExtent",a)),x.hasFunctionUniform("polygonOpacity")||x.setFunctionUniform("polygonOpacity",(function(){return vt(p.opacity)?p.opacity:1})),x.hasFunctionUniform("polygonFill")||x.setFunctionUniform("polygonFill",(function(){return Pt([],p.polygonFill||Nn)})),x.material.hasFunctionUniform("hsv")||x.material.setFunctionUniform("hsv",(function(){return p.hsv||kn}));const S=r.identity([]);if(f&&t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(S,S,t.matrices[e]);f&&r.multiply(S,d,S),x.properties.node=i,x.properties.projCenter=h,x.properties.nodeMatrix=S,x.properties.isSharedPosition=f,x.properties.rtcCoord=l,x.properties.rtcCenter=u,this.gt(x,m),y.push(x),delete t.attributes,x.H=r.copy([],x.localTransform)})),fr(g),v?(this.v[s]=y,o(null,{id:s,mesh:y})):(this.p[s]={meshes:y,count:w},y.kt=o),y}Bt(t){const e=this.o.Ut(t.id);if(!e||t.ut)return;let s,i,o,a;if(e.obbox)s=e.boxPosition,i=ar,o=e.boxCenter,a=lr;else if(e.sphereBox){const t=e.sphereBox[0],n=e.sphereBox[1];s=cr.vertices,i=cr.indices,o=t,a=[n,n,n]}const c=new n.Geometry({POSITION:s},i,0,{primitive:"lines",positionAttribute:"POSITION"}),h=new n.Mesh(c,new n.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),l=[];r.fromRotationTranslationScale(l,hr,o,a),h.localTransform=l,h.H=r.copy([],l),h.properties.node=t,t.ut=h}Dt(t){t.ut&&(t.ut.geometry.dispose(),t.ut.dispose(),delete t.ut)}Tt(t,e){e.POSITION&&t.setUniform("compressedPositionRange",e.POSITION),e.TEXCOORD_0&&t.setUniform("compressedTexcoordRange_0",e.TEXCOORD_0),e.TEXCOORD_1&&t.setUniform("compressedTexcoordRange_1",e.TEXCOORD_0),e.NORMAL&&t.setUniform("compressedNormalRange",e.NORMAL),e.TANGENT&&t.setUniform("compressedTangentRange",e.TANGENT),e.compressed_ratio&&t.setUniform("compressed_ratio",e.compressed_ratio)}gt(t,e){const{isSharedPosition:n,rtcCoord:s,rtcCenter:i,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=this.Lt(e||Qn,n,s,i,o,c));const h=t.localTransform||r.identity([]);r.multiply(h,e,a);const l=this.o.F(c.j);if(l.coordOffset){const t=this.Rt(Kn,c.j,s);r.multiply(h,t,h)}t.setLocalTransform(h),t.properties.heightOffset=l.heightOffset||0,t.properties.coordOffset=l.coordOffset&&l.coordOffset.slice(0)||Un}Lt(t,e,n,s,i,o){if(e){const e=this.St(rr,n),i=r.fromScaling(Jn,e),a=this.xt(Kn,o,s,n);r.multiply(t,a,i)}else this._t(t,n,i,o.j);return t}Nt(t,e){if(e&&e.TEXCOORD_0&&e.TEXCOORD_0.extensions&&e.TEXCOORD_0.extensions.WEB3D_quantized_attributes){const n=e.TEXCOORD_0.extensions.WEB3D_quantized_attributes.decodeMatrix;t.setUniform("decodeMatrix",n)}}xt(t,e,n,s){const i=this.getMap(),o=this.o.F(e.j).heightOffset||0,c=e.matrix?r.copy(t,e.matrix):r.identity(t);if(n){je(c,a.transformMat4(jn,n,c),c)}const h=function(t,e,n,r,s,i,o){e=_.copy(qe,e);const a=ne(qe,e[0]*We,e[1]*We,e[2]),c=T.getTranslation(He,n),h=r.ellipsoid;let l;l=0===_.len(c)?_.set(Ve,0,0,-6378137):ce(Ve,c),Ze.x=l[0],Ze.y=l[1];const u=r.project(Ze,Ye);$e[0]=u.x/s,$e[1]=u.y/s,$e[2]=(l[2]+o)*i;const f=ze(a,h,Xe);return je(function(t,e,n){const r=t[0],s=t[1],i=t[2],o=t[4],a=t[5],c=t[6],h=t[8],l=t[9],u=t[10],f=e[0],d=e[1],m=e[2],p=e[3],b=e[4],g=e[5],y=e[6],w=e[7],v=e[8],T=r*f+o*d+h*m,_=s*f+a*d+l*m,O=i*f+c*d+u*m,M=r*p+o*b+h*g,x=s*p+a*b+l*g,A=i*p+c*b+u*g,I=r*y+o*w+h*v,S=s*y+a*w+l*v,E=i*y+c*w+u*v;return n[0]=T,n[1]=_,n[2]=O,n[3]=0,n[4]=M,n[5]=x,n[6]=A,n[7]=0,n[8]=I,n[9]=S,n[10]=E,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(T.invert(Je,f),O.fromMat4(Ke,n),t),$e,t),t}(c,s,c,i.getProjection(),i.getGLRes(),this.B,o),l=function(t,e){return _.set(t,e[12],e[13],e[14]),t}(Xn,h);let u=this.o.options.offset;if(yt(u)){const t=this.o.Ut(e.id).boxCoord;u=u.call(this.o,t)}return a.set($n,u[0],u[1],0),a.sub(l,l,$n),je(h,l,h),h}Rt(t,e,n){const s=this.o.F(e);if(!s.coordOffset)return null;const i=this.getMap(),o=i.getGLRes();zn.set(n[0],n[1]);const c=i.coordToPointAtRes(zn,o,Hn),h=s.coordOffset,l=zn.set(n[0]+h[0],n[1]+h[1]),u=i.coordToPointAtRes(l,o,Vn),f=u.x-c.x,d=u.y-c.y,m=this.B,p=a.set($n,f,d,(h[2]||0)*m);return r.fromTranslation(t,p)}createCMPTMesh(t,e,n,r){if(this.O[e]){const t=this.O[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:s}=t,i=[];for(let t=0;t<s.length;t++){const{magic:r}=s[t],o=e+"."+t;"b3dm"===r?this.createB3DMMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"i3dm"===r?this.createI3DMMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"pnts"===r?this.createPntsMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"cmpt"===r&&this.createCMPTMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)}))}return this.O[e]=i,r(null,{id:e,mesh:i}),i}Ct(t,e,n,r,s){const i=("phong"===(this.o.F(r).shader||"pbr")?this.tt:this.et).getGeometryDefines(e);s.asset&&"S3M"===s.asset.generator&&this.Gt(i,e),e.data.uvRegion&&(i.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(i.VertexNormal=1),e.data[e.desc.color0Attribute]&&(i.VertexColor=1),e.data[e.desc.uv0Attribute]&&(i.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(i.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(i.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(i.TexCoord2=1),"MESHOPT"===this.o.Ft&&(i.MeshOPT_Compress=1),this.hasIBL()&&(i.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(i.HAS_WEB3D_quantized_attributes_TEXCOORD=1),i.HAS_MIN_ALTITUDE=1,i.HAS_LAYER_OPACITY=1,this.vt(i,t.compressed_int16_params);return gt(i,t.compressDefines),i}vt(t,e){e&&Object.keys(e).length>0&&(t.HAS_COMPRESSED_INT16=1,e.POSITION&&(t.HAS_COMPRESSED_INT16_POSITION=1),e.TEXCOORD_0&&(t.HAS_COMPRESSED_INT16_TEXCOORD_0=1),e.TEXCOORD_1&&(t.HAS_COMPRESSED_INT16_TEXCOORD_1=1),e.NORMAL&&(t.HAS_COMPRESSED_INT16_NORMAL=1),e.TANGENT&&(t.HAS_COMPRESSED_INT16_TANGENT=1),e.compressed_ratio&&(t.HAS_COMPRESSED_INT16_RATIO=1))}Z(t){const e=this.o.getRenderer();e&&e.updateMaskDefines(t)}Gt(t,e){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1)}Et(t,e,r,s,i,o,a,c){let h=!1;s.asset&&"S3M"===s.asset.generator&&(h=!0,s.extensions=s.extensions||{});const l=s.url+"-"+e+"-"+r;if(this.M[l])return this.M[l];let u,f;c.push(t);const d=s.materials&&s.materials[t.material],m=s.extensions&&s.extensions.KHR_techniques_webgl,p=this.o.F(i.j);if(m&&d.extensions&&d.extensions.KHR_techniques_webgl){const e=this.jt(t,s,o,h);u=e.material,f=e.geometry,p.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.zt(t,o,or);const e=p.material;u=this.qt(t.material,s,a,e||Rn,c,p)}u&&(u.setFunctionUniform("alphaTest",(function(){const t=p.alphaTest;return bt(t)?.1:t})),u.setFunctionUniform("environmentExposure",(()=>{const t=p.ambientLight;let e=p.environmentExposure;const n=this.getMap().getLightManager(),r=n&&n.getAmbientLight();if(t&&(!r||r.color)&&void 0===e){const n=r&&r.color?r.color[0]:.2;e=t[0]/n}return e||1}))),u&&!u.isReady()?u.Ht=i.id:u||(u=new n.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const b={geometry:f,material:u};return f.properties.url=l,this.M[l]=b,b}jt(t,e,n,r){const{geometry:s,material:i}=this.P.createMesh(t,e,n,r);return{geometry:s,material:i}}zt(t,e,r){const s=t.attributes,i="COLOR_0";let o=s._BATCHID&&s._BATCHID.array;if(o&&o.byteOffset&&(o=new o.constructor(o)),s[i]){const t=s[i].array||s[i];if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let n=0;n<e.length;n++)e[n]=Math.round(255*t[n]);s[i].array?(s[i].array=e,s[i].componentType=5121):s[i]=e}}const a={};for(const t in s){const e=On(this.u,s[t],{dimension:s[t].itemSize}),n=r[t]||t;a[n]={buffer:e},s[t].quantization&&(a[n].quantization=s[t].quantization),n===r.POSITION&&(a[n].array=s[t].array,a[n].min=s[t].min,a[n].max=s[t].max)}const c=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,h=new n.Geometry(a,c,0,{static:!0,positionAttribute:r.POSITION,normalAttribute:r.NORMAL,uv0Attribute:r.TEXCOORD_0,uv1Attribute:r.TEXCOORD_1,color0Attribute:r.COLOR_0,tangentAttribute:r.TANGENT,pickingIdAttribute:r._BATCHID,primitive:void 0===t.mode?"triangles":_n(t.mode)});return o&&c&&(h.properties.batchIdData=o,h.properties.batchIdMap=function(t,e){if(!e)return null;const n=new Map;for(let r=0;r<e.length;r++){const s=e[r],i=t[s];let o=n.get(i);o||(o=[],n.set(i,o)),o.push(s)}return n}(o,c)),h.generateBuffers(this.u,{excludeElementsInVAO:e}),h}_t(t,e,n,s){const i=r.identity(t),o=this.It(Pn);return this.Pt(Xn,n,s),r.translate(i,i,Xn),r.scale(i,i,o),i}Pt(t,e,n){const r=this.B;zn.x=e[0],zn.y=e[1];const s=this._prjToPoint(zn);let i=this.o.options.offset;yt(i)&&(i=i.call(this.o,zn));const o=this.o.F(n).heightOffset||0;return a.set(t,s.x-i[0],s.y-i[1],r*e[2]+r*o),t}Y(t,e){const n=this.o.Vt(er,e);t.localTransform=r.multiply(t.localTransform,n,t.H)}St(t,e){const n=this.getMap();zn.x=e[0],zn.y=e[1];const r=n.distanceToPointAtRes(100,100,n.getGLRes(),zn),s=this.B;return a.set(t,r.x/100,r.y/100,s),t}ot(t){if(this.et)return;const e={x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},s=[],o=[];this.rt=new n.MeshShader({vert:Wt,frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n vec2 circCoord = 2.0 * gl_PointCoord - 1.0;\n\n if (dot(circCoord, circCoord) > 1.0) {\n\n discard;\n\n } else {\n\n gl_FragColor = vColor;\n\n }\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.multiply(o,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,e)=>c.fromMat4(s,e.modelMatrix)}],extraCommandProps:{viewport:e,blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,range:[0,1],func:"<"}}});const a={},h=[];i.fillIncludes(a,h,t);const l=this.L();this.tt=new n.PhongShader({uniforms:h,defines:a,extraCommandProps:l}),this.et=new n.pbr.StandardShader({uniforms:h,defines:a,extraCommandProps:l}),this.st=new n.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const u=this.o;An(u.getRenderer().canvas,this.u,u.getMap()),this.picking=new n.FBORayPicking(this.m,{vert:this.et.vert,extraCommandProps:l,uniforms:this.et.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.$t=new n.FBORayPicking(this.m,{vert:Wt,extraCommandProps:l,uniforms:this.rt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}L(){return{viewport:{x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},cull:{enable:!0},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:">=",ref:(t,e)=>e.meshProperties.selectionDepth},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,range:[0,1],func:(t,e)=>e.meshProperties.depthFunc||"<"},blend:{enable:!0,func:{src:1,dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}nt(t){const e=this.getMap(),n=e.getLightManager(),r=(n&&n.getDirectionalLight()||{}).direction||[1,1,-1],s=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:s,lightDir:a.normalize(Dn,r)}}D(){const t=this.getMap(),e=this.o,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:s}=Sn(n),i=En(t,r,s),o=this.o.getRenderer(),a=o.getMaskUniforms();i.minAltitude=e.options.altitude||0;const c=o.canvas.gl&&o.canvas.gl.wrap?e.options.opacity||0:1;return i.layerOpacity=c,gt(i,{czm_lightDirectionEC:i.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[n.width,n.height],polygonFill:[1,1,1,1],polygonOpacity:1}),gt(i,a),i}qt(t,e,r,s,i,o){const a=e.materials&&e.materials[t];if(!a||!a.baseColorTexture&&!a.pbrMetallicRoughness)return null;const c=gt({},s);if(a.baseColorTexture){const t=e.textures[a.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.Xt(t,i)),c.baseColorFactor=t&&t.image.color||a.baseColorFactor||[1,1,1,1],n&&(c.baseColorTexture=n)}else{if(a.normalTexture){const t=this.Xt(e.textures[a.normalTexture.index],i);if(t){const e=a.normalTexture.scale||1;c.normalTexture=t,c.normalMapFactor=e}}if(a.occlusionTexture){const t=this.Xt(e.textures[a.occlusionTexture.index],i);if(t){const e=a.occlusionTexture.strength||1;c.occlusionTexture=t,c.occlusionFactor=e}}if(a.emissiveTexture){const t=this.Xt(e.textures[a.emissiveTexture.index],i);t&&(c.emissiveTexture=t)}a.emissiveFactor&&(c.emissiveFactor=a.emissiveFactor);const t=a.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(c.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const n=e.textures[t.baseColorTexture.index];if(n&&n.image&&n.image.color)c.baseColorFactor=c.baseColorFactor?h.multiply(c.baseColorFactor,c.baseColorFactor,n.image.color):n.image.color;else{const t=this.Xt(n,i);t&&(c.baseColorTexture=t,c.baseColorTexture.getREGLTexture(this.u))}}if(bt(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),bt(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),a.metallicRoughnessTexture){const t=this.Xt(e.textures[a.metallicRoughnessTexture.index],i);t&&(c.metallicRoughnessTexture=t)}}}if(a.s3mMaterial)return new n.Material(c);if(o.unlit||a.extensions&&a.extensions.KHR_materials_unlit){c.ambientColor=[1,1,1],c.light0_diffuse=[0,0,0,0],c.lightSpecular=[0,0,0];const t=new n.PhongMaterial(c);return t.unlit=void 0===o.unlit||!!o.unlit,t}let l=new n.pbr.StandardMaterial(c);"phong"===r&&(l=n.PhongMaterial.convertFrom(l));const u=a.pbrMetallicRoughness,f=u&&u.baseColorTexture&&u.baseColorTexture.extensions;return f&&f.KHR_texture_transform&&(l.set("khr_offset",f.KHR_texture_transform.offset||[0,0]),l.set("khr_rotation",f.KHR_texture_transform.rotation||0),l.set("khr_scale",f.KHR_texture_transform.scale||[1,1])),l.doubleSided=!(!o.doubleSided&&!a.doubleSided),l.once("complete",this.k),l}Xt(t,e){if(!t)return null;const r={type:t.type?vn(t.type):"uint8",format:t.format?Tn(t.format):"rgba",flipY:!!t.flipY},s=t.image;if(e.push(s),s.array?r.data=s.array:s.mipmap&&(r.mipmap=s.mipmap),!r.data&&!r.mipmap)return null;if(r.width=s.width,r.height=s.height,r.mipmap&&(r.width<4||r.height<4))return null;const i=t.sampler||t.texture&&t.texture.sampler;return i&&(i.magFilter&&(r.mag=gn(i.magFilter)),i.minFilter&&(r.min=yn(i.minFilter)),i.wrapS&&(r.wrapS=wn(i.wrapS)),i.wrapT&&(r.wrapT=wn(i.wrapT))),new n.Texture2D(r,this.N)}R({target:t}){const e=t.Ht,n=this.p[e];if(n.count--,!n.count){const t=n.meshes;this.v[e]=t,delete this.p[e];const r=t.kt;delete t.kt,r(null,{mesh:n.meshes,id:e})}}It(t){const e=1/this.getMap().getGLRes(),n=this.B;return t[0]=t[1]=e,t[2]=n,t}Jt(t){return this.o.Jt(t)}_pointToPrj(t){const e=this.getMap();return e.getGLZoom?e._pointToPrj(t,e.getGLZoom()):e._pointToPrjAtRes(t,e.getGLRes())}_prjToPoint(t){const e=this.getMap();return e.getGLZoom?e._prjToPoint(t,e.getGLZoom()):e._prjToPointAtRes(t,e.getGLRes(),qn)}Ot(t){return"Y"===t?Mn:"X"===t?xn:Ln}pick(t,e,n=3){const r=this.o;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const s=[],i=this.D(),o=this.Kt(this.picking,i,this.A,t,e,n);o&&s.push(o);const a=this.Kt(this.picking,i,this.S,t,e,n);a&&s.push(a);const c=this.nt(),h=this.Kt(this.$t,c,this.I,t,e,n);return h&&s.push(h),s}Kt(t,e,n,r,s,i){if(!n.getMeshes().length)return null;const o=this.o,a=this.getMap();t.render(n.getMeshes().filter((t=>!t.bloom)),e,!0);let c={};t.getRenderedMeshes().length&&(c=t.pick(r,s,i,e,{viewMatrix:a.viewMatrix,projMatrix:a.projMatrix,returnPoint:o.options.pickingPoint}));const{meshId:h,pickingId:l,point:u,coordinate:f}=c,d=(0===h||h)&&t.getMeshAt(h);if(!d||!d.geometry)return null;const m=d.properties;u&&u.length&&(u[0]=Math.round(1e5*u[0])/1e5,u[1]=Math.round(1e5*u[1])/1e5,u[2]=Math.round(1e5*u[2])/1e5);const p={batchId:l},b=o.options.services,g=b&&b[d.properties.serviceIndex];if(g&&g.debug&&(p.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=l;for(const s in t)void 0!==t[s].byteOffset?p[s]=xe(t[s],e,n,r):p[s]=t[s][r]}return{service:d.properties.serviceIndex,data:p,point:u,coordinate:f}}highlight(t){this.$=t;const e=this.o.getRenderer();this.X=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.$=null;const t=this.o.getRenderer();this.X=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.J=t;const e=this.o.getRenderer();this.K=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.J=null;const t=this.o.getRenderer();this.K=t.getFrameTimestamp(),t.setToRedraw(!0)}Zt(){if(!this.U)return[];const t={},e=[];for(const n in this.U){const r=this.U[n];if(r)for(let n=0;n<r.length;n++){const s=r[n],i=s&&s.geometry;if(!s||!i)continue;const o=s.properties.serviceIndex;t[o]||(t[o]=new Set);const a=i.properties.batchIdData;if(a)for(let n=0;n<a.length;n++)t[o].has(a[n])||(e.push({id:a[n],service:o}),t[o].add(a[n]))}}return e}hasIBL(){const t=this.getMap().getLightManager();return!!(t&&t.getAmbientResource())}}function fr(t){for(let e=0;e<t.length;e++)t[e]&&(t[e].array&&(t[e].array=null),t[e].mipmap&&(t[e].mipmap=null),t[e].indices&&(t[e].indices=null))}const dr=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")},mr=dr(),pr=mr.gl_trans__coders=mr.gl_trans__coders||{};function br(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}pr.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=mr.gl_trans__coders=mr.gl_trans__coders||{};let i=`${r}\n const _____getGlobal = ${dr.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in s)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+='tran_____scoders["'+t+'"] ='+s[t].toString()+"\n;");return i+="\n"+e.substring(r.length),i},pr.registerTranscoder=function(t,e){pr[t]=e},pr.getTranscoder=function(t){return pr[t]};const gr=[];class yr{constructor(t,e,n,r,s){this.o=r,this.Yt=t,this.j=e,this.Wt=s,this.Qt=n.version,t.indexOf("i3s:tileset:")<0?(this.Qt<=1.6?this.te="root":this.te=0,n.version=this.Qt):(this.te=t.substring(12),this.Qt>1.6&&(this.te=parseInt(this.te))),this.Yt=t,this.ee=n}load(){const t=this.ee,e=t.layerScene.baseUrl;if(this.Qt<=1.6)return t[this.te]&&t[this.te].lodSelection?(this.ne=t[this.te],this.re()):new Promise((n=>{let r=e+"/nodes/"+this.te;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Wt(this.j,r,(()=>{this.ne=t[this.te],n(this.re())}))}));if(this.Qt>=1.7){if(t[this.te])return this.ne=t[this.te],this.re();const n=Math.floor(this.te/t.nodesPerPage);return new Promise((r=>{let s=e+"/nodepages/"+n;t.layerScene.eslpk&&(s+=".json"),this.Wt(this.j,s,(()=>{this.ne=t[this.te],r(this.re())}))}))}return null}getTileset(){return this.se}getChildrenURL(){return this.ie}re(){const t=this.ee,e=t.layerScene.baseUrl,n=this.ne.children,r=[],s={};if(n)for(let i=0;i<n.length;i++)if(this.Qt<=1.6){const o=n[i].id;if(t[o])continue;const a=o;s[a]||(s[a]=new Promise((n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Wt(this.j,r,(()=>{n()}))})),r.push(s[a]))}else{const o=n[i];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);s[a]||(s[a]=new Promise((n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.Wt(this.j,r,(()=>{n()}))})),r.push(s[a]))}return r.length?Promise.all(r).then((()=>this.oe())):this.oe()}oe(){return Promise.resolve(this.ae())}ce(t){br(this.ee,t)}ae(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.he(this.ne,!0)}}he(t){const e=this.o.getRenderer(),n=this.ee.projection,r=!n||n&&4326===n.wkid,s=this.Qt,i=this.ee,o=t,a=o.obb,c=o.mbs,h={};let l;if(c)l=_.set([],c[0],c[1],c[2]),r||(l=e.le(l,l)),l=wr([],l[0],l[1],l[2]),h.sphere=[...l,c[3]];else if(a){l=_.set([],a.center[0],a.center[1],a.center[2]),r||(l=e.le(l,l)),l=wr([],l[0],l[1],l[2]);const t=function(t,e,n){const r=O.fromQuat([],n);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],[...t,...r]}(l,a.halfSize,a.quaternion),n=t[3]+t[6]+t[9],s=t[4]+t[7]+t[10],i=t[5]+t[8]+t[11];_.set(gr,n,s,i);const o=_.len(gr);h.sphere=[...l,o]}let u=1/0,f=0;if(o.mbs?f=o.mbs[3]:o.obb&&(f=Math.max(Math.max(o.obb.halfSize[0],o.obb.halfSize[1]),o.obb.halfSize[2])),void 0!==o.lodThreshold)if("maxScreenThresholdSQ"===i.lodSelectionMetricType){u=f/(Math.sqrt(o.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==o.lodSelection)for(let t=0;t<o.lodSelection.length;t++)"maxScreenThreshold"===o.lodSelection[t].metricType&&(u=f/o.lodSelection[t].maxError);(u===1/0||isNaN(u))&&(u=1e5);const d=16*u,m=T.identity([]),p=o.children;let b;if(p){b=[];const t=this.ee;for(let e=0;e<p.length;e++){const n=s<=1.6?p[e].id:p[e];if(!t[n]){b=null;break}b.push(this.he(t[n]))}}const g={refine:"REPLACE",boundingVolume:h,transform:m,geometricError:d};return s<=1.6?t.lodSelection?t.geometryData&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}):g.content={uri:"i3s:tileset:"+(t.id||t.index)}:p&&p.length&&!b?g.content={uri:"i3s:tileset:"+(t.id||t.index)}:o.mesh&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}),b&&b.length&&(g.children=b),g}getJSON(){return this.ne}}function wr(t,e,n,r){return ne(t,Tt(e),Tt(n),r)}const vr=!!pr.ktx2,Tr=r.identity([]),_r=(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1})();function Or(t){return t.indexOf("i3s:mesh")>=0}const Mr=9;function xr(t,e,n,r,s){const i=e.layerScene.eslpk,o=function(t,e){const n=e.substring(Mr);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,h=[];let l=!1;const u=Tr;let f,d;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;if(!t)return null;let n=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;i&&(n+=".bin");const r={geometry:{url:n,info:e.layerScene.store.defaultGeometrySchema}};let s=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(s){const t=e.layerScene.store.textureEncoding[0];let n;n="image/jpeg"===t?"jpg":"png",i&&(s+="."+n);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+s,factor:1,format:n,mimeType:t},metallicFactor:0}};r.material=o}h.push(r)}else{f=a.mesh.geometry,d=a.mesh.material;const t=e.layerScene.geometryDefinitions[f.definition],{geometryBuffers:o}=t;l=r&&2===o.length;const u=pr.draco&&l?o[1]:o[0],m=pr.draco&&l?1:0;let p=c+`/nodes/${f.resource}/geometries/`+m;i&&(p+=".bin");const b={geometry:{url:p,info:u}};if(s&&_r&&l&&!pr.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const g=e.layerScene.materialDefinitions,y=e.layerScene.textureSetDefinitions;let w,v=0;if(d&&(v=g[d.definition]),g){w=function(t,e,n,r,s,i){const o=JSON.parse(JSON.stringify(t));return Ar(o,e,n,r,s,i),o}(v,y,c,d.resource,n,e.layerScene.eslpk)}else w={pbrMetallicRoughness:{metallicFactor:0}};b.material=w,h.push(b)}return{dracoCompression:l,meshes:h,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:u}}function Ar(t,e,n,r,s,i){for(const o in t)if(t[o]&&t[o].textureSetDefinitionId>=0){const a=e[t[o].textureSetDefinitionId],c="images/"+a.formats[0].format,h=Ir(a.formats,s),l={url:n+`/nodes/${r}/textures/${h.name}`,factor:void 0===t[o].factor?1:t[o].factor,format:h.format,mimeType:c};if(i){let t="";switch(h.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=h.format}l.url+="."+t}t[o]=l}else wt(t[o])&&Ar(t[o],e,n,r,s,i)}function Ir(t,e){for(let n=0;n<=t.length;n++){const r=t[n].format;if("dds"===r&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[n];if("jpg"===r||"png"===r)return t[n];if("ktx2"===r&&vr)return t[n]}return null}const Sr=new t.Coordinate(0,0),Er=new t.Coordinate(0,0),Cr=new Set,Nr=[],kr=new class{constructor(t,e){this.max=t,this.currentSize=0,this.data=new Map,this.onRemove=e}reset(t){if(this.data){const e=this.data.keys();for(const n of e){const e=this.data.get(n);t&&t!==e.renderer||this.ue(n,e)}}return t||(this.data=new Map,this.currentSize=0),this}clear(t){this.reset(t)}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const n=this.data.get(t);n&&n.node&&n.node.memorySize&&(this.currentSize-=n.node.memorySize),this.data.delete(t),this.data.set(t,e)}else this.data.set(t,e);return this}shrink(){if(this.currentSize>this.max){let t=!1;const e=this.data.keys();let n=e.next();for(;this.currentSize>this.max&&void 0!==n.value;){!t&&this.data.get(n.value).current&&(t=!0,console.warn(`current maxGPUMemory(${this.max/1024/1024}) for Geo3DTilesLayer is not enough, one or more current tiles will be discarded.`));const r=this.getAndRemove(n.value);r&&this.onRemove(r),n=e.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const n=this.data.keys();for(const r of n)t[e++]=r;return t}getAndRemove(t){if(!this.has(t))return null;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),e}get(t){if(!this.has(t))return null;const e=this.data.get(t);return this.data.delete(t),this.data.set(t,e),e}remove(t){if(!this.has(t))return this;const e=this.data.get(t);return this.ue(t,e),this}ue(t,e){e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e)}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const n of e){const e=n&&n.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t,e){const n=this.data.values();for(const r of n)t&&r.renderer!==t||(r.current=e)}}(1024*(t.Browser.mobile?32:1024)*1024,(t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)}));let Rr=0;class Pr extends(l(t.renderer.CanvasRenderer)){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>kr.max&&kr.setMaxSize(e),this.tileCache=kr,Rr++,this.prepareWorker(),this.tilesLoading={},this.fe={},this.de=[],this.Wt=this.me.bind(this)}getAnalysisMeshes(){if(!this.painter)return Nr;const t=this.painter.getPaintedMeshes();if(!t)return Nr;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:s}=t;return n.length&&kt(e,n),r.length&&kt(e,r),s.length&&kt(e,s),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.de.length||super.needToRedraw())}getFrameTimestamp(){return this.pe}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.pe=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:s}=this.layer.getTiles(),i=s.length;if(!s||!i)return void this.completeRender();this.painter.prepareRender(e),this.be(),this.ge(e);const{selectedTiles:o,leaves:a,requests:c}=this.ye(r,s);c.length&&this.loadTiles(c),this.we(o,a,e),this.ve(),c.length||this.completeRender()}ye(t,e){let n=[];this.Te();let r=0;const s=this._e(),i={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const s=e[t],c=s.node;if(i[c.id])continue;i[c.id]=1;let h=!1;const l=this.getCachedTile(c.id);if(this.Oe(c.id)?(r++,h=a=!0,this.tilesLoading[c.id].current=!0):l?(this.getTileOpacity(l)<1&&(h=a=!0),o=!0,s.selected=!0,s.data=l):this.painter.has(c)||(h=a=!0,n.push(c)),!h)continue;if(this.Me(s))o=!0;else{this.xe(s).length&&(o=!0)}}let c=[],h={};if(o&&({selectedTiles:c,leaves:h}=this.Ae(t)),n.length>1&&(n.sort(Lr),s)){const t=s-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c,leaves:h}}Ae(t){const e=[],n={};let r;const s=[t],i=[];for(;s.length>0||i.length>0;){if(i.length>0){const t=i[i.length-1];if(t.Ie===s.length){i.pop(),t===r&&(t.leave=!0,n[t.node.id]=1),e.push(t);continue}}const t=s.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)n[t.node.id]=1,t.selectionDepth=i.length,e.push(t);else{if(t.selectionDepth=i.length,r=t,0===o.length){t.leave=!0,n[t.node.id]=1,e.push(t);continue}i.push(t),t.Ie=s.length}for(let t=0;t<o.length;t++)s.push(o[t])}return{selectedTiles:e,leaves:n}}Me(t){if(!t.parent)return null;let e=t.parent;for(;e&&e.level>=0;){const t=e.node.id;if(this.tileCache.has(t))return e.selected=!0,e.data=this.tileCache.get(t),e;e=e.parent}return null}xe(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.Se+1,r=[t.node];for(;r.length>0;){const s=r.pop().children;for(let i=0,o=s.length;i<o;i++){if((!s[i].content||!s[i].content.url)&&s[i].children&&s[i].children.length){r.push(s[i]);continue}const o=s[i].id;if(this.tileCache.has(o)){const n=this.layer.Ee(s[i],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else s[i].Se<=n&&r.push(s[i])}}return e}we(t,e,n){this.tileCache.markAll(this,!1);const r=[];for(let e=0,n=t.length;e<n;e++){const n=t[e].data;n.current=!0,n.renderer=this,this.tileCache.add(t[e].node.id,n);const s=n.node,i=this.layer.F(s.j);s.ut&&i.debug&&!Array.isArray(i.debug)&&r.push(s.ut)}this.tileCache.shrink();const s=this.layer.options.services;for(let t=0;t<s.length;t++){const e=s[t],n=Array.isArray(e.debug)&&e.debug;if(n)for(const t of n){const e=this.layer.Ut(t),n=e&&e.node;n&&n.ut&&r.push(n.ut)}}const i={tiles:t,leaves:e};this.onDrawTileStart(i);const o=this.painter.paint(t,e,r,n);this.layer.fire("drawtiles",{count:o}),this.onDrawTileEnd(i),o&&this.layer.fire("canvasisdirty",{renderCount:o})}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,n=t.length;e<n;e++){const n=t[e];this.tilesLoading[n.id]={current:!0,node:n},this.loadTile(n)}}loadTile(t){let e=t.content.url;if(Ct(e)){const n=Nt(e);return this.Ce(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.j,r=this.Ne[n];return new yr(e,n,r,this.layer,this.Wt).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Bt(e)&&!Or(e)&&(e=t.baseUrl+e),this.Ce(e,null,t),null}Ce(t,e,r){let s=this.ke;s||(s=n.Util.getSupportedFormats(this.gl.gl||this.gl),this.ke=s);const i=this.layer.F(r.j);i.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length),r=n.split("/"),s=[];for(let t=0;t<r.length;t++)s.push(encodeURIComponent(r[t]));return e+s.join("/")}(t,r.baseUrl));const o={url:this.layer.getTileUrl(t,this.layer.Re[r.j]),arraybuffer:e,rootIdx:r.j,upAxis:r.Mt,transform:r.matrix,supportedFormats:s};if(Or(t)){const e=this.Ne[r.j];if(o.projection=e.projection,o.i3sInfo=xr(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=gt({},i),i.offset&&delete o.service.offset,o.referrer=window&&window.location.href,this.workerConn.loadTile(this.layer.getId(),o,((e,n)=>{if(e)return void this.onTileError(e,r,t);const{magic:s}=n;"b3dm"===s||"pnts"===s||"i3dm"===s||"cmpt"===s||"gltf"===s?this.de.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}Bt(t){this.painter&&this.painter.Bt(t)}Dt(t){this.painter&&this.painter.Dt(t)}ge(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.de.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.de.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Pe(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Pe(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Pe(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Pe(t,e,n,r)})),n++}}Pe(t,e,n,r){if(n)this.onTileError(n,e);else{const n=this.Le(r);e.memorySize=n,this.onTileLoad(t,e)}}Le(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.Le(t[n]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.Be(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.Ft=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.Ue(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(t,e,n){if(!this.layer)return;const r=n||e.content.url,s=t&&t.message||t;t&&(404===t.status||204===t.status)||Cr.has(s)||(console.warn("failed to load 3d tile: "+r),console.warn(t),Cr.add(s)),delete this.tilesLoading[e.id],this.De(e,t),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}getShadowMeshes(){if(!this.painter)return;const t=[],e=this.painter.getCurrentB3DMMeshes();for(const n in e)e[n]&&t.push(e[n]);const n=this.painter.getCurrentI3DMMeshes();for(const e in n)n[e]&&t.push(n[e]);return t}De(e,n){const r={loadTime:t.Util.now(),current:!0,error:n,node:e};r.renderer=this,this.tileCache.add(e.id,r)}Be(e){const n={loadTime:t.Util.now(),current:!0,node:e};n.renderer=this,this.tileCache.add(e.id,n)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.fe[e]}Te(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}createContext(){const t=this.layer,e=t.options.glOptions||{alpha:!0,depth:!0,stencil:!0,preserveDrawingBuffer:!0,antialias:t.options.antialias},n=this.canvas.gl&&this.canvas.gl.wrap;n?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.Ge(this.canvas,e)),this.regl=this.regl||u({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),n&&(this.canvas.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height)),this.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height),this.painter=new ur(this.regl,t),this.layer.Fe(),this.layer.fire("contextcreate",{regl:this.regl})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new Gt("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let n=this.layer.options||{};n=gt({},n),delete n.offset;const r=t.options.spatialReference;n.projection=r&&r.coordType||r&&r.projection||t.getSpatialReference().getProjection().code;const s=this.layer.getId();e.addLayer(s,n,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),Rr--,Rr||kr.reset(),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.ve(!0),this.tileCache.reset(this),this.tilesLoading={},super.clear()}clearCanvas(){this.regl&&this.regl.clear({color:[0,0,0,0],depth:1,stencil:0}),super.clearCanvas()}getTileOpacity(){return 1}getStencilValue(){return 0}ve(t){this.je||(this.je=Date.now());const e=Date.now();if(!t&&e-this.je<this.layer.options.retireInterval)return;this.je=e;const n=[];for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||(n.push(e),this.abortTileLoading(r))}for(let t=0;t<n.length;t++)delete this.tilesLoading[n[t]]}_e(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}Ge(t,e){const n=["webgl","experimental-webgl"];let r=null;for(let s=0;s<n.length;++s){try{r=t.getContext(n[s],e)}catch(t){}if(r)break}return r}Oe(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,n){return Oe(t,e,0,n)}be(){if(!this.ze)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.ze){const s=this.ze[r];if("pending"===s.status)continue;s.status="pending";const i=s.rootIdx,o=Ut(this.layer.F(i).fetchOptions);if(n.push(w.getJSON(r,o).then((t=>{delete this.ze[r];const e=this.Ne[i];if(e){t.nodes?br(e,t.nodes):(e[t.id]=t,br(e,t.children));for(let t=0;t<s.length;t++)s[t]();this.setToRedraw()}else this.setToRedraw()}))),e++,e>=t)break}n.length&&Promise.all(n)}me(t,e,n){this.ze||(this.ze={}),this.ze[e]=this.ze[e]||[],this.ze[e].rootIdx=t,this.ze[e].push(n),this.setToRedraw()}Ue(t,e,n){this.Ne||(this.Ne=[]);const r=e.j;this.Ne[r]||(this.Ne[r]={});const s=this.Ne[r],i=this.layer.F(r);t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),s.version=+(i.i3sVersion||t.store.version),!t.spatialReference||t.spatialReference.wkid&&4326===t.spatialReference.wkid||console.warn("i3s has a spatialReference other than 4326.",t.spatialReference),s.projection=t.spatialReference,function(t,e,n,r,s,i,o){if(!i.layerScene){i.layerScene=e,i.nodesPerPage=e.nodePages&&e.nodePages.nodesPerPage||64,i.lodSelectionMetricType=e.nodePages&&e.nodePages.lodSelectionMetricType;let t=s;if(i.layerScene.eslpk=t.indexOf("3dSceneLayer.json")>=0,t.endsWith(".json")){const e=s.lastIndexOf("/");t=e<0?"./":s.substring(0,e)}i.layerScene.baseUrl=function(t){return t.split("?")[0]}(t)}return new yr(s,n,i,t,o).load()}(this.layer,t,r,0,n,s,this.Wt).then((t=>{this.onTilesetLoad(t,e,n)}))}pick(t,e,n){if(!this.painter)return[];const r=this.pickingFBO,{width:s,height:i}=this.canvas;return!this.pickingFBO||r.width===s&&r.height===i||r.resize(s,i),this.painter.pick(t,e,n&&n.tolerance)}highlight(t){if(this.$||(this.$=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.$[n];r||(r=this.$[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.$[e];n||(n=this.$[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.$)}cancelHighlight(t,e){if(!this.$)return;const n=this.$[t];if(n){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.delete(e[t]);else n.delete(e);n.size||(this.$[t]=null),this.painter.highlight(this.$)}}cancelAllHighlight(){delete this.$,this.painter.cancelAllHighlight()}showOnly(t){if(this.J||(this.J=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.J[n];r||(r=this.J[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.J[e];n||(n=this.J[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.J)}cancelShowOnly(){delete this.J,this.painter.cancelShowOnly()}Zt(){return this.painter?this.painter.Zt():[]}le(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.qe();return Sr.set(e[0],e[1]),n.unproject(Sr,Er),t[0]=Er.x,t[1]=Er.y,t}return Sr.set(e[0],e[1]),n.getProjection().unproject(Sr,Er),t[0]=Er.x,t[1]=Er.y,t}He(t,e){const n=this.qe();return Sr.set(e[0],e[1]),n.project(Sr,Er),t[0]=Er.x,t[1]=Er.y,t}Ve(t,e){const n=this.qe();return Sr.set(e[0],e[1]),n.unproject(Sr,Er),t[0]=Er.x,t[1]=Er.y,t}qe(){const e=this.getMap().options.spatialReference.coordType;if(!e)throw new Error("Missing coordType in map spatialReference.");return this.$e||(this.$e=t.SpatialReference.getProjectionInstance(e)),this.$e}}function Lr(t,e){return t.lt-e.lt}function Br(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function Ur(t,e,n){return Math.sqrt(function(t,e,n){const r=_.subtract(Dr,n,t),s=Br(Gr,e,0),i=Br(Fr,e,1),o=Br(jr,e,2),a=_.len(s),c=_.len(i),h=_.len(o);_.normalize(s,s),_.normalize(i,i),_.normalize(o,o);const l=zr;l[0]=_.dot(r,s),l[1]=_.dot(r,i),l[2]=_.dot(r,o);let u,f=0;l[0]<-a?(u=l[0]+a,f+=u*u):l[0]>a&&(u=l[0]-a,f+=u*u);l[1]<-c?(u=l[1]+c,f+=u*u):l[1]>c&&(u=l[1]-c,f+=u*u);l[2]<-h?(u=l[2]+h,f+=u*u):l[2]>h&&(u=l[2]-h,f+=u*u);return f}(t,e,n))}const Dr=[],Gr=[],Fr=[],jr=[],zr=[];const qr=2*Math.PI;class Hr{constructor(t,e,n,r){this.west=t,this.south=e,this.east=n,this.north=r}static contains(t,e){let n=e[0];const r=e[1],s=t.west;let i=t.east;return i<s&&(i+=qr,n<0&&(n+=qr)),(n>s||ge(n,s,1e-14))&&(n<i||ge(n,i,1e-14))&&r>=t.south&&r<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const Vr=[0,0,1];function $r(t,e){return ne(e,t[0],t[1],t[2])}class Xr{constructor(t,e){this.normal=a.copy([],t),this.distance=e}static fromPointNormal(t,e,n){const r=-a.dot(e,t);return a.copy(n.normal,e),n.distance=r,n}}const Jr=[],Kr=[],Zr=[],Yr=[],Wr=[],Qr=[],ts=[],es=[],ns=[],rs=[],ss=new Xr([1,0,0],0),is=[];class os{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new Hr(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let n=0;if(!Hr.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,r=this.northeastCornerCartesian,s=this.westNormal,i=this.southNormal,o=this.eastNormal,c=this.northNormal,h=a.subtract(is,t,e),l=a.dot(h,s),u=a.dot(h,i),f=a.subtract(is,t,r),d=a.dot(f,o),m=a.dot(f,c);l>0?n+=l*l:d>0&&(n+=d*d),u>0?n+=u*u:m>0&&(n+=m*m)}const r=e[2],s=this.minimumHeight,i=this.maximumHeight;if(r>i){const t=r-i;n+=t*t}else if(r<s){const t=s-r;n+=t*t}return Math.sqrt(n)}computeBox(t){const e=this;$r(Hr.southwest(t,Kr),e.southwestCornerCartesian),$r(Hr.northeast(t,Kr),e.northeastCornerCartesian),Jr[0]=t.west,Jr[1]=.5*(t.south+t.north),Jr[2]=0;const n=$r(Jr,Zr),r=a.cross(Wr,n,Vr);a.normalize(e.westNormal,r),Jr[0]=t.east;const s=$r(Jr,es),i=a.cross(Wr,Vr,s);a.normalize(e.eastNormal,i);const o=a.subtract(Wr,n,s),c=a.normalize(Yr,o),h=t.south;let l;if(h>0){Jr[0]=.5*(t.west+t.east),Jr[1]=h;const n=$r(Jr,ns);a.copy(rs,c);const r=Xr.fromPointNormal(e.southwestCornerCartesian,e.westNormal,ss);as(ns,rs,r,e.southwestCornerCartesian),l=me(n,Qr)}else l=pe(Hr.southeast(t,Kr),Qr);const u=a.cross(ts,l,o);a.normalize(e.southNormal,u);const f=t.north;let d;if(f<0){Jr[0]=.5*(t.west+t.east),Jr[1]=f;const n=$r(Jr,ns);a.scale(rs,c,-1);const r=Xr.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,ss);as(ns,rs,r,e.northeastCornerCartesian),d=me(n,Qr)}else d=pe(Hr.northwest(t,Kr),Qr);const m=a.cross(ts,o,d);a.normalize(e.northNormal,m)}}function as(t,e,n,r){const s=t,i=e,o=n.normal,c=a.dot(o,i);if(Math.abs(c)<1e-15)return;const h=(-n.distance-a.dot(o,s))/c;return h<0?void 0:(r=a.scale(r,i,h),a.add(r,s,r))}function cs(t){return[t.xmin,t.ymin,t.xmax,t.ymax]}const hs=t.BBOXUtil,ls={"services":[],"maxGPUMemory":t.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"debug":!1,"meshLimitPerFrame":1,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"alwaysShowTopTiles":!0,"antialias":!1,"offset":[0,0],"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"optionalExtensions":["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"]},us=[0,0,0],fs=[0,0,0],ds=[0,0,0],ms=[0,0,0],ps=[0,0,0],bs=[0,0,0],gs=[0,0,0],ys=[1,1,1],ws=[0,0,0,0],vs=[],Ts=new t.Coordinate(0,0),_s=new t.Point(0,0),Os=[0,0,0,0,0,0,0,0,0],Ms=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],xs=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],As=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Is=new t.Point(0,0),Ss=r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Es=[0,0],Cs=[0,0,0],Ns=[1,1,1],ks=[0,0,0],Rs=[0,0,0],Ps=[0,0,0,0],Ls=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1];class Bs extends(f(t.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new Bs(t.id,t.options):null}constructor(t,e){super(t,e),this.Xe(),this.Je=[]}Xe(){const t=this.options.services.map((t=>t.url));this.Ke=this.Ke||{},this.Re=this.Re||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.Ke[n];void 0===r&&(r=this.Ke[n]=this.Re.length),this.Re[r]=Gs(n,r,this.options.services[e])}this.fire("rootready",{roots:this.Re.slice(0)})}showService(t){return this.updateService(t,{visible:!0}),this}hideService(t){return this.updateService(t,{visible:!1}),this}setToRedraw(){return this.Ze(),this}addService(t){return this.options.services=this.options.services||[],this.options.services.push(t),this.Xe(),this.Ze(),this}updateService(t,e){if(!e)return this;const n=this.options.services;let r=!1;n&&n[t]&&(r=!(zs(n[t].coordOffset,e.coordOffset)&&zs(n[t].heightOffset,e.heightOffset)&&zs(n[t].scale,e.scale)&&zs(n[t].rotation,e.rotation)),gt(n[t],e));const s=n[t].url,i=this.Ke[s],o=this.Re&&this.Re[i];return o&&(bt(e.visible)||(o.visible=e.visible),r&&o.version++),this.Ze(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.Ke[n];this.Re[r]&&(this.Re[r]=null),delete this.Ke[n],e.splice(t,1)}return this.Ze(),this}getTileUrl(t,e){const n=e&&e.service&&e.service.subdomains;if(n&&e.domainKey){const r=n.length;if(r){const s=[...t].reduce(((t,e)=>t+e.charCodeAt(0)),0)%r;return t.replace(e.domainKey,n[s])}}return t}getExtent(e){if(!e&&0!==e){const e=new t.Extent;for(let t=0;t<this.Re.length;t++){const n=this.Re[t];if(n&&n.boundingVolume){const t=this.boundingVolumeToExtent(n);e._combine(t)}}return e}const n=this.Re[e];return n&&n.boundingVolume?this.boundingVolumeToExtent(n):null}boundingVolumeToExtent(e){const n=e.boundingVolume.Ye?Ss:e.matrix,r=this.getMap(),s="identity"===r.getProjection().code.toLowerCase(),i=this.getRenderer();if(e.boundingVolume.region){const n=e.boundingVolume.region;return new t.Extent(_t(n[0]),_t(n[1]),_t(n[2]),_t(n[3]))}if(e.boundingVolume.sphere){const o=e.boundingVolume.sphere,c=ce([],a.transformMat4([0,0,0],o,n));s&&i.He(c,c);const h=o[3],l=r.locate(c,-h,h),u=r.locate(c,h,-h);return new t.Extent(l,u)}if(e.boundingVolume.box){const o=e.boundingVolume.box,h=a.transformMat4([0,0,0],o,n),l=new t.Coordinate(ce([],h));s&&i.He(l,l);const u=o.slice(3);c.multiply(u,c.fromMat4([0,0,0,0,0,0,0,0,0],e.matrix),u);const f=a.length(u.slice(0,3)),d=a.length(u.slice(3,6)),m=a.length(u.slice(6,9)),p=Math.max(f,d,m),b=r.locate(l,-p,p),g=r.locate(l,p,-p);return new t.Extent(b,g)}return null}getRootTiles(){return this.Re}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Ze(),{tiles:vs};const e=this.getMap(),n=e.cameraPosition,r=e.pointAtResToDistance(n[2],0,e.getGLRes()),s=this.We(n);this.Qe=this.Qe||[0,0,0],a.set(this.Qe,Tt(s.x),Tt(s.y),r),this.tn=ne(this.tn||[],this.Qe[0],this.Qe[1],this.Qe[2]),this.nn=2*Math.tan(.5*Tt(e.getFov()));const i=e.projViewMatrix,o=e.getExtent(),c=o.getWidth()/2,h=o.getHeight()/2;o.xmin-=c,o.ymin-=h,o.xmax+=c,o.ymax+=h;const l=cs(o),u=(this.getMasks()||[]).filter((t=>t&&t instanceof d));u.forEach((t=>{if(!t.maskGeoJSON&&t.toGeoJSON)try{t.maskGeoJSON=t.toGeoJSON();const e=t.getExtent();t.maskGeoJSON.bbox=cs(e)}catch(t){console.error(t)}}));const f={children:[],level:-1};let m=f;const p=[];for(let e=0;e<this.Re.length;e++){const n=this.Re[e];if(!n||!n.visible)continue;const r=[n],s=this.rn(e);for(;r.length>0;){const e=r.pop();for(e.id||this.sn(e);m.level>=e.Se;)m=m.parent;const n=this.an(e,s,i,l,u);if(!(n===qs.VISIBLE||n!==qs.OUT_OF_FRUSTUM&&this.options.alwaysShowTopTiles&&js(e))){let t=m;for(;t&&!t.content;)t=t.parent;n===qs.SCREEN_ERROR_TOO_SMALL&&t&&t.content&&this.cn(p,t);continue}e.lt<1/0&&this.hn(e);const o=this.Ee(e,m);m.children.push(o);const a=e.children,c=a&&a.length,h=o.content;if(!c&&h&&this.cn(p,o),c){h&&"add"===e.refine&&this.cn(p,o),m=o;const n=a[0].parent;let s=!1;for(let i=0,o=a.length;i<o;i++){if(n){const e=t.getCachedTile(a[i].id);if(e&&e.error&&404!==e.error.status)continue;s=!0}else{s=!0,a[i].parent=e,a[i].Mt=e.Mt,a[i].baseUrl=e.baseUrl;const t=a[i].content&&(a[i].content.url||a[i].content.uri);t&&(Ct(t)||t.indexOf("i3s:")>=0?a[i].baseUrl=e.baseUrl:Bt(t)?a[i].content.url=e.baseUrl+t:a[i].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}r.push(a[i])}!s&&h&&this.cn(p,o)}}}return{root:f,tiles:p}}cn(t,e){const{viewerRequestVolume:n,matrix:r}=e.node;n&&!function(t,e,n,r){if(n.region){const e=n.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(n.sphere)return Us(n,e,r)<=0;if(n.box)return 0===Ds(n,e,r)}return!1}(this.Qe,this.tn,n,r)||t.push(e)}Ee(t,e){return{id:t.id,node:t,children:[],level:t.Se,parent:e,content:t.content&&t.content.url}}sn(e){const n=this.getId();e.id=n+":"+t.Util.GUID(),e.matrix=e.transform||r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e.ln=this.un(e),e.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(e)||(e.matrix=r.multiply(e.matrix,e.parent.matrix,e.matrix)),e.j=e.parent.j,void 0===e.Se&&(e.Se=e.parent.Se+1),e.maxExtent=e.parent.maxExtent),e.refine=e.refine&&e.refine.toLowerCase()||"replace",e.content&&!e.content.url&&e.content.uri&&(e.content.url=e.content.uri)}F(t){return this.Re[t].service}dn(t){const e=t.boundingVolume;if(!e||e.Ye&&!this.mn(t))return;const n=this.F(t.j),s=n.heightOffset||0,i=this.options.offset,o=yt(i)||i[0]||i[1],c=n.coordOffset||Es;if(!Array.isArray(c))throw new Error("service.coordOffset must be an array");if(!e.Ye&&(!t.boundingVolume||!s&&r.exactEquals(t.matrix,Ss)&&!o&&c===Es))return;e.box&&e.region&&delete e.region;const{region:h,box:l,sphere:u}=e;if(e.coordOffset=[c[0],c[1]],e.heightOffset=s,h){e.originalVolume||(e.originalVolume=h.slice(0));const t=e.originalVolume,n=this.pn([_t(t[0]),_t(t[1])]);h[0]=Tt(n.x+c[0]),h[1]=Tt(n.y+c[1]);const r=this.pn([_t(t[2]),_t(t[3])]);h[2]=Tt(r.x+c[0]),h[3]=Tt(r.y+c[1]),h[4]=t[4]+s+(c[2]||0),h[5]=t[5]+s+(c[2]||0)}else if(l||u){e.originalVolume||(e.originalVolume=(l||u).slice(0));const n=l||u,r=e.originalVolume,i=a.transformMat4(us,r,t.matrix),o=ce(fs,i),h=this.pn([o[0]+c[0],o[1]+c[1]]);o[0]=h.x,o[1]=h.y,o[2]+=s+(c[2]||0),ne(n,Tt(o[0]),Tt(o[1]),o[2])}e.Ye=!0;try{t.extent=this.boundingVolumeToExtent(t)}catch(t){console.error(t)}}mn(t){const e=t.boundingVolume,n=this.F(t.j),r=n.heightOffset||0,s=n.coordOffset||Es;return e.coordOffset[0]!==s[0]||e.coordOffset[1]!==s[1]||e.heightOffset!==r}un(t){return void 0===t.geometricError||!t.boundingVolume}hn(t){let e=t.parent;for(;e&&e.ln&&!(e.lt<=t.lt);)e.lt=t.lt,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const n=e.content.url;e.baseUrl=n.substring(0,n.lastIndexOf("/")+1),this.Ze()}}onTilesetLoad(t,e,n){if(!t)return void console.warn("invalid tileset at : "+n);const s=(t.asset&&t.asset.gltfUpAxis||e&&e.Mt||"Y").toUpperCase();t.root.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const i=n.indexOf("realspace/")>-1;0===e.Se&&t.asset&&t.asset.s3mType&&i&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root.Mt=s,e){const n=e.boundingVolume;gt(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",n&&(e.boundingVolume=n);const s=t.root.transform;s&&(e.parent?o||(e.matrix=r.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.parent.matrix,s)):e.matrix=s),delete e.content,t.root.content&&(e.content=t.root.content),e.ln=this.un(e);const i=e.content&&(e.content.url||e.content.uri);i&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),!o&&i&&!Ct(i)&&Bt(i)&&(e.content.url=e.baseUrl+i),t.root&&!e.parent&&this.bn(e)}this.Ze(),this.fire("loadtileset",{tileset:t,index:e&&e.j,url:n})}gn(t,e,n){if(!t.extent||!hs||!e)return!0;const r=t.extent;Ps[0]=r.xmin,Ps[1]=r.ymin,Ps[2]=r.xmax,Ps[3]=r.ymax;if(!hs.bboxIntersect(Ps,e))return!1;if(n.length){for(let t=0,e=n.length;t<e;t++){const e=n[t].maskGeoJSON;if(!e||!e.bbox||hs.bboxInMask(Ps,e))return!0}return!1}return!0}an(t,e,n,r,s){if(!this.gn(t,r,s))return qs.OUT_OF_FRUSTUM;if(t.lt=1/0,0===t.Se||t.ln)return this.bn(t),qs.VISIBLE;if(this.dn(t),!this.yn(t,e,n))return qs.OUT_OF_FRUSTUM;if(0===t.geometricError)return qs.VISIBLE;let i=this.F(t.j).maximumScreenSpaceError;null==i&&(i=16);let o=this.wn(t);return 0===o&&t.parent&&(o=.5*(t.parent.vn||0)),o>=i?qs.VISIBLE:qs.SCREEN_ERROR_TOO_SMALL}Jt(e,n){n||(n=new t.Point(0,0));const r=this.getMap();return r.coordToPointAtRes(e,r.getGLRes(),n)}yn(t,e,n){const r=t.id;let s=this.Je[r];const{boundingVolume:i}=t,o=i.region,a=i.box,c=i.sphere,h=this.Tn(t.j),l=this.getRenderer();s&&s.version===h.version||(o?s=this.Je[r]=this._n(t):a?s=this.Je[r]=this.On(t):c&&(s=this.Je[r]=this.Mn(t)),s.version=h.version,t.ut&&(l.Dt(t.ut),delete t.ut));return this.F(t.j).debug&&(this.Je[r].node=t,l.Bt(t)),s.obbox?b(n,s.obbox):!!c&&g(n,s.sphereBox)}_n(e){const n=this.getMap(),s=n.getGLRes(),i=e.boundingVolume.region;let{ws:o,en:c}=function(t){const e=t[0],n=t[1],r=t[2],s=t[3],i=t[4],o=t[5],a=ne([],e,n,i),c=ne([],r,s,o),h=ce(a,a),l=ce(c,c);return{ws:h,en:l}}(i);o=new t.Coordinate(o),c=new t.Coordinate(c);const h=n.coordToPointAtRes(o,s);h.z=n.altitudeToPoint(o.z,s);const l=n.coordToPointAtRes(c,s);l.z=n.altitudeToPoint(c.z,s);const u=[l.x,h.y,l.z,l.x,l.y,l.z,h.x,l.y,l.z,h.x,h.y,l.z,l.x,h.y,h.z,l.x,l.y,h.z,h.x,l.y,h.z,h.x,h.y,h.z],f=[(u[0]+u[18])/2,(u[1]+u[19])/2,(u[2]+u[20])/2],d=this.Tn(e.j);e!==d||d.xn||(d.xn=f);const m=this.Vt([],e),p=r.exactEquals(Ss,m);if(!p){a.transformMat4(f,f,m);const t=us;for(let e=0;e<u.length;e+=3){let n=a.set(t,u[e],u[e+1],u[e+2]);p||(n=a.transformMat4(n,n,m)),u[e]=n[0],u[e+1]=n[1],u[e+2]=n[2]}}const b=n.pointAtResToCoord(new t.Point(f),s);b.z=(o.z+c.z)/2;const g=this.An(u,f);for(let t=0;t<u.length;t++)u[t]-=f[t%3];return{obbox:g,boxPosition:u,boxCenter:f,boxCoord:b}}On(t){const e=this.getRenderer(),n=this.getMap(),s="identity"===n.getProjection().code.toLowerCase(),i=n.getGLRes(),{boxCenter:o,boxCoord:c}=this.In(t),h=t.boundingVolume.box,l=this.Sn(h,t.matrix),u=(d=h,function(t,e,n,r,s,i,o,a,c,h,l,u,f,d,m,p,b){return t[0]=e||0,t[1]=i||0,t[2]=h||0,t[3]=0,t[4]=n||0,t[5]=o||0,t[6]=l||0,t[7]=0,t[8]=r||0,t[9]=a||0,t[10]=u||0,t[11]=0,t[12]=s||0,t[13]=c||0,t[14]=f||0,t[15]=b,t}([],(f=l)[0],f[3],f[6],d[0],f[1],f[4],f[7],d[1],f[2],f[5],f[8],d[2],0,0,0,1));var f,d;const m=this.Vt([],t),p=r.exactEquals(Ss,m);p||a.transformMat4(o,o,m);const b=[],g=us;for(let t=0;t<Ls.length;t+=3){g[0]=Ls[t],g[1]=Ls[t+1],g[2]=Ls[t+2],a.transformMat4(g,g,u),ce(g,g),s&&e.He(g,g);const r=Ts.set(g[0],g[1],g[2]);n.coordToPointAtRes(r,i,_s);let o=a.set(g,_s.x,_s.y,n.altitudeToPoint(r.z,i));p||(o=a.transformMat4(o,o,m)),b[t]=o[0],b[t+1]=o[1],b[t+2]=o[2]}const y=this.An(b,o);for(let t=0;t<b.length;t++)b[t]-=o[t%3];return{obbox:y,boxPosition:b,boxCenter:o,boxCoord:c}}Mn(e){const n=this.getMap(),r=this.getRenderer(),s="identity"===n.getProjection().code.toLowerCase(),i=e.boundingVolume.sphere,o=i;let a=us;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:ce(a,o),s&&r.He(a,a);const c=new t.Coordinate(a),h=this.Jt(c,_s).toArray();h[2]=n.altitudeToPoint(c.z,n.getGLRes());const l=this.En(c);return{boxCenter:h,boxCoord:c,sphereBox:[h,i[3]*l[2]]}}An(t,e){const n=Fs(ps,t,0,1,4,5),r=Fs(bs,t,0,3,4,7),s=Fs(gs,t,0,1,2,3);return[...e,...a.sub(us,n,e),...a.sub(fs,r,e),...a.sub(ds,s,e)]}In(e){const n=this.getMap(),r=this.getRenderer(),s="identity"===n.getProjection().code.toLowerCase(),i=n.getGLRes(),o=e.boundingVolume.box.slice(0,3);ce(o,o),s&&r.He(o,o);const a=new t.Coordinate(o),c=n.coordToPointAtRes(a,i);return{boxCenter:[c.x,c.y,n.altitudeToPoint(a.z,i)],boxCoord:a}}Vt(t,e){const n=this.Tn(e.j),s=this.F(e.j),i=n.xn,c=r.fromTranslation(Ms,a.set(us,-i[0],-i[1],-i[2])),h=r.fromTranslation(xs,i),l=s.rotation||Cs,u=o.fromEuler(ws,...l),f=s.scale,d=f&&a.set(ks,f,f,f)||Ns,m=r.fromRotationTranslationScale(As,u,Rs,d);return t=r.multiply(t,m,c),r.multiply(t,h,t)}bn(t){const e=this.F(t.j);if(!t.boundingVolume||this.Cn(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,s=t.boundingVolume.sphere;let i=null;n?i=this.Nn(t).boxCenter:r?i=this.kn(t).boxCenter:s&&(i=this.Mn(t).boxCenter);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.Rn=[a[0]||0,a[1]||0],t.Pn=o,t.xn=i}Cn(t,e){if(!t.Rn)return!1;const n=e.coordOffset||Es;return t.Rn[0]===n[0]&&t.Rn[1]===n[1]&&t.Pn===(e.heightOffset||0)}kn(t){return this.dn(t),this._n(t)}Nn(t){return this.dn(t),this.In(t)}Sn(t,e){let n=t.slice(3,12);const r=c.fromMat4(Os,e);return n=c.multiply(n,r,n),n}En(t){const e=this.getMap(),n=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let r;return r=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:n.y/100,a.set(ys,n.x/100*1.01,n.y/100*1.01,r),ys}pn(e){Array.isArray(e)&&(e=new t.Coordinate(e));let n=this.options.offset;if(yt(n)&&(n=n.call(this,Array.isArray(e)?new t.Coordinate(e):e)),n[0]||n[1]){const t=this.getMap(),r=t.getGLRes(),s=t.coordToPointAtRes(e,r);return _s.set(n[0],n[1]),s._sub(_s),t.pointAtResToCoord(s,r)}return e}Tn(t){return this.Re[t]}rn(e){const n=this.F(e).maxExtent;if(!n)return null;const r=this.Re[e];return r.maxExtent||(r.maxExtent=new t.Extent(n).convertTo((t=>this.Jt(t)))),r.maxExtent}wn(t){const e=this.nn,n=t.geometricError;if(0===n)return t.vn=0,0;const r=this.F(t.j).scale||1,s=this.getMap();let i;t.boundingVolume.region?i=function(t,e,n){t.Ln||(t.Ln=new os(t.boundingVolume.region));return t.Ln.distanceToCamera(e,n)}(t,this.tn,this.Qe):t.boundingVolume.sphere?i=Us(t.boundingVolume,this.tn):t.boundingVolume.box&&(i=Ds(t.boundingVolume,this.tn));const o=Math.max(Math.abs(i),1e-7),a=n*r*s.height/(o*e);return t.lt=i,t.vn=a,a}Ze(){const t=this.getRenderer();t&&t.setToRedraw()}Ut(t){return this.Je[t]}identify(e,n={}){const r=this.getMap(),s=this.getRenderer();if(!r||!s)return[];Array.isArray(e)&&(e=new t.Coordinate(e));const i=r.coordToContainerPoint(e);return this.identifyAtPoint(i,n)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&kt(n,r)}const r=this.getMap(),s=this.getRenderer();if(!r||!s)return[];const i=r.getDevicePixelRatio();return kt(n,s.pick(t.x*i,t.y*i,e)),e&&e.filter&&!e.excludeMasks?n.filter((t=>e.filter(t))):n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.Zt():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.$||(this.$=[]),this.$.push(t),this)}Fe(){if(this.$){for(let t=0;t<this.$.length;t++)this.highlight(this.$[t]);delete this.$}}cancelHighlight(t,e){const n=this.getRenderer();return n?(n.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}showOnly(t){const e=this.getRenderer();return e?(e.showOnly(t),this):(this.J||(this.J=[]),this.J.push(t),this)}Bn(){if(this.J){for(let t=0;t<this.J.length;t++)this.showOnly(this.J[t]);delete this.J}}cancelShowOnly(t){const e=this.getRenderer();return e?(e.cancelShowOnly(t),this):this}setServiceOpacity(t,e){const n=this.options.services[t];n&&(n.opacity=e);return this.getRenderer()?(this.Ze(),this):this}setServiceDebug(t,e){const n=this.options.services[t];n&&(n.debug=e);return this.getRenderer()?(this.Ze(),this):this}We(t){const e=this.getMap(),n=e.getGLRes();Is.set(t[0],t[1]);const r=e.pointAtResToCoord(Is,n);return"identity"===e.getProjection().code.toLowerCase()?(fs[0]=r.x,fs[1]=r.y,this.getRenderer().Ve(us,fs),r.set(us[0],us[1]),r):r}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function Us(t,e,n){let r=t.sphere;n&&(r=a.transformMat4([0,0,0],r,n));const s=a.dist(r,e),i=t.sphere[3];return s<i?0:s-i}function Ds(t,e,n){const r=t.box;let s=a.set(us,r[0],r[1],r[2]);n&&(s=a.transformMat4([0,0,0],s,n));return Ur(s,c.set(Os,r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11]),e)}function Gs(t,e,n){const s=(t=Ot(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,ln:!0,service:n,visible:!!bt(n.visible)||n.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),j:e,Se:0,domainKey:s}}function Fs(t,e,n,r,s,i){const o=a.set(us,e[3*n],e[3*n+1],e[3*n+2]),c=a.set(fs,e[3*r],e[3*r+1],e[3*r+2]),h=a.set(ds,e[3*s],e[3*s+1],e[3*s+2]),l=a.set(ms,e[3*i],e[3*i+1],e[3*i+2]);return t[0]=(o[0]+c[0]+h[0]+l[0])/4,t[1]=(o[1]+c[1]+h[1]+l[1])/4,t[2]=(o[2]+c[2]+h[2]+l[2])/4,t}function js(t){if(!t.content||t.hasParentContent)return!1;let e=t.parent;if(e&&(e.content||e.hasParentContent))return t.hasParentContent||(t.hasParentContent=!0),!1;for(;e;){if(e.content||e.hasParentContent)return t.hasParentContent||(t.hasParentContent=!0),!1;e=e.parent}return!0}function zs(t,e){return Array.isArray(t)&&Array.isArray(e)?2===t.length?m.exactEquals(t,e):a.exactEquals(t,e):t===e}var qs;Bs.mergeOptions(ls),Bs.registerRenderer("gl",Pr),Bs.registerJSONType("Geo3DTilesLayer"),function(t){t[t.OUT_OF_FRUSTUM=0]="OUT_OF_FRUSTUM",t[t.SCREEN_ERROR_TOO_SMALL=1]="SCREEN_ERROR_TOO_SMALL",t[t.VISIBLE=2]="VISIBLE"}(qs||(qs={}));let Hs=null;function Vs(){return Hs||(Hs={"image/crn":pr.crn&&pr.crn(),"image/ktx2":pr.ktx2&&pr.ktx2(),"image/cttf":pr.ktx2&&pr.ktx2(),"draco":pr.draco&&pr.draco()}),Hs}class $s{constructor(t,e,n){this.Un=t,this.Dn=e||y,this.ke=n,this.Gn=Vs()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.Fn(t,e,n,r,s)):w.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Fn(t,s,n,r)}))}Fn(t,e,n,r,s){const i=s&&s.maxTextureSize,o=this.jn(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.Dn(a,o.glb,{transferable:!0,requestImage:this.Un,decoders:this.Gn,supportedFormats:this.ke,maxTextureSize:i});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${n}-${r}`;const s=c.transferables;for(let t=0;t<o.transferables.length;t++)s.indexOf(o.transferables[t])<0&&s.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:s,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}jn(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=s.getUint32(12,!0),c=s.getUint32(16,!0),h=s.getUint32(20,!0),l=s.getUint32(24,!0),u=28+e;h>=570425344?(u-=8,o=a,h=c,l=0,a=0,c=0):l>=570425344&&(u-=4,o=h,h=a,l=c,a=0,c=0);const f=[t];let d,m,p;if(a>0?(d=ve(t,u,a),u+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(u+=c),h>0&&(m=Te(t,u,h),u+=h,l>0)){const e=_e(0,u,l);p=t.slice(e.offset,e.offset+e.byteLength),u+=l,f.push(p)}const b=d.BATCH_LENGTH,g={};if(d&&d.BATCH_ID){g.BATCH_ID=Me(d.BATCH_ID,t,undefined.offset,b);const e=g.BATCH_ID.array&&g.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:p,b3dm:g,glb:{buffer:t,byteOffset:u,byteLength:s.byteLength+s.byteOffset-u}}}zn(){return null}}class Xs{constructor(t,e,n,r){this.Un=t,this.Dn=e||y,this.ke=n,this.Gn=Vs(),this.qn=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.Fn(t,e,n,r,s)):w.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Fn(t,s,n,r)}))}Fn(t,e,n,r,s){return this.Hn(t,e,n,r,s).then((({gltf:s,transferables:i})=>{const o=this.Vn(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete s.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:s})}))}Hn(t,e,n,r,s){const i=s&&s.maxTextureSize,o={transferable:!0,requestImage:this.Un,decoders:this.Gn,supportedFormats:this.ke,maxTextureSize:i},a=new DataView(e,n,r),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let r=At(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?w.getArrayBuffer(r,{}).then((t=>this.$n(r,{buffer:t.data,byteOffset:0},o))):w.getJSON(r,{}).then((t=>this.$n(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.$n(t,r,o)}}$n(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.Dn(r,e,n);return s.load({skipAttributeTransform:!0}).then((n=>{let r=0,i=0;return e.buffer&&(r=e.byteOffset||0,i=e.byteLength||0),n.url=`${t}-${r}-${i}`,{transferables:s.transferables,gltf:n}}))}Vn(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:l}=ke(s,32+e,o),u={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;u.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;u.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Xn(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(u.POSITION.array.buffer)}if(a.BATCH_ID){u.BATCH_ID=Me(a.BATCH_ID,t,c.offset,f);const e=u.BATCH_ID.array&&u.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Jn(new Uint16Array(t,e+c.offset,2*f))},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Jn(new Uint16Array(t,e+c.offset,2*f))},o.push(u.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;u.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).slice()},o.push(u.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;u.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:h,batchTableBin:l,featureTable:a,i3dm:u,transferables:o}}Jn(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)Js(r,t[2*s],t[2*s+1],65535),n[3*s]=r[0],n[3*s+1]=r[1],n[3*s+2]=r[2];return n}Xn(t,e,n){return Ne(new Float32Array(t.length),t,e,n)}zn(){return null}}function Js(t,e,n,r){if(t[0]=Ks(e,r),t[1]=Ks(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*Zs(e),t[1]=(1-Math.abs(e))*Zs(t[1])}return _.normalize(t,t)}function Ks(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function Zs(t){return t<0?-1:1}class Ys{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.Fn(t,e,n,r)):w.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Fn(t,s,n,r)}))}Fn(t,e,n,r){return this.Kn(e,n,r,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}Kn(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:l}=ke(s,e+28,o),u=a.QUANTIZED_VOLUME_OFFSET,f=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let m,p={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){p=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,p.byteOffset+c.offset,p.byteLength);const e={attributes:p.properties,useUniqueIDs:!1};return this.Zn||(this.Zn=Vs().draco),this.Zn(m,e).then((e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.Yn(t,e.attributes,c.offset,d,o,u,f);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Ce(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?r.BATCH_ID=Me(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=Ws(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:h,batchTableBin:l,featureTable:a,pnts:r,transferables:o}}))}const b=this.Yn(t,a,c.offset,d,o,u,f);if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?b.BATCH_ID=Me(a.BATCH_ID,t,c.offset,d):b.BATCH_ID=Ws(d);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:h,batchTableBin:l,featureTable:a,pnts:b,transferables:o})}Yn(t,e,n,r,s,i,o){const a={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:h}=e.POSITION_QUANTIZED;c=c||0;const l=h?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Xn(h||new Uint16Array(t,c+l,3*r),i,o)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},s.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},s.push(o.buffer)}return a}Xn(t,e,n){return Ne(new Float32Array(t.length),t,e,n)}zn(){return null}}function Ws(t){const e=Et(t),n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Ce(e),array:n}}class Qs{constructor(t,e,n,r){this.ke=n,this.Un=t,this.Dn=e||y,this.qn=r}load(t,e,n=0,r=0,s){return e?this.Fn(t,e,n,r,s):w.getArrayBuffer(t,{}).then((e=>{const s=e.data;return this.Fn(t,s,n,r)}))}Fn(t,e,n,r,s){r||(r=e.byteLength);const i=this.Wn(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new $s(this.Un,this.Dn,this.ke);else if("i3dm"===i[n].magic)r=new Xs(this.Un,this.Dn,this.ke,this.qn);else if("pnts"===i[n].magic)r=new Ys;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new Qs(this.Un,this.Dn,this.ke,this.qn)}o.push(r.load(t,e,i[n].offset,i[n].byteLength,s).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}Wn(t,e,n,r){const s=new DataView(t,n,r),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===s.byteLength)return[];const o=[],a=s.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=ye(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(e.transcoders){const n=t.Map.VERSION;if(n.indexOf("1.0.0-beta")>=0||n.indexOf("1.0.0-alpha")>=0){const n=e.transcoders.inject(x);t.registerWorkerAdapter("@maptalks/3dtiles",n)}else t.registerWorkerAdapter("@maptalks/3dtiles",(function(){return e.transcoders.inject(x)}))}else t.registerWorkerAdapter("@maptalks/3dtiles",x);export{$s as B3DMLoader,Qs as CMPTLoader,Bs as Geo3DTilesLayer,Lt as Geo3DTilesUtil,be as Geo3DTransform};"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.98.0");
|
|
11
|
+
*/(100,1),hr=[0,0,0,1],lr=[1,1,1];class ur{constructor(t,e){this.o=e,this.h=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.u=t,this.m=new n.Renderer(t),this.p={},this.v={},this.T={},this.M={},this.O={},this._={},this.A=new n.Scene,this.I=new n.Scene,this.S=new n.Scene,this.C=new n.Scene,this.k=new n.ResourceLoader(t.texture(2)),this.N=this.R.bind(this),this.L=new n.KHRTechniquesWebglManager(this.u,this.P(),this.k);const r=this.getMap();this.U=r.altitudeToPoint(100,r.getGLRes())/100}getI3DMMeshes(){return this.M}getPNTSMeshes(){return this.T}getB3DMMeshes(){return this.v}getPaintedMeshes(){return this.B}getMap(){return this.o.getMap()}paint(t,e,n,o){const a=o&&o.renderTarget,c=o&&o.sceneFilter,h=this.getMap();if(!t.length||!h)return null;const l=this.F(),u=h.projViewMatrix,f=[],d=[],m=[],y=[],b=[];for(let n=0,s=t.length;n<s;n++){const s=t[n].data.node;let a=this.D(s);if(!a)continue;const c=this.o.j(s.G),h=c.debugNodes,l=c.heightOffset||0,g=c.coordOffset||Bn;this.O[s.id]&&(a=this.O[s.id],a=St(a));let w=c.polygonOffset||kn;gt(w)&&(w=w()),Array.isArray(a)||(f[0]=a,a=f);for(let c=0,f=a.length;c<f;c++){const f=a[c].properties.magic;if(a[c].properties.heightOffset===l&&a[c].properties.coordOffset[0]===g[0]&&a[c].properties.coordOffset[1]===g[1]||(this.H(a[c]),a[c].q=r.copy([],a[c].localTransform)),a[c].V=s,"b3dm"===f){if(a[c].getBoundingBox&&!p(u,a[c].getBoundingBox()))continue;const{batchIdData:t,batchIdMap:e}=a[c].geometry.properties;if(t&&e){const t=a[c].properties.node.G;this.$&&this.$[t]?i.highlightMesh(this.u,a[c],this.$[t],this.J,e):this.$&&this.$[t]||i.highlightMesh(this.u,a[c],null,this.J,e),i.showOnly(this.u,a[c],this.Z&&this.Z[t],this.X,e)}if(h&&h.length&&h.indexOf(a[c].V.id)<0)continue;o&&o.bloom&&a[c].properties.hlBloomMesh&&(a[c].properties.hlBloomMesh.properties.depthFunc="always",a[c].properties.hlBloomMesh.properties.polygonOffset=w,m.push(a[c].properties.hlBloomMesh)),m.push(a[c])}else"pnts"===f?y.push(a[c]):"i3dm"===f&&b.push(a[c]);a[c].properties.isLeaf=!!e[s.id],a[c].properties.selectionDepth=255-t[n].selectionDepth,a[c].properties.polygonOffset=w,e[s.id]||d.push(a[c]),this.W(a[c]),this.K(a[c],s)}}let g=0;const w=this.L.getExcludeFilter();s.setIncludeUniformValues(l,o),g+=this.Y(this.tt,l,[c,Dn,w],a,d,m,b),g+=this.Y(this.et,l,[c,jn,w],a,d,m,b),this.L.forEachShader(((t,e,n)=>{const r=this.F(n);g+=this.Y(t,r,[c,e],a,d,m,b)})),this.I.setMeshes(y);const v=this.nt();return g+=this.m.render(this.rt,v,this.I,a&&a.fbo),this.B={pntsMeshes:y,i3dmMeshes:b,b3dmMeshes:m},this.C.setMeshes(n),this.m.render(this.it,l,this.C,a&&a.fbo),g}prepareRender(t){this.st(t)}st(t){t&&t.states&&t.states.includesChanged&&(this.et.dispose(),delete this.et,this.tt.dispose(),delete this.tt),this.ot(t)}Y(t,e,n,r,i,s,o){t.filter=n.filter((t=>!!t)),e.stencilEnable=!1;const a=r&&r.fbo;let c=0;const h=[];for(let n=0;n<s.length;n++){const{isLeaf:r,selectionDepth:i}=s[n].properties;r&&255===i?(e.stencilEnable&&(this.ct(a),this.A.setMeshes(h),c+=this.m.render(t,e,this.A,a),h.length=0,e.stencilEnable=!1),h.push(s[n])):(e.stencilEnable||(this.A.setMeshes(h),c+=this.m.render(t,e,this.A,a),h.length=0,e.stencilEnable=!0),h.push(s[n])),n===s.length-1&&(e.stencilEnable&&this.ct(a),this.A.setMeshes(h),c+=this.m.render(t,e,this.A,a))}return this.A.setMeshes(s.filter((t=>t.properties.isLeaf))),this.S.setMeshes(o),c+=this.m.render(t,e,this.S,r&&r.fbo),c}ct(t){this.u.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.A.getMeshes()}getCurrentI3DMMeshes(){return this.S.getMeshes()}ht(t,e){return e.V.lt-t.V.lt}deleteTile(t){const e=t.node;e.ut&&(e.ut.geometry.dispose(),e.ut.dispose(),delete e.ut);const n=e.id;this.ft(n)}ft(t){const e=this.v[t]||this.T[t]||this.M[t]||this.O[t]||this.p[t];this.O[t]?this.dt(t):e&&(this.yt(e),delete this.v[t],delete this.T[t],delete this.M[t],delete this.p[t])}dt(t){let e=this.O[t];e=St(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.ft(n)}delete this.O[t]}yt(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.yt(t[e]);else{i.showOnly(this.u,t),i.highlightMesh(this.u,t);const e=t.geometry.properties.url;if(e){const n=this._[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this._[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.o;In(t.getRenderer().canvas,t.getMap());for(const t in this.O)this.dt(t);this.O={};for(const t in this.v)this.ft(t);this.v={};for(const t in this.T)this.ft(t);this.T={};for(const t in this.M)this.ft(t);this.M={};for(const t in this.p)this.ft(t);this.p={},this.tt&&(this.tt.dispose(),delete this.tt),this.et&&(this.et.dispose(),delete this.et),this.rt&&(this.rt.dispose(),delete this.rt),this.it&&(this.it.dispose(),delete this.it),this.L.dispose(),this.picking&&this.picking.dispose()}D(t){return this.v[t.id]||this.T[t.id]||this.M[t.id]||this.O[t.id]}has(t){return this.D(t)||this.p[t.id]}H(t){const e=t.properties.magic;"b3dm"===e?this.bt(t):"i3dm"===e?this.gt(t):"pnts"===e&&this.wt(t)}createPntsMesh(t,e,i,s){if(this.T[e]){const t=this.T[e];return console.warn(`pnts mesh with id(${e}) was already created.`),s(null,{id:e,mesh:t}),t}const{pnts:o,featureTable:a,rootIdx:c,compressed_int16_params:h}=t,l=a.POINTS_LENGTH;o.BATCH_ID||(o.BATCH_ID=new Uint8Array(l),o.BATCH_ID.fill(0));const u=new n.Geometry(o,null,l,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});u.generateBuffers(this.u);const f={};o.POSITION?f.HAS_POSITION=1:o.POSITION_QUANTIZED&&(f.HAS_POSITION_QUANTIZED=1),o.RGB?f.HAS_RGB=1:o.RGBA?f.HAS_RGBA=1:o.RGB565&&(f.HAS_RGB565=1),(o.NORMAL||o.NORMAL_OCT16P)&&(f.HAS_NORMAL=1,o.NORMAL_OCT16P&&(f.HAS_NORMAL_OCT16P=1)),this.vt(f,h),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:d,rtcCoord:m,projCenter:p}=t,y=this.o.j(c),b=new n.Mesh(u);b.properties.magic="pnts",b.properties.id=e,b.properties.node=i,b.properties.count=l,b.properties.batchTable=t.batchTable,b.properties.batchTableBin=t.batchTableBin,b.properties.serviceIndex=c,b.properties.rtcCoord=m,b.properties.rtcCenter=d,b.properties.projCenter=p,b.setDefines(f),b.setFunctionUniform("pointColor",(function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:y&&y.pointColor||[1,1,1,1]}));const g=this.getMap();let w=null,v=null;b.setFunctionUniform("pointSize",(function(){if(!y)return 2;if(mn(y.pointSize)){const t=JSON.stringify(y.pointSize);t!==w&&(v=pn(y.pointSize),w=t);return v(g.getZoom())}return y.pointSize||2}));let T=null,M=null;return b.setFunctionUniform("pointOpacity",(function(){if(!y)return 1;if(mn(y.pointOpacity)){const t=JSON.stringify(y.pointOpacity);t!==T&&(M=pn(y.pointOpacity),T=t);return M(g.getZoom())}return y.pointOpacity||1})),this.Tt(b,h),this.wt(b),b.q=r.copy([],b.localTransform),this.T[e]=b,s(null,{id:e,mesh:[b]}),[b]}wt(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:i}=t.properties;this.Mt(e,n,i,r.G),t.setLocalTransform(e)}createI3DMMesh(t,e,i,s){if(this.M[e]){const t=this.M[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.p[e]||s(null,{id:e,mesh:t}),t}const c=this.o.j(i.G),h=this.Ot(i._t),{i3dm:l,featureTable:u,gltf:f,batchTable:d,batchTableBin:m,count:p}=t,y=u.INSTANCES_LENGTH,{rtcCenter:b,rtcCoord:w,projCenter:v}=t,T=this.At(Xn,i,b,w);ze(T,Un,T);const M=r.getRotation(Wn,T);o.normalize(M,M);const O=r.getScaling(Kn,T),_=r.fromScaling(Yn,O),A=this.xt(Qn,v,i),x=this.It(nr),I=this.St(rr,w),S=a.div(ir,I,x),C=r.fromScaling(sr,S),{POSITION:k,NORMAL_UP:N,NORMAL_RIGHT:R,SCALE:E,SCALE_NON_UNIFORM:L}=l,P={"instance_vectorA":new Float32Array(4*y),"instance_vectorB":new Float32Array(4*y),"instance_vectorC":new Float32Array(4*y),"aPickingId":new Uint16Array(y)};for(let t=0;t<y;t++)P.aPickingId[t]=t;const U=new Float32Array(3),B=new Float32Array(3),F=[],D=new Float32Array(1),j=new Float32Array(3),z=[],G=[],H=[],q=[];!function(t,e){let{byteOffset:n,byteStride:r,count:i}=t;const{componentType:s,itemSize:o}=t,a=t.array.buffer,c=s?g.getTypedArrayCtor(s):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,i=i||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,i*o);for(let r=0;r<i*o;r+=o)e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o);return}const h=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<i;t++){const i=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);h.set(i),e(new c(h.buffer),t),i.set(h)}}(k,((t,e)=>{N?(Wt(B,R,e),Wt(U,N,e),a.cross(F,B,U),a.normalize(F,F),It(z,B,0),It(z,U,1),It(z,F,2),o.fromMat3(G,z),o.normalize(G,G),o.multiply(G,M,G)):o.identity(G),E?(Wt(D,E,e),a.set(H,D[0],D[0],D[0])):L?(Wt(j,L,e),a.set(H,...j)):a.set(H,1,1,1),r.fromRotationTranslationScale(q,G,t,H),Kt(P.instance_vectorA,e,q,0),Kt(P.instance_vectorB,e,q,1),Kt(P.instance_vectorC,e,q,2)}));const V={};for(const t in P)V[t]={buffer:this.u.buffer({dimension:P[t].length/y,data:P[t]}),divisor:1};const $=c.shader||"pbr";let J=0,Z=!0;const X=[],W=[];return Gt(f,((t,s,o,a)=>{const c=this.Ct(t,s,o,a,i,!0,$,W),{geometry:l,material:f}=c;f&&!f.isReady()&&(Z=!1,J++);const g=new n.InstancedMesh(V,y,l,f);c.refMeshes||(c.refMeshes=new Set,c.refMeshes.add(g.uuid)),g.properties.magic="i3dm",g.properties.id=e,g.properties.count=p,g.properties.batchTable=d,g.properties.batchTableBin=m,g.properties.serviceIndex=i.G,g.properties.rtcCoord=w,g.properties.rtcCenter=b,g.properties.projCenter=v,g.properties.node=i;const M=this.kt(t,l,f,i.G,a);t.compressed_int16_params&&this.Tt(g,t.compressed_int16_params),this.Nt(g,t.attributes);const O=r.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(O,O,t.matrices[e]);r.multiply(O,h,O),r.multiply(O,C,O),u.EAST_NORTH_UP||N?r.multiply(O,_,O):r.multiply(O,T,O),g.setPositionMatrix(O),this.gt(g,A),g.setDefines(M),g.properties.polygonOffset={offset:0,factor:0},X.push(g),delete t.attributes,g.q=r.copy([],g.localTransform)})),fr(W),Z?(this.M[e]=X,s(null,{id:e,mesh:X})):(this.p[e]={meshes:X,count:J},X.Rt=s),X}gt(t,e){const{rtcCoord:n,node:i,projCenter:s}=t.properties;e||(e=this.xt(Qn,s,i));const o=this.o.j(i.G),a=t.localTransform||[];if(o.coordOffset){const t=this.Et(Xn,i.G,n);r.multiply(a,t,e)}else r.copy(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||Bn}xt(t,e,n){r.fromScaling(t,this.It(nr));const i=this.Lt(Jn,e,n.G);return r.multiply(t,r.fromTranslation(tr,i),t),t}createB3DMMesh(e,i,s,o){if(e.gltf&&(e.gltf.transferables=null),this.v[i]||this.p[i]){const t=this.v[i];return console.warn(`mesh with id(${i}) was already created.`),this.p[i]||o(null,{id:i,mesh:t}),t}let a;if(s.maxExtent){const e=new t.Extent(s.maxExtent).convertTo((t=>this._pointToPrj(t)));a=[e.xmin,e.ymin,e.xmax,e.ymax]}const c=e.gltf,{projCenter:h}=c.extensions.MAPTALKS_RTC,{rtcCoord:l,center:u}=c.extensions.CESIUM_RTC,f=c.asset.sharePosition,d=this.Ot(s._t),m=this.Pt(Qn,f,l,u,h,s),p=this.o.j(s.G);let y=p.shader||"pbr";if(p.unlit)y="phong";else if(c.materials)for(let t=0;t<c.materials.length;t++)if(c.materials[t]&&c.materials[t].extensions&&c.materials[t].extensions.KHR_materials_unlit){y="phong";break}const b=[],g=[];let w=0,v=!0;return Gt(c,((t,o,c,T)=>{const M=this.Ct(t,o,c,T,s,!1,y,b),{geometry:O,material:_}=M;_&&!_.isReady()&&(v=!1,w++);const A=new n.Mesh(O,_);M.refMeshes||(M.refMeshes=new Set,M.refMeshes.add(A.uuid)),A.properties.magic="b3dm",A.properties.id=i,A.properties.node=s,e.batchTable&&(A.properties.batchTable=e.batchTable,A.properties.batchTableBin=e.batchTableBin),A.properties.count=e.featureTable&&e.featureTable.BATCH_LENGTH||0,A.properties.serviceIndex=s.G;const x=this.kt(t,O,_,s.G,T);A.setDefines(x);const I=t.compressUniforms;if(I)for(const t in I)A.setUniform(t,I[t]);t.compressed_int16_params&&this.Tt(A,t.compressed_int16_params),this.Nt(A,t.attributes),a&&(x.USE_MAX_EXTENT=1,A.setUniform("maxPrjExtent",a)),A.hasFunctionUniform("polygonOpacity")||A.setFunctionUniform("polygonOpacity",(function(){return vt(p.opacity)?p.opacity:1})),A.hasFunctionUniform("polygonFill")||A.setFunctionUniform("polygonFill",(function(){return Lt([],p.polygonFill||Nn)})),A.material.hasFunctionUniform("hsv")||A.material.setFunctionUniform("hsv",(function(){return p.hsv||Rn}));const S=r.identity([]);if(f&&t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)r.multiply(S,S,t.matrices[e]);f&&r.multiply(S,d,S),A.properties.node=s,A.properties.projCenter=h,A.properties.nodeMatrix=S,A.properties.isSharedPosition=f,A.properties.rtcCoord=l,A.properties.rtcCenter=u,this.bt(A,m),g.push(A),delete t.attributes,A.q=r.copy([],A.localTransform)})),fr(b),v?(this.v[i]=g,o(null,{id:i,mesh:g})):(this.p[i]={meshes:g,count:w},g.Rt=o),g}Ut(t){const e=this.o.Bt(t.id);if(!e||t.ut)return;let i,s,o,a;if(e.obbox)i=e.boxPosition,s=ar,o=e.boxCenter,a=lr;else if(e.sphereBox){const t=e.sphereBox[0],n=e.sphereBox[1];i=cr.vertices,s=cr.indices,o=t,a=[n,n,n]}const c=new n.Geometry({POSITION:i},s,0,{primitive:"lines",positionAttribute:"POSITION"}),h=new n.Mesh(c,new n.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),l=[];r.fromRotationTranslationScale(l,hr,o,a),h.localTransform=l,h.q=r.copy([],l),h.properties.node=t,t.ut=h}Ft(t){t.ut&&(t.ut.geometry.dispose(),t.ut.dispose(),delete t.ut)}Tt(t,e){e.POSITION&&t.setUniform("compressedPositionRange",e.POSITION),e.TEXCOORD_0&&t.setUniform("compressedTexcoordRange_0",e.TEXCOORD_0),e.TEXCOORD_1&&t.setUniform("compressedTexcoordRange_1",e.TEXCOORD_0),e.NORMAL&&t.setUniform("compressedNormalRange",e.NORMAL),e.TANGENT&&t.setUniform("compressedTangentRange",e.TANGENT),e.compressed_ratio&&t.setUniform("compressed_ratio",e.compressed_ratio)}bt(t,e){const{isSharedPosition:n,rtcCoord:i,rtcCenter:s,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=this.Pt(e||Qn,n,i,s,o,c));const h=t.localTransform||r.identity([]);r.multiply(h,e,a);const l=this.o.j(c.G);if(l.coordOffset){const t=this.Et(Xn,c.G,i);r.multiply(h,t,h)}t.setLocalTransform(h),t.properties.heightOffset=l.heightOffset||0,t.properties.coordOffset=l.coordOffset&&l.coordOffset.slice(0)||Bn}Pt(t,e,n,i,s,o){if(e){const e=this.St(rr,n),s=r.fromScaling(Zn,e),a=this.At(Xn,o,i,n);r.multiply(t,a,s)}else this.Mt(t,n,s,o.G);return t}Nt(t,e){if(e&&e.TEXCOORD_0&&e.TEXCOORD_0.extensions&&e.TEXCOORD_0.extensions.WEB3D_quantized_attributes){const n=e.TEXCOORD_0.extensions.WEB3D_quantized_attributes.decodeMatrix;t.setUniform("decodeMatrix",n)}}At(t,e,n,i){const s=this.getMap(),o=this.o.j(e.G).heightOffset||0,c=e.matrix?r.copy(t,e.matrix):r.identity(t);if(n){ze(c,a.transformMat4(zn,n,c),c)}const h=function(t,e,n,r,i,s,o){e=M.copy(He,e);const a=ne(He,e[0]*Ye,e[1]*Ye,e[2]),c=T.getTranslation(qe,n),h=r.ellipsoid;let l;l=0===M.len(c)?M.set(Ve,0,0,-6378137):ce(Ve,c),We.x=l[0],We.y=l[1];const u=r.project(We,Ke);$e[0]=u.x/i,$e[1]=u.y/i,$e[2]=(l[2]+o)*s;const f=Ge(a,h,Je);return ze(function(t,e,n){const r=t[0],i=t[1],s=t[2],o=t[4],a=t[5],c=t[6],h=t[8],l=t[9],u=t[10],f=e[0],d=e[1],m=e[2],p=e[3],y=e[4],b=e[5],g=e[6],w=e[7],v=e[8],T=r*f+o*d+h*m,M=i*f+a*d+l*m,O=s*f+c*d+u*m,_=r*p+o*y+h*b,A=i*p+a*y+l*b,x=s*p+c*y+u*b,I=r*g+o*w+h*v,S=i*g+a*w+l*v,C=s*g+c*w+u*v;return n[0]=T,n[1]=M,n[2]=O,n[3]=0,n[4]=_,n[5]=A,n[6]=x,n[7]=0,n[8]=I,n[9]=S,n[10]=C,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(T.invert(Ze,f),O.fromMat4(Xe,n),t),$e,t),t}(c,i,c,s.getProjection(),s.getGLRes(),this.U,o),l=function(t,e){return M.set(t,e[12],e[13],e[14]),t}(Jn,h);let u=this.o.options.offset;if(gt(u)){const t=this.o.Bt(e.id).boxCoord;u=u.call(this.o,t)}return a.set($n,u[0],u[1],0),a.sub(l,l,$n),ze(h,l,h),h}Et(t,e,n){const i=this.o.j(e);if(!i.coordOffset)return null;const s=this.getMap(),o=s.getGLRes();Gn.set(n[0],n[1]);const c=s.coordToPointAtRes(Gn,o,qn),h=i.coordOffset,l=Gn.set(n[0]+h[0],n[1]+h[1]),u=s.coordToPointAtRes(l,o,Vn),f=u.x-c.x,d=u.y-c.y,m=this.U,p=a.set($n,f,d,(h[2]||0)*m);return r.fromTranslation(t,p)}createCMPTMesh(t,e,n,r){if(this.O[e]){const t=this.O[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:i}=t,s=[];for(let t=0;t<i.length;t++){const{magic:r}=i[t],o=e+"."+t;"b3dm"===r?this.createB3DMMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"i3dm"===r?this.createI3DMMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"pnts"===r?this.createPntsMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"cmpt"===r&&this.createCMPTMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)}))}return this.O[e]=s,r(null,{id:e,mesh:s}),s}kt(t,e,n,r,i){const s=("phong"===(this.o.j(r).shader||"pbr")?this.tt:this.et).getGeometryDefines(e);i.asset&&"S3M"===i.asset.generator&&this.Dt(s,e),e.data.uvRegion&&(s.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(s.VertexNormal=1),e.data[e.desc.color0Attribute]&&(s.VertexColor=1),e.data[e.desc.uv0Attribute]&&(s.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(s.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(s.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(s.TexCoord2=1),"MESHOPT"===this.o.jt&&(s.MeshOPT_Compress=1),this.hasIBL()&&(s.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(s.HAS_WEB3D_quantized_attributes_TEXCOORD=1),s.HAS_MIN_ALTITUDE=1,s.HAS_LAYER_OPACITY=1,this.vt(s,t.compressed_int16_params);return bt(s,t.compressDefines),s}vt(t,e){e&&Object.keys(e).length>0&&(t.HAS_COMPRESSED_INT16=1,e.POSITION&&(t.HAS_COMPRESSED_INT16_POSITION=1),e.TEXCOORD_0&&(t.HAS_COMPRESSED_INT16_TEXCOORD_0=1),e.TEXCOORD_1&&(t.HAS_COMPRESSED_INT16_TEXCOORD_1=1),e.NORMAL&&(t.HAS_COMPRESSED_INT16_NORMAL=1),e.TANGENT&&(t.HAS_COMPRESSED_INT16_TANGENT=1),e.compressed_ratio&&(t.HAS_COMPRESSED_INT16_RATIO=1))}W(t){const e=this.o.getRenderer();e&&e.updateMaskDefines(t)}Dt(t,e){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1)}Ct(t,e,r,i,s,o,a,c){let h=!1;i.asset&&"S3M"===i.asset.generator&&(h=!0,i.extensions=i.extensions||{});const l=i.url+"-"+e+"-"+r;if(this._[l])return this._[l];let u,f;c.push(t);const d=i.materials&&i.materials[t.material],m=i.extensions&&i.extensions.KHR_techniques_webgl,p=this.o.j(s.G);if(m&&d.extensions&&d.extensions.KHR_techniques_webgl){const e=this.zt(t,i,o,h);u=e.material,f=e.geometry,p.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.Gt(t,o,or);const e=p.material;u=this.Ht(t.material,i,a,e||En,c,p)}u&&(u.setFunctionUniform("alphaTest",(function(){const t=p.alphaTest;return yt(t)?.1:t})),u.setFunctionUniform("environmentExposure",(()=>{const t=p.ambientLight;let e=p.environmentExposure;const n=this.getMap().getLightManager(),r=n&&n.getAmbientLight();if(t&&(!r||r.color)&&void 0===e){const n=r&&r.color?r.color[0]:.2;e=t[0]/n}return e||1}))),u&&!u.isReady()?u.qt=s.id:u||(u=new n.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const y={geometry:f,material:u};return f.properties.url=l,this._[l]=y,y}zt(t,e,n,r){const{geometry:i,material:s}=this.L.createMesh(t,e,n,r);return{geometry:i,material:s}}Gt(t,e,r){const i=t.attributes,s="COLOR_0";let o=i._BATCHID&&i._BATCHID.array;if(o&&o.byteOffset&&(o=new o.constructor(o)),i[s]){const t=i[s].array||i[s];if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let n=0;n<e.length;n++)e[n]=Math.round(255*t[n]);i[s].array?(i[s].array=e,i[s].componentType=5121):i[s]=e}}const a={};for(const t in i){const e=On(this.u,i[t],{dimension:i[t].itemSize}),n=r[t]||t;a[n]={buffer:e},i[t].quantization&&(a[n].quantization=i[t].quantization),n===r.POSITION&&(a[n].array=i[t].array,a[n].min=i[t].min,a[n].max=i[t].max)}const c=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,h=new n.Geometry(a,c,0,{static:!0,positionAttribute:r.POSITION,normalAttribute:r.NORMAL,uv0Attribute:r.TEXCOORD_0,uv1Attribute:r.TEXCOORD_1,color0Attribute:r.COLOR_0,tangentAttribute:r.TANGENT,pickingIdAttribute:r._BATCHID,primitive:void 0===t.mode?"triangles":Mn(t.mode)});return o&&c&&(h.properties.batchIdData=o,h.properties.batchIdMap=function(t,e){if(!e)return null;const n=new Map;for(let r=0;r<e.length;r++){const i=e[r],s=t[i];let o=n.get(s);o||(o=[],n.set(s,o)),o.push(i)}return n}(o,c)),h.generateBuffers(this.u,{excludeElementsInVAO:e}),h}Mt(t,e,n,i){const s=r.identity(t),o=this.It(Ln);return this.Lt(Jn,n,i),r.translate(s,s,Jn),r.scale(s,s,o),s}Lt(t,e,n){const r=this.U;Gn.x=e[0],Gn.y=e[1];const i=this._prjToPoint(Gn);let s=this.o.options.offset;gt(s)&&(s=s.call(this.o,Gn));const o=this.o.j(n).heightOffset||0;return a.set(t,i.x-s[0],i.y-s[1],r*e[2]+r*o),t}K(t,e){const n=this.o.Vt(er,e);t.localTransform=r.multiply(t.localTransform,n,t.q)}St(t,e){const n=this.getMap();Gn.x=e[0],Gn.y=e[1];const r=n.distanceToPointAtRes(100,100,n.getGLRes(),Gn),i=this.U;return a.set(t,r.x/100,r.y/100,i),t}ot(t){if(this.et)return;const e={x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},i=[],o=[];this.rt=new n.MeshShader({vert:Yt,frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n vec2 circCoord = 2.0 * gl_PointCoord - 1.0;\n\n if (dot(circCoord, circCoord) > 1.0) {\n\n discard;\n\n } else {\n\n gl_FragColor = vColor;\n\n }\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>r.multiply(o,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,e)=>c.fromMat4(i,e.modelMatrix)}],extraCommandProps:{viewport:e,blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,range:[0,1],func:"<"}}});const a={},h=[];s.fillIncludes(a,h,t);const l=this.P();this.tt=new n.PhongShader({uniforms:h,defines:a,extraCommandProps:l}),this.et=new n.pbr.StandardShader({uniforms:h,defines:a,extraCommandProps:l}),this.it=new n.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const u=this.o;xn(u.getRenderer().canvas,this.u,u.getMap()),this.picking=new n.FBORayPicking(this.m,{vert:this.et.vert,extraCommandProps:l,uniforms:this.et.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.$t=new n.FBORayPicking(this.m,{vert:Yt,extraCommandProps:l,uniforms:this.rt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}P(){return{viewport:{x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},cull:{enable:!0},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:">=",ref:(t,e)=>e.meshProperties.selectionDepth},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,range:[0,1],func:(t,e)=>e.meshProperties.depthFunc||"<"},blend:{enable:!0,func:{src:1,dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}nt(t){const e=this.getMap(),n=e.getLightManager(),r=(n&&n.getDirectionalLight()||{}).direction||[1,1,-1],i=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:i,lightDir:a.normalize(Fn,r)}}F(){const t=this.getMap(),e=this.o,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:i}=Sn(n),s=Cn(t,r,i),o=this.o.getRenderer(),a=o.getMaskUniforms();s.minAltitude=e.options.altitude||0;const c=o.canvas.gl&&o.canvas.gl.wrap?e.options.opacity||0:1;return s.layerOpacity=c,bt(s,{czm_lightDirectionEC:s.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[n.width,n.height],polygonFill:[1,1,1,1],polygonOpacity:1}),bt(s,a),s}Ht(t,e,r,i,s,o){const a=e.materials&&e.materials[t];if(!a||!a.baseColorTexture&&!a.pbrMetallicRoughness)return null;const c=bt({},i);if(a.baseColorTexture){const t=e.textures[a.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.Jt(t,s)),c.baseColorFactor=t&&t.image.color||a.baseColorFactor||[1,1,1,1],n&&(c.baseColorTexture=n)}else{if(a.normalTexture){const t=this.Jt(e.textures[a.normalTexture.index],s);if(t){const e=a.normalTexture.scale||1;c.normalTexture=t,c.normalMapFactor=e}}if(a.occlusionTexture){const t=this.Jt(e.textures[a.occlusionTexture.index],s);if(t){const e=a.occlusionTexture.strength||1;c.occlusionTexture=t,c.occlusionFactor=e}}if(a.emissiveTexture){const t=this.Jt(e.textures[a.emissiveTexture.index],s);t&&(c.emissiveTexture=t)}a.emissiveFactor&&(c.emissiveFactor=a.emissiveFactor);const t=a.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(c.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const n=e.textures[t.baseColorTexture.index];if(n&&n.image&&n.image.color)c.baseColorFactor=c.baseColorFactor?h.multiply(c.baseColorFactor,c.baseColorFactor,n.image.color):n.image.color;else{const t=this.Jt(n,s);t&&(c.baseColorTexture=t,c.baseColorTexture.getREGLTexture(this.u))}}if(yt(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),yt(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),a.metallicRoughnessTexture){const t=this.Jt(e.textures[a.metallicRoughnessTexture.index],s);t&&(c.metallicRoughnessTexture=t)}}}if(a.s3mMaterial)return new n.Material(c);if(o.unlit||a.extensions&&a.extensions.KHR_materials_unlit){c.ambientColor=[1,1,1],c.light0_diffuse=[0,0,0,0],c.lightSpecular=[0,0,0];const t=new n.PhongMaterial(c);return t.unlit=void 0===o.unlit||!!o.unlit,t}let l=new n.pbr.StandardMaterial(c);"phong"===r&&(l=n.PhongMaterial.convertFrom(l));const u=a.pbrMetallicRoughness,f=u&&u.baseColorTexture&&u.baseColorTexture.extensions;return f&&f.KHR_texture_transform&&(l.set("khr_offset",f.KHR_texture_transform.offset||[0,0]),l.set("khr_rotation",f.KHR_texture_transform.rotation||0),l.set("khr_scale",f.KHR_texture_transform.scale||[1,1])),l.doubleSided=!(!o.doubleSided&&!a.doubleSided),l.once("complete",this.N),l}Jt(t,e){if(!t)return null;const r={type:t.type?vn(t.type):"uint8",format:t.format?Tn(t.format):"rgba",flipY:!!t.flipY},i=t.image;if(e.push(i),i.array?r.data=i.array:i.mipmap&&(r.mipmap=i.mipmap),!r.data&&!r.mipmap)return null;if(r.width=i.width,r.height=i.height,r.mipmap&&(r.width<4||r.height<4))return null;const s=t.sampler||t.texture&&t.texture.sampler;return s&&(s.magFilter&&(r.mag=bn(s.magFilter)),s.minFilter&&(r.min=gn(s.minFilter)),s.wrapS&&(r.wrapS=wn(s.wrapS)),s.wrapT&&(r.wrapT=wn(s.wrapT))),new n.Texture2D(r,this.k)}R({target:t}){const e=t.qt,n=this.p[e];if(n.count--,!n.count){const t=n.meshes;this.v[e]=t,delete this.p[e];const r=t.Rt;delete t.Rt,r(null,{mesh:n.meshes,id:e})}}It(t){const e=1/this.getMap().getGLRes(),n=this.U;return t[0]=t[1]=e,t[2]=n,t}Zt(t){return this.o.Zt(t)}_pointToPrj(t){const e=this.getMap();return e.getGLZoom?e._pointToPrj(t,e.getGLZoom()):e._pointToPrjAtRes(t,e.getGLRes())}_prjToPoint(t){const e=this.getMap();return e.getGLZoom?e._prjToPoint(t,e.getGLZoom()):e._prjToPointAtRes(t,e.getGLRes(),Hn)}Ot(t){return"Y"===t?_n:"X"===t?An:Pn}pick(t,e,n=3){const r=this.o;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const i=[],s=this.F(),o=this.Xt(this.picking,s,this.A,t,e,n);o&&i.push(o);const a=this.Xt(this.picking,s,this.S,t,e,n);a&&i.push(a);const c=this.nt(),h=this.Xt(this.$t,c,this.I,t,e,n);return h&&i.push(h),i}Xt(t,e,n,r,i,s){if(!n.getMeshes().length)return null;const o=this.o,a=this.getMap();t.render(n.getMeshes().filter((t=>!t.bloom)),e,!0);let c={};t.getRenderedMeshes().length&&(c=t.pick(r,i,s,e,{viewMatrix:a.viewMatrix,projMatrix:a.projMatrix,returnPoint:o.options.pickingPoint}));const{meshId:h,pickingId:l,point:u,coordinate:f}=c,d=(0===h||h)&&t.getMeshAt(h);if(!d||!d.geometry)return null;const m=d.properties;u&&u.length&&(u[0]=Math.round(1e5*u[0])/1e5,u[1]=Math.round(1e5*u[1])/1e5,u[2]=Math.round(1e5*u[2])/1e5);const p={batchId:l},y=o.options.services,b=y&&y[d.properties.serviceIndex];if(b&&b.debug&&(p.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=l;for(const i in t)void 0!==t[i].byteOffset?p[i]=Ae(t[i],e,n,r):p[i]=t[i][r]}return{service:d.properties.serviceIndex,data:p,point:u,coordinate:f}}highlight(t){this.$=t;const e=this.o.getRenderer();this.J=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.$=null;const t=this.o.getRenderer();this.J=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Z=t;const e=this.o.getRenderer();this.X=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Z=null;const t=this.o.getRenderer();this.X=t.getFrameTimestamp(),t.setToRedraw(!0)}Wt(){if(!this.B)return[];const t={},e=[];for(const n in this.B){const r=this.B[n];if(r)for(let n=0;n<r.length;n++){const i=r[n],s=i&&i.geometry;if(!i||!s)continue;const o=i.properties.serviceIndex;t[o]||(t[o]=new Set);const a=s.properties.batchIdData;if(a)for(let n=0;n<a.length;n++)t[o].has(a[n])||(e.push({id:a[n],service:o}),t[o].add(a[n]))}}return e}hasIBL(){const t=this.getMap().getLightManager();return!!(t&&t.getAmbientResource())}}function fr(t){for(let e=0;e<t.length;e++)t[e]&&(t[e].array&&(t[e].array=null),t[e].mipmap&&(t[e].mipmap=null),t[e].indices&&(t[e].indices=null))}const dr=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")},mr=dr(),pr=mr.gl_trans__coders=mr.gl_trans__coders||{};function yr(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}pr.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),i=mr.gl_trans__coders=mr.gl_trans__coders||{};let s=`${r}\n const _____getGlobal = ${dr.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\n;");return s+="\n"+e.substring(r.length),s},pr.registerTranscoder=function(t,e){pr[t]=e},pr.getTranscoder=function(t){return pr[t]};const br=[];class gr{constructor(t,e,n,r,i){this.o=r,this.Kt=t,this.G=e,this.Yt=i,this.Qt=n.version,t.indexOf("i3s:tileset:")<0?(this.Qt<=1.6?this.te="root":this.te=0,n.version=this.Qt):(this.te=t.substring(12),this.Qt>1.6&&(this.te=parseInt(this.te))),this.Kt=t,this.ee=n}load(){const t=this.ee,e=t.layerScene.baseUrl;if(this.Qt<=1.6)return t[this.te]&&t[this.te].lodSelection?(this.ne=t[this.te],this.re()):new Promise((n=>{let r=e+"/nodes/"+this.te;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Yt(this.G,r,(()=>{this.ne=t[this.te],n(this.re())}))}));if(this.Qt>=1.7){if(t[this.te])return this.ne=t[this.te],this.re();const n=Math.floor(this.te/t.nodesPerPage);return new Promise((r=>{let i=e+"/nodepages/"+n;t.layerScene.eslpk&&(i+=".json"),this.Yt(this.G,i,(()=>{this.ne=t[this.te],r(this.re())}))}))}return null}getTileset(){return this.ie}getChildrenURL(){return this.se}re(){const t=this.ee,e=t.layerScene.baseUrl,n=this.ne.children,r=[],i={};if(n)for(let s=0;s<n.length;s++)if(this.Qt<=1.6){const o=n[s].id;if(t[o])continue;const a=o;i[a]||(i[a]=new Promise((n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Yt(this.G,r,(()=>{n()}))})),r.push(i[a]))}else{const o=n[s];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);i[a]||(i[a]=new Promise((n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.Yt(this.G,r,(()=>{n()}))})),r.push(i[a]))}return r.length?Promise.all(r).then((()=>this.oe())):this.oe()}oe(){return Promise.resolve(this.ae())}ce(t){yr(this.ee,t)}ae(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.he(this.ne,!0)}}he(t){const e=this.o.getRenderer(),n=this.ee.projection,r=!n||n&&4326===n.wkid,i=this.Qt,s=this.ee,o=t,a=o.obb,c=o.mbs,h={};let l;if(c)l=M.set([],c[0],c[1],c[2]),r||(l=e.le(l,l)),l=wr([],l[0],l[1],l[2]),h.sphere=[...l,c[3]];else if(a){l=M.set([],a.center[0],a.center[1],a.center[2]),r||(l=e.le(l,l)),l=wr([],l[0],l[1],l[2]);const t=function(t,e,n){const r=O.fromQuat([],n);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],[...t,...r]}(l,a.halfSize,a.quaternion),n=t[3]+t[6]+t[9],i=t[4]+t[7]+t[10],s=t[5]+t[8]+t[11];M.set(br,n,i,s);const o=M.len(br);h.sphere=[...l,o]}let u=1/0,f=0;if(o.mbs?f=o.mbs[3]:o.obb&&(f=Math.max(Math.max(o.obb.halfSize[0],o.obb.halfSize[1]),o.obb.halfSize[2])),void 0!==o.lodThreshold)if("maxScreenThresholdSQ"===s.lodSelectionMetricType){u=f/(Math.sqrt(o.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==o.lodSelection)for(let t=0;t<o.lodSelection.length;t++)"maxScreenThreshold"===o.lodSelection[t].metricType&&(u=f/o.lodSelection[t].maxError);(u===1/0||isNaN(u))&&(u=1e5);const d=16*u,m=T.identity([]),p=o.children;let y;if(p){y=[];const t=this.ee;for(let e=0;e<p.length;e++){const n=i<=1.6?p[e].id:p[e];if(!t[n]){y=null;break}y.push(this.he(t[n]))}}const b={refine:"REPLACE",boundingVolume:h,transform:m,geometricError:d};return i<=1.6?t.lodSelection?t.geometryData&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}):b.content={uri:"i3s:tileset:"+(t.id||t.index)}:p&&p.length&&!y?b.content={uri:"i3s:tileset:"+(t.id||t.index)}:o.mesh&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}),y&&y.length&&(b.children=y),b}getJSON(){return this.ne}}function wr(t,e,n,r){return ne(t,Tt(e),Tt(n),r)}const vr=!!pr.ktx2,Tr=r.identity([]),Mr=(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1})();function Or(t){return t.indexOf("i3s:mesh")>=0}const _r=9;function Ar(t,e,n,r,i){const s=e.layerScene.eslpk,o=function(t,e){const n=e.substring(_r);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,h=[];let l=!1;const u=Tr;let f,d;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;if(!t)return null;let n=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;s&&(n+=".bin");const r={geometry:{url:n,info:e.layerScene.store.defaultGeometrySchema}};let i=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(i){const t=e.layerScene.store.textureEncoding[0];let n;n="image/jpeg"===t?"jpg":"png",s&&(i+="."+n);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+i,factor:1,format:n,mimeType:t},metallicFactor:0}};r.material=o}h.push(r)}else{f=a.mesh.geometry,d=a.mesh.material;const t=e.layerScene.geometryDefinitions[f.definition],{geometryBuffers:o}=t;l=r&&2===o.length;const u=pr.draco&&l?o[1]:o[0],m=pr.draco&&l?1:0;let p=c+`/nodes/${f.resource}/geometries/`+m;s&&(p+=".bin");const y={geometry:{url:p,info:u}};if(i&&Mr&&l&&!pr.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const b=e.layerScene.materialDefinitions,g=e.layerScene.textureSetDefinitions;let w,v=0;if(d&&(v=b[d.definition]),b){w=function(t,e,n,r,i,s){const o=JSON.parse(JSON.stringify(t));return xr(o,e,n,r,i,s),o}(v,g,c,d.resource,n,e.layerScene.eslpk)}else w={pbrMetallicRoughness:{metallicFactor:0}};y.material=w,h.push(y)}return{dracoCompression:l,meshes:h,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:u}}function xr(t,e,n,r,i,s){for(const o in t)if(t[o]&&t[o].textureSetDefinitionId>=0){const a=e[t[o].textureSetDefinitionId],c="images/"+a.formats[0].format,h=Ir(a.formats,i),l={url:n+`/nodes/${r}/textures/${h.name}`,factor:void 0===t[o].factor?1:t[o].factor,format:h.format,mimeType:c};if(s){let t="";switch(h.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=h.format}l.url+="."+t}t[o]=l}else wt(t[o])&&xr(t[o],e,n,r,i,s)}function Ir(t,e){for(let n=0;n<=t.length;n++){const r=t[n].format;if("dds"===r&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[n];if("jpg"===r||"png"===r)return t[n];if("ktx2"===r&&vr)return t[n]}return null}const Sr=new t.Coordinate(0,0),Cr=new t.Coordinate(0,0),kr=new Set,Nr=[],Rr=new class{constructor(t,e){this.max=t,this.currentSize=0,this.data=new Map,this.onRemove=e}reset(t){if(this.data){const e=this.data.keys();for(const n of e){const e=this.data.get(n);t&&t!==e.renderer||this.ue(n,e)}}return t||(this.data=new Map,this.currentSize=0),this}clear(t){this.reset(t)}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const n=this.data.get(t);n&&n.node&&n.node.memorySize&&(this.currentSize-=n.node.memorySize),this.data.delete(t),this.data.set(t,e)}else this.data.set(t,e);return this}shrink(){if(this.currentSize>this.max){let t=!1;const e=this.data.keys();let n=e.next();for(;this.currentSize>this.max&&void 0!==n.value;){!t&&this.data.get(n.value).current&&(t=!0,console.warn(`current maxGPUMemory(${this.max/1024/1024}) for Geo3DTilesLayer is not enough, one or more current tiles will be discarded.`));const r=this.getAndRemove(n.value);r&&this.onRemove(r),n=e.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const n=this.data.keys();for(const r of n)t[e++]=r;return t}getAndRemove(t){if(!this.has(t))return null;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),e}get(t){if(!this.has(t))return null;const e=this.data.get(t);return this.data.delete(t),this.data.set(t,e),e}remove(t){if(!this.has(t))return this;const e=this.data.get(t);return this.ue(t,e),this}ue(t,e){e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e)}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const n of e){const e=n&&n.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t,e){const n=this.data.values();for(const r of n)t&&r.renderer!==t||(r.current=e)}}(1024*(t.Browser.mobile?32:1024)*1024,(t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)}));let Er=0;class Lr extends(l(t.renderer.CanvasRenderer)){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>Rr.max&&Rr.setMaxSize(e),this.tileCache=Rr,Er++,this.prepareWorker(),this.tilesLoading={},this.fe={},this.de=[],this.Yt=this.me.bind(this)}getAnalysisMeshes(){if(!this.painter)return Nr;const t=this.painter.getPaintedMeshes();if(!t)return Nr;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:i}=t;return n.length&&Rt(e,n),r.length&&Rt(e,r),i.length&&Rt(e,i),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.de.length||super.needToRedraw())}getFrameTimestamp(){return this.pe}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.pe=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:i}=this.layer.getTiles(),s=i.length;if(!i||!s)return void this.completeRender();this.painter.prepareRender(e),this.ye(),this.be(e);const{selectedTiles:o,leaves:a,requests:c}=this.ge(r,i);c.length&&this.loadTiles(c),this.we(o,a,e),this.ve(),c.length||this.completeRender()}ge(t,e){let n=[];this.Te();let r=0;const i=this.Me(),s={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const i=e[t],c=i.node;if(s[c.id])continue;s[c.id]=1;let h=!1;const l=this.getCachedTile(c.id);if(this.Oe(c.id)?(r++,h=a=!0,this.tilesLoading[c.id].current=!0):l?(this.getTileOpacity(l)<1&&(h=a=!0),o=!0,i.selected=!0,i.data=l):this.painter.has(c)||(h=a=!0,n.push(c)),!h)continue;if(this._e(i))o=!0;else{this.Ae(i).length&&(o=!0)}}let c=[],h={};if(o&&({selectedTiles:c,leaves:h}=this.xe(t)),n.length>1&&(n.sort(Pr),i)){const t=i-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c,leaves:h}}xe(t){const e=[],n={};let r;const i=[t],s=[];for(;i.length>0||s.length>0;){if(s.length>0){const t=s[s.length-1];if(t.Ie===i.length){s.pop(),t===r&&(t.leave=!0,n[t.node.id]=1),e.push(t);continue}}const t=i.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)n[t.node.id]=1,t.selectionDepth=s.length,e.push(t);else{if(t.selectionDepth=s.length,r=t,0===o.length){t.leave=!0,n[t.node.id]=1,e.push(t);continue}s.push(t),t.Ie=i.length}for(let t=0;t<o.length;t++)i.push(o[t])}return{selectedTiles:e,leaves:n}}_e(t){if(!t.parent)return null;let e=t.parent;for(;e&&e.level>=0;){const t=e.node.id;if(this.tileCache.has(t))return e.selected=!0,e.data=this.tileCache.get(t),e;e=e.parent}return null}Ae(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.Se+1,r=[t.node];for(;r.length>0;){const i=r.pop().children;for(let s=0,o=i.length;s<o;s++){if((!i[s].content||!i[s].content.url)&&i[s].children&&i[s].children.length){r.push(i[s]);continue}const o=i[s].id;if(this.tileCache.has(o)){const n=this.layer.Ce(i[s],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else i[s].Se<=n&&r.push(i[s])}}return e}we(t,e,n){this.tileCache.markAll(this,!1);const r=[];for(let e=0,n=t.length;e<n;e++){const n=t[e].data;n.current=!0,n.renderer=this,this.tileCache.add(t[e].node.id,n);const i=n.node,s=this.layer.j(i.G);i.ut&&s.debug&&!Array.isArray(s.debug)&&r.push(i.ut)}this.tileCache.shrink();const i=this.layer.options.services;for(let t=0;t<i.length;t++){const e=i[t],n=Array.isArray(e.debug)&&e.debug;if(n)for(const t of n){const e=this.layer.Bt(t),n=e&&e.node;n&&n.ut&&r.push(n.ut)}}const s={tiles:t,leaves:e};this.onDrawTileStart(s);const o=this.painter.paint(t,e,r,n);this.layer.fire("drawtiles",{count:o}),this.onDrawTileEnd(s),o&&this.layer.fire("canvasisdirty",{renderCount:o})}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,n=t.length;e<n;e++){const n=t[e];this.tilesLoading[n.id]={current:!0,node:n},this.loadTile(n)}}loadTile(t){let e=t.content.url;if(kt(e)){const n=Nt(e);return this.ke(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.G,r=this.Ne[n];return new gr(e,n,r,this.layer,this.Yt).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Ut(e)&&!Or(e)&&(e=t.baseUrl+e),this.ke(e,null,t),null}ke(t,e,r){let i=this.Re;i||(i=n.Util.getSupportedFormats(this.gl.gl||this.gl),this.Re=i);const s=this.layer.j(r.G);s.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length),r=n.split("/"),i=[];for(let t=0;t<r.length;t++)i.push(encodeURIComponent(r[t]));return e+i.join("/")}(t,r.baseUrl));const o={url:this.layer.getTileUrl(t,this.layer.Ee[r.G]),arraybuffer:e,rootIdx:r.G,upAxis:r._t,transform:r.matrix,supportedFormats:i};if(Or(t)){const e=this.Ne[r.G];if(o.projection=e.projection,o.i3sInfo=Ar(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=bt({},s),s.offset&&delete o.service.offset,o.referrer=window&&window.location.href,this.workerConn.loadTile(this.layer.getId(),o,((e,n)=>{if(e)return void this.onTileError(e,r,t);const{magic:i}=n;"b3dm"===i||"pnts"===i||"i3dm"===i||"cmpt"===i||"gltf"===i?this.de.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}Ut(t){this.painter&&this.painter.Ut(t)}Ft(t){this.painter&&this.painter.Ft(t)}be(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.de.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.de.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Le(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Le(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Le(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Le(t,e,n,r)})),n++}}Le(t,e,n,r){if(n)this.onTileError(n,e);else{const n=this.Pe(r);e.memorySize=n,this.onTileLoad(t,e)}}Pe(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.Pe(t[n]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.Ue(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.jt=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.Be(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(t,e,n){if(!this.layer)return;const r=n||e.content.url,i=t&&t.message||t;t&&(404===t.status||204===t.status)||kr.has(i)||(console.warn("failed to load 3d tile: "+r),console.warn(t),kr.add(i)),delete this.tilesLoading[e.id],this.Fe(e,t),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}getShadowMeshes(){if(!this.painter)return;const t=[],e=this.painter.getCurrentB3DMMeshes();for(const n in e)e[n]&&t.push(e[n]);const n=this.painter.getCurrentI3DMMeshes();for(const e in n)n[e]&&t.push(n[e]);return t}Fe(e,n){const r={loadTime:t.Util.now(),current:!0,error:n,node:e};r.renderer=this,this.tileCache.add(e.id,r)}Ue(e){const n={loadTime:t.Util.now(),current:!0,node:e};n.renderer=this,this.tileCache.add(e.id,n)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.fe[e]}Te(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}createContext(){const t=this.layer,e=t.options.glOptions||{alpha:!0,depth:!0,stencil:!0,preserveDrawingBuffer:!0,antialias:t.options.antialias},n=this.canvas.gl&&this.canvas.gl.wrap;n?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.De(this.canvas,e)),this.regl=this.regl||u({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),n&&(this.canvas.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height)),this.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height),this.painter=new ur(this.regl,t),this.layer.je(),this.layer.fire("contextcreate",{regl:this.regl})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new Dt("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let n=this.layer.options||{};n=bt({},n),delete n.offset;const r=t.options.spatialReference;n.projection=r&&r.coordType||r&&r.projection||t.getSpatialReference().getProjection().code;const i=this.layer.getId();e.addLayer(i,n,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),Er--,Er||Rr.reset(),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.ve(!0),this.tileCache.reset(this),this.tilesLoading={},super.clear()}clearCanvas(){this.regl&&this.regl.clear({color:[0,0,0,0],depth:1,stencil:0}),super.clearCanvas()}getTileOpacity(){return 1}getStencilValue(){return 0}ve(t){this.ze||(this.ze=Date.now());const e=Date.now();if(!t&&e-this.ze<this.layer.options.retireInterval)return;this.ze=e;const n=[];for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||(n.push(e),this.abortTileLoading(r))}for(let t=0;t<n.length;t++)delete this.tilesLoading[n[t]]}Me(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}De(t,e){const n=["webgl","experimental-webgl"];let r=null;for(let i=0;i<n.length;++i){try{r=t.getContext(n[i],e)}catch(t){}if(r)break}return r}Oe(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,n){return Oe(t,e,0,n)}ye(){if(!this.Ge)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.Ge){const i=this.Ge[r];if("pending"===i.status)continue;i.status="pending";const s=i.rootIdx,o=Bt(this.layer.j(s).fetchOptions);if(n.push(w.getJSON(r,o).then((t=>{delete this.Ge[r];const e=this.Ne[s];if(e){t.nodes?yr(e,t.nodes):(e[t.id]=t,yr(e,t.children));for(let t=0;t<i.length;t++)i[t]();this.setToRedraw()}else this.setToRedraw()}))),e++,e>=t)break}n.length&&Promise.all(n)}me(t,e,n){this.Ge||(this.Ge={}),this.Ge[e]=this.Ge[e]||[],this.Ge[e].rootIdx=t,this.Ge[e].push(n),this.setToRedraw()}Be(t,e,n){this.Ne||(this.Ne=[]);const r=e.G;this.Ne[r]||(this.Ne[r]={});const i=this.Ne[r],s=this.layer.j(r);t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),i.version=+(s.i3sVersion||t.store.version),!t.spatialReference||t.spatialReference.wkid&&4326===t.spatialReference.wkid||console.warn("i3s has a spatialReference other than 4326.",t.spatialReference),i.projection=t.spatialReference,function(t,e,n,r,i,s,o){if(!s.layerScene){s.layerScene=e,s.nodesPerPage=e.nodePages&&e.nodePages.nodesPerPage||64,s.lodSelectionMetricType=e.nodePages&&e.nodePages.lodSelectionMetricType;let t=i;if(s.layerScene.eslpk=t.indexOf("3dSceneLayer.json")>=0,t.endsWith(".json")){const e=i.lastIndexOf("/");t=e<0?"./":i.substring(0,e)}s.layerScene.baseUrl=function(t){return t.split("?")[0]}(t)}return new gr(i,n,s,t,o).load()}(this.layer,t,r,0,n,i,this.Yt).then((t=>{this.onTilesetLoad(t,e,n)}))}pick(t,e,n){if(!this.painter)return[];const r=this.pickingFBO,{width:i,height:s}=this.canvas;return!this.pickingFBO||r.width===i&&r.height===s||r.resize(i,s),this.painter.pick(t,e,n&&n.tolerance)}highlight(t){if(this.$||(this.$=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.$[n];r||(r=this.$[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.$[e];n||(n=this.$[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.$)}cancelHighlight(t,e){if(!this.$)return;const n=this.$[t];if(n){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.delete(e[t]);else n.delete(e);n.size||(this.$[t]=null),this.painter.highlight(this.$)}}cancelAllHighlight(){delete this.$,this.painter.cancelAllHighlight()}showOnly(t){if(this.Z||(this.Z=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Z[n];r||(r=this.Z[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Z[e];n||(n=this.Z[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.Z)}cancelShowOnly(){delete this.Z,this.painter.cancelShowOnly()}Wt(){return this.painter?this.painter.Wt():[]}le(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.He();return Sr.set(e[0],e[1]),n.unproject(Sr,Cr),t[0]=Cr.x,t[1]=Cr.y,t}return Sr.set(e[0],e[1]),n.getProjection().unproject(Sr,Cr),t[0]=Cr.x,t[1]=Cr.y,t}qe(t,e){const n=this.He();return Sr.set(e[0],e[1]),n.project(Sr,Cr),t[0]=Cr.x,t[1]=Cr.y,t}Ve(t,e){const n=this.He();return Sr.set(e[0],e[1]),n.unproject(Sr,Cr),t[0]=Cr.x,t[1]=Cr.y,t}He(){const e=this.getMap().options.spatialReference.coordType;if(!e)throw new Error("Missing coordType in map spatialReference.");return this.$e||(this.$e=t.SpatialReference.getProjectionInstance(e)),this.$e}}function Pr(t,e){return t.lt-e.lt}function Ur(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function Br(t,e,n){return Math.sqrt(function(t,e,n){const r=M.subtract(Fr,n,t),i=Ur(Dr,e,0),s=Ur(jr,e,1),o=Ur(zr,e,2),a=M.len(i),c=M.len(s),h=M.len(o);M.normalize(i,i),M.normalize(s,s),M.normalize(o,o);const l=Gr;l[0]=M.dot(r,i),l[1]=M.dot(r,s),l[2]=M.dot(r,o);let u,f=0;l[0]<-a?(u=l[0]+a,f+=u*u):l[0]>a&&(u=l[0]-a,f+=u*u);l[1]<-c?(u=l[1]+c,f+=u*u):l[1]>c&&(u=l[1]-c,f+=u*u);l[2]<-h?(u=l[2]+h,f+=u*u):l[2]>h&&(u=l[2]-h,f+=u*u);return f}(t,e,n))}const Fr=[],Dr=[],jr=[],zr=[],Gr=[];const Hr=2*Math.PI;class qr{constructor(t,e,n,r){this.west=t,this.south=e,this.east=n,this.north=r}static contains(t,e){let n=e[0];const r=e[1],i=t.west;let s=t.east;return s<i&&(s+=Hr,n<0&&(n+=Hr)),(n>i||be(n,i,1e-14))&&(n<s||be(n,s,1e-14))&&r>=t.south&&r<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const Vr=[0,0,1];function $r(t,e){return ne(e,t[0],t[1],t[2])}class Jr{constructor(t,e){this.normal=a.copy([],t),this.distance=e}static fromPointNormal(t,e,n){const r=-a.dot(e,t);return a.copy(n.normal,e),n.distance=r,n}}const Zr=[],Xr=[],Wr=[],Kr=[],Yr=[],Qr=[],ti=[],ei=[],ni=[],ri=[],ii=new Jr([1,0,0],0),si=[];class oi{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new qr(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let n=0;if(!qr.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,r=this.northeastCornerCartesian,i=this.westNormal,s=this.southNormal,o=this.eastNormal,c=this.northNormal,h=a.subtract(si,t,e),l=a.dot(h,i),u=a.dot(h,s),f=a.subtract(si,t,r),d=a.dot(f,o),m=a.dot(f,c);l>0?n+=l*l:d>0&&(n+=d*d),u>0?n+=u*u:m>0&&(n+=m*m)}const r=e[2],i=this.minimumHeight,s=this.maximumHeight;if(r>s){const t=r-s;n+=t*t}else if(r<i){const t=i-r;n+=t*t}return Math.sqrt(n)}computeBox(t){const e=this;$r(qr.southwest(t,Xr),e.southwestCornerCartesian),$r(qr.northeast(t,Xr),e.northeastCornerCartesian),Zr[0]=t.west,Zr[1]=.5*(t.south+t.north),Zr[2]=0;const n=$r(Zr,Wr),r=a.cross(Yr,n,Vr);a.normalize(e.westNormal,r),Zr[0]=t.east;const i=$r(Zr,ei),s=a.cross(Yr,Vr,i);a.normalize(e.eastNormal,s);const o=a.subtract(Yr,n,i),c=a.normalize(Kr,o),h=t.south;let l;if(h>0){Zr[0]=.5*(t.west+t.east),Zr[1]=h;const n=$r(Zr,ni);a.copy(ri,c);const r=Jr.fromPointNormal(e.southwestCornerCartesian,e.westNormal,ii);ai(ni,ri,r,e.southwestCornerCartesian),l=me(n,Qr)}else l=pe(qr.southeast(t,Xr),Qr);const u=a.cross(ti,l,o);a.normalize(e.southNormal,u);const f=t.north;let d;if(f<0){Zr[0]=.5*(t.west+t.east),Zr[1]=f;const n=$r(Zr,ni);a.scale(ri,c,-1);const r=Jr.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,ii);ai(ni,ri,r,e.northeastCornerCartesian),d=me(n,Qr)}else d=pe(qr.northwest(t,Xr),Qr);const m=a.cross(ti,o,d);a.normalize(e.northNormal,m)}}function ai(t,e,n,r){const i=t,s=e,o=n.normal,c=a.dot(o,s);if(Math.abs(c)<1e-15)return;const h=(-n.distance-a.dot(o,i))/c;return h<0?void 0:(r=a.scale(r,s,h),a.add(r,i,r))}function ci(t){return[t.xmin,t.ymin,t.xmax,t.ymax]}const hi=t.BBOXUtil,li={"services":[],"maxGPUMemory":t.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"debug":!1,"meshLimitPerFrame":1,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"alwaysShowTopTiles":!0,"antialias":!1,"offset":[0,0],"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"optionalExtensions":["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"]},ui=[0,0,0],fi=[0,0,0],di=[0,0,0],mi=[0,0,0],pi=[0,0,0],yi=[0,0,0],bi=[0,0,0],gi=[1,1,1],wi=[0,0,0,0],vi=[],Ti=new t.Coordinate(0,0),Mi=new t.Point(0,0),Oi=[0,0,0,0,0,0,0,0,0],_i=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ai=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],xi=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],Ii=new t.Point(0,0),Si=r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Ci=[0,0],ki=[0,0,0],Ni=[1,1,1],Ri=[0,0,0],Ei=[0,0,0],Li=[0,0,0,0],Pi=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1];class Ui extends(f(t.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new Ui(t.id,t.options):null}constructor(t,e){super(t,e),this.Je(),this.Ze=[]}Je(){const t=this.options.services.map((t=>t.url));this.Xe=this.Xe||{},this.Ee=this.Ee||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.Xe[n];void 0===r&&(r=this.Xe[n]=this.Ee.length),this.Ee[r]=Di(n,r,this.options.services[e])}this.fire("rootready",{roots:this.Ee.slice(0)})}showService(t){return this.updateService(t,{visible:!0}),this}hideService(t){return this.updateService(t,{visible:!1}),this}setToRedraw(){return this.We(),this}addService(t){return this.options.services=this.options.services||[],this.options.services.push(t),this.Je(),this.We(),this}updateService(t,e){if(!e)return this;const n=this.options.services;let r=!1;n&&n[t]&&(r=!(Gi(n[t].coordOffset,e.coordOffset)&&Gi(n[t].heightOffset,e.heightOffset)&&Gi(n[t].scale,e.scale)&&Gi(n[t].rotation,e.rotation)),bt(n[t],e));const i=n[t].url,s=this.Xe[i],o=this.Ee&&this.Ee[s];return o&&(yt(e.visible)||(o.visible=e.visible),r&&o.version++),this.We(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.Xe[n];this.Ee[r]&&(this.Ee[r]=null),delete this.Xe[n],e.splice(t,1)}return this.We(),this}getTileUrl(t,e){const n=e&&e.service&&e.service.subdomains;if(n&&e.domainKey){const r=n.length;if(r){const i=[...t].reduce(((t,e)=>t+e.charCodeAt(0)),0)%r;return t.replace(e.domainKey,n[i])}}return t}getExtent(e){if(!e&&0!==e){const e=new t.Extent;for(let t=0;t<this.Ee.length;t++){const n=this.Ee[t];if(n&&n.boundingVolume){const t=this.boundingVolumeToExtent(n);e._combine(t)}}return e}const n=this.Ee[e];return n&&n.boundingVolume?this.boundingVolumeToExtent(n):null}boundingVolumeToExtent(e){const n=e.boundingVolume.Ke?Si:e.matrix,r=this.getMap(),i="identity"===r.getProjection().code.toLowerCase(),s=this.getRenderer();if(e.boundingVolume.region){const n=e.boundingVolume.region;return new t.Extent(Mt(n[0]),Mt(n[1]),Mt(n[2]),Mt(n[3]))}if(e.boundingVolume.sphere){const o=e.boundingVolume.sphere,c=ce([],a.transformMat4([0,0,0],o,n));i&&s.qe(c,c);const h=o[3],l=r.locate(c,-h,h),u=r.locate(c,h,-h);return new t.Extent(l,u)}if(e.boundingVolume.box){const o=e.boundingVolume.box,h=a.transformMat4([0,0,0],o,n),l=new t.Coordinate(ce([],h));i&&s.qe(l,l);const u=o.slice(3);c.multiply(u,c.fromMat4([0,0,0,0,0,0,0,0,0],e.matrix),u);const f=a.length(u.slice(0,3)),d=a.length(u.slice(3,6)),m=a.length(u.slice(6,9)),p=Math.max(f,d,m),y=r.locate(l,-p,p),b=r.locate(l,p,-p);return new t.Extent(y,b)}return null}getRootTiles(){return this.Ee}getTiles(){const t=this.getRenderer();if(!t.ready)return this.We(),{tiles:vi};const e=this.getMap(),n=e.cameraPosition,r=e.pointAtResToDistance(n[2],0,e.getGLRes()),i=this.Ye(n);this.Qe=this.Qe||[0,0,0],a.set(this.Qe,Tt(i.x),Tt(i.y),r),this.tn=ne(this.tn||[],this.Qe[0],this.Qe[1],this.Qe[2]),this.nn=2*Math.tan(.5*Tt(e.getFov()));const s=e.projViewMatrix,o=e.getExtent(),c=o.getWidth()/2,h=o.getHeight()/2;o.xmin-=c,o.ymin-=h,o.xmax+=c,o.ymax+=h;const l=ci(o),u=(this.getMasks()||[]).filter((t=>t&&t instanceof d));u.forEach((t=>{if(!t.maskGeoJSON&&t.toGeoJSON)try{t.maskGeoJSON=t.toGeoJSON();const e=t.getExtent();t.maskGeoJSON.bbox=ci(e)}catch(t){console.error(t)}}));const f={children:[],level:-1};let m=f;const p=[];for(let e=0;e<this.Ee.length;e++){const n=this.Ee[e];if(!n||!n.visible)continue;const r=[n],i=this.rn(e);for(;r.length>0;){const e=r.pop();for(e.id||this.sn(e);m.level>=e.Se;)m=m.parent;const n=this.an(e,i,s,l,u);if(!(n===Hi.VISIBLE||n!==Hi.OUT_OF_FRUSTUM&&this.options.alwaysShowTopTiles&&zi(e))){let t=m;for(;t&&!t.content;)t=t.parent;n===Hi.SCREEN_ERROR_TOO_SMALL&&t&&t.content&&this.cn(p,t);continue}e.lt<1/0&&this.hn(e);const o=this.Ce(e,m);m.children.push(o);const a=e.children,c=a&&a.length,h=o.content;if(!c&&h&&this.cn(p,o),c){h&&"add"===e.refine&&this.cn(p,o),m=o;const n=a[0].parent;let i=!1;for(let s=0,o=a.length;s<o;s++){if(n){const e=t.getCachedTile(a[s].id);if(e&&e.error&&404!==e.error.status)continue;i=!0}else{i=!0,a[s].parent=e,a[s]._t=e._t,a[s].baseUrl=e.baseUrl;const t=a[s].content&&(a[s].content.url||a[s].content.uri);t&&(kt(t)||t.indexOf("i3s:")>=0?a[s].baseUrl=e.baseUrl:Ut(t)?a[s].content.url=e.baseUrl+t:a[s].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}r.push(a[s])}!i&&h&&this.cn(p,o)}}}return{root:f,tiles:p}}cn(t,e){const{viewerRequestVolume:n,matrix:r}=e.node;n&&!function(t,e,n,r){if(n.region){const e=n.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(n.sphere)return Bi(n,e,r)<=0;if(n.box)return 0===Fi(n,e,r)}return!1}(this.Qe,this.tn,n,r)||t.push(e)}Ce(t,e){return{id:t.id,node:t,children:[],level:t.Se,parent:e,content:t.content&&t.content.url}}sn(e){const n=this.getId();e.id=n+":"+t.Util.GUID(),e.matrix=e.transform||r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e.ln=this.un(e),e.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(e)||(e.matrix=r.multiply(e.matrix,e.parent.matrix,e.matrix)),e.G=e.parent.G,void 0===e.Se&&(e.Se=e.parent.Se+1),e.maxExtent=e.parent.maxExtent),e.refine=e.refine&&e.refine.toLowerCase()||"replace",e.content&&!e.content.url&&e.content.uri&&(e.content.url=e.content.uri)}j(t){return this.Ee[t].service}dn(t){const e=t.boundingVolume;if(!e||e.Ke&&!this.mn(t))return;const n=this.j(t.G),i=n.heightOffset||0,s=this.options.offset,o=gt(s)||s[0]||s[1],c=n.coordOffset||Ci;if(!Array.isArray(c))throw new Error("service.coordOffset must be an array");if(!e.Ke&&(!t.boundingVolume||!i&&r.exactEquals(t.matrix,Si)&&!o&&c===Ci))return;e.box&&e.region&&delete e.region;const{region:h,box:l,sphere:u}=e;if(e.coordOffset=[c[0],c[1]],e.heightOffset=i,h){e.originalVolume||(e.originalVolume=h.slice(0));const t=e.originalVolume,n=this.pn([Mt(t[0]),Mt(t[1])]);h[0]=Tt(n.x+c[0]),h[1]=Tt(n.y+c[1]);const r=this.pn([Mt(t[2]),Mt(t[3])]);h[2]=Tt(r.x+c[0]),h[3]=Tt(r.y+c[1]),h[4]=t[4]+i+(c[2]||0),h[5]=t[5]+i+(c[2]||0)}else if(l||u){e.originalVolume||(e.originalVolume=(l||u).slice(0));const n=l||u,r=e.originalVolume,s=a.transformMat4(ui,r,t.matrix),o=ce(fi,s),h=this.pn([o[0]+c[0],o[1]+c[1]]);o[0]=h.x,o[1]=h.y,o[2]+=i+(c[2]||0),ne(n,Tt(o[0]),Tt(o[1]),o[2])}e.Ke=!0;try{t.extent=this.boundingVolumeToExtent(t)}catch(t){console.error(t)}}mn(t){const e=t.boundingVolume,n=this.j(t.G),r=n.heightOffset||0,i=n.coordOffset||Ci;return e.coordOffset[0]!==i[0]||e.coordOffset[1]!==i[1]||e.heightOffset!==r}un(t){return void 0===t.geometricError||!t.boundingVolume}hn(t){let e=t.parent;for(;e&&e.ln&&!(e.lt<=t.lt);)e.lt=t.lt,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const n=e.content.url;e.baseUrl=n.substring(0,n.lastIndexOf("/")+1),this.We()}}onTilesetLoad(t,e,n){if(!t)return void console.warn("invalid tileset at : "+n);const i=(t.asset&&t.asset.gltfUpAxis||e&&e._t||"Y").toUpperCase();t.root.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const s=n.indexOf("realspace/")>-1;0===e.Se&&t.asset&&t.asset.s3mType&&s&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root._t=i,e){const n=e.boundingVolume;bt(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",n&&(e.boundingVolume=n);const i=t.root.transform;i&&(e.parent?o||(e.matrix=r.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.parent.matrix,i)):e.matrix=i),delete e.content,t.root.content&&(e.content=t.root.content),e.ln=this.un(e);const s=e.content&&(e.content.url||e.content.uri);s&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),!o&&s&&!kt(s)&&Ut(s)&&(e.content.url=e.baseUrl+s),t.root&&!e.parent&&this.yn(e)}this.We(),this.fire("loadtileset",{tileset:t,index:e&&e.G,url:n})}bn(t,e,n){if(!t.extent||!hi||!e)return!0;const r=t.extent;Li[0]=r.xmin,Li[1]=r.ymin,Li[2]=r.xmax,Li[3]=r.ymax;if(!hi.bboxIntersect(Li,e))return!1;if(n.length){for(let t=0,e=n.length;t<e;t++){const e=n[t].maskGeoJSON;if(!e||!e.bbox||hi.bboxInMask(Li,e))return!0}return!1}return!0}an(t,e,n,r,i){if(!this.bn(t,r,i))return Hi.OUT_OF_FRUSTUM;if(t.lt=1/0,0===t.Se||t.ln)return this.yn(t),Hi.VISIBLE;if(this.dn(t),!this.gn(t,e,n))return Hi.OUT_OF_FRUSTUM;if(0===t.geometricError)return Hi.VISIBLE;let s=this.j(t.G).maximumScreenSpaceError;null==s&&(s=16);let o=this.wn(t);return 0===o&&t.parent&&(o=.5*(t.parent.vn||0)),o>=s?Hi.VISIBLE:Hi.SCREEN_ERROR_TOO_SMALL}Zt(e,n){n||(n=new t.Point(0,0));const r=this.getMap();return r.coordToPointAtRes(e,r.getGLRes(),n)}gn(t,e,n){const r=t.id;let i=this.Ze[r];const{boundingVolume:s}=t,o=s.region,a=s.box,c=s.sphere,h=this.Tn(t.G),l=this.getRenderer();i&&i.version===h.version||(o?i=this.Ze[r]=this.Mn(t):a?i=this.Ze[r]=this.On(t):c&&(i=this.Ze[r]=this._n(t)),i.version=h.version,t.ut&&(l.Ft(t.ut),delete t.ut));return this.j(t.G).debug&&(this.Ze[r].node=t,l.Ut(t)),i.obbox?y(n,i.obbox):!!c&&b(n,i.sphereBox)}Mn(e){const n=this.getMap(),i=n.getGLRes(),s=e.boundingVolume.region;let{ws:o,en:c}=function(t){const e=t[0],n=t[1],r=t[2],i=t[3],s=t[4],o=t[5],a=ne([],e,n,s),c=ne([],r,i,o),h=ce(a,a),l=ce(c,c);return{ws:h,en:l}}(s);o=new t.Coordinate(o),c=new t.Coordinate(c);const h=n.coordToPointAtRes(o,i);h.z=n.altitudeToPoint(o.z,i);const l=n.coordToPointAtRes(c,i);l.z=n.altitudeToPoint(c.z,i);const u=[l.x,h.y,l.z,l.x,l.y,l.z,h.x,l.y,l.z,h.x,h.y,l.z,l.x,h.y,h.z,l.x,l.y,h.z,h.x,l.y,h.z,h.x,h.y,h.z],f=[(u[0]+u[18])/2,(u[1]+u[19])/2,(u[2]+u[20])/2],d=this.Tn(e.G);e!==d||d.An||(d.An=f);const m=this.Vt([],e),p=r.exactEquals(Si,m);if(!p){a.transformMat4(f,f,m);const t=ui;for(let e=0;e<u.length;e+=3){let n=a.set(t,u[e],u[e+1],u[e+2]);p||(n=a.transformMat4(n,n,m)),u[e]=n[0],u[e+1]=n[1],u[e+2]=n[2]}}const y=n.pointAtResToCoord(new t.Point(f),i);y.z=(o.z+c.z)/2;const b=this.xn(u,f);for(let t=0;t<u.length;t++)u[t]-=f[t%3];return{obbox:b,boxPosition:u,boxCenter:f,boxCoord:y}}On(t){const e=this.getRenderer(),n=this.getMap(),i="identity"===n.getProjection().code.toLowerCase(),s=n.getGLRes(),{boxCenter:o,boxCoord:c}=this.In(t),h=t.boundingVolume.box,l=this.Sn(h,t.matrix),u=(d=h,function(t,e,n,r,i,s,o,a,c,h,l,u,f,d,m,p,y){return t[0]=e||0,t[1]=s||0,t[2]=h||0,t[3]=0,t[4]=n||0,t[5]=o||0,t[6]=l||0,t[7]=0,t[8]=r||0,t[9]=a||0,t[10]=u||0,t[11]=0,t[12]=i||0,t[13]=c||0,t[14]=f||0,t[15]=y,t}([],(f=l)[0],f[3],f[6],d[0],f[1],f[4],f[7],d[1],f[2],f[5],f[8],d[2],0,0,0,1));var f,d;const m=this.Vt([],t),p=r.exactEquals(Si,m);p||a.transformMat4(o,o,m);const y=[],b=ui;for(let t=0;t<Pi.length;t+=3){b[0]=Pi[t],b[1]=Pi[t+1],b[2]=Pi[t+2],a.transformMat4(b,b,u),ce(b,b),i&&e.qe(b,b);const r=Ti.set(b[0],b[1],b[2]);n.coordToPointAtRes(r,s,Mi);let o=a.set(b,Mi.x,Mi.y,n.altitudeToPoint(r.z,s));p||(o=a.transformMat4(o,o,m)),y[t]=o[0],y[t+1]=o[1],y[t+2]=o[2]}const g=this.xn(y,o);for(let t=0;t<y.length;t++)y[t]-=o[t%3];return{obbox:g,boxPosition:y,boxCenter:o,boxCoord:c}}_n(e){const n=this.getMap(),r=this.getRenderer(),i="identity"===n.getProjection().code.toLowerCase(),s=e.boundingVolume.sphere,o=s;let a=ui;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:ce(a,o),i&&r.qe(a,a);const c=new t.Coordinate(a),h=this.Zt(c,Mi).toArray();h[2]=n.altitudeToPoint(c.z,n.getGLRes());const l=this.Cn(c);return{boxCenter:h,boxCoord:c,sphereBox:[h,s[3]*l[2]]}}xn(t,e){const n=ji(pi,t,0,1,4,5),r=ji(yi,t,0,3,4,7),i=ji(bi,t,0,1,2,3);return[...e,...a.sub(ui,n,e),...a.sub(fi,r,e),...a.sub(di,i,e)]}In(e){const n=this.getMap(),r=this.getRenderer(),i="identity"===n.getProjection().code.toLowerCase(),s=n.getGLRes(),o=e.boundingVolume.box.slice(0,3);ce(o,o),i&&r.qe(o,o);const a=new t.Coordinate(o),c=n.coordToPointAtRes(a,s);return{boxCenter:[c.x,c.y,n.altitudeToPoint(a.z,s)],boxCoord:a}}Vt(t,e){const n=this.Tn(e.G),i=this.j(e.G),s=n.An,c=r.fromTranslation(_i,a.set(ui,-s[0],-s[1],-s[2])),h=r.fromTranslation(Ai,s),l=i.rotation||ki,u=o.fromEuler(wi,...l),f=i.scale,d=f&&a.set(Ri,f,f,f)||Ni,m=r.fromRotationTranslationScale(xi,u,Ei,d);return t=r.multiply(t,m,c),r.multiply(t,h,t)}yn(t){const e=this.j(t.G);if(!t.boundingVolume||this.kn(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,i=t.boundingVolume.sphere;let s=null;n?s=this.Nn(t).boxCenter:r?s=this.Rn(t).boxCenter:i&&(s=this._n(t).boxCenter);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.En=[a[0]||0,a[1]||0],t.Ln=o,t.An=s}kn(t,e){if(!t.En)return!1;const n=e.coordOffset||Ci;return t.En[0]===n[0]&&t.En[1]===n[1]&&t.Ln===(e.heightOffset||0)}Rn(t){return this.dn(t),this.Mn(t)}Nn(t){return this.dn(t),this.In(t)}Sn(t,e){let n=t.slice(3,12);const r=c.fromMat4(Oi,e);return n=c.multiply(n,r,n),n}Cn(t){const e=this.getMap(),n=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let r;return r=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:n.y/100,a.set(gi,n.x/100*1.01,n.y/100*1.01,r),gi}pn(e){Array.isArray(e)&&(e=new t.Coordinate(e));let n=this.options.offset;if(gt(n)&&(n=n.call(this,Array.isArray(e)?new t.Coordinate(e):e)),n[0]||n[1]){const t=this.getMap(),r=t.getGLRes(),i=t.coordToPointAtRes(e,r);return Mi.set(n[0],n[1]),i._sub(Mi),t.pointAtResToCoord(i,r)}return e}Tn(t){return this.Ee[t]}rn(e){const n=this.j(e).maxExtent;if(!n)return null;const r=this.Ee[e];return r.maxExtent||(r.maxExtent=new t.Extent(n).convertTo((t=>this.Zt(t)))),r.maxExtent}wn(t){const e=this.nn,n=t.geometricError;if(0===n)return t.vn=0,0;const r=this.j(t.G).scale||1,i=this.getMap();let s;t.boundingVolume.region?s=function(t,e,n){t.Pn||(t.Pn=new oi(t.boundingVolume.region));return t.Pn.distanceToCamera(e,n)}(t,this.tn,this.Qe):t.boundingVolume.sphere?s=Bi(t.boundingVolume,this.tn):t.boundingVolume.box&&(s=Fi(t.boundingVolume,this.tn));const o=Math.max(Math.abs(s),1e-7),a=n*r*i.height/(o*e);return t.lt=s,t.vn=a,a}We(){const t=this.getRenderer();t&&t.setToRedraw()}Bt(t){return this.Ze[t]}identify(e,n={}){const r=this.getMap(),i=this.getRenderer();if(!r||!i)return[];Array.isArray(e)&&(e=new t.Coordinate(e));const s=r.coordToContainerPoint(e);return this.identifyAtPoint(s,n)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&Rt(n,r)}const r=this.getMap(),i=this.getRenderer();if(!r||!i)return[];const s=r.getDevicePixelRatio();return Rt(n,i.pick(t.x*s,t.y*s,e)),e&&e.filter&&!e.excludeMasks?n.filter((t=>e.filter(t))):n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.Wt():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.$||(this.$=[]),this.$.push(t),this)}je(){if(this.$){for(let t=0;t<this.$.length;t++)this.highlight(this.$[t]);delete this.$}}cancelHighlight(t,e){const n=this.getRenderer();return n?(n.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}showOnly(t){const e=this.getRenderer();return e?(e.showOnly(t),this):(this.Z||(this.Z=[]),this.Z.push(t),this)}Un(){if(this.Z){for(let t=0;t<this.Z.length;t++)this.showOnly(this.Z[t]);delete this.Z}}cancelShowOnly(t){const e=this.getRenderer();return e?(e.cancelShowOnly(t),this):this}setServiceOpacity(t,e){const n=this.options.services[t];n&&(n.opacity=e);return this.getRenderer()?(this.We(),this):this}setServiceDebug(t,e){const n=this.options.services[t];n&&(n.debug=e);return this.getRenderer()?(this.We(),this):this}Ye(t){const e=this.getMap(),n=e.getGLRes();Ii.set(t[0],t[1]);const r=e.pointAtResToCoord(Ii,n);return"identity"===e.getProjection().code.toLowerCase()?(fi[0]=r.x,fi[1]=r.y,this.getRenderer().Ve(ui,fi),r.set(ui[0],ui[1]),r):r}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function Bi(t,e,n){let r=t.sphere;n&&(r=a.transformMat4([0,0,0],r,n));const i=a.dist(r,e),s=t.sphere[3];return i<s?0:i-s}function Fi(t,e,n){const r=t.box;let i=a.set(ui,r[0],r[1],r[2]);n&&(i=a.transformMat4([0,0,0],i,n));return Br(i,c.set(Oi,r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11]),e)}function Di(t,e,n){const i=(t=Ot(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,ln:!0,service:n,visible:!!yt(n.visible)||n.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:r.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),G:e,Se:0,domainKey:i}}function ji(t,e,n,r,i,s){const o=a.set(ui,e[3*n],e[3*n+1],e[3*n+2]),c=a.set(fi,e[3*r],e[3*r+1],e[3*r+2]),h=a.set(di,e[3*i],e[3*i+1],e[3*i+2]),l=a.set(mi,e[3*s],e[3*s+1],e[3*s+2]);return t[0]=(o[0]+c[0]+h[0]+l[0])/4,t[1]=(o[1]+c[1]+h[1]+l[1])/4,t[2]=(o[2]+c[2]+h[2]+l[2])/4,t}function zi(t){if(!t.content||t.hasParentContent)return!1;let e=t.parent;if(e&&(e.content||e.hasParentContent))return t.hasParentContent||(t.hasParentContent=!0),!1;for(;e;){if(e.content||e.hasParentContent)return t.hasParentContent||(t.hasParentContent=!0),!1;e=e.parent}return!0}function Gi(t,e){return Array.isArray(t)&&Array.isArray(e)?2===t.length?m.exactEquals(t,e):a.exactEquals(t,e):t===e}var Hi;Ui.mergeOptions(li),Ui.registerRenderer("gl",Lr),Ui.registerJSONType("Geo3DTilesLayer"),function(t){t[t.OUT_OF_FRUSTUM=0]="OUT_OF_FRUSTUM",t[t.SCREEN_ERROR_TOO_SMALL=1]="SCREEN_ERROR_TOO_SMALL",t[t.VISIBLE=2]="VISIBLE"}(Hi||(Hi={}));let qi=null;function Vi(){return qi||(qi={"image/crn":pr.crn&&pr.crn(),"image/ktx2":pr.ktx2&&pr.ktx2(),"image/cttf":pr.ktx2&&pr.ktx2(),"draco":pr.draco&&pr.draco()}),qi}class $i{constructor(t,e,n){this.Bn=t,this.Fn=e||g,this.Re=n,this.Dn=Vi()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.jn(t,e,n,r,i)):w.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.jn(t,i,n,r)}))}jn(t,e,n,r,i){const s=i&&i.maxTextureSize,o=this.zn(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.Fn(a,o.glb,{transferable:!0,requestImage:this.Bn,decoders:this.Dn,supportedFormats:this.Re,maxTextureSize:s});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${n}-${r}`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}zn(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=i.getUint32(12,!0),c=i.getUint32(16,!0),h=i.getUint32(20,!0),l=i.getUint32(24,!0),u=28+e;h>=570425344?(u-=8,o=a,h=c,l=0,a=0,c=0):l>=570425344&&(u-=4,o=h,h=a,l=c,a=0,c=0);const f=[t];let d,m,p;if(a>0?(d=ve(t,u,a),u+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(u+=c),h>0&&(m=Te(t,u,h),u+=h,l>0)){const e=Me(0,u,l);p=t.slice(e.offset,e.offset+e.byteLength),u+=l,f.push(p)}const y=d.BATCH_LENGTH,b={};if(d&&d.BATCH_ID){b.BATCH_ID=_e(d.BATCH_ID,t,undefined.offset,y);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:p,b3dm:b,glb:{buffer:t,byteOffset:u,byteLength:i.byteLength+i.byteOffset-u}}}Gn(){return null}}class Ji{constructor(t,e,n,r){this.Bn=t,this.Fn=e||g,this.Re=n,this.Dn=Vi(),this.Hn=r}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.jn(t,e,n,r,i)):w.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.jn(t,i,n,r)}))}jn(t,e,n,r,i){return this.qn(t,e,n,r,i).then((({gltf:i,transferables:s})=>{const o=this.Vn(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<s.length;t++)-1===o.transferables.indexOf(s[t])&&o.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:i})}))}qn(t,e,n,r,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.Bn,decoders:this.Dn,supportedFormats:this.Re,maxTextureSize:s},a=new DataView(e,n,r),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let r=xt(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?w.getArrayBuffer(r,{}).then((t=>this.$n(r,{buffer:t.data,byteOffset:0},o))):w.getJSON(r,{}).then((t=>this.$n(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.$n(t,r,o)}}$n(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),i=new this.Fn(r,e,n);return i.load({skipAttributeTransform:!0}).then((n=>{let r=0,s=0;return e.buffer&&(r=e.byteOffset||0,s=e.byteLength||0),n.url=`${t}-${r}-${s}`,{transferables:i.transferables,gltf:n}}))}Vn(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:l}=Re(i,32+e,o),u={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;u.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;u.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Jn(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(u.POSITION.array.buffer)}if(a.BATCH_ID){u.BATCH_ID=_e(a.BATCH_ID,t,c.offset,f);const e=u.BATCH_ID.array&&u.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Zn(new Uint16Array(t,e+c.offset,2*f))},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Zn(new Uint16Array(t,e+c.offset,2*f))},o.push(u.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;u.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).slice()},o.push(u.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;u.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(u.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:h,batchTableBin:l,featureTable:a,i3dm:u,transferables:o}}Zn(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let i=0;i<e;i++)Zi(r,t[2*i],t[2*i+1],65535),n[3*i]=r[0],n[3*i+1]=r[1],n[3*i+2]=r[2];return n}Jn(t,e,n){return Ne(new Float32Array(t.length),t,e,n)}Gn(){return null}}function Zi(t,e,n,r){if(t[0]=Xi(e,r),t[1]=Xi(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*Wi(e),t[1]=(1-Math.abs(e))*Wi(t[1])}return M.normalize(t,t)}function Xi(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function Wi(t){return t<0?-1:1}class Ki{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.jn(t,e,n,r)):w.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.jn(t,i,n,r)}))}jn(t,e,n,r){return this.Xn(e,n,r,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}Xn(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:l}=Re(i,e+28,o),u=a.QUANTIZED_VOLUME_OFFSET,f=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let m,p={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){p=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,p.byteOffset+c.offset,p.byteLength);const e={attributes:p.properties,useUniqueIDs:!1};return this.Wn||(this.Wn=Vi().draco),this.Wn(m,e).then((e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.Kn(t,e.attributes,c.offset,d,o,u,f);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:ke(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?r.BATCH_ID=_e(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=Yi(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:h,batchTableBin:l,featureTable:a,pnts:r,transferables:o}}))}const y=this.Kn(t,a,c.offset,d,o,u,f);if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?y.BATCH_ID=_e(a.BATCH_ID,t,c.offset,d):y.BATCH_ID=Yi(d);const e=y.BATCH_ID.array&&y.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:h,batchTableBin:l,featureTable:a,pnts:y,transferables:o})}Kn(t,e,n,r,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:h}=e.POSITION_QUANTIZED;c=c||0;const l=h?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Jn(h||new Uint16Array(t,c+l,3*r),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:o}=e.NORMAL_OCT16P;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},i.push(o.buffer)}return a}Jn(t,e,n){return Ne(new Float32Array(t.length),t,e,n)}Gn(){return null}}function Yi(t){const e=Ct(t),n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:ke(e),array:n}}class Qi{constructor(t,e,n,r){this.Re=n,this.Bn=t,this.Fn=e||g,this.Hn=r}load(t,e,n=0,r=0,i){return e?this.jn(t,e,n,r,i):w.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.jn(t,i,n,r)}))}jn(t,e,n,r,i){r||(r=e.byteLength);const s=this.Yn(e,t,n,r),o=[];for(let n=0;n<s.length;n++){let r;if("b3dm"===s[n].magic)r=new $i(this.Bn,this.Fn,this.Re);else if("i3dm"===s[n].magic)r=new Ji(this.Bn,this.Fn,this.Re,this.Hn);else if("pnts"===s[n].magic)r=new Ki;else{if("cmpt"!==s[n].magic){console.warn("Unsupported magic in CMPT tile:",s[n].magic);continue}r=new Qi(this.Bn,this.Fn,this.Re,this.Hn)}o.push(r.load(t,e,s[n].offset,s[n].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}Yn(t,e,n,r){const i=new DataView(t,n,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported cmpt version: "+s+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const o=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=ge(i,c),r=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(e.transcoders){const n=t.Map.VERSION;if(n.indexOf("1.0.0-beta")>=0||n.indexOf("1.0.0-alpha")>=0){const n=e.transcoders.inject(A);t.registerWorkerAdapter("@maptalks/3dtiles",n)}else t.registerWorkerAdapter("@maptalks/3dtiles",(function(){return e.transcoders.inject(A)}))}else t.registerWorkerAdapter("@maptalks/3dtiles",A);export{$i as B3DMLoader,Qi as CMPTLoader,Ui as Geo3DTilesLayer,Pt as Geo3DTilesUtil,ye as Geo3DTransform};"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.100.0");
|
|
12
12
|
//# sourceMappingURL=maptalks.3dtiles.es.js.map
|