@maptalks/3dtiles 0.102.1 → 0.102.2

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,9 +1,9 @@
1
1
  /*!
2
- * @maptalks/3dtiles v0.102.1
2
+ * @maptalks/3dtiles v0.102.2
3
3
  * LICENSE : UNLICENSED
4
4
  * (c) 2016-2024 maptalks.org
5
5
  */
6
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maptalks"),require("@maptalks/gl")):"function"==typeof define&&define.amd?define(["exports","maptalks","@maptalks/gl"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).maptalks=t.maptalks||{},t.maptalks,t.maptalksgl)}(this,(function(t,e,n){"use strict";function r(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var s=r(e),i=r(n);const o="${",a=`function(t){\n/*!\n * @maptalks/gltf-loader v0.98.4\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.org\n */\nvar e="undefined"!=typeof Float32Array?Float32Array:Array;function n(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],f=e[7],l=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],A=n[3];return t[0]=w*r+v*a+M*l+A*m,t[1]=w*i+v*c+M*h+A*b,t[2]=w*s+v*u+M*d+A*p,t[3]=w*o+v*f+M*y+A*g,w=n[4],v=n[5],M=n[6],A=n[7],t[4]=w*r+v*a+M*l+A*m,t[5]=w*i+v*c+M*h+A*b,t[6]=w*s+v*u+M*d+A*p,t[7]=w*o+v*f+M*y+A*g,w=n[8],v=n[9],M=n[10],A=n[11],t[8]=w*r+v*a+M*l+A*m,t[9]=w*i+v*c+M*h+A*b,t[10]=w*s+v*u+M*d+A*p,t[11]=w*o+v*f+M*y+A*g,w=n[12],v=n[13],M=n[14],A=n[15],t[12]=w*r+v*a+M*l+A*m,t[13]=w*i+v*c+M*h+A*b,t[14]=w*s+v*u+M*d+A*p,t[15]=w*o+v*f+M*y+A*g,t}function r(){var t=new e(3);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function i(t,n,r){var i=new e(3);return i[0]=t,i[1]=n,i[2]=r,i}function s(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function o(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function a(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function c(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function u(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t}function f(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*s+n[12]*o,t[1]=n[1]*r+n[5]*i+n[9]*s+n[13]*o,t[2]=n[2]*r+n[6]*i+n[10]*s+n[14]*o,t[3]=n[3]*r+n[7]*i+n[11]*s+n[15]*o,t}function l(){var t=new e(4);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),r(),function(){var t;t=new e(4),e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var h,d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};r(),i(1,0,0),i(0,1,0),l(),l(),h=new e(9),e!=Float32Array&&(h[1]=0,h[2]=0,h[3]=0,h[5]=0,h[6]=0,h[7]=0),h[0]=1,h[4]=1,h[8]=1;let y=0;function m(t){return null==t}function b(t){return!m(t)}function p(t){return!m(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function g(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 w(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 v(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function M(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 A=[],T=[],_=[],k=[0,0,0],O=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),x=[1,1,1];function S(t,e,n,r,i,s,o){const a=w(o),c=a.BYTES_PER_ELEMENT;if((0===i||i===r*c)&&s%c==0){const i=new a(e,s,n*r);return t.set(i),t}0===i&&(i=r*c);const u=new Uint8Array(r*c);for(let o=0;o<n;o++){let n=null;const f=new Uint8Array(e,i*o+s,r*c);u.set(f),n=new a(u.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const I="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function E(t,e,n){const r=new Uint8Array(t,e,n);return I.decode(r)}const C={get:function(t,e={},n){e||(e={});const r=new AbortController,i=r.signal,s=g({},e);s.signal=i,s.method||(s.method="GET"),s.referrerPolicy=s.referrerPolicy||"origin","undefined"==typeof window||s.referrer||(s.referrer=window.location.href),n&&(t=n(t));const o=fetch(t,s).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(${o}t.status}): ${o}t.statusText}\`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={},n)=>(e||(e={}),e.responseType="arraybuffer",C.get(t,e,n)),getJSON:function(t,e={},n){return e&&e.jsonp?C.jsonp(t):((e=e||{}).responseType="json",C.get(t,e,n))},jsonp:function(t){const e="_maptalks_jsonp_"+y++;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 U{constructor(t,e,n,r,i){this.i=t,this.decoders=e,this.o=n,this.images={},this.u={},this.h=r||{},this.m=i}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],i=this.p(e,r);return this.getImageByBuffer(i,n)}if(this.u[t.id])return this.u[t.id].then((()=>{const r=this.buffers[t.id],i=this.p(e,r);return this.getImageByBuffer(i,n)}));if(v(t.uri)){const r=this.buffers[t.id]=M(t.uri),i=this.p(e,r);return this.getImageByBuffer(i,n)}let r;const i=t.uri.indexOf("blob:")>=0;return r=t.uri.indexOf("://")>0||i?t.uri:this.rootPath+"/"+t.uri,this.u[t.id]=C.getArrayBuffer(r,this.h,this.m).then((r=>{const i=this.buffers[t.id]=r.data,s=this.p(e,i);return this.getImageByBuffer(s,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 i=e;this.m&&(i=this.m(e)),this.i(i,this.h,((i,s)=>{i?r(i):(URL.revokeObjectURL(e),this.images[t]=s,n(this.images[t]))}))}))}}const F=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],N=[];class P{constructor(t,e,n,r,i){this.rootPath=t,this.gltf=e,this.M=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.A(),this.h=r,this.m=i}T(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 i=n.bufferViews[r.bufferView];return this.k(i).then((n=>{const{buffer:i,byteOffset:s}=n;return this.accessors[r.id]=this._(t,e,i,s)}))}k(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(v(e.uri)){const t=this.buffers[e.id]=M(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]=C.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 i=this.gltf,s=i.accessors[e],o=void 0!==s.bufferView?i.bufferViews[s.bufferView]:{},a=(o.byteOffset||0)+r,c=this.O(s.type),u=w(s.componentType),l=o.byteStride||0,h={array:void 0,name:t,accessorName:e,byteLength:s.count*c*u.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:c,max:s.max,min:s.min,extensions:s.extensions};if(s.min&&(h.min=s.min),s.max&&(h.max=s.max),n)if(this.M)h.byteStride=l,h.byteOffset=a+(s.byteOffset||0),!l||l===c*u.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(h.array=this.S(n,s.count,c,a+(s.byteOffset||0),u),h.array.buffer.byteLength===h.byteLength&&(h.byteOffset=0)):h.array=new Uint8Array(n,a,o.byteLength);else if(s.interleaved){h.byteStride=0,h.byteOffset=0;const t=new u(s.count*c);if(h.array=S(t,n,s.count,c,l,a+(s.byteOffset||0),s.componentType),h.extensions&&h.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(h.array.length),{decodeMatrix:e}=h.extensions.WEB3D_quantized_attributes;for(let n=0;n<h.array.length;n+=c){N[0]=h.array[n],N[1]=h.array[n+1],N[2]=h.array[n+2],N[3]=1;const r=f(N,N,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}h.componentType=5126,h.array=t}}else h.byteStride=0,h.array=this.S(n,s.count,c,a+(s.byteOffset||0),u),h.byteOffset=h.array.byteOffset;else{h.array=new u(s.count);const t=h.min||h.max;t&&(h.array[0]=t[0],h.array[1]=t[1],h.array[2]=t[2])}return h}A(){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,i){return r%i.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*i.BYTES_PER_ELEMENT),r=0),new i(t,r,n*e)}O(t){const e=F.indexOf(t);return F[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.k(e).then((r=>{const{buffer:i,byteOffset:s}=r,o=E(i,s+(e.byteOffset||0),n);return t.content=o,t}))}if(t.uri){if(v(t.uri)){const e=M(t.uri),n=E(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return C.get(e,this.h,this.m).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(n).then((()=>t))}}class B extends U{constructor(t,e,n,r,i,s,o,a){super(r,i,s,o,a),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new P(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(b(t.name)&&(e.name=t.name),b(t.children)&&(e.children=t.children),b(t.jointName)&&(e.jointName=t.jointName),b(t.matrix)&&(e.matrix=t.matrix),b(t.rotation)&&(e.rotation=t.rotation),b(t.scale)&&(e.scale=t.scale),b(t.translation)&&(e.translation=t.translation),b(t.extras)&&(e.extras=t.extras),b(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 r=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}(A,e.translation||k),i=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,u=n*o,f=r*o,l=r*a,h=i*o,d=i*a,y=i*c,m=s*o,b=s*a,p=s*c;return t[0]=1-l-y,t[1]=f+p,t[2]=h-b,t[3]=0,t[4]=f-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-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(T,e.rotation||O),s=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}(_,e.scale||x);return n(s,i,s),n(t,r,s)}return function(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}(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 i,s;r.instanceTechnique&&r.instanceTechnique.values?(i=r.instanceTechnique,s=i.values.diffuse):(i=r,s=i.values.tex||i.values.diffuseTex||i.values.diffuse);const o={baseColorTexture:{index:s}};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,i=n.byteLength,s=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,i);return this.getImageByBuffer(s,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 i=this.gltf.textures[r];if(!i)return null;const s=this.gltf.samplers[i.sampler];return{format:i.format||6408,internalFormat:i.internalFormat||6408,type:i.type||5121,sampler:s,source:this.gltf.images[i.source]}}getMaterial(){return null}getAnimations(){return null}}const D=9729;class R extends U{constructor(t,e,n,r,i,s,o,a){super(r,i,s,o,a),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new P(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 g(e,t),!b(t.weights)&&this.gltf.meshes&&b(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),!b(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}};g(n,e);const i=b(e.sampler)?this.gltf.samplers[e.sampler]:void 0;if(i&&(n.sampler=i,n.sampler.magFilter=i.magFilter||D,n.sampler.minFilter=i.minFilter||9987,n.sampler.wrapS=i.wrapS||10497,n.sampler.wrapT=i.wrapT||10497),"image/ktx2"===n.image.mimeType&&!n.image.mipmap&&n.sampler&&n.sampler.minFilter!==D&&9728!==n.sampler.minFilter){const t=n.sampler.minFilter;n.sampler.minFilter=9984===t||9986===t?9728:D}return t.format&&(n.format=t.format),n}))}C(t){if(!b(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,i=t.byteLength;return new Uint8Array(e,r,i)}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++)(b(t[n].input)||b(t[n].output))&&(e.push(this.accessor.T("input",t[n].input)),e.push(this.accessor.T("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 L="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class j{static read(t,e=0,n=0){n||(n=t.byteLength);const r=new DataView(t,e,n),i=r.getUint32(4,!0);if(1===i)return j.readV1(r,e);if(2===i)return j.readV2(t,e);throw new Error("Unsupported glb version : "+i)}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 i=z(t.buffer,20+e,r);return{json:JSON.parse(i),glbBuffer:{byteOffset:20+e+r,buffer:t.buffer,byteLength:n}}}static readV2(t,e){let n,r,i;const s=new DataView(t,e+12);let o=0;for(;o+8<s.byteLength;){const a=s.getUint32(o,!0);o+=4;const c=s.getUint32(o,!0);if(o+=4,1313821514===c)n=z(t,e+12+o,a);else if(5130562===c){i=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:i,buffer:t,byteLength:r}}}}function z(t,e,n){if(L){const r=new Uint8Array(t,e,n);return L.decode(r)}return function(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=q[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}(new Uint8Array(t,e,n))}const q=[1,1,1,1,2,2,3,0],V=[0,0,0],G=[0,0,0,1],$=[1,1,1],X={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},H={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},J={P(t,e,n,r,i,o,a,c){const u=b(t)?e.animations:[e.animations[0]],f={};for(let e=0;e<u.length;e++){const l=u[e],h=l.name||e;if(b(t)&&h!==t)continue;const y=l.channelsMap[n];if(y)for(let t=0;t<y.length;t++){const e=y[t];"translation"===e.target.path?(this.B(i,l.samplers[e.sampler],r,1),f.translation=s(V,i)):"rotation"===e.target.path?(this.D(o,l.samplers[e.sampler],r,1),f.rotation=d(G,o)):"scale"===e.target.path?(this.B(a,l.samplers[e.sampler],r,1),f.scale=s($,a)):"weights"===e.target.path&&c&&(this.B(c,l.samplers[e.sampler],r,c.length),f.weights=c)}}return f},B(t,e,n,r){switch(e.interpolation){case"LINEAR":{const i=this.R(H,e,n,1*r);i&&(t=function(t,e,n,r){for(let i=0;i<t.length;i++)t[i]=e[i]+r*(n[i]-e[i]);return t}(t,i.PREVIOUS,i.NEXT,i.INTERPOLATION));break}case"STEP":{const i=this.R(H,e,n,1*r);i&&(t=function(t,e){for(let n=0;n<t.length;n++)t[n]=e[n];return t}(t,...i.PREVIOUS));break}case"CUBICSPLINE":{const i=this.R(H,e,n,3*r);i&&(t=this.L(t,i,e.input.array,3*r));break}}return t},D(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.R(H,e,n,1);r&&function(t,e,n,r){var i,s,o,a,c,u=e[0],f=e[1],l=e[2],h=e[3],d=n[0],y=n[1],m=n[2],b=n[3];(s=u*d+f*y+l*m+h*b)<0&&(s=-s,d=-d,y=-y,m=-m,b=-b),1-s>1e-6?(i=Math.acos(s),o=Math.sin(i),a=Math.sin((1-r)*i)/o,c=Math.sin(r*i)/o):(a=1-r,c=r),t[0]=a*u+c*d,t[1]=a*f+c*y,t[2]=a*l+c*m,t[3]=a*h+c*b}(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.R(H,e,n,1);r&&(t=u(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.R(H,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,i,s,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,i=c+1,s=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:i,interpolation:s}}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 i=e.input.array,s=e.output.array,o=e.output.itemSize;(n<i[0]||n>i[i.length-1])&&(n=Math.max(i[0],Math.min(i[i.length-1],n))),n===i[i.length-1]&&(n=i[0]);const a=this.j(i,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:u,interpolation:f}=a;t.PREINDEX=c,t.NEXTINDEX=u,t.INTERPOLATION=f;const l=o*r;return t.PREVIOUS=s.subarray(t.PREINDEX*l,(t.PREINDEX+1)*l),t.NEXT=s.subarray(t.NEXTINDEX*l,(t.NEXTINDEX+1)*l),t},L(t,e,n,r){const i=e.INTERPOLATION,s=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-s)*e.PREVIOUS[2*r+n],u=e.NEXT[3+n],f=(o-s)*e.NEXT[n],l=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*a+(Math.pow(i,3)-2*Math.pow(i,2)+i)*c+(2*-Math.pow(i,3)+3*Math.pow(i,2))*u+(Math.pow(i,3)-Math.pow(i,2))*f;t[n]=l}return t},getAnimationClip(t,e,n,r){const i=t.nodes[e]&&t.nodes[e].weights;return o(V,...X.TRANSLATION),u(G,...X.ROTATION),o($,...X.SCALE),this.P(r,t,e,n,V,G,$,i)},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,i=1/0;const s=e.channels;for(let t=0;t<s.length;t++){const n=s[t],o=e.samplers[n.sampler].input.array;o[o.length-1]>r&&(r=o[o.length-1]),o[0]<i&&(i=o[0])}const o=e.name||n;t.timeSpan[o]={max:r,min:i}})),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?b(e)?n[e]:n[Object.keys(n)[0]]:null}};let K=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Je){}t&&"undefined"!=typeof createImageBitmap&&(K=!0)}const Y="undefined"==typeof document?null:document.createElement("canvas");class Q{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}=j.read(e.buffer,e.byteOffset,e.byteLength);this.q(t,n,r)}else this.q(t,e);this.V=new P(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(),i=this.$();return Promise.all([e,n,r,i]).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 J.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return J.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return w(t)}static readInterleavedArray(t,e,n,r,i,s,o){return S(t,e,n,r,i,s,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=K?it.bind(this):this.options.requestImage||W,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new R(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 B(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)||p(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,i,s)=>{const o={};i.name&&(o.name=i.name),i.nodes&&(o.nodes=i.nodes.map((e=>t[e]))),this.gltf.scene===r&&(n=s),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.T("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 b(t)?this.adapter.getAnimations(t):null}W(t){this.meshes={};let e=[];return this.adapter.iterate(((n,r,i)=>{e.push(this.et(r,t).then((t=>{t.index=i,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 g(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=[],i=t.extensions;if(b(t.targets))for(let e=0;e<t.targets.length;e++){const n=t.targets[e];for(const t in n){const i=this.adapter.accessor.T(\`morphTargets_${o}t}_${o}e}\`,n[t]);i&&r.push(i)}}if(i&&i.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:s,attributes:o}=i.KHR_draco_mesh_compression,a=this.gltf.bufferViews[s],c=this.V.k(a).then((n=>{const{buffer:r,byteOffset:i}=n;let{byteOffset:s}=a;const c=a.byteLength;s||(s=0);const u=new DataView(r,i+s,c),f={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(u,f).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.T(t,e[t]);n&&r.push(n)}if(b(t.indices)){const e=this.adapter.accessor.T("indices",t.indices);e&&r.push(e)}n=Promise.all(r)}return n.then((e=>{if(i&&i.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 s={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:i}=e,s=i.length/r;for(let e=0;e<s;e++)for(let s=0;s<r;s++){const o=e*r+s;i[o]<t[s]&&(t[s]=i[o]),i[o]>n[s]&&(n[s]=i[o])}if(e.quantization){const r=e.quantization,i=r.range/(1<<r.quantizationBits),s=r.minValues;c(t,t,i),a(t,t,s),c(n,n,i),a(n,n,s)}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&&(s.indices=n),r&&(s.morphTargets=r),s.mode=b(t.mode)?t.mode:4,b(t.extras)&&(s.extras=t.extras),s}))}}function W(t,e,n){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!Y)return void n(new Error("There is no canvas to draw image!"));Y.width=r.width,Y.height=r.height;const t=Y.getContext("2d",{willReadFrequently:!0});t.drawImage(r,0,0,r.width,r.height);const e=t.getImageData(0,0,r.width,r.height),i={width:r.width,height:r.height,data:new Uint8Array(e.data)};n(null,i)},r.onerror=function(t){n(t)},r.src=t}const Z=[],tt=[],et=30;let nt,rt;function it(t,e,n){nt||(nt=new OffscreenCanvas(2,2),rt=nt.getContext("2d",{willReadFrequently:!0}));let r=null;if(p(t))this.options.urlModifier&&(t=this.options.urlModifier(t)),Z.push([t,e,n,this]),st();else{const e=new Blob([t]);r=createImageBitmap(e),r.then(ot.bind(this)).then((t=>{n(null,t)})).catch((t=>{console.warn(t),n(t)}))}}function st(){if(!Z.length||tt.length>et)return;const t=Z.shift(),[e,n,r,i]=t;tt.push(t),fetch(e,n).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then(ot.bind(i)).then((e=>{r.call(i,null,e);const n=tt.indexOf(t);tt.splice(n,1),st()})).catch((e=>{console.warn(e),r.call(i,e);const n=tt.indexOf(t);tt.splice(n,1),st()}))}function ot(t){let{width:e,height:n}=t;at(e)||(e=ct(e)),at(n)||(n=ct(n));const r=this.options.maxTextureSize;r&&(e=Math.min(r,e),n=Math.min(r,n)),nt.width=e,nt.height=n,rt.drawImage(t,0,0,e,n),t.close();const i=rt.getImageData(0,0,e,n);return{width:e,height:n,data:new Uint8Array(i.data)}}function at(t){return!(t&t-1)&&0!==t}function ct(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var ut="undefined"!=typeof Float32Array?Float32Array:Array;function ft(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 lt(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],f=e[7],l=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],A=n[3];return t[0]=w*r+v*a+M*l+A*m,t[1]=w*i+v*c+M*h+A*b,t[2]=w*s+v*u+M*d+A*p,t[3]=w*o+v*f+M*y+A*g,w=n[4],v=n[5],M=n[6],A=n[7],t[4]=w*r+v*a+M*l+A*m,t[5]=w*i+v*c+M*h+A*b,t[6]=w*s+v*u+M*d+A*p,t[7]=w*o+v*f+M*y+A*g,w=n[8],v=n[9],M=n[10],A=n[11],t[8]=w*r+v*a+M*l+A*m,t[9]=w*i+v*c+M*h+A*b,t[10]=w*s+v*u+M*d+A*p,t[11]=w*o+v*f+M*y+A*g,w=n[12],v=n[13],M=n[14],A=n[15],t[12]=w*r+v*a+M*l+A*m,t[13]=w*i+v*c+M*h+A*b,t[14]=w*s+v*u+M*d+A*p,t[15]=w*o+v*f+M*y+A*g,t}function ht(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 dt(){var t=new ut(3);return ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function yt(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function mt(t,e,n){var r=new ut(3);return r[0]=t,r[1]=e,r[2]=n,r}function bt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function pt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function gt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function wt(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function vt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Mt(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[3]*r+n[7]*i+n[11]*s+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*i+n[8]*s+n[12])/o,t[1]=(n[1]*r+n[5]*i+n[9]*s+n[13])/o,t[2]=(n[2]*r+n[6]*i+n[10]*s+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 At=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},Tt=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},_t=yt;function kt(){var t=new ut(4);return ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}dt(),function(){var t,e=(t=new ut(4),ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var Ot;function xt(t){return t&&t.rt&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}dt(),mt(1,0,0),mt(0,1,0),kt(),kt(),Ot=new ut(9),ut!=Float32Array&&(Ot[1]=0,Ot[2]=0,Ot[3]=0,Ot[5]=0,Ot[6]=0,Ot[7]=0),Ot[0]=1,Ot[4]=1,Ot[8]=1;var St={exports:{}},It={exports:{}},Et=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))},Ct=Array.prototype.concat,Ut=Array.prototype.slice,Ft=It.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];Et(i)?e=Ct.call(e,Ut.call(i)):e.push(i)}return e};Ft.wrap=function(t){return function(){return t(Ft(arguments))}};var Nt=It.exports,Pt={"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]},Bt=Nt,Dt=Object.hasOwnProperty,Rt=Object.create(null);for(var Lt in Pt)Dt.call(Pt,Lt)&&(Rt[Pt[Lt]]=Lt);var jt=St.exports={to:{},get:{}};function zt(t,e,n){return Math.min(Math.max(e,t),n)}function qt(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}jt.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=jt.get.hsl(t),n="hsl";break;case"hwb":e=jt.get.hwb(t),n="hwb";break;default:e=jt.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},jt.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]:Dt.call(Pt,e[1])?((i=Pt[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]=zt(i[n],0,255);return i[3]=zt(i[3],0,1),i},jt.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,zt(parseFloat(e[2]),0,100),zt(parseFloat(e[3]),0,100),zt(isNaN(n)?1:n,0,1)]}return null},jt.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,zt(parseFloat(e[2]),0,100),zt(parseFloat(e[3]),0,100),zt(isNaN(n)?1:n,0,1)]}return null},jt.to.hex=function(){var t=Bt(arguments);return"#"+qt(t[0])+qt(t[1])+qt(t[2])+(t[3]<1?qt(Math.round(255*t[3])):"")},jt.to.rgb=function(){var t=Bt(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]+")"},jt.to.rgb.percent=function(){var t=Bt(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]+")"},jt.to.hsl=function(){var t=Bt(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},jt.to.hwb=function(){var t=Bt(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},jt.to.keyword=function(t){return Rt[t.slice(0,3)]};var Vt=St.exports,Gt={exports:{}},$t={"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]},Xt={};for(var Ht in $t)$t.hasOwnProperty(Ht)&&(Xt[$t[Ht]]=Ht);var Jt=Gt.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 Kt in Jt)if(Jt.hasOwnProperty(Kt)){if(!("channels"in Jt[Kt]))throw new Error("missing channels property: "+Kt);if(!("labels"in Jt[Kt]))throw new Error("missing channel labels property: "+Kt);if(Jt[Kt].labels.length!==Jt[Kt].channels)throw new Error("channel and label counts mismatch: "+Kt);var Yt=Jt[Kt].channels,Qt=Jt[Kt].labels;delete Jt[Kt].channels,delete Jt[Kt].labels,Object.defineProperty(Jt[Kt],"channels",{value:Yt}),Object.defineProperty(Jt[Kt],"labels",{value:Qt})}function Wt(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}Jt.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]},Jt.rgb.hsv=function(t){var e,n,r,i,s,o=t[0]/255,a=t[1]/255,c=t[2]/255,u=Math.max(o,a,c),f=u-Math.min(o,a,c),l=function(t){return(u-t)/6/f+.5};return 0===f?i=s=0:(s=f/u,e=l(o),n=l(a),r=l(c),o===u?i=r-n:a===u?i=1/3+e-r:c===u&&(i=2/3+n-e),i<0?i+=1:i>1&&(i-=1)),[360*i,100*s,100*u]},Jt.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[Jt.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)))]},Jt.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]},Jt.rgb.keyword=function(t){var e=Xt[t];if(e)return e;var n,r=1/0;for(var i in $t)if($t.hasOwnProperty(i)){var s=Wt(t,$t[i]);s<r&&(r=s,n=i)}return n},Jt.keyword.rgb=function(t){return $t[t]},Jt.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)]},Jt.rgb.lab=function(t){var e=Jt.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))]},Jt.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 u=0;u<3;u++)(r=o+1/3*-(u-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[u]=255*s;return i},Jt.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)]},Jt.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]}},Jt.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)]},Jt.hwb.rgb=function(t){var e,n,r,i,s,o,a,c=t[0]/360,u=t[1]/100,f=t[2]/100,l=u+f;switch(l>1&&(u/=l,f/=l),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),i=u+r*((n=1-f)-u),e){default:case 6:case 0:s=n,o=i,a=u;break;case 1:s=i,o=n,a=u;break;case 2:s=u,o=n,a=i;break;case 3:s=u,o=i,a=n;break;case 4:s=i,o=u,a=n;break;case 5:s=n,o=u,a=i}return[255*s,255*o,255*a]},Jt.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))]},Jt.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))]},Jt.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))]},Jt.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]},Jt.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]},Jt.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)]},Jt.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],i=1 in arguments?arguments[1]:Jt.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},Jt.hsv.ansi16=function(t){return Jt.rgb.ansi16(Jt.hsv.rgb(t),t[2])},Jt.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)},Jt.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]},Jt.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]},Jt.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},Jt.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]},Jt.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)]},Jt.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]},Jt.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]},Jt.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)]},Jt.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]},Jt.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]},Jt.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)]},Jt.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]},Jt.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},Jt.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},Jt.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},Jt.gray.hsl=Jt.gray.hsv=function(t){return[0,0,t[0]]},Jt.gray.hwb=function(t){return[0,100,t[0]]},Jt.gray.cmyk=function(t){return[0,0,0,t[0]]},Jt.gray.lab=function(t){return[t[0],0,0]},Jt.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},Jt.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var Zt=Gt.exports,te=Zt;function ee(t){var e=function(){for(var t={},e=Object.keys(te),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(te[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 ne(t,e){return function(n){return e(t(n))}}function re(t,e){for(var n=[e[t].parent,t],r=te[e[t].parent][t],i=e[t].parent;e[i].parent;)n.unshift(e[i].parent),r=ne(te[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}var ie=Zt,se=function(t){for(var e=ee(t),n={},r=Object.keys(e),i=r.length,s=0;s<i;s++){var o=r[s];null!==e[o].parent&&(n[o]=re(o,e))}return n},oe={};Object.keys(ie).forEach((function(t){oe[t]={},Object.defineProperty(oe[t],"channels",{value:ie[t].channels}),Object.defineProperty(oe[t],"labels",{value:ie[t].labels});var e=se(t);Object.keys(e).forEach((function(n){var r=e[n];oe[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),oe[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 ae=Vt,ce=oe,ue=[].slice,fe=["keyword","gray","hex"],le={};Object.keys(ce).forEach((function(t){le[ue.call(ce[t].labels).sort().join("")]=t}));var he={};function de(t,e){if(!(this instanceof de))return new de(t,e);if(e&&e in fe&&(e=null),e&&!(e in ce))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 de)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var i=ae.get(t);if(null===i)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=ce[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=ce[this.model].channels;var s=ue.call(t,0,r);this.color=be(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 le))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=le[a];var c=ce[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=be(u)}if(he[this.model])for(r=ce[this.model].channels,n=0;n<r;n++){var f=he[this.model][n];f&&(this.color[n]=f(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ye(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(he[t]||(he[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 me(t){return function(e){return Math.max(0,Math.min(t,e))}}function be(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function pe(t){return null==t}function ge(t){return"object"==typeof t&&!!t}function we(t){return t/Math.PI*180}de.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in ae.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return ae.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 ae.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=ce[this.model].channels,n=ce[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 de(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 de(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ye("rgb",0,me(255)),green:ye("rgb",1,me(255)),blue:ye("rgb",2,me(255)),hue:ye(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ye("hsl",1,me(100)),lightness:ye("hsl",2,me(100)),saturationv:ye("hsv",1,me(100)),value:ye("hsv",2,me(100)),chroma:ye("hcg",1,me(100)),gray:ye("hcg",2,me(100)),white:ye("hwb",1,me(100)),wblack:ye("hwb",2,me(100)),cyan:ye("cmyk",0,me(100)),magenta:ye("cmyk",1,me(100)),yellow:ye("cmyk",2,me(100)),black:ye("cmyk",3,me(100)),x:ye("xyz",0,me(100)),y:ye("xyz",1,me(100)),z:ye("xyz",2,me(100)),l:ye("lab",0,me(100)),a:ye("lab",1),b:ye("lab",2),keyword:function(t){return arguments.length?new de(t):ce[this.model].keyword(this.color)},hex:function(t){return arguments.length?new de(t):ae.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 de.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 de.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(ce).forEach((function(t){if(-1===fe.indexOf(t)){var e=ce[t].channels;de.prototype[t]=function(){if(this.model===t)return new de(this);if(arguments.length)return new de(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new de((n=ce[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},de[t]=function(n){return"number"==typeof n&&(n=be(ue.call(arguments),e)),new de(n,t)}}}));const ve=[1,1,1,1,2,2,3,0];function Me(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=ve[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}new Array(3),new Array(3);const Ae=[1/6378137,1/6378137,1/6356752.314245179],Te=[1/40680631590769,1/40680631590769,1/40408299984661.445],_e=new Array(3),ke=new Array(3),Oe=new Array(3);function xe(t,e){const n=Te,r=function(t,e,n,r,i){const s=e[0],o=e[1],a=e[2],c=n[0],u=n[1],f=n[2],l=s*s*c*c,h=o*o*u*u,d=a*a*f*f,y=l+h+d,m=Math.sqrt(1/y),b=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(Se,e,m);if(y<i)return isFinite(m)?b:void 0;const p=r[0],g=r[1],w=r[2],v=Ie;v[0]=b[0]*p*2,v[1]=b[1]*g*2,v[2]=b[2]*w*2;let M,A,T,_,k,O,x,S,I,E,C,U=(1-m)*Ce(e)/(.5*Ce(v)),F=0;do{U-=F,T=1/(1+U*p),_=1/(1+U*g),k=1/(1+U*w),O=T*T,x=_*_,S=k*k,I=O*T,E=x*_,C=S*k,M=l*O+h*x+d*S-1,A=l*I*p+h*E*g+d*C*w;F=M/(-2*A)}while(Math.abs(M)>Ee);return t[0]=s*T,t[1]=o*_,t[2]=a*k,t}(_e,e,Ae,n,.1);let i=Tt(ke,r,n);i=function(t,e){const n=e[0],r=e[1],i=e[2];let s=n*n+r*r+i*i;s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s);return t}(i,i);const s=At(Oe,e,r),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=function(t){return Math.sign?Math.sign(t):0==(t=+t)||isNaN(t)?Number(t):t>0?1:-1}(vt(s,e))*Ce(s);return t[0]=we(o),t[1]=we(a),t[2]=c,t}const Se=new Array(3),Ie=new Array(3),Ee=1e-12;function Ce(t){return yt(t)}function Ue(t,e){let n="";for(let r=0;r<4;r++){const i=t.getUint8(e+r);n+=String.fromCharCode(i)}return n}const Fe="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ne(t,e,n){const r=new Uint8Array(t,e,n);return Fe?JSON.parse(Fe.decode(r)):JSON.parse(Me(r))}function Pe(t,e,n){const r=new Uint8Array(t,e,n);return Fe?JSON.parse(Fe.decode(r)):JSON.parse(Me(r))}function Be(t,e,n){return{offset:e,byteLength:n}}function De(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=function(t){return je[t]}(s||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Le[t]}(o);return{byteStride:0,byteOffset:i+n,itemSize:u,count:r*u,componentType:c,array:new a(e,n+i,r*u)}}function Re(t,e,n,r){const i=De(t,e,n,r);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}const Le={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const je={"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 ze(t){for(const e in je)if(t===je[e].ctor)return je[e].type;throw new Error("unrecognized ctor:"+t)}function qe(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 Ve(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,u={},f={},l=null;r>0&&(u=Ne(a,e,r),e+=r),i>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,i),e+=i),s>0&&(f=Pe(a,e,s),e+=s);const h=Be(0,e,o);return l=a.slice(h.offset,h.offset+h.byteLength),n.push(l),{featureTable:u,featureTableBin:c,batchTable:f,batchTableBin:l}}const Ge={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function $e(t){for(const e in Ge)if(t===Ge[e])return+e;throw new Error("unrecognized ctor:"+t)}\n/*!\n * @maptalks/gl v0.102.1\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.com\n */const Xe=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")},He=Xe(),Je=He.gl_trans__coders=He.gl_trans__coders||{};Je.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),i=He.gl_trans__coders=He.gl_trans__coders||{};let s=\`${o}r}\\n const _____getGlobal = ${o}Xe.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},Je.registerTranscoder=function(t,e){Je[t]=e},Je.getTranscoder=function(t){return Je[t]};let Ke=null;function Ye(){return Ke||(Ke={"image/crn":Je.crn&&Je.crn(),"image/ktx2":Je.ktx2&&Je.ktx2(),"image/cttf":Je.ktx2&&Je.ktx2(),"draco":Je.draco&&Je.draco()}),Ke}class Qe{constructor(t,e,n){this.i=t,this.it=e||Q,this.o=n,this.st=Ye()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,i)):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,n,r)}))}ot(t,e,n,r,i){const s=i&&i.maxTextureSize,o=this.ct(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.it(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.st,supportedFormats:this.o,maxTextureSize:s})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${o}t}-${o}n}-${o}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}}))}ct(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),u=i.getUint32(20,!0),f=i.getUint32(24,!0),l=28+e;u>=570425344?(l-=8,o=a,u=c,f=0,a=0,c=0):f>=570425344&&(l-=4,o=u,u=a,f=c,a=0,c=0);const h=[t];let d,y,m;if(a>0?(d=Ne(t,l,a),l+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(l+=c),u>0&&(y=Pe(t,l,u),l+=u,f>0)){const e=Be(0,l,f);m=t.slice(e.offset,e.offset+e.byteLength),l+=f,h.push(m)}const b=d.BATCH_LENGTH,p={};if(d&&d.BATCH_ID){p.BATCH_ID=Re(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:l,byteLength:i.byteLength+i.byteOffset-l}}}ut(){return null}}class We{constructor(t,e,n,r){this.i=t,this.it=e||Q,this.o=n,this.st=Ye(),this.ft=r}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,i)):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,n,r)}))}ot(t,e,n,r,i){return this.lt(t,e,n,r,i).then((({gltf:i,transferables:s})=>{const o=this.ht(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})}))}lt(t,e,n,r,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.st,supportedFormats:this.o,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=Me(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?C.getArrayBuffer(r,{}).then((t=>this.dt(r,{buffer:t.data,byteOffset:0},o))):C.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("/")),i=new this.it(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=\`${o}t}-${o}r}-${o}s}\`,{transferables:i.transferables,gltf:n}}))}ht(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:u,batchTableBin:f}=Ve(i,32+e,o),l={},h=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;l.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(l.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;l.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(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=Re(a.BATCH_ID,t,c.offset,h);const e=l.BATCH_ID.array&&l.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(l.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;l.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(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,l.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(l.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;l.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},o.push(l.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;l.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(l.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:f,featureTable:a,i3dm:l,transferables:o}}bt(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let i=0;i<e;i++)Ze(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}yt(t,e,n){return qe(new Float32Array(t.length),t,e,n)}ut(){return null}}function Ze(t,e,n,r){if(t[0]=tn(e,r),t[1]=tn(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]))*en(e),t[1]=(1-Math.abs(e))*en(t[1])}return wt(t,t)}function tn(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 en(t){return t<0?-1:1}class nn{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.ot(t,e,n,r)):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,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 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:u,batchTableBin:f}=Ve(i,e+28,o),l=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=Ye().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,l,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:ze(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?r.BATCH_ID=Re(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=rn(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:f,featureTable:a,pnts:r,transferables:o}}))}const b=this.vt(t,a,c.offset,d,o,l,h);if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?b.BATCH_ID=Re(a.BATCH_ID,t,c.offset,d):b.BATCH_ID=rn(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:f,featureTable:a,pnts:b,transferables:o})}vt(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:u}=e.POSITION_QUANTIZED;c=c||0;const f=u?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.yt(u||new Uint16Array(t,c+f,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}yt(t,e,n){return qe(new Float32Array(t.length),t,e,n)}ut(){return null}}function rn(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:ze(e),array:r}}class sn{constructor(t,e,n,r){this.o=n,this.i=t,this.it=e||Q,this.ft=r}load(t,e,n=0,r=0,i){return e?this.ot(t,e,n,r,i):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.ot(t,i,n,r)}))}ot(t,e,n,r,i){r||(r=e.byteLength);const s=this.Mt(e,t,n,r),o=[];for(let n=0;n<s.length;n++){let r;if("b3dm"===s[n].magic)r=new Qe(this.i,this.it,this.o);else if("i3dm"===s[n].magic)r=new We(this.i,this.it,this.o,this.ft);else if("pnts"===s[n].magic)r=new nn;else{if("cmpt"!==s[n].magic){console.warn("Unsupported magic in CMPT tile:",s[n].magic);continue}r=new sn(this.i,this.it,this.o,this.ft)}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})))}Mt(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=Ue(i,c),r=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}function on(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=[];dn(r[n],i,t,e)}}}const an=[],cn=[],un=[],fn=[0,0,0],ln=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),hn=[1,1,1];function dn(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=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}(an,t.translation||fn),n=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,u=n*o,f=r*o,l=r*a,h=i*o,d=i*a,y=i*c,m=s*o,b=s*a,p=s*c;return t[0]=1-l-y,t[1]=f+p,t[2]=h-b,t[3]=0,t[4]=f-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-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(cn,t.rotation||ln),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}(un,t.scale||hn);lt(r,n,r);const s=lt([],e,r);i.push(s)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)dn(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 yn(t,e){let{byteOffset:n,byteStride:r,count:i}=t;const{componentType:s,itemSize:o}=t,a=t.array.buffer,c=s?Q.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 u=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);u.set(i);e(new c(u.buffer),t),i.set(u)}}var mn=vn("DXT1"),bn=vn("DXT3"),pn=vn("DXT5"),gn=vn("DX10"),wn=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 i=r[21];switch(i){case mn:e=8,n="dxt1";break;case bn:e=16,n="dxt3";break;case pn:e=16,n="dxt5";break;case 116:n="rgba32f";break;case gn:var s=new Uint32Array(t.slice(128,148));n=s[0];var o=s[1];if(s[2],s[3],s[4],3!==o||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(a=i,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 f=!1;512&r[28]&&(f=!0);var l,h=r[4],d=r[3],y=r[1]+4,m=h,b=d,p=[];i===gn&&(y+=20);if(f)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++)l=h*d*16,p.push({offset:y,length:l,shape:[h,d]}),v<u&&(y+=l),h=Math.floor(h/2),d=Math.floor(d/2)}else for(v=0;v<u;v++)l=Math.max(4,h)/4*Math.max(4,d)/4*e,p.push({offset:y,length:l,shape:[h,d]}),y+=l,h=Math.floor(h/2),d=Math.floor(d/2);return{shape:[m,b],images:p,format:n,flags:c,cubemap:f}};function vn(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var Mn=xt(wn),An=Math.abs,Tn=Math.sin,_n=Math.cos,kn=Math.tan,On=Math.atan,xn=Math.atan2,Sn=Math.sqrt,In=Math.log,En=Math.hypot,Cn=Math.sinh,Un=Math.cosh,Fn=1/0;function Nn(t){var e,n,r,i,s,o,a=[],c=[],u=[],f=[];function l(t,e){for(var n,r=2*_n(2*e),i=t.length-1,s=t[i],o=0;--i>=0;)n=r*s-o+t[i],o=s,s=n;return e+n*Tn(2*e)}function h(t,e,n){for(var r,i,s=Tn(e),o=_n(e),a=Cn(n),c=Un(n),u=2*o*c,f=-2*s*a,l=t.length-1,h=t[l],d=0,y=0,m=0;--l>=0;)r=y,i=d,h=u*(y=h)-r-f*(d=m)+t[l],m=f*y-i+u*d;return[(u=s*c)*h-(f=o*a)*m,u*m+f*h]}t.es,s=i=(r=t.es/(1+Sn(1-t.es)))/(2-r),a[0]=i*(2+i*(-2/3+i*(i*(116/45+i*(26/45+i*(-2854/675)))-2))),c[0]=i*(i*(2/3+i*(4/3+i*(-82/45+i*(32/45+i*(4642/4725)))))-2),s*=i,a[1]=s*(7/3+i*(i*(-227/45+i*(2704/315+i*(2323/945)))-1.6)),c[1]=s*(5/3+i*(-16/15+i*(-13/9+i*(904/315+i*(-1522/945))))),s*=i,a[2]=s*(56/15+i*(-136/35+i*(-1262/105+i*(73814/2835)))),c[2]=s*(-26/15+i*(34/21+i*(1.6+i*(-12686/2835)))),s*=i,a[3]=s*(4279/630+i*(-332/35+i*(-399572/14175))),c[3]=s*(1237/630+i*(i*(-24832/14175)-2.4)),s*=i,a[4]=s*(4174/315+i*(-144838/6237)),c[4]=s*(-734/315+i*(109598/31185)),s*=i,a[5]=s*(601676/22275),c[5]=s*(444337/155925),s=i*i,e=t.k0/(1+i)*(1+s*(1/4+s*(1/64+s/256))),u[0]=i*(i*(2/3+i*(-37/96+i*(1/360+i*(81/512+i*(-96199/604800)))))-.5),f[0]=i*(.5+i*(-2/3+i*(5/16+i*(41/180+i*(-127/288+i*(7891/37800)))))),u[1]=s*(-1/48+i*(-1/15+i*(437/1440+i*(-46/105+i*(1118711/3870720))))),f[1]=s*(13/48+i*(i*(557/1440+i*(281/630+i*(-1983433/1935360)))-.6)),s*=i,u[2]=s*(-17/480+i*(37/840+i*(209/4480+i*(-5569/90720)))),f[2]=s*(61/240+i*(-103/140+i*(15061/26880+i*(167603/181440)))),s*=i,u[3]=s*(-4397/161280+i*(11/504+i*(830251/7257600))),f[3]=s*(49561/161280+i*(-179/168+i*(6601661/7257600))),s*=i,u[4]=s*(-4583/161280+i*(108847/3991680)),f[4]=s*(34729/80640+i*(-3418889/1995840)),s*=i,u[5]=s*(-20648693/638668800),f[5]=.6650675310896665*s,o=l(c,t.phi0),n=-e*(o+function(t,e){var n,r=2*_n(e),i=t.length-1,s=t[i],o=0;for(;--i>=0;)n=r*s-o+t[i],o=s,s=n;return Tn(e)*n}(f,2*o)),t.fwd=function(t,r){var i,s,o,a,u,d=t.phi,y=t.lam;d=l(c,d),i=Tn(d),s=_n(d),a=Tn(y),o=_n(y),d=xn(i,o*s),y=xn(a*s,En(i,s*o)),y=function(t){var e=An(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*In(e)/n}(e*(1+e/(En(1,e)+1))),t<0?-e:e}(kn(y)),u=h(f,2*d,2*y),d+=u[0],y+=u[1],An(y)<=2.623395162778?(r.y=e*d+n,r.x=e*y):r.x=r.y=Fn},t.inv=function(t,r){var i,s,o,c,f,d=t.y,y=t.x;d=(d-n)/e,An(y/=e)<=2.623395162778?(d+=(f=h(u,2*d,2*y))[0],y+=f[1],y=On(Cn(y)),i=Tn(d),s=_n(d),c=Tn(y),o=_n(y),y=xn(c,o*s),d=xn(i*o,En(c,o*s)),r.phi=l(a,d),r.lam=y):r.phi=r.lam=Fn}}const Pn=Math.PI/180,Bn=6378137*Math.PI/180,Dn=85.0511287798,Rn={};function Ln(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=Dn,r=e[0],i=Math.max(Math.min(n,e[1]),-n);let s;s=0===i?0:Math.log(Math.tan((90+i)*Pn/2))/Pn;return t[0]=r*Bn,t[1]=s*Bn,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return jn(t,e);if("baidu"===n)return jn(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 i=JSON.stringify(n);let s=Rn[i];return s||(s=Rn[i]=function(t){const e={a:qn,es:Vn,x0:pe(t.falseEasting)?5e5:t.falseEasting,y0:pe(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*zn,phi0:(t.latitudeOfOrigin||0)*zn,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Nn(e);const n={lam:0,phi:0},r={};let i=0,s=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*zn-e.lam0,n.phi=e.originPhi0*zn,e.fwd(n,r),i=e.a*r.x+e.x0,s=e.a*r.y+e.y0);return{project:function(t,o){n.lam=t[0]*zn-e.lam0,n.phi=t[1]*zn,e.fwd(n,r);const a=e.a*r.x+e.x0-i,c=e.a*r.y+e.y0-s;return o[0]=a,o[1]=c,o}}}(n)),s.project(e,t)}}function jn(t,e){return t[0]=e[0],t[1]=e[1],t}const zn=.017453292519943295,qn=6378137,Vn=.0066943799901413165;const Gn=ft([]),$n=Ye().draco,Xn=Ye().ktx2,Hn={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},Jn={"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 Kn(t,e,n,r,i,s){const o=[],a=[],c=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],i=C.getArrayBuffer(n.url,s);i.xhr.url=n.url,c.push(i.xhr);const u=i.then((t=>({buffer:t})));o.push(u);const f=[];if(rr(r,f),f.length){const t=f.map((t=>{const e=C.getArrayBuffer(t.url,s);return e.xhr.url=t.url,c.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));o.push(...t)}a[e]=f.length}const u=Promise.all(o).then((s=>{for(let t=0;t<s.length;t++)if(!s[t]||!s[t].buffer)return Promise.resolve(null);const o=[];let c=0;for(let t=0;t<a.length;t++){const e=a[t];o.push({geoBuffer:{data:s[c].buffer.data},textureBuffers:s.slice(c+1,e+c+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),c+=1+e}const u=function(t,e,n,r,i,s){const o={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},a=[];for(let c=0;c<t.meshes.length;c++){let{material:u}=t.meshes[c];const{geometry:f}=t.meshes[c];let l;const h=e[c].geoBuffer.data;if(!h)continue;l=ur(h)?Qn(o,c,f,h,t.transform,t.center,i,s):Zn(o,c,f,h,t.transform,t.center,i,s),a.push(l),o.nodes[c]={mesh:c,nodeIndex:c,matrix:ft([])},o.scenes[0].nodes[c]=o.nodes[c],u||(u=Hn);const d=er(c,o,u,e[c].textureBuffers,n,r);a.push(d)}return Promise.all(a).then((()=>({gltf:o,featureTable:{BATCH_LENGTH:0},transferables:o.transferables})))}(t,o,e,i,n,r);return u}));return u.xhr=c,u}const Yn={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Qn(t,e,n,r,i,s,o,a){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=Jn[e];if(!r)return t;return t[r.name||e]=n,t}),{});return $n(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>tr(n,t,e,i,s,o,a)))}const Wn={position:function(t,e,n){const r=3*t.vertexCount,i=new Float32Array(e,n,r);return t.position={array:i,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,i=new Float32Array(e,n,r);return t.normal={array:i,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,i=new Float32Array(e,n,r);return t.uv0={array:i,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,i=new Uint8Array(e,n,r);return t.color={array:i,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,i=new Uint32Array(e,n,r);return t.faceRange={array:i,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,i=new Uint16Array(e,n,r);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,i=new Uint16Array(e,n,r);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Zn(t,e,n,r,i,s,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++)Wn[n[e]]?t=Wn[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let i=e.ordering,s=e.featureAttributeOrder;const o=null;o&&o.geometryData&&o.geometryData[0]&&o.geometryData[0].params;for(let e=0;e<i.length;e++){const n=Wn[i[e]];n||console.log(i[e]),t=n(c,r,t)}for(let e=0;e<s.length;e++){const n=Wn[s[e]];n||console.log(s[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const f={};for(const t in c){const e=Jn[t]&&Jn[t].name;e&&(f[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(l=e)<=255?Uint8Array:l<=65535?Uint16Array:Uint32Array,r=new n(f.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,i=t[e],s=t[e+1];for(let t=i;t<=s;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}f._BATCHID={componentType:$e(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var l;return tr({attributes:f},t,e,i,s,o,a)}function tr(t,e,n,r,i,s,o){const a={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 c=function(t,e,n,r,i){let s,o=[0,0,0,1];const a=[0,0],c=Ln([],n,r,i);c[2]=n[2];const u=e&&ht(Gn,e);return yn(t,(t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],u||(o=Mt(o,o,e)),n&&gt(o,o,n),Ln(a,o,r,i),s=o[2],t[0]=a[0]-c[0],t[1]=a[1]-c[1],t[2]=s-c[2],t))),c}(t.attributes.POSITION,r,i,s,o);e.meshes[n]={primitives:[a],index:n},e.extensions.MAPTALKS_RTC={projCenter:c},e.extensions.CESIUM_RTC={rtcCoord:i};for(const n in t.attributes)cr(e.transferables,t.attributes[n].array.buffer);return t.indices&&cr(e.transferables,t.indices.array.buffer),a}function er(t,e,n,r,i,s){const o=r.map((t=>function(t,e,n,r,i){if("dds"===e){const e=Mn(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),i="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Yn,format:i})}if("png"===e||"jpg"===e)return function(t,e){ir||(ir=new OffscreenCanvas(2,2),sr=ir.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;or(n)||(n=ar(n)),or(r)||(r=ar(r));const i=e;i&&(n=Math.min(i,n),r=Math.min(i,r)),ir.width=n,ir.height=r,sr.drawImage(t,0,0,n,r),t.close();const s=sr.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(s.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,i).then((t=>{t.mimeType=n;return{image:t,sampler:Yn,format:6408}}));if("ktx2"===e)return Xn(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Yn,format:t.format})));return null}(t.data,t.format,t.mimeType,i,s).then((t=>{if(t.image)if(t.image.array)cr(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)cr(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(o).then((r=>{nr(t,e,n,r)}))}function nr(t,e,n,r){const i=JSON.parse(JSON.stringify(n)),s=e.textures;r.ptr||(r.ptr=0);for(const t in n)n[t]&&n[t].url?(s.push(r[r.ptr++]),i[t]={index:s.length-1},void 0!==n[t].factor&&(i[t].scale=n[t].factor)):ge(n[t])&&(i[t]=nr(-1,e,n[t],r));return t>=0&&(e.materials[t]=i),i}function rr(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}):ge(t[n])&&rr(t[n],e)}let ir,sr;function or(t){return!(t&t-1)&&0!==t}function ar(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function cr(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function ur(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 fr="undefined"!=typeof Float32Array?Float32Array:Array;function lr(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var hr=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 fr(3);return fr!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const dr=[];const yr=[],mr=[],br=[],pr=[],gr=[],wr=[],vr=[];function Mr(t,e,n,r,i,s){lr(pr,t[3*e],t[3*e+1],t[3*e+2]),lr(gr,t[3*n],t[3*n+1],t[3*n+2]),lr(wr,t[3*r],t[3*r+1],t[3*r+2]);const o=hr(yr,wr,gr),a=hr(mr,pr,gr),c=function(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[0],a=n[1],c=n[2];return t[0]=i*c-s*a,t[1]=s*o-r*c,t[2]=r*a-i*o,t}(br,o,a);!function(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;s>0&&(s=1/Math.sqrt(s),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s)}(vr,c),i[3*e]=i[3*e]||0,i[3*n]=i[3*n]||0,i[3*r]=i[3*r]||0,i[3*e+1]=i[3*e+1]||0,i[3*n+1]=i[3*n+1]||0,i[3*r+1]=i[3*r+1]||0,i[3*e+2]=i[3*e+2]||0,i[3*n+2]=i[3*n+2]||0,i[3*r+2]=i[3*r+2]||0,i[3*e]+=vr[0],i[3*n]+=vr[0],i[3*r]+=vr[0],i[3*e+1]+=vr[1],i[3*n+1]+=vr[1],i[3*r+1]+=vr[1],i[3*e+2]+=vr[2],i[3*n+2]+=vr[2],i[3*r+2]+=vr[2],s[e]+=1,s[n]+=1,s[r]+=1}const Ar=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Tr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],_r=2*Math.PI*6378137/360,kr="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let Or,xr,Sr=!1;if("undefined"!=typeof OffscreenCanvas){try{xr=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}xr&&"undefined"!=typeof createImageBitmap&&(Sr=!0)}const Ir=ft([]),Er=[0,0,0],Cr=[],Ur=[],Fr=[],Nr=[],Pr={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Br={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Dr;class Rr{constructor(t,e,n,r){this.id=t,this.options=e,this.At=(...t)=>this.requestImage.call(this,...t),this.Tt=n,this._t={},r(null,{},[])}kt(t){this.Ot||(this.o=t,this.xt=new nn,this.Ot=new Qe(this.At,Q,t),this.St=new We(this.At,Q,t))}requestImage(t,e){Sr?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{Or.width=t.width,Or.height=t.height,xr.drawImage(t,0,0);const n=xr.getImageData(0,0,Or.width,Or.height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.Tt("requestImage",{url:t},null,e)}loadTile(t,e){this.kt(t.supportedFormats);const{service:n,url:r,arraybuffer:i}=t,s=n.fetchOptions||{};if(s.referrer=t.referrer,s.referrerPolicy=s.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const i=t.i3sInfo,o=n.maxTextureSize||0,a=Kn(i,t.supportedFormats,this.options.projection,t.projection,o,s);return a.then((t=>{if(delete this._t[r],!t)return void e({status:404,url:r,i3sInfo:i});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:i});t.gltf.url=r;const{transferables:s}=t;t.magic="b3dm",n.createNormalIfMissed&&this.It(t.gltf),Hr(n)&&this.Et(t.gltf),e(null,t,s)})),void(this._t[r]=a.xhr)}if(i){delete this._t[r];const n=Ue(new DataView(i),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(kr){const r=new Uint8Array(t,e,n);return kr.decode(r)}return Me(new Uint8Array(t,e,n))}(i,0,i.byteLength),s=JSON.parse(n);s.accessors?this.Ct(s,r,t,"gltf",e):this.Ut(t.rootIdx,s,i,r,e)}else this.Ct(i,r,t,n,e)}else{let i=n.urlParams;i&&(i=(r.indexOf("?")>0?"&":"?")+i);const o=r.replace(/\\+/g,"%2B");let a=C.getArrayBuffer(o+(i||""),s);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,i){r=r&&r.toLowerCase();const{service:s}=n;if("b3dm"===r){this.Ot.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{if(t.error)return void i(t);const{content:e,transferables:r}=this.Ft(t,n);s.createNormalIfMissed&&this.It(e.gltf),Hr(s)&&this.Et(e.gltf),i(null,e,r)})).catch((t=>{i(t)}))}else if("pnts"===r){const r=n.transform||Ir;this.xt.load(e,t).then((t=>{const{content:e,transferables:s}=this.Nt(t,r,n.rootIdx);this.Pt(e),i(null,e,s)}))}else if("i3dm"===r){const r=n.transform||Ir;this.St.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{const{content:e,transferables:o}=this.Bt(t,r,n.rootIdx);s.createNormalIfMissed&&this.It(e.gltf),Hr(s)&&this.Et(e.gltf),i(null,e,o)}))}else if("cmpt"===r){new sn(this.At,Q,this.o,s.maxTextureSize||0).load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{const{content:e,transferables:r}=this.Dt(t,n);this.Rt(e,s),Hr(s)&&this.Lt(e),i(null,e,r)})).catch((t=>{i(t)}))}else if("gltf"===r){this.st||(this.st=Ye());const r=e.substring(0,e.lastIndexOf("/")),o=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t;let a;try{a=new Q(r,o,{transferable:!0,requestImage:this.At,decoders:this.st,supportedFormats:this.o,maxTextureSize:s.maxTextureSize||0})}catch(t){i(t)}a.load({skipAttributeTransform:!1}).then((t=>{t.url=e,this.jt(t,null,n),s.createNormalIfMissed&&this.It(t),Hr(s)&&this.Et(t),i(null,{magic:"gltf",gltf:t},a.transferables)}))}else i(new Error("unsupported tile format: "+r))}Rt(t,e){t.content?t.content.forEach((t=>{this.Rt(t,e)})):e.createNormalIfMissed&&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()?Dr.subarray(0,n):e,i=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const i=dr;i.length<t.length/3&&(i.length=t.length/3),i.fill(0,0,t.length/3);const s=void 0===e.length?e:e.length;for(let n=0;n<s/3;n++)void 0===e.length?Mr(t,3*n,3*n+1,3*n+2,r,i):Mr(t,e[3*n],e[3*n+1],e[3*n+2],r,i);const o=r.getLength?r.getLength():r.length;for(let t=0;t<o;t+=3){const e=i[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:i,byteLength:i.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:i.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(Pr[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=_r,t.compressed_int16_params.compressed_ratio=r);const i=Gr(e[n].array,r,e[n].min,e[n].max,n);if(!i)continue;const{array:s,range:o}=i;e[n].componentType=5124,e[n].array=s,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(Pr[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=_r,t.compressed_int16_params.compressed_ratio=r);const{array:i,range:s}=Gr(e[n].array,r,e[n].min,e[n].max,n);e[n].array=i,t.compressed_int16_params[n]=s}}Gt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const i={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(i)}return e}Ut(t,e,n,r,i){return e.capabilities,void i(null,e)}Dt(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},i=[];for(let t=0;t<n.length;t++){const{magic:s}=n[t];if("b3dm"===s){const{content:s,transferables:o}=this.Ft(n[t],e);qr(i,o),r.content.push(s)}else if("i3dm"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:c}=this.Bt(n[t],s,o);qr(i,c),r.content.push(a)}else if("pnts"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:c}=this.Nt(n[t],s,o);qr(i,c),r.content.push(a)}else if("cmpt"===s){const{content:s,transferables:o}=this.Dt(n[t],e);qr(i,o),r.content.push(s)}}return{content:r,transferables:i}}Ft(t,e){const{gltf:n,transferables:r,featureTable:i}=t;return this.jt(n,i,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 i in t.meshes){const s=t.meshes[i],{primitives:o}=s;if(o)for(let t=0;t<o.length;t++){const i=o[t].attributes&&o[t].attributes.POSITION;if(!i||!i.array)continue;i.array.buffer[e]||(i.array.buffer[e]=n++);const s=n-1+"-"+(i.byteOffset||0);if(r.indexOf(s)>=0)return!0;r.push(s)}}return!1}(t);this.$t(t);n.service.createNormalIfMissed||this.Xt(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.Ht(t,e,n.upAxis,n.transform)):this.Jt(t,e,n.upAxis,n.transform)}Bt(t,e,n){const{featureTable:r}=t,i=t.i3dm,s=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,a=e&&ht(Ir,e),c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};jr(i.POSITION.array,3,s,Ir,c);const u=zr(c);e&&!a&&Mt(u,u,e);const f=this.Kt(u),l=[];Ln(l,f,o),l[2]=f[2];const h=bt([],u),d=[0,0,0],y=[0,0,0],m=[0,0],b=[1/0,1/0,1/0],p=[-1/0,-1/0,-1/0];yn(i.POSITION,(t=>{d[0]=t[0]+s[0],d[1]=t[1]+s[1],d[2]=t[2]+s[2],e&&!a&&Mt(d,d,e),0===_t(d)?pt(y,0,0,-6378137):xe(y,d),Ln(m,y,o),t[0]=m[0]-l[0],t[1]=m[1]-l[1],t[2]=y[2]-l[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[0]>p[0]&&(p[0]=t[0]),t[1]>p[1]&&(p[1]=t[1]),t[2]>p[2]&&(p[2]=t[2])})),i.POSITION.min=b,i.POSITION.max=p,e&&Mt(u,u,e),t.rtcCenter=h,t.rtcCoord=f,t.projCenter=l,t.rootIdx=n;const g=t.transferables;return delete t.transferables,{content:t,transferables:g}}Nt(t,e,n){const{featureTable:r}=t,i=t.pnts,s=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,a=e&&ht(Ir,e),c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};jr(i.POSITION.array,3,s,e,c);const u=zr(c),f=this.Yt(u),l=bt([],u),h=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];let y=[0,0,0,1];const m=[0,0,0],b=[0,0];yn(i.POSITION,(t=>(y[0]=t[0]+s[0],y[1]=t[1]+s[1],y[2]=t[2]+s[2],e&&!a&&(y=Mt(y,y,e)),0===_t(y)?pt(m,0,0,-6378137):xe(m,y),Ln(b,m,o),t[0]=b[0]-f[0],t[1]=b[1]-f[1],t[2]=m[2]-f[2],t[0]<h[0]&&(h[0]=t[0]),t[1]<h[1]&&(h[1]=t[1]),t[2]<h[2]&&(h[2]=t[2]),t[0]>d[0]&&(d[0]=t[0]),t[1]>d[1]&&(d[1]=t[1]),t[2]>d[2]&&(d[2]=t[2]),t))),i.POSITION.min=h,i.POSITION.max=d,e&&Mt(u,u,e);const p=this.Kt(u);t.rtcCenter=l,t.projCenter=f,t.rtcCoord=p,t.rootIdx=n;const g=t.transferables;return delete t.transferables,{content:t,transferables:g}}$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],i=n[1],s=n[2],o=n[3];let a=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==i||n[t+2]!==s||n[t+3]!==o){a=!1;break}a&&(e[t].image.color=[r/255,i/255,s/255,o/255],delete e[t].image.array)}}}Xt(t){const e=t.meshes;for(const n in e){const r=e[n];if(!r)continue;const i=r.primitives;if(i)for(let e=0;e<i.length;e++){if(!i[e])continue;if(!i[e].attributes||i[e].attributes.NORMAL)continue;const n=i[e].material;if(!pe(n)){const e=t.materials[n];if(!e)continue;e.extensions||(e.extensions={}),e.extensions.KHR_materials_unlit={}}}}}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)}Qt(t,e,n,r){const i=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let s=Ar;"X"===(n=n&&n.toUpperCase())?s=Tr:"Z"===n&&(s=Ir),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),i&&(t.extensions.CESIUM_RTC.center=i),t.extensions.MAPTALKS_RTC={};const o={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};on(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=ft(Cr);t.matrices&&Vr(e,t.matrices);const n=t.attributes.POSITION.array,a=t.attributes.POSITION.itemSize;lt(e,s,e),r&&lt(e,r,e),jr(n,a,i||Er,e,o,t.compressUniforms)}));const a=zr(o);return{rtcCenter:i,modelCenter:a,upAxisTransform:s}}Ht(t,e,n,r){const{modelCenter:i,upAxisTransform:s,rtcCenter:o}=this.Qt(t,e,n),a=this.Yt(i);t.extensions.MAPTALKS_RTC.projCenter=a,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Kt(i);const c=bt([],i);r&&Mt(i,i,r),t.extensions.CESIUM_RTC.rtcCoord=this.Kt(i),o||(on(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=ft(Cr);t.matrices&&Vr(n,t.matrices),lt(n,s,n);const r=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],u=e[7],f=e[8],l=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-i*o,v=n*u-s*o,M=r*c-i*a,A=r*u-s*a,T=i*u-s*c,_=f*m-l*y,k=f*b-h*y,O=f*p-d*y,x=l*b-h*m,S=l*p-d*m,I=h*p-d*b,E=g*I-w*S+v*x+M*O-A*k+T*_;return E?(E=1/E,t[0]=(a*I-c*S+u*x)*E,t[1]=(i*S-r*I-s*x)*E,t[2]=(m*T-b*A+p*M)*E,t[3]=(h*A-l*T-d*M)*E,t[4]=(c*O-o*I-u*k)*E,t[5]=(n*I-i*O+s*k)*E,t[6]=(b*v-y*T-p*w)*E,t[7]=(f*T-h*v+d*w)*E,t[8]=(o*S-a*O+u*_)*E,t[9]=(r*O-n*S-s*_)*E,t[10]=(y*A-m*v+p*g)*E,t[11]=(l*v-f*A-d*g)*E,t[12]=(a*k-o*x-c*_)*E,t[13]=(n*x-r*k+i*_)*E,t[14]=(m*w-y*M-b*g)*E,t[15]=(f*M-l*w+h*g)*E,t):null}(Ur,n),i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];yn(e,(t=>{Mt(t,t,n),t[0]=t[0]-c[0],t[1]=t[1]-c[1],t[2]=t[2]-c[2],Mt(t,t,r),t[0]<i[0]&&(i[0]=t[0]),t[1]<i[1]&&(i[1]=t[1]),t[2]<i[2]&&(i[2]=t[2]),t[0]>o[0]&&(o[0]=t[0]),t[1]>o[1]&&(o[1]=t[1]),t[2]>o[2]&&(o[2]=t[2])})),e.min=i,e.max=o,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=c)}Jt(t,e,n,r){const{modelCenter:i,rtcCenter:s}=this.Qt(t,e,n,r),o=this.Yt(i);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Kt(i),on(t,(e=>{if(e.attributes&&e.attributes.POSITION){const i=this.qt(e,t);if(i){const t=e.attributes.POSITION.array.length;(!Dr||Dr.length<t)&&(Dr=new Float32Array(t))}e.attributes.NORMAL&&this.Wt(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.Wt(e.attributes.TANGENT,e.matrices,n);const{newPositions:o}=this.Zt(e.attributes.POSITION,e.matrices,s,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,i),{componentType:a}=e.attributes.POSITION;5126!==a&&(e.attributes.POSITION.array=new Float32Array(o))}}));for(const e in t.nodes){t.nodes[e].matrix=Ir}}Yt(t){const e=this.options.projection;"identity"===e?bt(Fr,t):0===_t(t)?pt(Fr,0,0,-6378137):xe(Fr,t),Ln(Nr,Fr,e);const n=Fr[2],r=[];return r[0]=Nr[0],r[1]=Nr[1],r[2]=n,r}Wt(t,e,n){let r;r="Y"===n?Ar:"X"===n?Tr:Ir;const i=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(Vr(i,e),ht(i,Ir))return;const s=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}([],i),o=[];yn(t,(t=>(function(t,e,n){var r=e[0],i=e[1],s=e[2];t[0]=r*n[0]+i*n[3]+s*n[6],t[1]=r*n[1]+i*n[4]+s*n[7],t[2]=r*n[2]+i*n[5]+s*n[8]}(o,t,s),wt(o,o),bt(t,o),o)))}Zt(t,e,n,r,i,s,o,a){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const c=ft([]);Vr(c,e);const u=this.options.projection;i=i&&i.toUpperCase();const f=n;let l=null;"Y"===i?l=Ar:"X"===i&&(l=Tr);let h=[0,0,0,1];const d=[0,0,0],y=[0,0],m=r.projCenter,b=Ln([],r.rtcCoord,"EPSG:3857"),p=s&&ht(Ir,s),g=t.min=t.min||[],w=t.max=t.max||[];pt(g,1/0,1/0,1/0),pt(w,-1/0,-1/0,-1/0);const v=o||{},{decode_position_min:M,decode_position_normConstant:A}=v;let T=[0,0,0,0],_=1;M&&(T=M),A&&(_=A);const k=[];return yn(t,((e,n)=>{if(h[0]=e[0]*_+T[0],h[1]=e[1]*_+T[1],h[2]=e[2]*_+T[2],h=Mt(h,h,c),l&&(h=Mt(h,h,l)),f&&gt(h,h,f),s&&!p&&(h=Mt(h,h,s)),0===_t(h)?pt(d,0,0,-6378137):xe(d,h),a){const t=Dr;Ln(y,d,u),t[3*n]=y[0]-b[0],t[3*n+1]=y[0]-b[1],t[3*n+2]=y[0]-b[2]}if(Ln(y,d,u),e instanceof Float32Array)e[0]=y[0]-m[0],e[1]=y[1]-m[1],e[2]=d[2]-m[2];else{const n=y[0]-m[0],r=y[1]-m[1],i=d[2]-m[2];5126!==t.componentType&&(k.push(n),k.push(r),k.push(i),k.push(e[3]))}return e[0]<g[0]&&(g[0]=e[0]),e[1]<g[1]&&(g[1]=e[1]),e[2]<g[2]&&(g[2]=e[2]),e[0]>w[0]&&(w[0]=e[0]),e[1]>w[1]&&(w[1]=e[1]),e[2]>w[2]&&(w[2]=e[2]),e})),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:m,newPositions:k}}Kt(t){return 0===_t(t)?pt([],0,0,-6378137):xe([],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;return!t.attributes.TANGENT}}const Lr=[];function jr(t,e,n,r,i,s){const o=s||{},{decode_position_min:a,decode_position_normConstant:c}=o;let u=[0,0,0,0],f=1;a&&(u=a),c&&(f=c);for(let s=0,o=t.length;s<o;s+=e){const{xmin:o,ymin:a,xmax:c,ymax:l,hmin:h,hmax:d}=i;pt(Lr,t[s]*f+u[0],t[s+1]*f+u[1],t[s+2]*f+u[2]),Mt(Lr,Lr,r);const y=gt(Lr,n,Lr);y[0]<o&&(i.xmin=y[0]),y[0]>c&&(i.xmax=y[0]),y[1]<a&&(i.ymin=y[1]),y[1]>l&&(i.ymax=y[1]),e>2&&(y[2]<h&&(i.hmin=y[2]),y[2]>d&&(i.hmax=y[2]))}}function zr(t){const{xmax:e,ymax:n,xmin:r,ymin:i,hmin:s,hmax:o}=t,a=[(r+e)/2,(i+n)/2,(s+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 qr(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function Vr(t,e){const n=t;for(let t=e.length-1;t>=0;t--)lt(n,e[t],n);return n}function Gr(t,e,n,r,i){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let s,o;if(n&&r&&1===e)s=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);s=e,o=n}return!function(t,e,n,r){for(let i=0;i<t.length;i++){const s=$r(Xr(t[i],e,n),e,n);if(Math.abs(s-t[i])>Br[r])return!1}return!0}(t,s,o,i)&&Br[i]?null:function(t,e,n){const r=new Int16Array(t.length);for(let i=0;i<t.length;i++)r[i]=Xr(t[i],e,n);return{array:r,range:[e,n]}}(t,s,o)}function $r(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function Xr(t,e,n){const r=2*(t-e)/(n-e)-1,i=Math.max(-1,Math.min(1,r));return i<0?32768*i:32767*i}function Hr(t){return void 0===t.compressGeometry||t.compressGeometry}let Jr=0;class Kr{constructor(t){this.workerId=t,this.workers={},this.te={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},i){if(this.ee(e,n))return;const s=this.ne(e,n),o=r.options;this.workers[s]=new Rr(n,o,((...e)=>this.send.call(this,t,...e)),i)}removeLayer({mapId:t,layerId:e},n){const r=this.ee(t,e),i=this.ne(t,e);delete this.workers[i],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const i=this.ee(t,e);i&&i.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const i=this.ee(t,e);i&&i.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.te[e];delete this.te[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,i){const s=i?\`${o}t}-${o}Jr++}\`:null;i&&(this.te[s]=i),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(s)},r||[])}ne(t,e){return\`${o}t}-${o}e}\`}ee(t,e){const n=this.ne(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new Kr(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)}))}}`
6
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maptalks"),require("@maptalks/gl")):"function"==typeof define&&define.amd?define(["exports","maptalks","@maptalks/gl"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).maptalks=t.maptalks||{},t.maptalks,t.maptalksgl)}(this,(function(t,e,n){"use strict";function r(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var s=r(e),i=r(n);const o="${",a=`function(t){\n/*!\n * @maptalks/gltf-loader v0.98.4\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.org\n */\nvar e="undefined"!=typeof Float32Array?Float32Array:Array;function n(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],f=e[7],l=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],A=n[3];return t[0]=w*r+v*a+M*l+A*m,t[1]=w*i+v*c+M*h+A*b,t[2]=w*s+v*u+M*d+A*p,t[3]=w*o+v*f+M*y+A*g,w=n[4],v=n[5],M=n[6],A=n[7],t[4]=w*r+v*a+M*l+A*m,t[5]=w*i+v*c+M*h+A*b,t[6]=w*s+v*u+M*d+A*p,t[7]=w*o+v*f+M*y+A*g,w=n[8],v=n[9],M=n[10],A=n[11],t[8]=w*r+v*a+M*l+A*m,t[9]=w*i+v*c+M*h+A*b,t[10]=w*s+v*u+M*d+A*p,t[11]=w*o+v*f+M*y+A*g,w=n[12],v=n[13],M=n[14],A=n[15],t[12]=w*r+v*a+M*l+A*m,t[13]=w*i+v*c+M*h+A*b,t[14]=w*s+v*u+M*d+A*p,t[15]=w*o+v*f+M*y+A*g,t}function r(){var t=new e(3);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function i(t,n,r){var i=new e(3);return i[0]=t,i[1]=n,i[2]=r,i}function s(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function o(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function a(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function c(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function u(t,e,n,r,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=i,t}function f(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3];return t[0]=n[0]*r+n[4]*i+n[8]*s+n[12]*o,t[1]=n[1]*r+n[5]*i+n[9]*s+n[13]*o,t[2]=n[2]*r+n[6]*i+n[10]*s+n[14]*o,t[3]=n[3]*r+n[7]*i+n[11]*s+n[15]*o,t}function l(){var t=new e(4);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),r(),function(){var t;t=new e(4),e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var h,d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};r(),i(1,0,0),i(0,1,0),l(),l(),h=new e(9),e!=Float32Array&&(h[1]=0,h[2]=0,h[3]=0,h[5]=0,h[6]=0,h[7]=0),h[0]=1,h[4]=1,h[8]=1;let y=0;function m(t){return null==t}function b(t){return!m(t)}function p(t){return!m(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function g(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 w(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 v(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function M(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 A=[],T=[],_=[],k=[0,0,0],O=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),x=[1,1,1];function S(t,e,n,r,i,s,o){const a=w(o),c=a.BYTES_PER_ELEMENT;if((0===i||i===r*c)&&s%c==0){const i=new a(e,s,n*r);return t.set(i),t}0===i&&(i=r*c);const u=new Uint8Array(r*c);for(let o=0;o<n;o++){let n=null;const f=new Uint8Array(e,i*o+s,r*c);u.set(f),n=new a(u.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const I="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function E(t,e,n){const r=new Uint8Array(t,e,n);return I.decode(r)}const C={get:function(t,e={},n){e||(e={});const r=new AbortController,i=r.signal,s=g({},e);s.signal=i,s.method||(s.method="GET"),s.referrerPolicy=s.referrerPolicy||"origin","undefined"==typeof window||s.referrer||(s.referrer=window.location.href),n&&(t=n(t));const o=fetch(t,s).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(${o}t.status}): ${o}t.statusText}\`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={},n)=>(e||(e={}),e.responseType="arraybuffer",C.get(t,e,n)),getJSON:function(t,e={},n){return e&&e.jsonp?C.jsonp(t):((e=e||{}).responseType="json",C.get(t,e,n))},jsonp:function(t){const e="_maptalks_jsonp_"+y++;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 U{constructor(t,e,n,r,i){this.i=t,this.decoders=e,this.o=n,this.images={},this.u={},this.h=r||{},this.m=i}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],i=this.p(e,r);return this.getImageByBuffer(i,n)}if(this.u[t.id])return this.u[t.id].then((()=>{const r=this.buffers[t.id],i=this.p(e,r);return this.getImageByBuffer(i,n)}));if(v(t.uri)){const r=this.buffers[t.id]=M(t.uri),i=this.p(e,r);return this.getImageByBuffer(i,n)}let r;const i=t.uri.indexOf("blob:")>=0;return r=t.uri.indexOf("://")>0||i?t.uri:this.rootPath+"/"+t.uri,this.u[t.id]=C.getArrayBuffer(r,this.h,this.m).then((r=>{const i=this.buffers[t.id]=r.data,s=this.p(e,i);return this.getImageByBuffer(s,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 i=e;this.m&&(i=this.m(e)),this.i(i,this.h,((i,s)=>{i?r(i):(URL.revokeObjectURL(e),this.images[t]=s,n(this.images[t]))}))}))}}const F=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],N=[];class P{constructor(t,e,n,r,i){this.rootPath=t,this.gltf=e,this.M=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.A(),this.h=r,this.m=i}T(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 i=n.bufferViews[r.bufferView];return this.k(i).then((n=>{const{buffer:i,byteOffset:s}=n;return this.accessors[r.id]=this._(t,e,i,s)}))}k(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(v(e.uri)){const t=this.buffers[e.id]=M(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]=C.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 i=this.gltf,s=i.accessors[e],o=void 0!==s.bufferView?i.bufferViews[s.bufferView]:{},a=(o.byteOffset||0)+r,c=this.O(s.type),u=w(s.componentType),l=o.byteStride||0,h={array:void 0,name:t,accessorName:e,byteLength:s.count*c*u.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:c,max:s.max,min:s.min,extensions:s.extensions};if(s.min&&(h.min=s.min),s.max&&(h.max=s.max),n)if(this.M)h.byteStride=l,h.byteOffset=a+(s.byteOffset||0),!l||l===c*u.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(h.array=this.S(n,s.count,c,a+(s.byteOffset||0),u),h.array.buffer.byteLength===h.byteLength&&(h.byteOffset=0)):h.array=new Uint8Array(n,a,o.byteLength);else if(s.interleaved){h.byteStride=0,h.byteOffset=0;const t=new u(s.count*c);if(h.array=S(t,n,s.count,c,l,a+(s.byteOffset||0),s.componentType),h.extensions&&h.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(h.array.length),{decodeMatrix:e}=h.extensions.WEB3D_quantized_attributes;for(let n=0;n<h.array.length;n+=c){N[0]=h.array[n],N[1]=h.array[n+1],N[2]=h.array[n+2],N[3]=1;const r=f(N,N,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}h.componentType=5126,h.array=t}}else h.byteStride=0,h.array=this.S(n,s.count,c,a+(s.byteOffset||0),u),h.byteOffset=h.array.byteOffset;else{h.array=new u(s.count);const t=h.min||h.max;t&&(h.array[0]=t[0],h.array[1]=t[1],h.array[2]=t[2])}return h}A(){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,i){return r%i.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*i.BYTES_PER_ELEMENT),r=0),new i(t,r,n*e)}O(t){const e=F.indexOf(t);return F[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.k(e).then((r=>{const{buffer:i,byteOffset:s}=r,o=E(i,s+(e.byteOffset||0),n);return t.content=o,t}))}if(t.uri){if(v(t.uri)){const e=M(t.uri),n=E(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return C.get(e,this.h,this.m).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(n).then((()=>t))}}class B extends U{constructor(t,e,n,r,i,s,o,a){super(r,i,s,o,a),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new P(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(b(t.name)&&(e.name=t.name),b(t.children)&&(e.children=t.children),b(t.jointName)&&(e.jointName=t.jointName),b(t.matrix)&&(e.matrix=t.matrix),b(t.rotation)&&(e.rotation=t.rotation),b(t.scale)&&(e.scale=t.scale),b(t.translation)&&(e.translation=t.translation),b(t.extras)&&(e.extras=t.extras),b(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 r=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}(A,e.translation||k),i=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,u=n*o,f=r*o,l=r*a,h=i*o,d=i*a,y=i*c,m=s*o,b=s*a,p=s*c;return t[0]=1-l-y,t[1]=f+p,t[2]=h-b,t[3]=0,t[4]=f-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-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(T,e.rotation||O),s=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}(_,e.scale||x);return n(s,i,s),n(t,r,s)}return function(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}(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 i,s;r.instanceTechnique&&r.instanceTechnique.values?(i=r.instanceTechnique,s=i.values.diffuse):(i=r,s=i.values.tex||i.values.diffuseTex||i.values.diffuse);const o={baseColorTexture:{index:s}};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,i=n.byteLength,s=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,i);return this.getImageByBuffer(s,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 i=this.gltf.textures[r];if(!i)return null;const s=this.gltf.samplers[i.sampler];return{format:i.format||6408,internalFormat:i.internalFormat||6408,type:i.type||5121,sampler:s,source:this.gltf.images[i.source]}}getMaterial(){return null}getAnimations(){return null}}const D=9729;class R extends U{constructor(t,e,n,r,i,s,o,a){super(r,i,s,o,a),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new P(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 g(e,t),!b(t.weights)&&this.gltf.meshes&&b(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),!b(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}};g(n,e);const i=b(e.sampler)?this.gltf.samplers[e.sampler]:void 0;if(i&&(n.sampler=i,n.sampler.magFilter=i.magFilter||D,n.sampler.minFilter=i.minFilter||9987,n.sampler.wrapS=i.wrapS||10497,n.sampler.wrapT=i.wrapT||10497),"image/ktx2"===n.image.mimeType&&!n.image.mipmap&&n.sampler&&n.sampler.minFilter!==D&&9728!==n.sampler.minFilter){const t=n.sampler.minFilter;n.sampler.minFilter=9984===t||9986===t?9728:D}return t.format&&(n.format=t.format),n}))}C(t){if(!b(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,i=t.byteLength;return new Uint8Array(e,r,i)}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++)(b(t[n].input)||b(t[n].output))&&(e.push(this.accessor.T("input",t[n].input)),e.push(this.accessor.T("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 L="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class j{static read(t,e=0,n=0){n||(n=t.byteLength);const r=new DataView(t,e,n),i=r.getUint32(4,!0);if(1===i)return j.readV1(r,e);if(2===i)return j.readV2(t,e);throw new Error("Unsupported glb version : "+i)}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 i=z(t.buffer,20+e,r);return{json:JSON.parse(i),glbBuffer:{byteOffset:20+e+r,buffer:t.buffer,byteLength:n}}}static readV2(t,e){let n,r,i;const s=new DataView(t,e+12);let o=0;for(;o+8<s.byteLength;){const a=s.getUint32(o,!0);o+=4;const c=s.getUint32(o,!0);if(o+=4,1313821514===c)n=z(t,e+12+o,a);else if(5130562===c){i=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:i,buffer:t,byteLength:r}}}}function z(t,e,n){if(L){const r=new Uint8Array(t,e,n);return L.decode(r)}return function(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=q[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}(new Uint8Array(t,e,n))}const q=[1,1,1,1,2,2,3,0],V=[0,0,0],G=[0,0,0,1],$=[1,1,1],X={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},H={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},J={P(t,e,n,r,i,o,a,c){const u=b(t)?e.animations:[e.animations[0]],f={};for(let e=0;e<u.length;e++){const l=u[e],h=l.name||e;if(b(t)&&h!==t)continue;const y=l.channelsMap[n];if(y)for(let t=0;t<y.length;t++){const e=y[t];"translation"===e.target.path?(this.B(i,l.samplers[e.sampler],r,1),f.translation=s(V,i)):"rotation"===e.target.path?(this.D(o,l.samplers[e.sampler],r,1),f.rotation=d(G,o)):"scale"===e.target.path?(this.B(a,l.samplers[e.sampler],r,1),f.scale=s($,a)):"weights"===e.target.path&&c&&(this.B(c,l.samplers[e.sampler],r,c.length),f.weights=c)}}return f},B(t,e,n,r){switch(e.interpolation){case"LINEAR":{const i=this.R(H,e,n,1*r);i&&(t=function(t,e,n,r){for(let i=0;i<t.length;i++)t[i]=e[i]+r*(n[i]-e[i]);return t}(t,i.PREVIOUS,i.NEXT,i.INTERPOLATION));break}case"STEP":{const i=this.R(H,e,n,1*r);i&&(t=function(t,e){for(let n=0;n<t.length;n++)t[n]=e[n];return t}(t,...i.PREVIOUS));break}case"CUBICSPLINE":{const i=this.R(H,e,n,3*r);i&&(t=this.L(t,i,e.input.array,3*r));break}}return t},D(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.R(H,e,n,1);r&&function(t,e,n,r){var i,s,o,a,c,u=e[0],f=e[1],l=e[2],h=e[3],d=n[0],y=n[1],m=n[2],b=n[3];(s=u*d+f*y+l*m+h*b)<0&&(s=-s,d=-d,y=-y,m=-m,b=-b),1-s>1e-6?(i=Math.acos(s),o=Math.sin(i),a=Math.sin((1-r)*i)/o,c=Math.sin(r*i)/o):(a=1-r,c=r),t[0]=a*u+c*d,t[1]=a*f+c*y,t[2]=a*l+c*m,t[3]=a*h+c*b}(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.R(H,e,n,1);r&&(t=u(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.R(H,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,i,s,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,i=c+1,s=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:i,interpolation:s}}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 i=e.input.array,s=e.output.array,o=e.output.itemSize;(n<i[0]||n>i[i.length-1])&&(n=Math.max(i[0],Math.min(i[i.length-1],n))),n===i[i.length-1]&&(n=i[0]);const a=this.j(i,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:u,interpolation:f}=a;t.PREINDEX=c,t.NEXTINDEX=u,t.INTERPOLATION=f;const l=o*r;return t.PREVIOUS=s.subarray(t.PREINDEX*l,(t.PREINDEX+1)*l),t.NEXT=s.subarray(t.NEXTINDEX*l,(t.NEXTINDEX+1)*l),t},L(t,e,n,r){const i=e.INTERPOLATION,s=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-s)*e.PREVIOUS[2*r+n],u=e.NEXT[3+n],f=(o-s)*e.NEXT[n],l=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*a+(Math.pow(i,3)-2*Math.pow(i,2)+i)*c+(2*-Math.pow(i,3)+3*Math.pow(i,2))*u+(Math.pow(i,3)-Math.pow(i,2))*f;t[n]=l}return t},getAnimationClip(t,e,n,r){const i=t.nodes[e]&&t.nodes[e].weights;return o(V,...X.TRANSLATION),u(G,...X.ROTATION),o($,...X.SCALE),this.P(r,t,e,n,V,G,$,i)},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,i=1/0;const s=e.channels;for(let t=0;t<s.length;t++){const n=s[t],o=e.samplers[n.sampler].input.array;o[o.length-1]>r&&(r=o[o.length-1]),o[0]<i&&(i=o[0])}const o=e.name||n;t.timeSpan[o]={max:r,min:i}})),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?b(e)?n[e]:n[Object.keys(n)[0]]:null}};let K=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Je){}t&&"undefined"!=typeof createImageBitmap&&(K=!0)}const Y="undefined"==typeof document?null:document.createElement("canvas");class Q{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}=j.read(e.buffer,e.byteOffset,e.byteLength);this.q(t,n,r)}else this.q(t,e);this.V=new P(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(),i=this.$();return Promise.all([e,n,r,i]).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 J.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return J.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return w(t)}static readInterleavedArray(t,e,n,r,i,s,o){return S(t,e,n,r,i,s,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=K?it.bind(this):this.options.requestImage||W,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new R(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 B(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)||p(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,i,s)=>{const o={};i.name&&(o.name=i.name),i.nodes&&(o.nodes=i.nodes.map((e=>t[e]))),this.gltf.scene===r&&(n=s),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.T("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 b(t)?this.adapter.getAnimations(t):null}W(t){this.meshes={};let e=[];return this.adapter.iterate(((n,r,i)=>{e.push(this.et(r,t).then((t=>{t.index=i,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 g(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=[],i=t.extensions;if(b(t.targets))for(let e=0;e<t.targets.length;e++){const n=t.targets[e];for(const t in n){const i=this.adapter.accessor.T(\`morphTargets_${o}t}_${o}e}\`,n[t]);i&&r.push(i)}}if(i&&i.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:s,attributes:o}=i.KHR_draco_mesh_compression,a=this.gltf.bufferViews[s],c=this.V.k(a).then((n=>{const{buffer:r,byteOffset:i}=n;let{byteOffset:s}=a;const c=a.byteLength;s||(s=0);const u=new DataView(r,i+s,c),f={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(u,f).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.T(t,e[t]);n&&r.push(n)}if(b(t.indices)){const e=this.adapter.accessor.T("indices",t.indices);e&&r.push(e)}n=Promise.all(r)}return n.then((e=>{if(i&&i.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 s={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:i}=e,s=i.length/r;for(let e=0;e<s;e++)for(let s=0;s<r;s++){const o=e*r+s;i[o]<t[s]&&(t[s]=i[o]),i[o]>n[s]&&(n[s]=i[o])}if(e.quantization){const r=e.quantization,i=r.range/(1<<r.quantizationBits),s=r.minValues;c(t,t,i),a(t,t,s),c(n,n,i),a(n,n,s)}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&&(s.indices=n),r&&(s.morphTargets=r),s.mode=b(t.mode)?t.mode:4,b(t.extras)&&(s.extras=t.extras),s}))}}function W(t,e,n){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!Y)return void n(new Error("There is no canvas to draw image!"));Y.width=r.width,Y.height=r.height;const t=Y.getContext("2d",{willReadFrequently:!0});t.drawImage(r,0,0,r.width,r.height);const e=t.getImageData(0,0,r.width,r.height),i={width:r.width,height:r.height,data:new Uint8Array(e.data)};n(null,i)},r.onerror=function(t){n(t)},r.src=t}const Z=[],tt=[],et=30;let nt,rt;function it(t,e,n){nt||(nt=new OffscreenCanvas(2,2),rt=nt.getContext("2d",{willReadFrequently:!0}));let r=null;if(p(t))this.options.urlModifier&&(t=this.options.urlModifier(t)),Z.push([t,e,n,this]),st();else{const e=new Blob([t]);r=createImageBitmap(e),r.then(ot.bind(this)).then((t=>{n(null,t)})).catch((t=>{console.warn(t),n(t)}))}}function st(){if(!Z.length||tt.length>et)return;const t=Z.shift(),[e,n,r,i]=t;tt.push(t),fetch(e,n).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then(ot.bind(i)).then((e=>{r.call(i,null,e);const n=tt.indexOf(t);tt.splice(n,1),st()})).catch((e=>{console.warn(e),r.call(i,e);const n=tt.indexOf(t);tt.splice(n,1),st()}))}function ot(t){let{width:e,height:n}=t;at(e)||(e=ct(e)),at(n)||(n=ct(n));const r=this.options.maxTextureSize;r&&(e=Math.min(r,e),n=Math.min(r,n)),nt.width=e,nt.height=n,rt.drawImage(t,0,0,e,n),t.close();const i=rt.getImageData(0,0,e,n);return{width:e,height:n,data:new Uint8Array(i.data)}}function at(t){return!(t&t-1)&&0!==t}function ct(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var ut="undefined"!=typeof Float32Array?Float32Array:Array;function ft(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 lt(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],u=e[6],f=e[7],l=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],A=n[3];return t[0]=w*r+v*a+M*l+A*m,t[1]=w*i+v*c+M*h+A*b,t[2]=w*s+v*u+M*d+A*p,t[3]=w*o+v*f+M*y+A*g,w=n[4],v=n[5],M=n[6],A=n[7],t[4]=w*r+v*a+M*l+A*m,t[5]=w*i+v*c+M*h+A*b,t[6]=w*s+v*u+M*d+A*p,t[7]=w*o+v*f+M*y+A*g,w=n[8],v=n[9],M=n[10],A=n[11],t[8]=w*r+v*a+M*l+A*m,t[9]=w*i+v*c+M*h+A*b,t[10]=w*s+v*u+M*d+A*p,t[11]=w*o+v*f+M*y+A*g,w=n[12],v=n[13],M=n[14],A=n[15],t[12]=w*r+v*a+M*l+A*m,t[13]=w*i+v*c+M*h+A*b,t[14]=w*s+v*u+M*d+A*p,t[15]=w*o+v*f+M*y+A*g,t}function ht(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 dt(){var t=new ut(3);return ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function yt(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function mt(t,e,n){var r=new ut(3);return r[0]=t,r[1]=e,r[2]=n,r}function bt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function pt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function gt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function wt(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function vt(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function Mt(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[3]*r+n[7]*i+n[11]*s+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*i+n[8]*s+n[12])/o,t[1]=(n[1]*r+n[5]*i+n[9]*s+n[13])/o,t[2]=(n[2]*r+n[6]*i+n[10]*s+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 At=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},Tt=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},_t=yt;function kt(){var t=new ut(4);return ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}dt(),function(){var t,e=(t=new ut(4),ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var Ot;function xt(t){return t&&t.rt&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}dt(),mt(1,0,0),mt(0,1,0),kt(),kt(),Ot=new ut(9),ut!=Float32Array&&(Ot[1]=0,Ot[2]=0,Ot[3]=0,Ot[5]=0,Ot[6]=0,Ot[7]=0),Ot[0]=1,Ot[4]=1,Ot[8]=1;var St={exports:{}},It={exports:{}},Et=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))},Ct=Array.prototype.concat,Ut=Array.prototype.slice,Ft=It.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];Et(i)?e=Ct.call(e,Ut.call(i)):e.push(i)}return e};Ft.wrap=function(t){return function(){return t(Ft(arguments))}};var Nt=It.exports,Pt={"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]},Bt=Nt,Dt=Object.hasOwnProperty,Rt=Object.create(null);for(var Lt in Pt)Dt.call(Pt,Lt)&&(Rt[Pt[Lt]]=Lt);var jt=St.exports={to:{},get:{}};function zt(t,e,n){return Math.min(Math.max(e,t),n)}function qt(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}jt.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=jt.get.hsl(t),n="hsl";break;case"hwb":e=jt.get.hwb(t),n="hwb";break;default:e=jt.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},jt.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]:Dt.call(Pt,e[1])?((i=Pt[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]=zt(i[n],0,255);return i[3]=zt(i[3],0,1),i},jt.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,zt(parseFloat(e[2]),0,100),zt(parseFloat(e[3]),0,100),zt(isNaN(n)?1:n,0,1)]}return null},jt.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,zt(parseFloat(e[2]),0,100),zt(parseFloat(e[3]),0,100),zt(isNaN(n)?1:n,0,1)]}return null},jt.to.hex=function(){var t=Bt(arguments);return"#"+qt(t[0])+qt(t[1])+qt(t[2])+(t[3]<1?qt(Math.round(255*t[3])):"")},jt.to.rgb=function(){var t=Bt(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]+")"},jt.to.rgb.percent=function(){var t=Bt(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]+")"},jt.to.hsl=function(){var t=Bt(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},jt.to.hwb=function(){var t=Bt(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},jt.to.keyword=function(t){return Rt[t.slice(0,3)]};var Vt=St.exports,Gt={exports:{}},$t={"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]},Xt={};for(var Ht in $t)$t.hasOwnProperty(Ht)&&(Xt[$t[Ht]]=Ht);var Jt=Gt.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 Kt in Jt)if(Jt.hasOwnProperty(Kt)){if(!("channels"in Jt[Kt]))throw new Error("missing channels property: "+Kt);if(!("labels"in Jt[Kt]))throw new Error("missing channel labels property: "+Kt);if(Jt[Kt].labels.length!==Jt[Kt].channels)throw new Error("channel and label counts mismatch: "+Kt);var Yt=Jt[Kt].channels,Qt=Jt[Kt].labels;delete Jt[Kt].channels,delete Jt[Kt].labels,Object.defineProperty(Jt[Kt],"channels",{value:Yt}),Object.defineProperty(Jt[Kt],"labels",{value:Qt})}function Wt(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}Jt.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]},Jt.rgb.hsv=function(t){var e,n,r,i,s,o=t[0]/255,a=t[1]/255,c=t[2]/255,u=Math.max(o,a,c),f=u-Math.min(o,a,c),l=function(t){return(u-t)/6/f+.5};return 0===f?i=s=0:(s=f/u,e=l(o),n=l(a),r=l(c),o===u?i=r-n:a===u?i=1/3+e-r:c===u&&(i=2/3+n-e),i<0?i+=1:i>1&&(i-=1)),[360*i,100*s,100*u]},Jt.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[Jt.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)))]},Jt.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]},Jt.rgb.keyword=function(t){var e=Xt[t];if(e)return e;var n,r=1/0;for(var i in $t)if($t.hasOwnProperty(i)){var s=Wt(t,$t[i]);s<r&&(r=s,n=i)}return n},Jt.keyword.rgb=function(t){return $t[t]},Jt.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)]},Jt.rgb.lab=function(t){var e=Jt.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))]},Jt.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 u=0;u<3;u++)(r=o+1/3*-(u-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[u]=255*s;return i},Jt.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)]},Jt.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]}},Jt.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)]},Jt.hwb.rgb=function(t){var e,n,r,i,s,o,a,c=t[0]/360,u=t[1]/100,f=t[2]/100,l=u+f;switch(l>1&&(u/=l,f/=l),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),i=u+r*((n=1-f)-u),e){default:case 6:case 0:s=n,o=i,a=u;break;case 1:s=i,o=n,a=u;break;case 2:s=u,o=n,a=i;break;case 3:s=u,o=i,a=n;break;case 4:s=i,o=u,a=n;break;case 5:s=n,o=u,a=i}return[255*s,255*o,255*a]},Jt.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))]},Jt.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))]},Jt.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))]},Jt.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]},Jt.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]},Jt.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)]},Jt.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],i=1 in arguments?arguments[1]:Jt.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},Jt.hsv.ansi16=function(t){return Jt.rgb.ansi16(Jt.hsv.rgb(t),t[2])},Jt.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)},Jt.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]},Jt.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]},Jt.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},Jt.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]},Jt.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)]},Jt.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]},Jt.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]},Jt.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)]},Jt.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]},Jt.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]},Jt.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)]},Jt.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]},Jt.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},Jt.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},Jt.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},Jt.gray.hsl=Jt.gray.hsv=function(t){return[0,0,t[0]]},Jt.gray.hwb=function(t){return[0,100,t[0]]},Jt.gray.cmyk=function(t){return[0,0,0,t[0]]},Jt.gray.lab=function(t){return[t[0],0,0]},Jt.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},Jt.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var Zt=Gt.exports,te=Zt;function ee(t){var e=function(){for(var t={},e=Object.keys(te),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(te[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 ne(t,e){return function(n){return e(t(n))}}function re(t,e){for(var n=[e[t].parent,t],r=te[e[t].parent][t],i=e[t].parent;e[i].parent;)n.unshift(e[i].parent),r=ne(te[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}var ie=Zt,se=function(t){for(var e=ee(t),n={},r=Object.keys(e),i=r.length,s=0;s<i;s++){var o=r[s];null!==e[o].parent&&(n[o]=re(o,e))}return n},oe={};Object.keys(ie).forEach((function(t){oe[t]={},Object.defineProperty(oe[t],"channels",{value:ie[t].channels}),Object.defineProperty(oe[t],"labels",{value:ie[t].labels});var e=se(t);Object.keys(e).forEach((function(n){var r=e[n];oe[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),oe[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 ae=Vt,ce=oe,ue=[].slice,fe=["keyword","gray","hex"],le={};Object.keys(ce).forEach((function(t){le[ue.call(ce[t].labels).sort().join("")]=t}));var he={};function de(t,e){if(!(this instanceof de))return new de(t,e);if(e&&e in fe&&(e=null),e&&!(e in ce))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 de)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var i=ae.get(t);if(null===i)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=ce[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=ce[this.model].channels;var s=ue.call(t,0,r);this.color=be(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 le))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=le[a];var c=ce[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=be(u)}if(he[this.model])for(r=ce[this.model].channels,n=0;n<r;n++){var f=he[this.model][n];f&&(this.color[n]=f(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ye(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(he[t]||(he[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 me(t){return function(e){return Math.max(0,Math.min(t,e))}}function be(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function pe(t){return null==t}function ge(t){return"object"==typeof t&&!!t}function we(t){return t/Math.PI*180}de.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in ae.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return ae.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 ae.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=ce[this.model].channels,n=ce[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 de(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 de(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ye("rgb",0,me(255)),green:ye("rgb",1,me(255)),blue:ye("rgb",2,me(255)),hue:ye(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ye("hsl",1,me(100)),lightness:ye("hsl",2,me(100)),saturationv:ye("hsv",1,me(100)),value:ye("hsv",2,me(100)),chroma:ye("hcg",1,me(100)),gray:ye("hcg",2,me(100)),white:ye("hwb",1,me(100)),wblack:ye("hwb",2,me(100)),cyan:ye("cmyk",0,me(100)),magenta:ye("cmyk",1,me(100)),yellow:ye("cmyk",2,me(100)),black:ye("cmyk",3,me(100)),x:ye("xyz",0,me(100)),y:ye("xyz",1,me(100)),z:ye("xyz",2,me(100)),l:ye("lab",0,me(100)),a:ye("lab",1),b:ye("lab",2),keyword:function(t){return arguments.length?new de(t):ce[this.model].keyword(this.color)},hex:function(t){return arguments.length?new de(t):ae.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 de.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 de.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(ce).forEach((function(t){if(-1===fe.indexOf(t)){var e=ce[t].channels;de.prototype[t]=function(){if(this.model===t)return new de(this);if(arguments.length)return new de(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new de((n=ce[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},de[t]=function(n){return"number"==typeof n&&(n=be(ue.call(arguments),e)),new de(n,t)}}}));const ve=[1,1,1,1,2,2,3,0];function Me(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=ve[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}new Array(3),new Array(3);const Ae=[1/6378137,1/6378137,1/6356752.314245179],Te=[1/40680631590769,1/40680631590769,1/40408299984661.445],_e=new Array(3),ke=new Array(3),Oe=new Array(3);function xe(t,e){const n=Te,r=function(t,e,n,r,i){const s=e[0],o=e[1],a=e[2],c=n[0],u=n[1],f=n[2],l=s*s*c*c,h=o*o*u*u,d=a*a*f*f,y=l+h+d,m=Math.sqrt(1/y),b=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(Se,e,m);if(y<i)return isFinite(m)?b:void 0;const p=r[0],g=r[1],w=r[2],v=Ie;v[0]=b[0]*p*2,v[1]=b[1]*g*2,v[2]=b[2]*w*2;let M,A,T,_,k,O,x,S,I,E,C,U=(1-m)*Ce(e)/(.5*Ce(v)),F=0;do{U-=F,T=1/(1+U*p),_=1/(1+U*g),k=1/(1+U*w),O=T*T,x=_*_,S=k*k,I=O*T,E=x*_,C=S*k,M=l*O+h*x+d*S-1,A=l*I*p+h*E*g+d*C*w;F=M/(-2*A)}while(Math.abs(M)>Ee);return t[0]=s*T,t[1]=o*_,t[2]=a*k,t}(_e,e,Ae,n,.1);let i=Tt(ke,r,n);i=function(t,e){const n=e[0],r=e[1],i=e[2];let s=n*n+r*r+i*i;s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s);return t}(i,i);const s=At(Oe,e,r),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=function(t){return Math.sign?Math.sign(t):0==(t=+t)||isNaN(t)?Number(t):t>0?1:-1}(vt(s,e))*Ce(s);return t[0]=we(o),t[1]=we(a),t[2]=c,t}const Se=new Array(3),Ie=new Array(3),Ee=1e-12;function Ce(t){return yt(t)}function Ue(t,e){let n="";for(let r=0;r<4;r++){const i=t.getUint8(e+r);n+=String.fromCharCode(i)}return n}const Fe="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ne(t,e,n){const r=new Uint8Array(t,e,n);return Fe?JSON.parse(Fe.decode(r)):JSON.parse(Me(r))}function Pe(t,e,n){const r=new Uint8Array(t,e,n);return Fe?JSON.parse(Fe.decode(r)):JSON.parse(Me(r))}function Be(t,e,n){return{offset:e,byteLength:n}}function De(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=function(t){return je[t]}(s||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Le[t]}(o);return{byteStride:0,byteOffset:i+n,itemSize:u,count:r*u,componentType:c,array:new a(e,n+i,r*u)}}function Re(t,e,n,r){const i=De(t,e,n,r);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}const Le={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const je={"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 ze(t){for(const e in je)if(t===je[e].ctor)return je[e].type;throw new Error("unrecognized ctor:"+t)}function qe(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 Ve(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,u={},f={},l=null;r>0&&(u=Ne(a,e,r),e+=r),i>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,i),e+=i),s>0&&(f=Pe(a,e,s),e+=s);const h=Be(0,e,o);return l=a.slice(h.offset,h.offset+h.byteLength),n.push(l),{featureTable:u,featureTableBin:c,batchTable:f,batchTableBin:l}}const Ge={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function $e(t){for(const e in Ge)if(t===Ge[e])return+e;throw new Error("unrecognized ctor:"+t)}\n/*!\n * @maptalks/gl v0.102.2\n * LICENSE : UNLICENSED\n * (c) 2016-2024 maptalks.com\n */const Xe=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")},He=Xe(),Je=He.gl_trans__coders=He.gl_trans__coders||{};Je.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),i=He.gl_trans__coders=He.gl_trans__coders||{};let s=\`${o}r}\\n const _____getGlobal = ${o}Xe.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},Je.registerTranscoder=function(t,e){Je[t]=e},Je.getTranscoder=function(t){return Je[t]};let Ke=null;function Ye(){return Ke||(Ke={"image/crn":Je.crn&&Je.crn(),"image/ktx2":Je.ktx2&&Je.ktx2(),"image/cttf":Je.ktx2&&Je.ktx2(),"draco":Je.draco&&Je.draco()}),Ke}class Qe{constructor(t,e,n){this.i=t,this.it=e||Q,this.o=n,this.st=Ye()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,i)):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,n,r)}))}ot(t,e,n,r,i){const s=i&&i.maxTextureSize,o=this.ct(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.it(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.st,supportedFormats:this.o,maxTextureSize:s})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${o}t}-${o}n}-${o}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}}))}ct(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),u=i.getUint32(20,!0),f=i.getUint32(24,!0),l=28+e;u>=570425344?(l-=8,o=a,u=c,f=0,a=0,c=0):f>=570425344&&(l-=4,o=u,u=a,f=c,a=0,c=0);const h=[t];let d,y,m;if(a>0?(d=Ne(t,l,a),l+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(l+=c),u>0&&(y=Pe(t,l,u),l+=u,f>0)){const e=Be(0,l,f);m=t.slice(e.offset,e.offset+e.byteLength),l+=f,h.push(m)}const b=d.BATCH_LENGTH,p={};if(d&&d.BATCH_ID){p.BATCH_ID=Re(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:l,byteLength:i.byteLength+i.byteOffset-l}}}ut(){return null}}class We{constructor(t,e,n,r){this.i=t,this.it=e||Q,this.o=n,this.st=Ye(),this.ft=r}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.ot(t,e,n,r,i)):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,n,r)}))}ot(t,e,n,r,i){return this.lt(t,e,n,r,i).then((({gltf:i,transferables:s})=>{const o=this.ht(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})}))}lt(t,e,n,r,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.st,supportedFormats:this.o,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=Me(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?C.getArrayBuffer(r,{}).then((t=>this.dt(r,{buffer:t.data,byteOffset:0},o))):C.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("/")),i=new this.it(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=\`${o}t}-${o}r}-${o}s}\`,{transferables:i.transferables,gltf:n}}))}ht(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:u,batchTableBin:f}=Ve(i,32+e,o),l={},h=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;l.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(l.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;l.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(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=Re(a.BATCH_ID,t,c.offset,h);const e=l.BATCH_ID.array&&l.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},o.push(l.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;l.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(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,l.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(l.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;l.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},o.push(l.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;l.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(l.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:f,featureTable:a,i3dm:l,transferables:o}}bt(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let i=0;i<e;i++)Ze(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}yt(t,e,n){return qe(new Float32Array(t.length),t,e,n)}ut(){return null}}function Ze(t,e,n,r){if(t[0]=tn(e,r),t[1]=tn(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]))*en(e),t[1]=(1-Math.abs(e))*en(t[1])}return wt(t,t)}function tn(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 en(t){return t<0?-1:1}class nn{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.ot(t,e,n,r)):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.ot(t,i,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 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:u,batchTableBin:f}=Ve(i,e+28,o),l=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=Ye().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,l,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:ze(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?r.BATCH_ID=Re(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=rn(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:f,featureTable:a,pnts:r,transferables:o}}))}const b=this.vt(t,a,c.offset,d,o,l,h);if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?b.BATCH_ID=Re(a.BATCH_ID,t,c.offset,d):b.BATCH_ID=rn(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:f,featureTable:a,pnts:b,transferables:o})}vt(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:u}=e.POSITION_QUANTIZED;c=c||0;const f=u?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.yt(u||new Uint16Array(t,c+f,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}yt(t,e,n){return qe(new Float32Array(t.length),t,e,n)}ut(){return null}}function rn(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:ze(e),array:r}}class sn{constructor(t,e,n,r){this.o=n,this.i=t,this.it=e||Q,this.ft=r}load(t,e,n=0,r=0,i){return e?this.ot(t,e,n,r,i):C.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.ot(t,i,n,r)}))}ot(t,e,n,r,i){r||(r=e.byteLength);const s=this.Mt(e,t,n,r),o=[];for(let n=0;n<s.length;n++){let r;if("b3dm"===s[n].magic)r=new Qe(this.i,this.it,this.o);else if("i3dm"===s[n].magic)r=new We(this.i,this.it,this.o,this.ft);else if("pnts"===s[n].magic)r=new nn;else{if("cmpt"!==s[n].magic){console.warn("Unsupported magic in CMPT tile:",s[n].magic);continue}r=new sn(this.i,this.it,this.o,this.ft)}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})))}Mt(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=Ue(i,c),r=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}function on(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=[];dn(r[n],i,t,e)}}}const an=[],cn=[],un=[],fn=[0,0,0],ln=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),hn=[1,1,1];function dn(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=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}(an,t.translation||fn),n=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,u=n*o,f=r*o,l=r*a,h=i*o,d=i*a,y=i*c,m=s*o,b=s*a,p=s*c;return t[0]=1-l-y,t[1]=f+p,t[2]=h-b,t[3]=0,t[4]=f-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-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(cn,t.rotation||ln),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}(un,t.scale||hn);lt(r,n,r);const s=lt([],e,r);i.push(s)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)dn(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 yn(t,e){let{byteOffset:n,byteStride:r,count:i}=t;const{componentType:s,itemSize:o}=t,a=t.array.buffer,c=s?Q.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 u=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);u.set(i);e(new c(u.buffer),t),i.set(u)}}var mn=vn("DXT1"),bn=vn("DXT3"),pn=vn("DXT5"),gn=vn("DX10"),wn=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 i=r[21];switch(i){case mn:e=8,n="dxt1";break;case bn:e=16,n="dxt3";break;case pn:e=16,n="dxt5";break;case 116:n="rgba32f";break;case gn:var s=new Uint32Array(t.slice(128,148));n=s[0];var o=s[1];if(s[2],s[3],s[4],3!==o||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(a=i,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 f=!1;512&r[28]&&(f=!0);var l,h=r[4],d=r[3],y=r[1]+4,m=h,b=d,p=[];i===gn&&(y+=20);if(f)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++)l=h*d*16,p.push({offset:y,length:l,shape:[h,d]}),v<u&&(y+=l),h=Math.floor(h/2),d=Math.floor(d/2)}else for(v=0;v<u;v++)l=Math.max(4,h)/4*Math.max(4,d)/4*e,p.push({offset:y,length:l,shape:[h,d]}),y+=l,h=Math.floor(h/2),d=Math.floor(d/2);return{shape:[m,b],images:p,format:n,flags:c,cubemap:f}};function vn(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var Mn=xt(wn),An=Math.abs,Tn=Math.sin,_n=Math.cos,kn=Math.tan,On=Math.atan,xn=Math.atan2,Sn=Math.sqrt,In=Math.log,En=Math.hypot,Cn=Math.sinh,Un=Math.cosh,Fn=1/0;function Nn(t){var e,n,r,i,s,o,a=[],c=[],u=[],f=[];function l(t,e){for(var n,r=2*_n(2*e),i=t.length-1,s=t[i],o=0;--i>=0;)n=r*s-o+t[i],o=s,s=n;return e+n*Tn(2*e)}function h(t,e,n){for(var r,i,s=Tn(e),o=_n(e),a=Cn(n),c=Un(n),u=2*o*c,f=-2*s*a,l=t.length-1,h=t[l],d=0,y=0,m=0;--l>=0;)r=y,i=d,h=u*(y=h)-r-f*(d=m)+t[l],m=f*y-i+u*d;return[(u=s*c)*h-(f=o*a)*m,u*m+f*h]}t.es,s=i=(r=t.es/(1+Sn(1-t.es)))/(2-r),a[0]=i*(2+i*(-2/3+i*(i*(116/45+i*(26/45+i*(-2854/675)))-2))),c[0]=i*(i*(2/3+i*(4/3+i*(-82/45+i*(32/45+i*(4642/4725)))))-2),s*=i,a[1]=s*(7/3+i*(i*(-227/45+i*(2704/315+i*(2323/945)))-1.6)),c[1]=s*(5/3+i*(-16/15+i*(-13/9+i*(904/315+i*(-1522/945))))),s*=i,a[2]=s*(56/15+i*(-136/35+i*(-1262/105+i*(73814/2835)))),c[2]=s*(-26/15+i*(34/21+i*(1.6+i*(-12686/2835)))),s*=i,a[3]=s*(4279/630+i*(-332/35+i*(-399572/14175))),c[3]=s*(1237/630+i*(i*(-24832/14175)-2.4)),s*=i,a[4]=s*(4174/315+i*(-144838/6237)),c[4]=s*(-734/315+i*(109598/31185)),s*=i,a[5]=s*(601676/22275),c[5]=s*(444337/155925),s=i*i,e=t.k0/(1+i)*(1+s*(1/4+s*(1/64+s/256))),u[0]=i*(i*(2/3+i*(-37/96+i*(1/360+i*(81/512+i*(-96199/604800)))))-.5),f[0]=i*(.5+i*(-2/3+i*(5/16+i*(41/180+i*(-127/288+i*(7891/37800)))))),u[1]=s*(-1/48+i*(-1/15+i*(437/1440+i*(-46/105+i*(1118711/3870720))))),f[1]=s*(13/48+i*(i*(557/1440+i*(281/630+i*(-1983433/1935360)))-.6)),s*=i,u[2]=s*(-17/480+i*(37/840+i*(209/4480+i*(-5569/90720)))),f[2]=s*(61/240+i*(-103/140+i*(15061/26880+i*(167603/181440)))),s*=i,u[3]=s*(-4397/161280+i*(11/504+i*(830251/7257600))),f[3]=s*(49561/161280+i*(-179/168+i*(6601661/7257600))),s*=i,u[4]=s*(-4583/161280+i*(108847/3991680)),f[4]=s*(34729/80640+i*(-3418889/1995840)),s*=i,u[5]=s*(-20648693/638668800),f[5]=.6650675310896665*s,o=l(c,t.phi0),n=-e*(o+function(t,e){var n,r=2*_n(e),i=t.length-1,s=t[i],o=0;for(;--i>=0;)n=r*s-o+t[i],o=s,s=n;return Tn(e)*n}(f,2*o)),t.fwd=function(t,r){var i,s,o,a,u,d=t.phi,y=t.lam;d=l(c,d),i=Tn(d),s=_n(d),a=Tn(y),o=_n(y),d=xn(i,o*s),y=xn(a*s,En(i,s*o)),y=function(t){var e=An(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*In(e)/n}(e*(1+e/(En(1,e)+1))),t<0?-e:e}(kn(y)),u=h(f,2*d,2*y),d+=u[0],y+=u[1],An(y)<=2.623395162778?(r.y=e*d+n,r.x=e*y):r.x=r.y=Fn},t.inv=function(t,r){var i,s,o,c,f,d=t.y,y=t.x;d=(d-n)/e,An(y/=e)<=2.623395162778?(d+=(f=h(u,2*d,2*y))[0],y+=f[1],y=On(Cn(y)),i=Tn(d),s=_n(d),c=Tn(y),o=_n(y),y=xn(c,o*s),d=xn(i*o,En(c,o*s)),r.phi=l(a,d),r.lam=y):r.phi=r.lam=Fn}}const Pn=Math.PI/180,Bn=6378137*Math.PI/180,Dn=85.0511287798,Rn={};function Ln(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=Dn,r=e[0],i=Math.max(Math.min(n,e[1]),-n);let s;s=0===i?0:Math.log(Math.tan((90+i)*Pn/2))/Pn;return t[0]=r*Bn,t[1]=s*Bn,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return jn(t,e);if("baidu"===n)return jn(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 i=JSON.stringify(n);let s=Rn[i];return s||(s=Rn[i]=function(t){const e={a:qn,es:Vn,x0:pe(t.falseEasting)?5e5:t.falseEasting,y0:pe(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*zn,phi0:(t.latitudeOfOrigin||0)*zn,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Nn(e);const n={lam:0,phi:0},r={};let i=0,s=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*zn-e.lam0,n.phi=e.originPhi0*zn,e.fwd(n,r),i=e.a*r.x+e.x0,s=e.a*r.y+e.y0);return{project:function(t,o){n.lam=t[0]*zn-e.lam0,n.phi=t[1]*zn,e.fwd(n,r);const a=e.a*r.x+e.x0-i,c=e.a*r.y+e.y0-s;return o[0]=a,o[1]=c,o}}}(n)),s.project(e,t)}}function jn(t,e){return t[0]=e[0],t[1]=e[1],t}const zn=.017453292519943295,qn=6378137,Vn=.0066943799901413165;const Gn=ft([]),$n=Ye().draco,Xn=Ye().ktx2,Hn={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},Jn={"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 Kn(t,e,n,r,i,s){const o=[],a=[],c=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],i=C.getArrayBuffer(n.url,s);i.xhr.url=n.url,c.push(i.xhr);const u=i.then((t=>({buffer:t})));o.push(u);const f=[];if(rr(r,f),f.length){const t=f.map((t=>{const e=C.getArrayBuffer(t.url,s);return e.xhr.url=t.url,c.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));o.push(...t)}a[e]=f.length}const u=Promise.all(o).then((s=>{for(let t=0;t<s.length;t++)if(!s[t]||!s[t].buffer)return Promise.resolve(null);const o=[];let c=0;for(let t=0;t<a.length;t++){const e=a[t];o.push({geoBuffer:{data:s[c].buffer.data},textureBuffers:s.slice(c+1,e+c+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),c+=1+e}const u=function(t,e,n,r,i,s){const o={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},a=[];for(let c=0;c<t.meshes.length;c++){let{material:u}=t.meshes[c];const{geometry:f}=t.meshes[c];let l;const h=e[c].geoBuffer.data;if(!h)continue;l=ur(h)?Qn(o,c,f,h,t.transform,t.center,i,s):Zn(o,c,f,h,t.transform,t.center,i,s),a.push(l),o.nodes[c]={mesh:c,nodeIndex:c,matrix:ft([])},o.scenes[0].nodes[c]=o.nodes[c],u||(u=Hn);const d=er(c,o,u,e[c].textureBuffers,n,r);a.push(d)}return Promise.all(a).then((()=>({gltf:o,featureTable:{BATCH_LENGTH:0},transferables:o.transferables})))}(t,o,e,i,n,r);return u}));return u.xhr=c,u}const Yn={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Qn(t,e,n,r,i,s,o,a){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=Jn[e];if(!r)return t;return t[r.name||e]=n,t}),{});return $n(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>tr(n,t,e,i,s,o,a)))}const Wn={position:function(t,e,n){const r=3*t.vertexCount,i=new Float32Array(e,n,r);return t.position={array:i,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,i=new Float32Array(e,n,r);return t.normal={array:i,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,i=new Float32Array(e,n,r);return t.uv0={array:i,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,i=new Uint8Array(e,n,r);return t.color={array:i,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,i=new Uint32Array(e,n,r);return t.faceRange={array:i,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,i=new Uint16Array(e,n,r);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,i=new Uint16Array(e,n,r);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Zn(t,e,n,r,i,s,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++)Wn[n[e]]?t=Wn[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let i=e.ordering,s=e.featureAttributeOrder;const o=null;o&&o.geometryData&&o.geometryData[0]&&o.geometryData[0].params;for(let e=0;e<i.length;e++){const n=Wn[i[e]];n||console.log(i[e]),t=n(c,r,t)}for(let e=0;e<s.length;e++){const n=Wn[s[e]];n||console.log(s[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const f={};for(const t in c){const e=Jn[t]&&Jn[t].name;e&&(f[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(l=e)<=255?Uint8Array:l<=65535?Uint16Array:Uint32Array,r=new n(f.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,i=t[e],s=t[e+1];for(let t=i;t<=s;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}f._BATCHID={componentType:$e(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var l;return tr({attributes:f},t,e,i,s,o,a)}function tr(t,e,n,r,i,s,o){const a={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 c=function(t,e,n,r,i){let s,o=[0,0,0,1];const a=[0,0],c=Ln([],n,r,i);c[2]=n[2];const u=e&&ht(Gn,e);return yn(t,(t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],u||(o=Mt(o,o,e)),n&&gt(o,o,n),Ln(a,o,r,i),s=o[2],t[0]=a[0]-c[0],t[1]=a[1]-c[1],t[2]=s-c[2],t))),c}(t.attributes.POSITION,r,i,s,o);e.meshes[n]={primitives:[a],index:n},e.extensions.MAPTALKS_RTC={projCenter:c},e.extensions.CESIUM_RTC={rtcCoord:i};for(const n in t.attributes)cr(e.transferables,t.attributes[n].array.buffer);return t.indices&&cr(e.transferables,t.indices.array.buffer),a}function er(t,e,n,r,i,s){const o=r.map((t=>function(t,e,n,r,i){if("dds"===e){const e=Mn(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),i="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Yn,format:i})}if("png"===e||"jpg"===e)return function(t,e){ir||(ir=new OffscreenCanvas(2,2),sr=ir.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;or(n)||(n=ar(n)),or(r)||(r=ar(r));const i=e;i&&(n=Math.min(i,n),r=Math.min(i,r)),ir.width=n,ir.height=r,sr.drawImage(t,0,0,n,r),t.close();const s=sr.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(s.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,i).then((t=>{t.mimeType=n;return{image:t,sampler:Yn,format:6408}}));if("ktx2"===e)return Xn(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Yn,format:t.format})));return null}(t.data,t.format,t.mimeType,i,s).then((t=>{if(t.image)if(t.image.array)cr(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)cr(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(o).then((r=>{nr(t,e,n,r)}))}function nr(t,e,n,r){const i=JSON.parse(JSON.stringify(n)),s=e.textures;r.ptr||(r.ptr=0);for(const t in n)n[t]&&n[t].url?(s.push(r[r.ptr++]),i[t]={index:s.length-1},void 0!==n[t].factor&&(i[t].scale=n[t].factor)):ge(n[t])&&(i[t]=nr(-1,e,n[t],r));return t>=0&&(e.materials[t]=i),i}function rr(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}):ge(t[n])&&rr(t[n],e)}let ir,sr;function or(t){return!(t&t-1)&&0!==t}function ar(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function cr(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function ur(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 fr="undefined"!=typeof Float32Array?Float32Array:Array;function lr(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var hr=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 fr(3);return fr!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const dr=[];const yr=[],mr=[],br=[],pr=[],gr=[],wr=[],vr=[];function Mr(t,e,n,r,i,s){lr(pr,t[3*e],t[3*e+1],t[3*e+2]),lr(gr,t[3*n],t[3*n+1],t[3*n+2]),lr(wr,t[3*r],t[3*r+1],t[3*r+2]);const o=hr(yr,wr,gr),a=hr(mr,pr,gr),c=function(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[0],a=n[1],c=n[2];return t[0]=i*c-s*a,t[1]=s*o-r*c,t[2]=r*a-i*o,t}(br,o,a);!function(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;s>0&&(s=1/Math.sqrt(s),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s)}(vr,c),i[3*e]=i[3*e]||0,i[3*n]=i[3*n]||0,i[3*r]=i[3*r]||0,i[3*e+1]=i[3*e+1]||0,i[3*n+1]=i[3*n+1]||0,i[3*r+1]=i[3*r+1]||0,i[3*e+2]=i[3*e+2]||0,i[3*n+2]=i[3*n+2]||0,i[3*r+2]=i[3*r+2]||0,i[3*e]+=vr[0],i[3*n]+=vr[0],i[3*r]+=vr[0],i[3*e+1]+=vr[1],i[3*n+1]+=vr[1],i[3*r+1]+=vr[1],i[3*e+2]+=vr[2],i[3*n+2]+=vr[2],i[3*r+2]+=vr[2],s[e]+=1,s[n]+=1,s[r]+=1}const Ar=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Tr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],_r=2*Math.PI*6378137/360,kr="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let Or,xr,Sr=!1;if("undefined"!=typeof OffscreenCanvas){try{xr=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}xr&&"undefined"!=typeof createImageBitmap&&(Sr=!0)}const Ir=ft([]),Er=[0,0,0],Cr=[],Ur=[],Fr=[],Nr=[],Pr={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Br={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Dr;class Rr{constructor(t,e,n,r){this.id=t,this.options=e,this.At=(...t)=>this.requestImage.call(this,...t),this.Tt=n,this._t={},r(null,{},[])}kt(t){this.Ot||(this.o=t,this.xt=new nn,this.Ot=new Qe(this.At,Q,t),this.St=new We(this.At,Q,t))}requestImage(t,e){Sr?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{Or.width=t.width,Or.height=t.height,xr.drawImage(t,0,0);const n=xr.getImageData(0,0,Or.width,Or.height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.Tt("requestImage",{url:t},null,e)}loadTile(t,e){this.kt(t.supportedFormats);const{service:n,url:r,arraybuffer:i}=t,s=n.fetchOptions||{};if(s.referrer=t.referrer,s.referrerPolicy=s.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const i=t.i3sInfo,o=n.maxTextureSize||0,a=Kn(i,t.supportedFormats,this.options.projection,t.projection,o,s);return a.then((t=>{if(delete this._t[r],!t)return void e({status:404,url:r,i3sInfo:i});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:i});t.gltf.url=r;const{transferables:s}=t;t.magic="b3dm",n.createNormalIfMissed&&this.It(t.gltf),Hr(n)&&this.Et(t.gltf),e(null,t,s)})),void(this._t[r]=a.xhr)}if(i){delete this._t[r];const n=Ue(new DataView(i),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(kr){const r=new Uint8Array(t,e,n);return kr.decode(r)}return Me(new Uint8Array(t,e,n))}(i,0,i.byteLength),s=JSON.parse(n);s.accessors?this.Ct(s,r,t,"gltf",e):this.Ut(t.rootIdx,s,i,r,e)}else this.Ct(i,r,t,n,e)}else{let i=n.urlParams;i&&(i=(r.indexOf("?")>0?"&":"?")+i);const o=r.replace(/\\+/g,"%2B");let a=C.getArrayBuffer(o+(i||""),s);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,i){r=r&&r.toLowerCase();const{service:s}=n;if("b3dm"===r){this.Ot.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{if(t.error)return void i(t);const{content:e,transferables:r}=this.Ft(t,n);s.createNormalIfMissed&&this.It(e.gltf),Hr(s)&&this.Et(e.gltf),i(null,e,r)})).catch((t=>{i(t)}))}else if("pnts"===r){const r=n.transform||Ir;this.xt.load(e,t).then((t=>{const{content:e,transferables:s}=this.Nt(t,r,n.rootIdx);this.Pt(e),i(null,e,s)}))}else if("i3dm"===r){const r=n.transform||Ir;this.St.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{const{content:e,transferables:o}=this.Bt(t,r,n.rootIdx);s.createNormalIfMissed&&this.It(e.gltf),Hr(s)&&this.Et(e.gltf),i(null,e,o)}))}else if("cmpt"===r){new sn(this.At,Q,this.o,s.maxTextureSize||0).load(e,t,0,0,{maxTextureSize:s.maxTextureSize||0}).then((t=>{const{content:e,transferables:r}=this.Dt(t,n);this.Rt(e,s),Hr(s)&&this.Lt(e),i(null,e,r)})).catch((t=>{i(t)}))}else if("gltf"===r){this.st||(this.st=Ye());const r=e.substring(0,e.lastIndexOf("/")),o=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t;let a;try{a=new Q(r,o,{transferable:!0,requestImage:this.At,decoders:this.st,supportedFormats:this.o,maxTextureSize:s.maxTextureSize||0})}catch(t){i(t)}a.load({skipAttributeTransform:!1}).then((t=>{t.url=e,this.jt(t,null,n),s.createNormalIfMissed&&this.It(t),Hr(s)&&this.Et(t),i(null,{magic:"gltf",gltf:t},a.transferables)}))}else i(new Error("unsupported tile format: "+r))}Rt(t,e){t.content?t.content.forEach((t=>{this.Rt(t,e)})):e.createNormalIfMissed&&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()?Dr.subarray(0,n):e,i=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const i=dr;i.length<t.length/3&&(i.length=t.length/3),i.fill(0,0,t.length/3);const s=void 0===e.length?e:e.length;for(let n=0;n<s/3;n++)void 0===e.length?Mr(t,3*n,3*n+1,3*n+2,r,i):Mr(t,e[3*n],e[3*n+1],e[3*n+2],r,i);const o=r.getLength?r.getLength():r.length;for(let t=0;t<o;t+=3){const e=i[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:i,byteLength:i.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:i.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(Pr[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=_r,t.compressed_int16_params.compressed_ratio=r);const i=Gr(e[n].array,r,e[n].min,e[n].max,n);if(!i)continue;const{array:s,range:o}=i;e[n].componentType=5124,e[n].array=s,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(Pr[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.Vt()&&"POSITION"===n&&(r=_r,t.compressed_int16_params.compressed_ratio=r);const{array:i,range:s}=Gr(e[n].array,r,e[n].min,e[n].max,n);e[n].array=i,t.compressed_int16_params[n]=s}}Gt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const i={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(i)}return e}Ut(t,e,n,r,i){return e.capabilities,void i(null,e)}Dt(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},i=[];for(let t=0;t<n.length;t++){const{magic:s}=n[t];if("b3dm"===s){const{content:s,transferables:o}=this.Ft(n[t],e);qr(i,o),r.content.push(s)}else if("i3dm"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:c}=this.Bt(n[t],s,o);qr(i,c),r.content.push(a)}else if("pnts"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:c}=this.Nt(n[t],s,o);qr(i,c),r.content.push(a)}else if("cmpt"===s){const{content:s,transferables:o}=this.Dt(n[t],e);qr(i,o),r.content.push(s)}}return{content:r,transferables:i}}Ft(t,e){const{gltf:n,transferables:r,featureTable:i}=t;return this.jt(n,i,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 i in t.meshes){const s=t.meshes[i],{primitives:o}=s;if(o)for(let t=0;t<o.length;t++){const i=o[t].attributes&&o[t].attributes.POSITION;if(!i||!i.array)continue;i.array.buffer[e]||(i.array.buffer[e]=n++);const s=n-1+"-"+(i.byteOffset||0);if(r.indexOf(s)>=0)return!0;r.push(s)}}return!1}(t);this.$t(t);n.service.createNormalIfMissed||this.Xt(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.Ht(t,e,n.upAxis,n.transform)):this.Jt(t,e,n.upAxis,n.transform)}Bt(t,e,n){const{featureTable:r}=t,i=t.i3dm,s=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,a=e&&ht(Ir,e),c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};jr(i.POSITION.array,3,s,Ir,c);const u=zr(c);e&&!a&&Mt(u,u,e);const f=this.Kt(u),l=[];Ln(l,f,o),l[2]=f[2];const h=bt([],u),d=[0,0,0],y=[0,0,0],m=[0,0],b=[1/0,1/0,1/0],p=[-1/0,-1/0,-1/0];yn(i.POSITION,(t=>{d[0]=t[0]+s[0],d[1]=t[1]+s[1],d[2]=t[2]+s[2],e&&!a&&Mt(d,d,e),0===_t(d)?pt(y,0,0,-6378137):xe(y,d),Ln(m,y,o),t[0]=m[0]-l[0],t[1]=m[1]-l[1],t[2]=y[2]-l[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[0]>p[0]&&(p[0]=t[0]),t[1]>p[1]&&(p[1]=t[1]),t[2]>p[2]&&(p[2]=t[2])})),i.POSITION.min=b,i.POSITION.max=p,e&&Mt(u,u,e),t.rtcCenter=h,t.rtcCoord=f,t.projCenter=l,t.rootIdx=n;const g=t.transferables;return delete t.transferables,{content:t,transferables:g}}Nt(t,e,n){const{featureTable:r}=t,i=t.pnts,s=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,a=e&&ht(Ir,e),c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};jr(i.POSITION.array,3,s,e,c);const u=zr(c),f=this.Yt(u),l=bt([],u),h=[1/0,1/0,1/0],d=[-1/0,-1/0,-1/0];let y=[0,0,0,1];const m=[0,0,0],b=[0,0];yn(i.POSITION,(t=>(y[0]=t[0]+s[0],y[1]=t[1]+s[1],y[2]=t[2]+s[2],e&&!a&&(y=Mt(y,y,e)),0===_t(y)?pt(m,0,0,-6378137):xe(m,y),Ln(b,m,o),t[0]=b[0]-f[0],t[1]=b[1]-f[1],t[2]=m[2]-f[2],t[0]<h[0]&&(h[0]=t[0]),t[1]<h[1]&&(h[1]=t[1]),t[2]<h[2]&&(h[2]=t[2]),t[0]>d[0]&&(d[0]=t[0]),t[1]>d[1]&&(d[1]=t[1]),t[2]>d[2]&&(d[2]=t[2]),t))),i.POSITION.min=h,i.POSITION.max=d,e&&Mt(u,u,e);const p=this.Kt(u);t.rtcCenter=l,t.projCenter=f,t.rtcCoord=p,t.rootIdx=n;const g=t.transferables;return delete t.transferables,{content:t,transferables:g}}$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],i=n[1],s=n[2],o=n[3];let a=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==i||n[t+2]!==s||n[t+3]!==o){a=!1;break}a&&(e[t].image.color=[r/255,i/255,s/255,o/255],delete e[t].image.array)}}}Xt(t){const e=t.meshes;for(const n in e){const r=e[n];if(!r)continue;const i=r.primitives;if(i)for(let e=0;e<i.length;e++){if(!i[e])continue;if(!i[e].attributes||i[e].attributes.NORMAL)continue;const n=i[e].material;if(!pe(n)){const e=t.materials[n];if(!e)continue;e.extensions||(e.extensions={}),e.extensions.KHR_materials_unlit={}}}}}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)}Qt(t,e,n,r){const i=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let s=Ar;"X"===(n=n&&n.toUpperCase())?s=Tr:"Z"===n&&(s=Ir),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),i&&(t.extensions.CESIUM_RTC.center=i),t.extensions.MAPTALKS_RTC={};const o={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};on(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=ft(Cr);t.matrices&&Vr(e,t.matrices);const n=t.attributes.POSITION.array,a=t.attributes.POSITION.itemSize;lt(e,s,e),r&&lt(e,r,e),jr(n,a,i||Er,e,o,t.compressUniforms)}));const a=zr(o);return{rtcCenter:i,modelCenter:a,upAxisTransform:s}}Ht(t,e,n,r){const{modelCenter:i,upAxisTransform:s,rtcCenter:o}=this.Qt(t,e,n),a=this.Yt(i);t.extensions.MAPTALKS_RTC.projCenter=a,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Kt(i);const c=bt([],i);r&&Mt(i,i,r),t.extensions.CESIUM_RTC.rtcCoord=this.Kt(i),o||(on(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=ft(Cr);t.matrices&&Vr(n,t.matrices),lt(n,s,n);const r=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],u=e[7],f=e[8],l=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-i*o,v=n*u-s*o,M=r*c-i*a,A=r*u-s*a,T=i*u-s*c,_=f*m-l*y,k=f*b-h*y,O=f*p-d*y,x=l*b-h*m,S=l*p-d*m,I=h*p-d*b,E=g*I-w*S+v*x+M*O-A*k+T*_;return E?(E=1/E,t[0]=(a*I-c*S+u*x)*E,t[1]=(i*S-r*I-s*x)*E,t[2]=(m*T-b*A+p*M)*E,t[3]=(h*A-l*T-d*M)*E,t[4]=(c*O-o*I-u*k)*E,t[5]=(n*I-i*O+s*k)*E,t[6]=(b*v-y*T-p*w)*E,t[7]=(f*T-h*v+d*w)*E,t[8]=(o*S-a*O+u*_)*E,t[9]=(r*O-n*S-s*_)*E,t[10]=(y*A-m*v+p*g)*E,t[11]=(l*v-f*A-d*g)*E,t[12]=(a*k-o*x-c*_)*E,t[13]=(n*x-r*k+i*_)*E,t[14]=(m*w-y*M-b*g)*E,t[15]=(f*M-l*w+h*g)*E,t):null}(Ur,n),i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];yn(e,(t=>{Mt(t,t,n),t[0]=t[0]-c[0],t[1]=t[1]-c[1],t[2]=t[2]-c[2],Mt(t,t,r),t[0]<i[0]&&(i[0]=t[0]),t[1]<i[1]&&(i[1]=t[1]),t[2]<i[2]&&(i[2]=t[2]),t[0]>o[0]&&(o[0]=t[0]),t[1]>o[1]&&(o[1]=t[1]),t[2]>o[2]&&(o[2]=t[2])})),e.min=i,e.max=o,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=c)}Jt(t,e,n,r){const{modelCenter:i,rtcCenter:s}=this.Qt(t,e,n,r),o=this.Yt(i);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.Kt(i),on(t,(e=>{if(e.attributes&&e.attributes.POSITION){const i=this.qt(e,t);if(i){const t=e.attributes.POSITION.array.length;(!Dr||Dr.length<t)&&(Dr=new Float32Array(t))}e.attributes.NORMAL&&this.Wt(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.Wt(e.attributes.TANGENT,e.matrices,n);const{newPositions:o}=this.Zt(e.attributes.POSITION,e.matrices,s,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,i),{componentType:a}=e.attributes.POSITION;5126!==a&&(e.attributes.POSITION.array=new Float32Array(o))}}));for(const e in t.nodes){t.nodes[e].matrix=Ir}}Yt(t){const e=this.options.projection;"identity"===e?bt(Fr,t):0===_t(t)?pt(Fr,0,0,-6378137):xe(Fr,t),Ln(Nr,Fr,e);const n=Fr[2],r=[];return r[0]=Nr[0],r[1]=Nr[1],r[2]=n,r}Wt(t,e,n){let r;r="Y"===n?Ar:"X"===n?Tr:Ir;const i=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(Vr(i,e),ht(i,Ir))return;const s=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}([],i),o=[];yn(t,(t=>(function(t,e,n){var r=e[0],i=e[1],s=e[2];t[0]=r*n[0]+i*n[3]+s*n[6],t[1]=r*n[1]+i*n[4]+s*n[7],t[2]=r*n[2]+i*n[5]+s*n[8]}(o,t,s),wt(o,o),bt(t,o),o)))}Zt(t,e,n,r,i,s,o,a){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const c=ft([]);Vr(c,e);const u=this.options.projection;i=i&&i.toUpperCase();const f=n;let l=null;"Y"===i?l=Ar:"X"===i&&(l=Tr);let h=[0,0,0,1];const d=[0,0,0],y=[0,0],m=r.projCenter,b=Ln([],r.rtcCoord,"EPSG:3857"),p=s&&ht(Ir,s),g=t.min=t.min||[],w=t.max=t.max||[];pt(g,1/0,1/0,1/0),pt(w,-1/0,-1/0,-1/0);const v=o||{},{decode_position_min:M,decode_position_normConstant:A}=v;let T=[0,0,0,0],_=1;M&&(T=M),A&&(_=A);const k=[];return yn(t,((e,n)=>{if(h[0]=e[0]*_+T[0],h[1]=e[1]*_+T[1],h[2]=e[2]*_+T[2],h=Mt(h,h,c),l&&(h=Mt(h,h,l)),f&&gt(h,h,f),s&&!p&&(h=Mt(h,h,s)),0===_t(h)?pt(d,0,0,-6378137):xe(d,h),a){const t=Dr;Ln(y,d,u),t[3*n]=y[0]-b[0],t[3*n+1]=y[0]-b[1],t[3*n+2]=y[0]-b[2]}if(Ln(y,d,u),e instanceof Float32Array)e[0]=y[0]-m[0],e[1]=y[1]-m[1],e[2]=d[2]-m[2];else{const n=y[0]-m[0],r=y[1]-m[1],i=d[2]-m[2];5126!==t.componentType&&(k.push(n),k.push(r),k.push(i),k.push(e[3]))}return e[0]<g[0]&&(g[0]=e[0]),e[1]<g[1]&&(g[1]=e[1]),e[2]<g[2]&&(g[2]=e[2]),e[0]>w[0]&&(w[0]=e[0]),e[1]>w[1]&&(w[1]=e[1]),e[2]>w[2]&&(w[2]=e[2]),e})),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:m,newPositions:k}}Kt(t){return 0===_t(t)?pt([],0,0,-6378137):xe([],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;return!t.attributes.TANGENT}}const Lr=[];function jr(t,e,n,r,i,s){const o=s||{},{decode_position_min:a,decode_position_normConstant:c}=o;let u=[0,0,0,0],f=1;a&&(u=a),c&&(f=c);for(let s=0,o=t.length;s<o;s+=e){const{xmin:o,ymin:a,xmax:c,ymax:l,hmin:h,hmax:d}=i;pt(Lr,t[s]*f+u[0],t[s+1]*f+u[1],t[s+2]*f+u[2]),Mt(Lr,Lr,r);const y=gt(Lr,n,Lr);y[0]<o&&(i.xmin=y[0]),y[0]>c&&(i.xmax=y[0]),y[1]<a&&(i.ymin=y[1]),y[1]>l&&(i.ymax=y[1]),e>2&&(y[2]<h&&(i.hmin=y[2]),y[2]>d&&(i.hmax=y[2]))}}function zr(t){const{xmax:e,ymax:n,xmin:r,ymin:i,hmin:s,hmax:o}=t,a=[(r+e)/2,(i+n)/2,(s+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 qr(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function Vr(t,e){const n=t;for(let t=e.length-1;t>=0;t--)lt(n,e[t],n);return n}function Gr(t,e,n,r,i){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let s,o;if(n&&r&&1===e)s=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);s=e,o=n}return!function(t,e,n,r){for(let i=0;i<t.length;i++){const s=$r(Xr(t[i],e,n),e,n);if(Math.abs(s-t[i])>Br[r])return!1}return!0}(t,s,o,i)&&Br[i]?null:function(t,e,n){const r=new Int16Array(t.length);for(let i=0;i<t.length;i++)r[i]=Xr(t[i],e,n);return{array:r,range:[e,n]}}(t,s,o)}function $r(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function Xr(t,e,n){const r=2*(t-e)/(n-e)-1,i=Math.max(-1,Math.min(1,r));return i<0?32768*i:32767*i}function Hr(t){return void 0===t.compressGeometry||t.compressGeometry}let Jr=0;class Kr{constructor(t){this.workerId=t,this.workers={},this.te={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},i){if(this.ee(e,n))return;const s=this.ne(e,n),o=r.options;this.workers[s]=new Rr(n,o,((...e)=>this.send.call(this,t,...e)),i)}removeLayer({mapId:t,layerId:e},n){const r=this.ee(t,e),i=this.ne(t,e);delete this.workers[i],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const i=this.ee(t,e);i&&i.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const i=this.ee(t,e);i&&i.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.te[e];delete this.te[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,i){const s=i?\`${o}t}-${o}Jr++}\`:null;i&&(this.te[s]=i),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(s)},r||[])}ne(t,e){return\`${o}t}-${o}e}\`}ee(t,e){const n=this.ne(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new Kr(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)}))}}`
7
7
  /*!
8
8
  * Contains code from THREE.js
9
9
  * MIT License
@@ -16,8 +16,8 @@
16
16
  */
17
17
  var Dt="undefined"!=typeof Float32Array?Float32Array:Array;function Ft(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],h=e[6],u=e[7],l=e[8],f=e[9],d=e[10],m=e[11],p=e[12],g=e[13],y=e[14],b=e[15],w=n[0],v=n[1],T=n[2],_=n[3];return t[0]=w*r+v*a+T*l+_*p,t[1]=w*s+v*c+T*f+_*g,t[2]=w*i+v*h+T*d+_*y,t[3]=w*o+v*u+T*m+_*b,w=n[4],v=n[5],T=n[6],_=n[7],t[4]=w*r+v*a+T*l+_*p,t[5]=w*s+v*c+T*f+_*g,t[6]=w*i+v*h+T*d+_*y,t[7]=w*o+v*u+T*m+_*b,w=n[8],v=n[9],T=n[10],_=n[11],t[8]=w*r+v*a+T*l+_*p,t[9]=w*s+v*c+T*f+_*g,t[10]=w*i+v*h+T*d+_*y,t[11]=w*o+v*u+T*m+_*b,w=n[12],v=n[13],T=n[14],_=n[15],t[12]=w*r+v*a+T*l+_*p,t[13]=w*s+v*c+T*f+_*g,t[14]=w*i+v*h+T*d+_*y,t[15]=w*o+v*u+T*m+_*b,t}function jt(){var t=new Dt(3);return Dt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function qt(t,e,n){var r=new Dt(3);return r[0]=t,r[1]=e,r[2]=n,r}function zt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Ht(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function Gt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function Vt(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function Jt(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 Kt(){var t=new Dt(4);return Dt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),jt(),function(){var t;t=new Dt(4),Dt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0)}();var Xt,Yt=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};jt(),qt(1,0,0),qt(0,1,0),Kt(),Kt(),Xt=new Dt(9),Dt!=Float32Array&&(Xt[1]=0,Xt[2]=0,Xt[3]=0,Xt[5]=0,Xt[6]=0,Xt[7]=0),Xt[0]=1,Xt[4]=1,Xt[8]=1;let Wt=0;function Zt(t){return null==t}function Qt(t){return!Zt(t)}function te(t){return!Zt(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function ee(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 ne(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 re(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function se(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 ie=[],oe=[],ae=[],ce=[0,0,0],he=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),ue=[1,1,1];function le(t,e,n,r,s,i,o){const a=ne(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 h=new Uint8Array(r*c);for(let o=0;o<n;o++){let n=null;const u=new Uint8Array(e,s*o+i,r*c);h.set(u),n=new a(h.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const fe="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function de(t,e,n){const r=new Uint8Array(t,e,n);return fe.decode(r)}const me={get:function(t,e={},n){e||(e={});const r=new AbortController,s=r.signal,i=ee({},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.i(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},i:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={},n)=>(e||(e={}),e.responseType="arraybuffer",me.get(t,e,n)),getJSON:function(t,e={},n){return e&&e.jsonp?me.jsonp(t):((e=e||{}).responseType="json",me.get(t,e,n))},jsonp:function(t){const e="_maptalks_jsonp_"+Wt++;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 pe{constructor(t,e,n,r,s){this.o=t,this.decoders=e,this.h=n,this.images={},this.u={},this.m=r||{},this.p=s}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],s=this.v(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.v(e,r);return this.getImageByBuffer(s,n)}));if(re(t.uri)){const r=this.buffers[t.id]=se(t.uri),s=this.v(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]=me.getArrayBuffer(r,this.m,this.p).then((r=>{const s=this.buffers[t.id]=r.data,i=this.v(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.h}):"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.T(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.T(t.id,e)}T(t,e){return new Promise(((n,r)=>{let s=e;this.p&&(s=this.p(e)),this.o(s,this.m,((s,i)=>{s?r(s):(URL.revokeObjectURL(e),this.images[t]=i,n(this.images[t]))}))}))}}const ge=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],ye=[];class be{constructor(t,e,n,r,s){this.rootPath=t,this.gltf=e,this._=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.M(),this.m=r,this.p=s}A(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this.O(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.I(s).then((n=>{const{buffer:s,byteOffset:i}=n;return this.accessors[r.id]=this.O(t,e,s,i)}))}I(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(re(e.uri)){const t=this.buffers[e.id]=se(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]=me.getArrayBuffer(t,this.m,!n&&this.p).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})}O(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.S(i.type),h=ne(i.componentType),u=o.byteStride||0,l={array:void 0,name:t,accessorName:e,byteLength:i.count*c*h.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&&(l.min=i.min),i.max&&(l.max=i.max),n)if(this._)l.byteStride=u,l.byteOffset=a+(i.byteOffset||0),!u||u===c*h.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(l.array=this.C(n,i.count,c,a+(i.byteOffset||0),h),l.array.buffer.byteLength===l.byteLength&&(l.byteOffset=0)):l.array=new Uint8Array(n,a,o.byteLength);else if(i.interleaved){l.byteStride=0,l.byteOffset=0;const t=new h(i.count*c);if(l.array=le(t,n,i.count,c,u,a+(i.byteOffset||0),i.componentType),l.extensions&&l.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(l.array.length),{decodeMatrix:e}=l.extensions.WEB3D_quantized_attributes;for(let n=0;n<l.array.length;n+=c){ye[0]=l.array[n],ye[1]=l.array[n+1],ye[2]=l.array[n+2],ye[3]=1;const r=$t(ye,ye,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}l.componentType=5126,l.array=t}}else l.byteStride=0,l.array=this.C(n,i.count,c,a+(i.byteOffset||0),h),l.byteOffset=l.array.byteOffset;else{l.array=new h(i.count);const t=l.min||l.max;t&&(l.array[0]=t[0],l.array[1]=t[1],l.array[2]=t[2])}return l}M(){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)}C(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)}S(t){const e=ge.indexOf(t);return ge[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.I(e).then((r=>{const{buffer:s,byteOffset:i}=r,o=de(s,i+(e.byteOffset||0),n);return t.content=o,t}))}if(t.uri){if(re(t.uri)){const e=se(t.uri),n=de(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return me.get(e,this.m,this.p).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(n).then((()=>t))}}class we extends pe{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 be(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(Qt(t.name)&&(e.name=t.name),Qt(t.children)&&(e.children=t.children),Qt(t.jointName)&&(e.jointName=t.jointName),Qt(t.matrix)&&(e.matrix=t.matrix),Qt(t.rotation)&&(e.rotation=t.rotation),Qt(t.scale)&&(e.scale=t.scale),Qt(t.translation)&&(e.translation=t.translation),Qt(t.extras)&&(e.extras=t.extras),Qt(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=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}(ie,e.translation||ce),r=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,h=n*o,u=r*o,l=r*a,f=s*o,d=s*a,m=s*c,p=i*o,g=i*a,y=i*c;return t[0]=1-l-m,t[1]=u+y,t[2]=f-g,t[3]=0,t[4]=u-y,t[5]=1-h-m,t[6]=d+p,t[7]=0,t[8]=f+g,t[9]=d-p,t[10]=1-h-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(oe,e.rotation||he),s=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}(ae,e.scale||ue);return Ft(s,r,s),Ft(t,n,s)}return function(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}(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}N(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}k(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)}R(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.k(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 ve=9729;class Te extends pe{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 be(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 ee(e,t),!Qt(t.weights)&&this.gltf.meshes&&Qt(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}R(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),!Qt(n))return null;const r=this.gltf.images[n];return this.k(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}};ee(n,e);const s=Qt(e.sampler)?this.gltf.samplers[e.sampler]:void 0;if(s&&(n.sampler=s,n.sampler.magFilter=s.magFilter||ve,n.sampler.minFilter=s.minFilter||9987,n.sampler.wrapS=s.wrapS||10497,n.sampler.wrapT=s.wrapT||10497),"image/ktx2"===n.image.mimeType&&!n.image.mipmap&&n.sampler&&n.sampler.minFilter!==ve&&9728!==n.sampler.minFilter){const t=n.sampler.minFilter;n.sampler.minFilter=9984===t||9986===t?9728:ve}return t.format&&(n.format=t.format),n}))}k(t){if(!Qt(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.P(e,t)}return null}P(t,e){const n=this.v(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}v(t,e,n){n=n||0;const r=(t.byteOffset||0)+n,s=t.byteLength;return new Uint8Array(e,r,s)}L(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++)(Qt(t[n].input)||Qt(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 _e="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class Me{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 Me.readV1(r,e);if(2===s)return Me.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=Ae(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+8<i.byteLength;){const a=i.getUint32(o,!0);o+=4;const c=i.getUint32(o,!0);if(o+=4,1313821514===c)n=Ae(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 Ae(t,e,n){if(_e){const r=new Uint8Array(t,e,n);return _e.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=Oe[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 Oe=[1,1,1,1,2,2,3,0],xe=[0,0,0],Ie=[0,0,0,1],Se=[1,1,1],Ee={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},Ce={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},Ne={B(t,e,n,r,s,i,o,a){const c=Qt(t)?e.animations:[e.animations[0]],h={};for(let e=0;e<c.length;e++){const u=c[e],l=u.name||e;if(Qt(t)&&l!==t)continue;const f=u.channelsMap[n];if(f)for(let t=0;t<f.length;t++){const e=f[t];"translation"===e.target.path?(this.U(s,u.samplers[e.sampler],r,1),h.translation=zt(xe,s)):"rotation"===e.target.path?(this.D(i,u.samplers[e.sampler],r,1),h.rotation=Yt(Ie,i)):"scale"===e.target.path?(this.U(o,u.samplers[e.sampler],r,1),h.scale=zt(Se,o)):"weights"===e.target.path&&a&&(this.U(a,u.samplers[e.sampler],r,a.length),h.weights=a)}}return h},U(t,e,n,r){switch(e.interpolation){case"LINEAR":{const s=this.F(Ce,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.F(Ce,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.F(Ce,e,n,3*r);s&&(t=this.j(t,s,e.input.array,3*r));break}}return t},D(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.F(Ce,e,n,1);r&&function(t,e,n,r){var s,i,o,a,c,h=e[0],u=e[1],l=e[2],f=e[3],d=n[0],m=n[1],p=n[2],g=n[3];(i=h*d+u*m+l*p+f*g)<0&&(i=-i,d=-d,m=-m,p=-p,g=-g),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*h+c*d,t[1]=a*u+c*m,t[2]=a*l+c*p,t[3]=a*f+c*g}(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.F(Ce,e,n,1);r&&(t=Jt(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.F(Ce,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.j(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},q(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},F(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.q(s,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:h,interpolation:u}=a;t.PREINDEX=c,t.NEXTINDEX=h,t.INTERPOLATION=u;const l=o*r;return t.PREVIOUS=i.subarray(t.PREINDEX*l,(t.PREINDEX+1)*l),t.NEXT=i.subarray(t.NEXTINDEX*l,(t.NEXTINDEX+1)*l),t},j(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],h=e.NEXT[3+n],u=(o-i)*e.NEXT[n],l=(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))*h+(Math.pow(s,3)-Math.pow(s,2))*u;t[n]=l}return t},getAnimationClip(t,e,n,r){const s=t.nodes[e]&&t.nodes[e].weights;return Ht(xe,...Ee.TRANSLATION),Jt(Ie,...Ee.ROTATION),Ht(Se,...Ee.SCALE),this.B(r,t,e,n,xe,Ie,Se,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?Qt(e)?n[e]:n[Object.keys(n)[0]]:null}};let ke=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Gs){}t&&"undefined"!=typeof createImageBitmap&&(ke=!0)}const Re="undefined"==typeof document?null:document.createElement("canvas");class Pe{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),this.m=this.options.fetchOptions||{},e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=Me.read(e.buffer,e.byteOffset,e.byteLength);this.H(t,n,r)}else this.H(t,e);this.G=new be(this.rootPath,this.gltf,this.glbBuffer,this.m,this.options.urlModifier),this.V()}V(){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.")}}J(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.G.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.$(t),n=this.K(),r=this.X(),s=this.J();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 Ne.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return Ne.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return ne(t)}static readInterleavedArray(t,e,n,r,s,i,o){return le(t,e,n,r,s,i,o)}H(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=ke?qe.bind(this):this.options.requestImage||Le,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new Te(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.m,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 we(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.m,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"))}Y(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(n=t.children[0])&&isFinite(n)||te(t.children[0])))return t;const r=t.children.map((t=>{const n=e[t];return n.nodeIndex=t,this.Y(n,e)}));t.children=r}var n;return t}$(t){return this.W(t).then((t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.Y(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.N(this.gltf.materials);r.materials=t}return delete this.gltf.buffers,r.json=this.gltf,r}))}W(t){return this.Z(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}))}tt(){this.skins=[];const t=[];return this.adapter.iterate(((e,n,r)=>{t.push(this.et(n).then((t=>{t.index=r,this.skins.push(t)})))}),"skins"),t}et(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)))}K(){const t=this.gltf.animations;return Qt(t)?this.adapter.getAnimations(t):null}Z(t){this.meshes={};let e=[];return this.adapter.iterate(((n,r,s)=>{e.push(this.nt(r,t).then((t=>{t.index=s,this.meshes[n]=t})))}),"meshes"),e=e.concat(this.tt()),Promise.all(e)}nt(t,e){const n=t.primitives.map((t=>this.rt(t,e))).filter((t=>!!t));return Promise.all(n).then((e=>{const n={};return ee(n,t),n.primitives=e,n}))}X(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.R(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}))}rt(t,e){let n;const r=[],s=t.extensions;if(Qt(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_${t}_${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.G.I(a).then((n=>{const{buffer:r,byteOffset:s}=n;let{byteOffset:i}=a;const c=a.byteLength;i||(i=0);const h=new DataView(r,s+i,c),u={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(h,u).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(Qt(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;Vt(t,t,s),Gt(t,t,i),Vt(n,n,s),Gt(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=Qt(t.mode)?t.mode:4,Qt(t.extras)&&(i.extras=t.extras),i}))}}function Le(t,e,n){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!Re)return void n(new Error("There is no canvas to draw image!"));Re.width=r.width,Re.height=r.height;const t=Re.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 Be=[],Ue=[],De=30;let Fe,je;function qe(t,e,n){Fe||(Fe=new OffscreenCanvas(2,2),je=Fe.getContext("2d",{willReadFrequently:!0}));let r=null;if(te(t))this.options.urlModifier&&(t=this.options.urlModifier(t)),Be.push([t,e,n,this]),ze();else{const e=new Blob([t]);r=createImageBitmap(e),r.then(He.bind(this)).then((t=>{n(null,t)})).catch((t=>{console.warn(t),n(t)}))}}function ze(){if(!Be.length||Ue.length>De)return;const t=Be.shift(),[e,n,r,s]=t;Ue.push(t),fetch(e,n).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then(He.bind(s)).then((e=>{r.call(s,null,e);const n=Ue.indexOf(t);Ue.splice(n,1),ze()})).catch((e=>{console.warn(e),r.call(s,e);const n=Ue.indexOf(t);Ue.splice(n,1),ze()}))}function He(t){let{width:e,height:n}=t;Ge(e)||(e=Ve(e)),Ge(n)||(n=Ve(n));const r=this.options.maxTextureSize;r&&(e=Math.min(r,e),n=Math.min(r,n)),Fe.width=e,Fe.height=n,je.drawImage(t,0,0,e,n),t.close();const s=je.getImageData(0,0,e,n);return{width:e,height:n,data:new Uint8Array(s.data)}}function Ge(t){return!(t&t-1)&&0!==t}function Ve(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}const Je="undefined"==typeof document?null:document.createElement("canvas");class $e extends s.worker.Actor{constructor(t,e,n){super(t),this.mapId=e,this.st=n}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(!Je)return void e(new Error("There is no canvas to draw image!"));const t=this.st?n:function(t){if(Ke(t.width)&&Ke(t.height))return t;let e=t.width,n=t.height;Ke(e)||(e=Xe(e));Ke(n)||(n=Xe(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);Je.width=t.width,Je.height=t.height;const r=Je.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 Ke(t){return!(t&t-1)&&0!==t}function Xe(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var Ye=1e-6,We="undefined"!=typeof Float32Array?Float32Array:Array;function Ze(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],h=e[6],u=e[7],l=e[8],f=e[9],d=e[10],m=e[11],p=e[12],g=e[13],y=e[14],b=e[15],w=n[0],v=n[1],T=n[2],_=n[3];return t[0]=w*r+v*a+T*l+_*p,t[1]=w*s+v*c+T*f+_*g,t[2]=w*i+v*h+T*d+_*y,t[3]=w*o+v*u+T*m+_*b,w=n[4],v=n[5],T=n[6],_=n[7],t[4]=w*r+v*a+T*l+_*p,t[5]=w*s+v*c+T*f+_*g,t[6]=w*i+v*h+T*d+_*y,t[7]=w*o+v*u+T*m+_*b,w=n[8],v=n[9],T=n[10],_=n[11],t[8]=w*r+v*a+T*l+_*p,t[9]=w*s+v*c+T*f+_*g,t[10]=w*i+v*h+T*d+_*y,t[11]=w*o+v*u+T*m+_*b,w=n[12],v=n[13],T=n[14],_=n[15],t[12]=w*r+v*a+T*l+_*p,t[13]=w*s+v*c+T*f+_*g,t[14]=w*i+v*h+T*d+_*y,t[15]=w*o+v*u+T*m+_*b,t}function Qe(){var t=new We(3);return We!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function tn(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function en(t,e,n){var r=new We(3);return r[0]=t,r[1]=e,r[2]=n,r}function nn(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function rn(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function sn(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function on(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function an(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function cn(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 hn(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function un(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}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var ln=sn,fn=on,dn=tn;function mn(){var t=new We(4);return We!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}Qe(),function(){var t,e=(t=new We(4),We!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var pn;function gn(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=[];Mn(r[n],s,t,e)}}}Qe(),en(1,0,0),en(0,1,0),mn(),mn(),pn=new We(9),We!=Float32Array&&(pn[1]=0,pn[2]=0,pn[3]=0,pn[5]=0,pn[6]=0,pn[7]=0),pn[0]=1,pn[4]=1,pn[8]=1;const yn=[],bn=[],wn=[],vn=[0,0,0],Tn=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),_n=[1,1,1];function Mn(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=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}(yn,t.translation||vn),n=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,h=n*o,u=r*o,l=r*a,f=s*o,d=s*a,m=s*c,p=i*o,g=i*a,y=i*c;return t[0]=1-l-m,t[1]=u+y,t[2]=f-g,t[3]=0,t[4]=u-y,t[5]=1-h-m,t[6]=d+p,t[7]=0,t[8]=f+g,t[9]=d-p,t[10]=1-h-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(bn,t.rotation||Tn),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}(wn,t.scale||_n);Ze(r,n,r);const i=Ze([],e,r);s.push(i)}if(t.children&&t.children.length)for(let e=0,i=t.children.length;e<i;e++)Mn(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 An(t,e,n){let{byteOffset:r,byteStride:s}=e;const{componentType:i,itemSize:o}=e,a=e.array.buffer,c=i?Pe.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 On(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 xn="#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 In=new Array(3),Sn=new Array(3),En=[40680631590769,40680631590769,40408299984661.445];function Cn(t,e,n,r){const s=En,i=Math.cos(n);In[0]=i*Math.cos(e),In[1]=i*Math.sin(e),In[2]=Math.sin(n),qn(In,In),on(Sn,s,In);const o=Math.sqrt(hn(In,Sn));var a,c,h;return c=Sn,h=o,(a=Sn)[0]=c[0]/h,a[1]=c[1]/h,a[2]=c[2]/h,an(In,In,r),function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}(t,Sn,In)}const Nn=[1/6378137,1/6378137,1/6356752.314245179],kn=[1/40680631590769,1/40680631590769,1/40408299984661.445],Rn=new Array(3),Pn=new Array(3),Ln=new Array(3);function Bn(t,e){const n=kn,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],h=n[1],u=n[2],l=i*i*c*c,f=o*o*h*h,d=a*a*u*u,m=l+f+d,p=Math.sqrt(1/m),g=an(Un,e,p);if(m<s)return isFinite(p)?g:void 0;const y=r[0],b=r[1],w=r[2],v=Dn;v[0]=g[0]*y*2,v[1]=g[1]*b*2,v[2]=g[2]*w*2;let T,_,M,A,O,x,I,S,E,C,N,k=(1-p)*jn(e)/(.5*jn(v)),R=0;do{k-=R,M=1/(1+k*y),A=1/(1+k*b),O=1/(1+k*w),x=M*M,I=A*A,S=O*O,E=x*M,C=I*A,N=S*O,T=l*x+f*I+d*S-1,_=l*E*y+f*C*b+d*N*w;R=T/(-2*_)}while(Math.abs(T)>Fn);return t[0]=i*M,t[1]=o*A,t[2]=a*O,t}(Rn,e,Nn,n,.1);let s=fn(Pn,r,n);s=qn(s,s);const i=ln(Ln,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=At(hn(i,e))*jn(i);return t[0]=_t(o),t[1]=_t(a),t[2]=c,t}const Un=new Array(3),Dn=new Array(3),Fn=1e-12;function jn(t){return tn(t)}function qn(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 zn(t,e){return on(e,t,kn),cn(e,e)}function Hn(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,cn(e,e)}var Gn=Object.freeze({__proto__:null,cartesian3ToDegree:Bn,geodeticSurfaceNormal:zn,geodeticSurfaceNormalCartographic:Hn,normalizeCartesian:qn,radianToCartesian3:Cn});function Vn(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 Jn(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const $n="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Kn(t,e,n){const r=new Uint8Array(t,e,n);return $n?JSON.parse($n.decode(r)):JSON.parse(xt(r))}function Xn(t,e,n){const r=new Uint8Array(t,e,n);return $n?JSON.parse($n.decode(r)):JSON.parse(xt(r))}function Yn(t,e,n){return{offset:e,byteLength:n}}function Wn(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=rr(i||"UNSIGNED_SHORT"),h=er(o);return{byteStride:0,byteOffset:s+n,itemSize:h,count:r*h,componentType:c,array:new a(e,n+s,r*h)}}function Zn(t,e,n,r){const s=Wn(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}function Qn(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a}=rr(i||"UNSIGNED_SHORT"),c=er(o),h=new a(e,s,n*c);return 1===c?h[r]:h.subarray(r*c,r*c+c)}const tr={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function er(t){return t?tr[t]:1}const nr={"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 rr(t){return nr[t]}function sr(t){for(const e in nr)if(t===nr[e].ctor)return nr[e].type;throw new Error("unrecognized ctor:"+t)}function ir(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 or(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={},u={},l=null;r>0&&(h=Kn(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(u=Xn(a,e,i),e+=i);const f=Yn(0,e,o);return l=a.slice(f.offset,f.offset+f.byteLength),n.push(l),{featureTable:h,featureTableBin:c,batchTable:u,batchTableBin:l}}const ar={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"}},cr={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},hr={},ur={east:[],north:[],up:[],west:[],south:[],down:[]};let lr=[],fr=[],dr=[];const mr=[0,0,0];function pr(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 gr=function(t,e){const n=ar[t][e];let r;const s=t+e;return hr[s]?r=hr[s]:(r=function(r,s,i){if(function(t,e){var n=t[0],r=t[1],s=t[2],i=e[0],o=e[1],a=e[2];return Math.abs(n-i)<=Ye*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(r-o)<=Ye*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(s-a)<=Ye*Math.max(1,Math.abs(s),Math.abs(a))}(r,mr))nn(lr,cr[t]),nn(fr,cr[e]),nn(dr,cr[n]);else if(Vn(r[0],0,1e-14)&&Vn(r[1],0,1e-14)){const s=At(r[2]);nn(lr,cr[t]),nn(fr,cr[e]),an(fr,fr,s),nn(dr,cr[n]),an(dr,dr,s)}else{zn(r,ur.up);const s=ur.up,i=ur.east;i[0]=-r[1],i[1]=r[0],i[2]=0,cn(ur.east,i),un(ur.north,s,i),an(ur.down,ur.up,-1),an(ur.west,ur.east,-1),an(ur.south,ur.north,-1),lr=ur[t],fr=ur[e],dr=ur[n]}return i[0]=lr[0],i[1]=lr[1],i[2]=lr[2],i[3]=0,i[4]=fr[0],i[5]=fr[1],i[6]=fr[2],i[7]=0,i[8]=dr[0],i[9]=dr[1],i[10]=dr[2],i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i},hr[s]=r),r}("east","north"),yr=[],br=[],wr=[],vr=[],Tr=[],_r=[],Mr=[],Ar={x:0,y:0},Or={x:0,y:0},xr=Math.PI/180;let Ir;const Sr={width:100,height:10};let Er=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),Er=!0}catch(t){Er=!1}function Cr(){if(!Ir){const{width:t,height:e}=Sr;Er?Ir=new OffscreenCanvas(t,e):(Ir=document.createElement("canvas"),Ir.width=t,Ir.height=e)}return Ir}class Nr{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({},Sr,e),this.it()}getImageData(){return this.imgData}it(){const t=Cr(),{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 kr;function Rr(t,e){var n,r,s;if(Hr(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=Br;else if("interval"===h)i=Lr;else if("categorical"===h)i=Pr;else if("identity"===h)i=Fr;else if("color-interpolate"===h)i=Dr;else{if("calculate-expression"!==h)throw new Error('Unknown function type "'+h+'"');i=jr}if(o){var u={},l=[];for(let e=0;e<t.stops.length;e++){var f=t.stops[e];void 0===u[f[0].zoom]&&(u[f[0].zoom]={zoom:f[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),u[f[0].zoom].stops.push([f[0].value,f[1]])}for(let t in u)l.push([u[t].zoom,Rr(u[t])]);n=function(e,n){const r=Br({stops:l,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 Pr(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 Lr(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 Br(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]:qr(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(kr=new Map);const Ur={width:100,height:1};function Dr(t,e){const n=t.stops;if(n&&n.length>1){let t;if(kr){const e=JSON.stringify(n);if(!kr.has(e)){const t=new Nr(n,Ur);kr.set(e,t)}t=kr.get(e)}else t=new Nr(n,Ur);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 Fr(t,e){return function(t,e,n){return void 0!==t?t:void 0!==e?e:null}(e,t.default)}function jr(t,e){const n=String(t.property),r=t.expression,s=e;function i(e){return null==e||""===e||isNaN(e)?t.default:e}if(null==e||""===e||isNaN(e)||e<0)return i(t.default);{const e=function t(e,n,r){const s=Number(r),i=String(n);return Array.isArray(e)?e.map((e=>t(e,i,s))):e===i?s:e}(r,n,s);return i(function e(n){if(!Array.isArray(n)){if("number"==typeof n)return n;throw new Error("Invalid expression format")}{const r=n[0];if(!["+","-","*","/"].includes(r))throw new Error(`Unknown operator: ${r}`);const s=n.slice(1).map((t=>e(t)));switch(r){case"+":return s.reduce(((t,e)=>t+e),0);case"-":return s.reduce(((t,e)=>t-e));case"*":return s.reduce(((t,e)=>t*e),1);case"/":return s.some((t=>0===t))?t.default:s.reduce(((t,e)=>t/e));default:throw new Error(`Unsupported operator: ${r}`)}}}(e))}}function qr(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 qr(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]=zr(t,e,n,r,s[a],i[a]);return o}(t,e,n,r,s,i):zr(t,e,n,r,s,i)}function zr(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 Hr(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type||t.expression&&"calculate-expression"===t.type)}function Gr(t){return Vr(t,"exponential")}function Vr(t,e){if(!Hr(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(Hr(s[t][1])){const i=Vr(s[t][1],e);n=n&&i.isZoomConstant,r=r&&i.isFeatureConstant,s[t]=[s[t][0],i]}const i=Rr(t,e);return i.isZoomConstant=n&&i.isZoomConstant,i.isFeatureConstant=r&&i.isFeatureConstant,i}const{getTextureMagFilter:Jr,getTextureMinFilter:$r,getTextureWrap:Kr,getMaterialType:Xr,getMaterialFormat:Yr,getPrimitive:Wr,getUniqueREGLBuffer:Zr}=n.reshader.REGLHelper,Qr=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],ts=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:es,logoutIBLResOnCanvas:ns,getIBLResOnCanvas:rs,getPBRUniforms:ss}=n.reshader.pbr.PBRUtils,is={factor:0,units:0},os=[1,1,1,1],as=[0,0,0],cs={specularStrength:0,materialShininess:1},hs=[1,1,1],us=n.mat4.identity([]),ls=[0,0,0],fs=[0,0],ds=[],ms=t=>t.material instanceof n.reshader.PhongMaterial,ps=t=>t.material instanceof n.reshader.pbr.StandardMaterial,gs=[],ys=new s.Coordinate(0,0),bs=new s.Point(0,0),ws=new s.Point(0,0),vs=new s.Point(0,0),Ts=[],_s=[],Ms=[],As=[],Os=[],xs=[],Is=[],Ss=[],Es=[],Cs=[],Ns=[],ks=[],Rs=[],Ps=[],Ls={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},Bs=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],Us=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}}
18
18
  /*!
19
- * @maptalks/gl v0.102.1
19
+ * @maptalks/gl v0.102.2
20
20
  * LICENSE : UNLICENSED
21
21
  * (c) 2016-2024 maptalks.com
22
- */(100,1),Ds=[0,0,0,1],Fs=[1,1,1];class js{constructor(t,e){this.ot=e,this.ct=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.ht=t,this.ut=new n.reshader.Renderer(t),this.lt={},this.ft={},this.dt={},this.gt={},this.yt={},this.bt={},this.wt=new n.reshader.Scene,this.vt=new n.reshader.Scene,this.Tt=new n.reshader.Scene,this._t=new n.reshader.Scene,this.Mt=new n.reshader.ResourceLoader(t.texture(2)),this.At=(...t)=>this.Ot.call(this,...t),this.xt=new n.reshader.KHRTechniquesWebglManager(this.ht,this.It(),this.Mt);const r=this.getMap();this.St=r.altitudeToPoint(100,r.getGLRes())/100}getI3DMMeshes(){return this.gt}getPNTSMeshes(){return this.dt}getB3DMMeshes(){return this.ft}getPaintedMeshes(){return this.Et}getMap(){return this.ot.getMap()}paint(t,e,r,s){const i=s&&s.renderTarget,o=s&&s.sceneFilter,a=this.getMap();if(!t.length||!a)return null;const c=this.Ct(),h=a.projViewMatrix,u=[],f=[],d=[],m=[],p=[];for(let r=0,i=t.length;r<i;r++){const i=t[r].data.node;let o=this.Nt(i);if(!o)continue;const a=this.ot.kt(i.Rt),c=a.debugNodes,g=a.heightOffset||0,y=a.coordOffset||fs;this.yt[i.id]&&(o=this.yt[i.id],o=St(o));let b=a.polygonOffset||is;bt(b)&&(b=b()),Array.isArray(o)||(u[0]=o,o=u);for(let a=0,u=o.length;a<u;a++){if(!o[a]||!o[a].isValid||!o[a].isValid())continue;const u=o[a].properties.magic;if(o[a].properties.heightOffset===g&&o[a].properties.coordOffset[0]===y[0]&&o[a].properties.coordOffset[1]===y[1]||(this.Pt(o[a]),o[a].Lt=n.mat4.copy([],o[a].localTransform)),o[a].Bt=i,"b3dm"===u){if(o[a].getBoundingBox&&!l(h,o[a].getBoundingBox()))continue;const{batchIdData:t,batchIdMap:e}=o[a].geometry.properties;if(t&&e){const t=o[a].properties.node.Rt;this.Ut&&this.Ut[t]?n.HighlightUtil.highlightMesh(this.ht,o[a],this.Ut[t],this.Dt,e):this.Ut&&this.Ut[t]||n.HighlightUtil.highlightMesh(this.ht,o[a],null,this.Dt,e),n.HighlightUtil.showOnly(this.ht,o[a],this.Ft&&this.Ft[t],this.jt,e)}if(c&&c.length&&c.indexOf(o[a].Bt.id)<0)continue;s&&s.bloom&&o[a].properties.hlBloomMesh&&(o[a].properties.hlBloomMesh.properties.depthFunc="always",o[a].properties.hlBloomMesh.properties.polygonOffset=b,d.push(o[a].properties.hlBloomMesh)),d.push(o[a])}else"pnts"===u?m.push(o[a]):"i3dm"===u&&p.push(o[a]);o[a].properties.isLeaf=!!e[i.id],o[a].properties.selectionDepth=255-t[r].selectionDepth,o[a].properties.polygonOffset=b,e[i.id]||f.push(o[a]),this.qt(o[a]),this.zt(o[a],i)}}let g=0;const y=this.xt.getExcludeFilter();n.ContextUtil.setIncludeUniformValues(c,s),g+=this.Ht(this.Gt,c,[o,ms,y],i,f,d,p),g+=this.Ht(this.Vt,c,[o,ps,y],i,f,d,p),this.xt.forEachShader(((t,e,n)=>{const r=this.Ct(n);g+=this.Ht(t,r,[o,e],i,f,d,p)})),this.vt.setMeshes(m);const b=this.Jt();return g+=this.ut.render(this.$t,b,this.vt,i&&i.fbo),this.Et={pntsMeshes:m,i3dmMeshes:p,b3dmMeshes:d},this._t.setMeshes(r),this.ut.render(this.Kt,c,this._t,i&&i.fbo),g}prepareRender(t){this.Xt(t)}Xt(t){t&&t.states&&t.states.includesChanged&&(this.Vt.dispose(),delete this.Vt,this.Gt.dispose(),delete this.Gt),this.Yt(t)}Ht(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.Wt(a),this.wt.setMeshes(h),c+=this.ut.render(t,e,this.wt,a),h.length=0,e.stencilEnable=!1),h.push(i[n])):(e.stencilEnable||(this.wt.setMeshes(h),c+=this.ut.render(t,e,this.wt,a),h.length=0,e.stencilEnable=!0),h.push(i[n])),n===i.length-1&&(e.stencilEnable&&this.Wt(a),this.wt.setMeshes(h),c+=this.ut.render(t,e,this.wt,a))}return this.wt.setMeshes(i.filter((t=>t.properties.isLeaf))),this.Tt.setMeshes(o),c+=this.ut.render(t,e,this.Tt,r&&r.fbo),c}Wt(t){this.ht.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.wt.getMeshes()}getCurrentI3DMMeshes(){return this.Tt.getMeshes()}Zt(t,e){return e.Bt.Qt-t.Bt.Qt}deleteTile(t){const e=t.node;e.te&&(e.te.geometry.dispose(),e.te.dispose(),delete e.te);const n=e.id;this.ee(n)}ee(t){const e=this.ft[t]||this.dt[t]||this.gt[t]||this.yt[t]||this.lt[t];this.yt[t]?this.ne(t):e&&(this.re(e),delete this.ft[t],delete this.dt[t],delete this.gt[t],delete this.lt[t])}ne(t){let e=this.yt[t];e=St(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.ee(n)}delete this.yt[t]}re(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.re(t[e]);else{n.HighlightUtil.showOnly(this.ht,t),n.HighlightUtil.highlightMesh(this.ht,t);const e=t.geometry.properties.url;if(e){const n=this.bt[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this.bt[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.ot;ns(t.getRenderer().canvas,t.getMap());for(const t in this.yt)this.ne(t);this.yt={};for(const t in this.ft)this.ee(t);this.ft={};for(const t in this.dt)this.ee(t);this.dt={};for(const t in this.gt)this.ee(t);this.gt={};for(const t in this.lt)this.ee(t);this.lt={},this.Gt&&(this.Gt.dispose(),delete this.Gt),this.Vt&&(this.Vt.dispose(),delete this.Vt),this.$t&&(this.$t.dispose(),delete this.$t),this.Kt&&(this.Kt.dispose(),delete this.Kt),this.xt.dispose(),this.picking&&this.picking.dispose()}Nt(t){return this.ft[t.id]||this.dt[t.id]||this.gt[t.id]||this.yt[t.id]}has(t){return this.Nt(t)||this.lt[t.id]}Pt(t){const e=t.properties.magic;"b3dm"===e?this.se(t):"i3dm"===e?this.ie(t):"pnts"===e&&this.oe(t)}createPntsMesh(t,e,r,s){if(this.dt[e]){const t=this.dt[e];return console.warn(`pnts mesh with id(${e}) was already created.`),s(null,{id:e,mesh:t}),t}const{pnts:i,featureTable:o,rootIdx:a,compressed_int16_params:c}=t,h=o.POINTS_LENGTH;i.BATCH_ID||(i.BATCH_ID=new Uint8Array(h),i.BATCH_ID.fill(0));const u=new n.reshader.Geometry(i,null,h,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});u.generateBuffers(this.ht);const l={};i.POSITION?l.HAS_POSITION=1:i.POSITION_QUANTIZED&&(l.HAS_POSITION_QUANTIZED=1),i.RGB?l.HAS_RGB=1:i.RGBA?l.HAS_RGBA=1:i.RGB565&&(l.HAS_RGB565=1),(i.NORMAL||i.NORMAL_OCT16P)&&(l.HAS_NORMAL=1,i.NORMAL_OCT16P&&(l.HAS_NORMAL_OCT16P=1)),this.ae(l,c),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:f,rtcCoord:d,projCenter:m}=t,p=this.ot.kt(a),g=new n.reshader.Mesh(u);g.properties.magic="pnts",g.properties.id=e,g.properties.node=r,g.properties.count=h,g.properties.batchTable=t.batchTable,g.properties.batchTableBin=t.batchTableBin,g.properties.serviceIndex=a,g.properties.rtcCoord=d,g.properties.rtcCenter=f,g.properties.projCenter=m,g.setDefines(l),g.setFunctionUniform("pointColor",(function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:p&&p.pointColor||[1,1,1,1]}));const y=this.getMap();let b=null,w=null;g.setFunctionUniform("pointSize",(function(){if(!p)return 2;if(Hr(p.pointSize)){const t=JSON.stringify(p.pointSize);t!==b&&(w=Gr(p.pointSize),b=t);return w(y.getZoom())}return p.pointSize||2}));let v=null,T=null;return g.setFunctionUniform("pointOpacity",(function(){if(!p)return 1;if(Hr(p.pointOpacity)){const t=JSON.stringify(p.pointOpacity);t!==v&&(T=Gr(p.pointOpacity),v=t);return T(y.getZoom())}return p.pointOpacity||1})),this.ce(g,c),this.oe(g),g.Lt=n.mat4.copy([],g.localTransform),this.dt[e]=g,s(null,{id:e,mesh:[g]}),[g]}oe(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:s}=t.properties;this.he(e,n,s,r.Rt),t.setLocalTransform(e)}createI3DMMesh(t,e,r,s){if(this.gt[e]){const t=this.gt[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.lt[e]||s(null,{id:e,mesh:t}),t}const i=this.ot.kt(r.Rt),o=this.ue(r.le),{i3dm:a,featureTable:c,gltf:h,batchTable:u,batchTableBin:l,count:f}=t,d=c.INSTANCES_LENGTH,{rtcCenter:m,rtcCoord:p,projCenter:g}=t,y=this.fe(As,r,m,p);pr(y,ls,y);const b=n.mat4.getRotation(Os,y);n.quat.normalize(b,b);const w=n.mat4.getScaling(xs,y),v=n.mat4.fromScaling(Is,w),T=this.de(Ss,g,r),_=this.me(Ns),M=this.pe(ks,p),A=n.vec3.div(Rs,M,_),O=n.mat4.fromScaling(Ps,A),{POSITION:x,NORMAL_UP:I,NORMAL_RIGHT:S,SCALE:E,SCALE_NON_UNIFORM:C}=a,N={"instance_vectorA":new Float32Array(4*d),"instance_vectorB":new Float32Array(4*d),"instance_vectorC":new Float32Array(4*d),"aPickingId":new Uint16Array(d)};for(let t=0;t<d;t++)N.aPickingId[t]=t;const k=new Float32Array(3),R=new Float32Array(3),P=[],L=new Float32Array(1),B=new Float32Array(3),U=[],D=[],F=[],j=[];!function(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?Pe.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)}}(x,((t,e)=>{I?(An(R,S,e),An(k,I,e),n.vec3.cross(P,R,k),n.vec3.normalize(P,P),It(U,R,0),It(U,k,1),It(U,P,2),n.quat.fromMat3(D,U),n.quat.normalize(D,D),n.quat.multiply(D,b,D)):n.quat.identity(D),E?(An(L,E,e),n.vec3.set(F,L[0],L[0],L[0])):C?(An(B,C,e),n.vec3.set(F,...B)):n.vec3.set(F,1,1,1),n.mat4.fromRotationTranslationScale(j,D,t,F),On(N.instance_vectorA,e,j,0),On(N.instance_vectorB,e,j,1),On(N.instance_vectorC,e,j,2)}));const q={};for(const t in N)q[t]={buffer:this.ht.buffer({dimension:N[t].length/d,data:N[t]}),divisor:1};const z=i.shader||"pbr";let H=0,G=!0;const V=[],J=[];return gn(h,((t,s,i,a)=>{const h=this.ge(t,s,i,a,r,!0,z,J),{geometry:b,material:w}=h;w&&!w.isReady()&&(G=!1,H++);const _=new n.reshader.InstancedMesh(q,d,b,w);h.refMeshes||(h.refMeshes=new Set,h.refMeshes.add(_.uuid)),_.properties.magic="i3dm",_.properties.id=e,_.properties.count=f,_.properties.batchTable=u,_.properties.batchTableBin=l,_.properties.serviceIndex=r.Rt,_.properties.rtcCoord=p,_.properties.rtcCenter=m,_.properties.projCenter=g,_.properties.node=r;const M=this.ye(t,b,w,r.Rt,a);t.compressed_int16_params&&this.ce(_,t.compressed_int16_params),this.be(_,t.attributes);const A=n.mat4.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.mat4.multiply(A,A,t.matrices[e]);n.mat4.multiply(A,o,A),n.mat4.multiply(A,O,A),c.EAST_NORTH_UP||I?n.mat4.multiply(A,v,A):n.mat4.multiply(A,y,A),_.setPositionMatrix(A),this.ie(_,T),_.setDefines(M),_.properties.polygonOffset={offset:0,factor:0},V.push(_),delete t.attributes,_.Lt=n.mat4.copy([],_.localTransform)})),qs(J),G?(this.gt[e]=V,s(null,{id:e,mesh:V})):(this.lt[e]={meshes:V,count:H},V.we=s),V}ie(t,e){const{rtcCoord:r,node:s,projCenter:i}=t.properties;e||(e=this.de(Ss,i,s));const o=this.ot.kt(s.Rt),a=t.localTransform||[];if(o.coordOffset){const t=this.ve(As,s.Rt,r);n.mat4.multiply(a,t,e)}else n.mat4.copy(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||fs}de(t,e,r){n.mat4.fromScaling(t,this.me(Ns));const s=this.Te(_s,e,r.Rt);return n.mat4.multiply(t,n.mat4.fromTranslation(Es,s),t),t}createB3DMMesh(t,e,r,i){if(t.gltf&&(t.gltf.transferables=null),this.ft[e]||this.lt[e]){const t=this.ft[e];return console.warn(`mesh with id(${e}) was already created.`),this.lt[e]||i(null,{id:e,mesh:t}),t}let o;if(r.maxExtent){const t=new s.Extent(r.maxExtent).convertTo((t=>this._pointToPrj(t)));o=[t.xmin,t.ymin,t.xmax,t.ymax]}const a=t.gltf,{projCenter:c}=a.extensions.MAPTALKS_RTC,{rtcCoord:h,center:u}=a.extensions.CESIUM_RTC,l=a.asset.sharePosition,f=this.ue(r.le),d=this._e(Ss,l,h,u,c,r),m=this.ot.kt(r.Rt);let p=m.shader||"pbr";if(m.unlit)p="phong";else if(a.materials)for(let t=0;t<a.materials.length;t++)if(a.materials[t]&&a.materials[t].extensions&&a.materials[t].extensions.KHR_materials_unlit){p="phong";break}const g=[],y=[];let b=0,w=!0;return gn(a,((s,i,a,v)=>{const T=this.ge(s,i,a,v,r,!1,p,g),{geometry:_,material:M}=T;M&&!M.isReady()&&(w=!1,b++);const A=new n.reshader.Mesh(_,M);T.refMeshes||(T.refMeshes=new Set,T.refMeshes.add(A.uuid)),A.properties.magic="b3dm",A.properties.id=e,A.properties.node=r,t.batchTable&&(A.properties.batchTable=t.batchTable,A.properties.batchTableBin=t.batchTableBin),A.properties.count=t.featureTable&&t.featureTable.BATCH_LENGTH||0,A.properties.serviceIndex=r.Rt;const O=this.ye(s,_,M,r.Rt,v);A.setDefines(O);const x=s.compressUniforms;if(x)for(const t in x)A.setUniform(t,x[t]);s.compressed_int16_params&&this.ce(A,s.compressed_int16_params),this.be(A,s.attributes),o&&(O.USE_MAX_EXTENT=1,A.setUniform("maxPrjExtent",o)),A.hasFunctionUniform("polygonOpacity")||A.setFunctionUniform("polygonOpacity",(function(){return vt(m.opacity)?m.opacity:1})),A.hasFunctionUniform("polygonFill")||A.setFunctionUniform("polygonFill",(function(){return Pt([],m.polygonFill||os)})),A.material.hasFunctionUniform("hsv")||A.material.setFunctionUniform("hsv",(function(){return m.hsv||as}));const I=n.mat4.identity([]);if(l&&s.matrices&&s.matrices.length)for(let t=0;t<s.matrices.length;t++)n.mat4.multiply(I,I,s.matrices[t]);l&&n.mat4.multiply(I,f,I),A.properties.node=r,A.properties.projCenter=c,A.properties.nodeMatrix=I,A.properties.isSharedPosition=l,A.properties.rtcCoord=h,A.properties.rtcCenter=u,this.se(A,d),y.push(A),delete s.attributes,A.Lt=n.mat4.copy([],A.localTransform)})),qs(g),w?(this.ft[e]=y,i(null,{id:e,mesh:y})):(this.lt[e]={meshes:y,count:b},y.we=i),y}Me(t){const e=this.ot.Ae(t.id);if(!e||t.te)return;let r,s,i,o;if(e.obbox)r=e.boxPosition,s=Bs,i=e.boxCenter,o=Fs;else if(e.sphereBox){const t=e.sphereBox[0],n=e.sphereBox[1];r=Us.vertices,s=Us.indices,i=t,o=[n,n,n]}const a=new n.reshader.Geometry({POSITION:r},s,0,{primitive:"lines",positionAttribute:"POSITION"}),c=new n.reshader.Mesh(a,new n.reshader.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),h=[];n.mat4.fromRotationTranslationScale(h,Ds,i,o),c.localTransform=h,c.Lt=n.mat4.copy([],h),c.properties.node=t,t.te=c}Oe(t){t.te&&(t.te.geometry.dispose(),t.te.dispose(),delete t.te)}ce(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)}se(t,e){const{isSharedPosition:r,rtcCoord:s,rtcCenter:i,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=this._e(e||Ss,r,s,i,o,c));const h=t.localTransform||n.mat4.identity([]);n.mat4.multiply(h,e,a);const u=this.ot.kt(c.Rt);if(u.coordOffset){const t=this.ve(As,c.Rt,s);n.mat4.multiply(h,t,h)}t.setLocalTransform(h),t.properties.heightOffset=u.heightOffset||0,t.properties.coordOffset=u.coordOffset&&u.coordOffset.slice(0)||fs}_e(t,e,r,s,i,o){if(e){const e=this.pe(ks,r),i=n.mat4.fromScaling(Ms,e),a=this.fe(As,o,s,r);n.mat4.multiply(t,a,i)}else this.he(t,r,i,o.Rt);return t}be(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)}}fe(t,e,r,s){const i=this.getMap(),o=this.ot.kt(e.Rt).heightOffset||0,a=e.matrix?n.mat4.copy(t,e.matrix):n.mat4.identity(t);if(r){pr(a,n.vec3.transformMat4(gs,r,a),a)}const c=function(t,e,n,r,s,i,o){e=nn(yr,e);const a=Cn(yr,e[0]*xr,e[1]*xr,e[2]),c=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(br,n),h=r.ellipsoid;let u;u=0===dn(c)?rn(wr,0,0,-6378137):Bn(wr,c),Ar.x=u[0],Ar.y=u[1];const l=r.project(Ar,Or);vr[0]=l.x/s,vr[1]=l.y/s,vr[2]=(u[2]+o)*i;const f=gr(a,h,Tr),d=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],h=e[7],u=e[8],l=e[9],f=e[10],d=e[11],m=e[12],p=e[13],g=e[14],y=e[15],b=n*a-r*o,w=n*c-s*o,v=n*h-i*o,T=r*c-s*a,_=r*h-i*a,M=s*h-i*c,A=u*p-l*m,O=u*g-f*m,x=u*y-d*m,I=l*g-f*p,S=l*y-d*p,E=f*y-d*g,C=b*E-w*S+v*I+T*x-_*O+M*A;return C?(C=1/C,t[0]=(a*E-c*S+h*I)*C,t[1]=(s*S-r*E-i*I)*C,t[2]=(p*M-g*_+y*T)*C,t[3]=(f*_-l*M-d*T)*C,t[4]=(c*x-o*E-h*O)*C,t[5]=(n*E-s*x+i*O)*C,t[6]=(g*v-m*M-y*w)*C,t[7]=(u*M-f*v+d*w)*C,t[8]=(o*S-a*x+h*A)*C,t[9]=(r*x-n*S-i*A)*C,t[10]=(m*_-p*v+y*b)*C,t[11]=(l*v-u*_-d*b)*C,t[12]=(a*O-o*I-c*A)*C,t[13]=(n*I-r*O+s*A)*C,t[14]=(p*w-m*T-g*b)*C,t[15]=(u*T-l*w+f*b)*C,t):null}(_r,f),m=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}(Mr,n);return pr(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],u=t[9],l=t[10],f=e[0],d=e[1],m=e[2],p=e[3],g=e[4],y=e[5],b=e[6],w=e[7],v=e[8],T=r*f+o*d+h*m,_=s*f+a*d+u*m,M=i*f+c*d+l*m,A=r*p+o*g+h*y,O=s*p+a*g+u*y,x=i*p+c*g+l*y,I=r*b+o*w+h*v,S=s*b+a*w+u*v,E=i*b+c*w+l*v;return n[0]=T,n[1]=_,n[2]=M,n[3]=0,n[4]=A,n[5]=O,n[6]=x,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}(d,m,t),vr,t),t}(a,s,a,i.getProjection(),i.getGLRes(),this.St,o),h=function(t,e){return rn(t,e[12],e[13],e[14]),t}(_s,c);let u=this.ot.options.offset;if(bt(u)){const t=this.ot.Ae(e.id).boxCoord;u=u.call(this.ot,t)}return n.vec3.set(Ts,u[0],u[1],0),n.vec3.sub(h,h,Ts),pr(c,h,c),c}ve(t,e,r){const s=this.ot.kt(e);if(!s.coordOffset)return null;const i=this.getMap(),o=i.getGLRes();ys.set(r[0],r[1]);const a=i.coordToPointAtRes(ys,o,ws),c=s.coordOffset,h=ys.set(r[0]+c[0],r[1]+c[1]),u=i.coordToPointAtRes(h,o,vs),l=u.x-a.x,f=u.y-a.y,d=this.St,m=n.vec3.set(Ts,l,f,(c[2]||0)*d);return n.mat4.fromTranslation(t,m)}createCMPTMesh(t,e,n,r){if(this.yt[e]){const t=this.yt[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.yt[e]=i,r(null,{id:e,mesh:i}),i}ye(t,e,n,r,s){const i=("phong"===(this.ot.kt(r).shader||"pbr")?this.Gt:this.Vt).getGeometryDefines(e);s.asset&&"S3M"===s.asset.generator&&this.xe(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.ot.Ie&&(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.ae(i,t.compressed_int16_params);return yt(i,t.compressDefines),i}ae(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))}qt(t){const e=this.ot.getRenderer();e&&e.updateMaskDefines(t)}xe(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)}ge(t,e,r,s,i,o,a,c){let h=!1;s.asset&&"S3M"===s.asset.generator&&(h=!0,s.extensions=s.extensions||{});const u=s.url+"-"+e+"-"+r;if(this.bt[u])return this.bt[u];let l,f;c.push(t);const d=s.materials&&s.materials[t.material],m=s.extensions&&s.extensions.KHR_techniques_webgl,p=this.ot.kt(i.Rt);if(m&&d.extensions&&d.extensions.KHR_techniques_webgl){const e=this.Se(t,s,o,h);l=e.material,f=e.geometry,p.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.Ee(t,o,Ls);const e=p.material;l=this.Ce(t.material,s,a,e||cs,c,p)}l&&(l.setFunctionUniform("alphaTest",(function(){const t=p.alphaTest;return gt(t)?.1:t})),l.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}))),l&&!l.isReady()?l.Ne=i.id:l||(l=new n.reshader.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const g={geometry:f,material:l};return f.properties.url=u,this.bt[u]=g,g}Se(t,e,n,r){const{geometry:s,material:i}=this.xt.createMesh(t,e,n,r);return{geometry:s,material:i}}Ee(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=Zr(this.ht,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.reshader.Geometry(a,c,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":Wr(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.ht,{excludeElementsInVAO:e}),h}he(t,e,r,s){const i=n.mat4.identity(t),o=this.me(hs);return this.Te(_s,r,s),n.mat4.translate(i,i,_s),n.mat4.scale(i,i,o),i}Te(t,e,r){const s=this.St;ys.x=e[0],ys.y=e[1];const i=this._prjToPoint(ys);let o=this.ot.options.offset;bt(o)&&(o=o.call(this.ot,ys));const a=this.ot.kt(r).heightOffset||0;return n.vec3.set(t,i.x-o[0],i.y-o[1],s*e[2]+s*a),t}zt(t,e){const r=this.ot.ke(Cs,e);t.localTransform=n.mat4.multiply(t.localTransform,r,t.Lt)}pe(t,e){const r=this.getMap();ys.x=e[0],ys.y=e[1];const s=r.distanceToPointAtRes(100,100,r.getGLRes(),ys),i=this.St;return n.vec3.set(t,s.x/100,s.y/100,i),t}Yt(t){if(this.Vt)return;const e={x:0,y:0,width:()=>this.ct?this.ct.width:1,height:()=>this.ct?this.ct.height:1},r=[],s=[];this.$t=new n.reshader.MeshShader({vert:xn,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)=>n.mat4.multiply(s,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,e)=>n.mat3.fromMat4(r,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 i={},o=[];n.ContextUtil.fillIncludes(i,o,t);const a=this.It();this.Gt=new n.reshader.PhongShader({uniforms:o,defines:i,extraCommandProps:a}),this.Vt=new n.reshader.pbr.StandardShader({uniforms:o,defines:i,extraCommandProps:a}),this.Kt=new n.reshader.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.ct?this.ct.width:1,height:()=>this.ct?this.ct.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const c=this.ot;es(c.getRenderer().canvas,this.ht,c.getMap()),this.picking=new n.reshader.FBORayPicking(this.ut,{vert:this.Vt.vert,extraCommandProps:a,uniforms:this.Vt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.Re=new n.reshader.FBORayPicking(this.ut,{vert:xn,extraCommandProps:a,uniforms:this.$t.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}It(){return{viewport:{x:0,y:0,width:()=>this.ct?this.ct.width:1,height:()=>this.ct?this.ct.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}}}Jt(t){const e=this.getMap(),r=e.getLightManager(),s=(r&&r.getDirectionalLight()||{}).direction||[1,1,-1],i=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:i,lightDir:n.vec3.normalize(ds,s)}}Ct(){const t=this.getMap(),e=this.ot,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:s}=rs(n),i=ss(t,r,s),o=this.ot.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,yt(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}),yt(i,a),i}Ce(t,e,r,s,i,o){const a=e.materials&&e.materials[t];if(!a||!a.baseColorTexture&&!a.pbrMetallicRoughness)return null;const c=yt({},s);if(a.baseColorTexture){const t=e.textures[a.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.R(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.R(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.R(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.R(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 r=e.textures[t.baseColorTexture.index];if(r&&r.image&&r.image.color)c.baseColorFactor=c.baseColorFactor?n.vec4.multiply(c.baseColorFactor,c.baseColorFactor,r.image.color):r.image.color;else{const t=this.R(r,i);t&&(c.baseColorTexture=t,c.baseColorTexture.getREGLTexture(this.ht))}}if(gt(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),gt(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),a.metallicRoughnessTexture){const t=this.R(e.textures[a.metallicRoughnessTexture.index],i);t&&(c.metallicRoughnessTexture=t)}}}if(a.s3mMaterial)return new n.reshader.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.reshader.PhongMaterial(c);return t.unlit=void 0===o.unlit||!!o.unlit,t}let h=new n.reshader.pbr.StandardMaterial(c);"phong"===r&&(h=n.reshader.PhongMaterial.convertFrom(h));const u=a.pbrMetallicRoughness,l=u&&u.baseColorTexture&&u.baseColorTexture.extensions;return l&&l.KHR_texture_transform&&(h.set("khr_offset",l.KHR_texture_transform.offset||[0,0]),h.set("khr_rotation",l.KHR_texture_transform.rotation||0),h.set("khr_scale",l.KHR_texture_transform.scale||[1,1])),h.doubleSided=!(!o.doubleSided&&!a.doubleSided),h.once("complete",this.At),h}R(t,e){if(!t)return null;const r={type:t.type?Xr(t.type):"uint8",format:t.format?Yr(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=Jr(i.magFilter)),i.minFilter&&(r.min=$r(i.minFilter)),i.wrapS&&(r.wrapS=Kr(i.wrapS)),i.wrapT&&(r.wrapT=Kr(i.wrapT))),new n.reshader.Texture2D(r,this.Mt)}Ot({target:t}){const e=t.Ne,n=this.lt[e];if(n.count--,!n.count){const t=n.meshes;this.ft[e]=t,delete this.lt[e];const r=t.we;delete t.we,r(null,{mesh:n.meshes,id:e})}}me(t){const e=1/this.getMap().getGLRes(),n=this.St;return t[0]=t[1]=e,t[2]=n,t}Pe(t){return this.ot.Pe(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(),bs)}ue(t){return"Y"===t?Qr:"X"===t?ts:us}pick(t,e,n=3){const r=this.ot;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const s=[],i=this.Ct(),o=this.Le(this.picking,i,this.wt,t,e,n);o&&s.push(o);const a=this.Le(this.picking,i,this.Tt,t,e,n);a&&s.push(a);const c=this.Jt(),h=this.Le(this.Re,c,this.vt,t,e,n);return h&&s.push(h),s}Le(t,e,n,r,s,i){if(!n.getMeshes().length)return null;const o=this.ot,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:u,point:l,coordinate:f}=c,d=(0===h||h)&&t.getMeshAt(h);if(!d||!d.geometry)return null;const m=d.properties;l&&l.length&&(l[0]=Math.round(1e5*l[0])/1e5,l[1]=Math.round(1e5*l[1])/1e5,l[2]=Math.round(1e5*l[2])/1e5);const p={batchId:u},g=o.options.services,y=g&&g[d.properties.serviceIndex];if(y&&y.debug&&(p.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=u;for(const s in t)void 0!==t[s].byteOffset?p[s]=Qn(t[s],e,n,r):p[s]=t[s][r]}return{service:d.properties.serviceIndex,data:p,point:l,coordinate:f}}highlight(t){this.Ut=t;const e=this.ot.getRenderer();this.Dt=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.Ut=null;const t=this.ot.getRenderer();this.Dt=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Ft=t;const e=this.ot.getRenderer();this.jt=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Ft=null;const t=this.ot.getRenderer();this.jt=t.getFrameTimestamp(),t.setToRedraw(!0)}Be(){if(!this.Et)return[];const t={},e=[];for(const n in this.Et){const r=this.Et[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 qs(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 zs=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")},Hs=zs(),Gs=Hs.gl_trans__coders=Hs.gl_trans__coders||{};function Vs(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}Gs.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=Hs.gl_trans__coders=Hs.gl_trans__coders||{};let i=`${r}\n const _____getGlobal = ${zs.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},Gs.registerTranscoder=function(t,e){Gs[t]=e},Gs.getTranscoder=function(t){return Gs[t]};const Js=[];class $s{constructor(t,e,n,r,s){this.ot=r,this.Ue=t,this.Rt=e,this.De=s,this.Fe=n.version,t.indexOf("i3s:tileset:")<0?(this.Fe<=1.6?this.je="root":this.je=0,n.version=this.Fe):(this.je=t.substring(12),this.Fe>1.6&&(this.je=parseInt(this.je))),this.Ue=t,this.qe=n}load(){const t=this.qe,e=t.layerScene.baseUrl;if(this.Fe<=1.6)return t[this.je]&&t[this.je].lodSelection?(this.ze=t[this.je],this.He()):new Promise((n=>{let r=e+"/nodes/"+this.je;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.De(this.Rt,r,(()=>{this.ze=t[this.je],n(this.He())}))}));if(this.Fe>=1.7){if(t[this.je])return this.ze=t[this.je],this.He();const n=Math.floor(this.je/t.nodesPerPage);return new Promise((r=>{let s=e+"/nodepages/"+n;t.layerScene.eslpk&&(s+=".json"),this.De(this.Rt,s,(()=>{this.ze=t[this.je],r(this.He())}))}))}return null}getTileset(){return this.Ge}getChildrenURL(){return this.Ve}He(){const t=this.qe,e=t.layerScene.baseUrl,n=this.ze.children,r=[],s={};if(n)for(let i=0;i<n.length;i++)if(this.Fe<=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.De(this.Rt,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.De(this.Rt,r,(()=>{n()}))})),r.push(s[a]))}return r.length?Promise.all(r).then((()=>this.Je())):this.Je()}Je(){return Promise.resolve(this.$e())}Ke(t){Vs(this.qe,t)}$e(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.Xe(this.ze,!0)}}Xe(t){const e=this.ot.getRenderer(),n=this.qe.projection,r=!n||n&&4326===n.wkid,s=this.Fe,i=this.qe,o=t,a=o.obb,c=o.mbs,h={};let u;if(c)u=rn([],c[0],c[1],c[2]),r||(u=e.Ye(u,u)),u=Ks([],u[0],u[1],u[2]),h.sphere=[...u,c[3]];else if(a){u=rn([],a.center[0],a.center[1],a.center[2]),r||(u=e.Ye(u,u)),u=Ks([],u[0],u[1],u[2]);const t=function(t,e,n){const r=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,h=n*o,u=r*o,l=r*a,f=s*o,d=s*a,m=s*c,p=i*o,g=i*a,y=i*c;return t[0]=1-l-m,t[3]=u-y,t[6]=f+g,t[1]=u+y,t[4]=1-h-m,t[7]=d-p,t[2]=f-g,t[5]=d+p,t[8]=1-h-l,t}([],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]}(u,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];rn(Js,n,s,i);const o=dn(Js);h.sphere=[...u,o]}let l=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){l=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&&(l=f/o.lodSelection[t].maxError);(l===1/0||isNaN(l))&&(l=1e5);const d=16*l,m=function(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}([]),p=m,g=o.children;let y;if(g){y=[];const t=this.qe;for(let e=0;e<g.length;e++){const n=s<=1.6?g[e].id:g[e];if(!t[n]){y=null;break}y.push(this.Xe(t[n]))}}const b={refine:"REPLACE",boundingVolume:h,transform:p,geometricError:d};return s<=1.6?t.lodSelection?t.geometryData&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}):b.content={uri:"i3s:tileset:"+(t.id||t.index)}:g&&g.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.ze}}function Ks(t,e,n,r){return Cn(t,Tt(e),Tt(n),r)}const Xs=!!Gs.ktx2,Ys=n.mat4.identity([]),Ws=(()=>{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 Zs(t){return t.indexOf("i3s:mesh")>=0}const Qs=9;function ti(t,e,n,r,s){const i=e.layerScene.eslpk,o=function(t,e){const n=e.substring(Qs);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,h=[];let u=!1;const l=Ys;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,o=(e.layerScene.store||{}).textureEncoding,l=t[f.definition],{geometryBuffers:m}=l;u=r&&2===m.length;const p=Gs.draco&&u?m[1]:m[0],g=Gs.draco&&u?1:0;let y=c+`/nodes/${f.resource}/geometries/`+g;i&&(y+=".bin");const b={geometry:{url:y,info:p}};if(s&&Ws&&u&&!Gs.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const w=e.layerScene.materialDefinitions,v=e.layerScene.textureSetDefinitions;let T,_=0;if(d&&(_=w[d.definition]),w){T=function(t,e,n,r,s,i,o){const a=JSON.parse(JSON.stringify(e));return ei(t,a,n,r,s,i,o),a}(o,_,v,c,d.resource,n,e.layerScene.eslpk)}else T={pbrMetallicRoughness:{metallicFactor:0}};b.material=T,h.push(b)}return{dracoCompression:u,meshes:h,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:l}}function ei(t,e,n,r,s,i,o){for(const a in e)if(e[a]&&e[a].textureSetDefinitionId>=0){const c=n[e[a].textureSetDefinitionId],h="images/"+c.formats[0].format,u=ri(c.formats,i,t),l={url:r+`/nodes/${s}/textures/${u.name}`,factor:void 0===e[a].factor?1:e[a].factor,format:u.format,mimeType:h};if(o){let t="";switch(u.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=u.format}l.url+="."+t}e[a]=l}else wt(e[a])&&ei(t,e[a],n,r,s,i,o)}const ni={"image/jpeg":"jpg","image/jpg":"jpg","image/png":"jpg","image/vnd-ms.dds":"dds","image/ktx":"jpg"};function ri(t,e,n){if(n&&n.length){const e=n[n.length-1],r=ni[e];if(r)for(let e=0,n=t.length;e<n;e++){if(t[e].format===r)return t[e]}else console.error("i3s not find texture format type from:",ni,"current textureEncoding:",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&&Xs)return t[n]}return null}const si=new s.Coordinate(0,0),ii=new s.Coordinate(0,0),oi=new Set,ai=[],ci=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.We(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.We(t,e),this}We(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*(s.Browser.mobile?32:1024)*1024,(t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)}));let hi=0;class ui extends(n.MaskRendererMixin(s.renderer.CanvasRenderer)){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>ci.max&&ci.setMaxSize(e),this.tileCache=ci,hi++,this.tilesLoading={},this.Ze={},this.Qe=[],this.De=(...t)=>this.tn.call(this,...t)}getAnalysisMeshes(){if(!this.painter)return ai;const t=this.painter.getPaintedMeshes();if(!t)return ai;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:s}=t;return n.length&&kt(e,n.filter((t=>!(!t||!t.geometry)))),r.length&&kt(e,r.filter((t=>!(!t||!t.geometry)))),s.length&&kt(e,s.filter((t=>!(!t||!t.geometry)))),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.Qe.length||super.needToRedraw())}getFrameTimestamp(){return this.nn}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.nn=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.rn(),this.sn(e);const{selectedTiles:o,leaves:a,requests:c}=this.an(r,s);c.length&&this.loadTiles(c),this.cn(o,a,e),this.hn(),c.length||this.completeRender()}an(t,e){let n=[];this.un();let r=0;const s=this.ln(),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 u=this.getCachedTile(c.id);if(this.dn(c.id)?(r++,h=a=!0,this.tilesLoading[c.id].current=!0):u?(this.getTileOpacity(u)<1&&(h=a=!0),o=!0,s.selected=!0,s.data=u):this.painter.has(c)||(h=a=!0,n.push(c)),!h)continue;if(this.mn(s))o=!0;else{this.pn(s).length&&(o=!0)}}let c=[],h={};if(o&&({selectedTiles:c,leaves:h}=this.gn(t)),n.length>1&&(n.sort(li),s)){const t=s-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c,leaves:h}}gn(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.yn===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.yn=s.length}for(let t=0;t<o.length;t++)s.push(o[t])}return{selectedTiles:e,leaves:n}}mn(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}pn(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.bn+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.wn(s[i],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else s[i].bn<=n&&r.push(s[i])}}return e}cn(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.kt(s.Rt);s.te&&i.debug&&!Array.isArray(i.debug)&&r.push(s.te)}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.Ae(t),n=e&&e.node;n&&n.te&&r.push(n.te)}}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}),this.tileCache.shrink()}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.vn(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.Rt,r=this.Tn[n];return new $s(e,n,r,this.layer,this.De).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Bt(e)&&!Zs(e)&&(e=t.baseUrl+e),this.vn(e,null,t),null}vn(t,e,r){let s=this.h;s||(s=n.reshader.Util.getSupportedFormats(this.gl.gl||this.gl),this.h=s);const i=this.layer.kt(r.Rt);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._n[r.Rt]),arraybuffer:e,rootIdx:r.Rt,upAxis:r.le,transform:r.matrix,supportedFormats:s};if(Zs(t)){const e=this.Tn[r.Rt];if(o.projection=e.projection,o.i3sInfo=ti(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=yt({},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.Qe.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}Me(t){this.painter&&this.painter.Me(t)}Oe(t){this.painter&&this.painter.Oe(t)}sn(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.Qe.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.Qe.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Mn(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Mn(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Mn(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Mn(t,e,n,r)})),n++}}Mn(t,e,n,r){if(n)this.onTileError(n,e);else{const n=this.An(r);e.memorySize=n,this.onTileLoad(t,e)}}An(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.An(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.On(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.Ie=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.xn(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)||oi.has(i)||(console.warn("failed to load 3d tile: "+r),console.warn(t),oi.add(i)),delete this.tilesLoading[e.id],(!this.layer.options.onlyCacheNoContentTileWhenError||t&&!s.Util.isNoContentHttpCode(t.status))&&this.In(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]&&e[n].isValid&&e[n].isValid()&&t.push(e[n]);const n=this.painter.getCurrentI3DMMeshes();for(const e in n)n[e]&&n[e].isValid&&n[e].isValid()&&t.push(n[e]);return t}In(t,e){const n={loadTime:s.Util.now(),current:!0,error:e,node:t};n.renderer=this,this.tileCache.add(t.id,n)}On(t){const e={loadTime:s.Util.now(),current:!0,node:t};e.renderer=this,this.tileCache.add(t.id,e)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.Ze[e]}un(){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},r=this.canvas.gl&&this.canvas.gl.wrap;r?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.Sn(this.canvas,e)),this.regl=this.regl||n.createREGL({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),this.prepareWorker(),r&&(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 js(this.regl,t),this.layer.En(),this.layer.fire("contextcreate",{regl:this.regl})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new $e("@maptalks/3dtiles",t.id,n.reshader.Util.supportNPOT(this.regl)));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=yt({},r),delete r.offset;const s=t.options.spatialReference;r.projection=s&&s.coordType||s&&s.projection||t.getSpatialReference().getProjection().code;const i=this.layer.getId();e.addLayer(i,r,(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),hi--,hi||ci.reset(),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.hn(!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}hn(t){this.Cn||(this.Cn=Date.now());const e=Date.now();if(!t&&e-this.Cn<this.layer.options.retireInterval)return;this.Cn=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]]}ln(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}Sn(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}dn(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 Wn(t,e,0,n)}rn(){if(!this.Nn)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.Nn){const s=this.Nn[r];if("pending"===s.status)continue;s.status="pending";const i=s.rootIdx,o=Ut(this.layer.kt(i).fetchOptions);if(n.push(me.getJSON(r,o).then((t=>{delete this.Nn[r];const e=this.Tn[i];if(e){t.nodes?Vs(e,t.nodes):(e[t.id]=t,Vs(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)}tn(t,e,n){this.Nn||(this.Nn={}),this.Nn[e]=this.Nn[e]||[],this.Nn[e].rootIdx=t,this.Nn[e].push(n),this.setToRedraw()}xn(t,e,n){this.Tn||(this.Tn=[]);const r=e.Rt;this.Tn[r]||(this.Tn[r]={});const s=this.Tn[r],i=this.layer.kt(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),t.spatialReference&&4490===t.spatialReference.wkid&&(console.warn("i3s spatialReference is 4490,auto set spatialReference to 4326,This may cause some location issues, please ensure that your service is 4326"),t.spatialReference.wkid=4326),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 $s(s,n,i,t,o).load()}(this.layer,t,r,0,n,s,this.De).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.Ut||(this.Ut=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Ut[n];r||(r=this.Ut[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Ut[e];n||(n=this.Ut[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.Ut)}cancelHighlight(t,e){if(!this.Ut)return;const n=this.Ut[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.Ut[t]=null),this.painter.highlight(this.Ut)}}cancelAllHighlight(){delete this.Ut,this.painter.cancelAllHighlight()}showOnly(t){if(this.Ft||(this.Ft=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Ft[n];r||(r=this.Ft[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Ft[e];n||(n=this.Ft[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.Ft)}cancelShowOnly(){delete this.Ft,this.painter.cancelShowOnly()}Be(){return this.painter?this.painter.Be():[]}Ye(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.kn();return si.set(e[0],e[1]),n.unproject(si,ii),t[0]=ii.x,t[1]=ii.y,t}return si.set(e[0],e[1]),n.getProjection().unproject(si,ii),t[0]=ii.x,t[1]=ii.y,t}Rn(t,e){const n=this.kn();return si.set(e[0],e[1]),n.project(si,ii),t[0]=ii.x,t[1]=ii.y,t}Pn(t,e){const n=this.kn();return si.set(e[0],e[1]),n.unproject(si,ii),t[0]=ii.x,t[1]=ii.y,t}kn(){const t=this.getMap().options.spatialReference.coordType;if(!t)throw new Error("Missing coordType in map spatialReference.");return this.Ln||(this.Ln=s.SpatialReference.getProjectionInstance(t)),this.Ln}}function li(t,e){return t.Qt-e.Qt}function fi(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function di(t,e,n){return Math.sqrt(function(t,e,n){const r=sn(mi,n,t),s=fi(pi,e,0),i=fi(gi,e,1),o=fi(yi,e,2),a=dn(s),c=dn(i),h=dn(o);cn(s,s),cn(i,i),cn(o,o);const u=bi;u[0]=hn(r,s),u[1]=hn(r,i),u[2]=hn(r,o);let l,f=0;u[0]<-a?(l=u[0]+a,f+=l*l):u[0]>a&&(l=u[0]-a,f+=l*l);u[1]<-c?(l=u[1]+c,f+=l*l):u[1]>c&&(l=u[1]-c,f+=l*l);u[2]<-h?(l=u[2]+h,f+=l*l):u[2]>h&&(l=u[2]-h,f+=l*l);return f}(t,e,n))}const mi=[],pi=[],gi=[],yi=[],bi=[];const wi=2*Math.PI;class vi{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+=wi,n<0&&(n+=wi)),(n>s||Vn(n,s,1e-14))&&(n<i||Vn(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 Ti=[0,0,1];function _i(t,e){return Cn(e,t[0],t[1],t[2])}class Mi{constructor(t,e){this.normal=n.vec3.copy([],t),this.distance=e}static fromPointNormal(t,e,r){const s=-n.vec3.dot(e,t);return n.vec3.copy(r.normal,e),r.distance=s,r}}const Ai=[],Oi=[],xi=[],Ii=[],Si=[],Ei=[],Ci=[],Ni=[],ki=[],Ri=[],Pi=new Mi([1,0,0],0),Li=[];class Bi{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new vi(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let r=0;if(!vi.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,s=this.northeastCornerCartesian,i=this.westNormal,o=this.southNormal,a=this.eastNormal,c=this.northNormal,h=n.vec3.subtract(Li,t,e),u=n.vec3.dot(h,i),l=n.vec3.dot(h,o),f=n.vec3.subtract(Li,t,s),d=n.vec3.dot(f,a),m=n.vec3.dot(f,c);u>0?r+=u*u:d>0&&(r+=d*d),l>0?r+=l*l:m>0&&(r+=m*m)}const s=e[2],i=this.minimumHeight,o=this.maximumHeight;if(s>o){const t=s-o;r+=t*t}else if(s<i){const t=i-s;r+=t*t}return Math.sqrt(r)}computeBox(t){const e=this;_i(vi.southwest(t,Oi),e.southwestCornerCartesian),_i(vi.northeast(t,Oi),e.northeastCornerCartesian),Ai[0]=t.west,Ai[1]=.5*(t.south+t.north),Ai[2]=0;const r=_i(Ai,xi),s=n.vec3.cross(Si,r,Ti);n.vec3.normalize(e.westNormal,s),Ai[0]=t.east;const i=_i(Ai,Ni),o=n.vec3.cross(Si,Ti,i);n.vec3.normalize(e.eastNormal,o);const a=n.vec3.subtract(Si,r,i),c=n.vec3.normalize(Ii,a),h=t.south;let u;if(h>0){Ai[0]=.5*(t.west+t.east),Ai[1]=h;const r=_i(Ai,ki);n.vec3.copy(Ri,c);const s=Mi.fromPointNormal(e.southwestCornerCartesian,e.westNormal,Pi);Ui(ki,Ri,s,e.southwestCornerCartesian),u=zn(r,Ei)}else u=Hn(vi.southeast(t,Oi),Ei);const l=n.vec3.cross(Ci,u,a);n.vec3.normalize(e.southNormal,l);const f=t.north;let d;if(f<0){Ai[0]=.5*(t.west+t.east),Ai[1]=f;const r=_i(Ai,ki);n.vec3.scale(Ri,c,-1);const s=Mi.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,Pi);Ui(ki,Ri,s,e.northeastCornerCartesian),d=zn(r,Ei)}else d=Hn(vi.northwest(t,Oi),Ei);const m=n.vec3.cross(Ci,a,d);n.vec3.normalize(e.northNormal,m)}}function Ui(t,e,r,s){const i=t,o=e,a=r.normal,c=n.vec3.dot(a,o);if(Math.abs(c)<1e-15)return;const h=(-r.distance-n.vec3.dot(a,i))/c;return h<0?void 0:(s=n.vec3.scale(s,o,h),n.vec3.add(s,i,s))}function Di(t){return[t.xmin,t.ymin,t.xmax,t.ymax]}const Fi=s.BBOXUtil,ji={"services":[],"maxGPUMemory":s.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"debug":!1,"meshLimitPerFrame":1,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"onlyCacheNoContentTileWhenError":!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"]},qi=[0,0,0],zi=[0,0,0],Hi=[0,0,0],Gi=[0,0,0],Vi=[0,0,0],Ji=[0,0,0],$i=[0,0,0],Ki=[1,1,1],Xi=[1,1,1],Yi=[0,0,0,0],Wi=[],Zi=new s.Coordinate(0,0),Qi=new s.Point(0,0),to=[0,0,0,0,0,0,0,0,0],eo=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],no=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ro=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],so=new s.Point(0,0),io=n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),oo=[0,0],ao=[0,0,0],co=[1,1,1],ho=[0,0,0],uo=[0,0,0],lo=[0,0,0,0],fo=[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 mo extends(n.MaskLayerMixin(s.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new mo(t.id,t.options):null}static getEnuTransform(t,e=[1,1,1],r=[0,0,0]){const s=Cn([],t[0]*Math.PI/180,t[1]*Math.PI/180,t[2]||0),i=gr(s,null,[]),o=n.quat.fromEuler([0,0,0,0],...r),a=n.mat4.fromRotationTranslationScale([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o,[0,0,0],e);return n.mat4.multiply(a,i,a)}constructor(t,e){super(t,e),this.isGeo3DTilesLayer=!0,this.Bn(),this.Un=[]}Bn(){const t=this.options.services.map((t=>t.url));this.Dn=this.Dn||{},this._n=this._n||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.Dn[n];void 0===r&&(r=this.Dn[n]=this._n.length),this._n[r]=yo(n,r,this.options.services[e])}this.fire("rootready",{roots:this._n.slice(0)})}showService(t){return this.updateService(t,{visible:!0}),this}hideService(t){return this.updateService(t,{visible:!1}),this}setToRedraw(){return this.Fn(),this}addService(t){return this.options.services=this.options.services||[],this.options.services.push(t),this.Bn(),this.Fn(),this}updateService(t,e){if(!e)return this;const n=this.options.services;let r=!1;n&&n[t]&&(r=!(vo(n[t].coordOffset,e.coordOffset)&&vo(n[t].heightOffset,e.heightOffset)&&vo(n[t].scale,e.scale)&&vo(n[t].rotation,e.rotation)),yt(n[t],e));const s=n[t].url,i=this.Dn[s],o=this._n&&this._n[i];return o&&(gt(e.visible)||(o.visible=e.visible),r&&o.version++),this.Fn(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.Dn[n];this._n[r]&&(this._n[r]=null),delete this.Dn[n],e.splice(t,1)}return this.Fn(),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),i=s%r;return t.replace(e.domainKey,n[i])}}return t}getExtent(t){if(!t&&0!==t){const t=new s.Extent;for(let e=0;e<this._n.length;e++){const n=this._n[e];if(n&&n.boundingVolume){const e=this.boundingVolumeToExtent(n);t._combine(e)}}return t}const e=this._n[t];return e&&e.boundingVolume?this.boundingVolumeToExtent(e):null}boundingVolumeToExtent(t){const e=t.boundingVolume.jn?io:t.matrix,r=this.getMap(),i="identity"===r.getProjection().code.toLowerCase(),o=this.getRenderer();if(t.boundingVolume.region){const e=t.boundingVolume.region;return new s.Extent(_t(e[0]),_t(e[1]),_t(e[2]),_t(e[3]))}if(t.boundingVolume.sphere){const a=t.boundingVolume.sphere,c=Bn([],n.vec3.transformMat4([0,0,0],a,e));i&&o.Rn(c,c);const h=a[3],u=r.locate(c,-h,h),l=r.locate(c,h,-h);return new s.Extent(u,l)}if(t.boundingVolume.box){const a=t.boundingVolume.box,c=n.vec3.transformMat4([0,0,0],a,e),h=new s.Coordinate(Bn([],c));i&&o.Rn(h,h);const u=a.slice(3);n.mat3.multiply(u,n.mat3.fromMat4([0,0,0,0,0,0,0,0,0],t.matrix),u);const l=n.vec3.length(u.slice(0,3)),f=n.vec3.length(u.slice(3,6)),d=n.vec3.length(u.slice(6,9)),m=Math.max(l,f,d),p=r.locate(h,-m,m),g=r.locate(h,m,-m);return new s.Extent(p,g)}return null}getRootTiles(){return this._n}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Fn(),{tiles:Wi};const e=this.getMap(),r=e.cameraPosition,s=e.pointAtResToDistance(r[2],0,e.getGLRes()),i=this.qn(r);this.zn=this.zn||[0,0,0],n.vec3.set(this.zn,Tt(i.x),Tt(i.y),s),this.Hn=Cn(this.Hn||[],this.zn[0],this.zn[1],this.zn[2]),this.Gn=2*Math.tan(.5*Tt(e.getFov()));const o=e.projViewMatrix;let a;if(e.getPitch()<=80){const t=e.getExtent(),n=t.getWidth()/2,r=t.getHeight()/2;t.xmin-=n,t.ymin-=r,t.xmax+=n,t.ymax+=r,a=Di(t)}const c=(this.getMasks()||[]).filter((t=>t&&t instanceof n.ClipOutsideMask));c.forEach((t=>{if(!t.maskGeoJSON&&t.toGeoJSON)try{t.maskGeoJSON=t.toGeoJSON();const e=t.getExtent();t.maskGeoJSON.bbox=Di(e)}catch(t){console.error(t)}}));const h={children:[],level:-1};let u=h;const l=[];for(let e=0;e<this._n.length;e++){const n=this._n[e];if(!n||!n.visible)continue;const r=n.service,s=[n],i=this.Vn(e);for(;s.length>0;){const e=s.pop();for(e.id||this.Jn(e);u.level>=e.bn;)u=u.parent;const n=this.$n(e,i,o,a,c);if(e.service=r,!(n===To.VISIBLE||n!==To.OUT_OF_FRUSTUM&&this.options.alwaysShowTopTiles&&wo(e))){let t=u;for(;t&&!t.content;)t=t.parent;n===To.SCREEN_ERROR_TOO_SMALL&&t&&t.content&&this.Kn(l,t);continue}e.Qt<1/0&&this.Xn(e);const h=this.wn(e,u);u.children.push(h);const f=e.children,d=f&&f.length,m=h.content;if(m&&(!d||n===To.SCREEN_ERROR_TOO_SMALL)&&this.Kn(l,h),n!==To.SCREEN_ERROR_TOO_SMALL&&d){m&&"add"===e.refine&&this.Kn(l,h),u=h;const n=f[0].parent;let r=!1;for(let i=0,o=f.length;i<o;i++){if(n){const e=t.getCachedTile(f[i].id);if(e&&e.error&&404!==e.error.status)continue;r=!0}else{r=!0,f[i].parent=e,f[i].le=e.le,f[i].baseUrl=e.baseUrl;const t=f[i].content&&(f[i].content.url||f[i].content.uri);t&&(Ct(t)||t.indexOf("i3s:")>=0?f[i].baseUrl=e.baseUrl:Bt(t)?f[i].content.url=e.baseUrl+t:f[i].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}s.push(f[i])}!r&&m&&this.Kn(l,h)}}}return{root:h,tiles:l}}Kn(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 po(n,e,r)<=0;if(n.box)return 0===go(n,e,r)}return!1}(this.zn,this.Hn,n,r)||t.push(e)}wn(t,e){return{id:t.id,node:t,children:[],level:t.bn,parent:e,content:t.content&&t.content.url}}Jn(t){const e=this.getId();t.id=e+":"+s.Util.GUID(),t.matrix=t.transform||n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),t.Yn=this.Wn(t),t.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(t)||(t.matrix=n.mat4.multiply(t.matrix,t.parent.matrix,t.matrix)),t.Rt=t.parent.Rt,void 0===t.bn&&(t.bn=t.parent.bn+1),t.maxExtent=t.parent.maxExtent),t.refine=t.refine&&t.refine.toLowerCase()||"replace",t.content&&!t.content.url&&t.content.uri&&(t.content.url=t.content.uri)}kt(t){return this._n[t].service}Zn(t){const e=t.boundingVolume;if(!e||e.jn&&!this.Qn(t))return;const r=this.kt(t.Rt),s=r.heightOffset||0,i=this.options.offset,o=bt(i)||i[0]||i[1],a=r.coordOffset||oo;if(!Array.isArray(a))throw new Error("service.coordOffset must be an array");if(!e.jn&&(!t.boundingVolume||!s&&n.mat4.exactEquals(t.matrix,io)&&!o&&a===oo))return;e.box&&e.region&&delete e.region;const{region:c,box:h,sphere:u}=e;if(e.coordOffset=[a[0],a[1]],e.heightOffset=s,c){e.originalVolume||(e.originalVolume=c.slice(0));const t=e.originalVolume,n=this.tr([_t(t[0]),_t(t[1])]);c[0]=Tt(n.x+a[0]),c[1]=Tt(n.y+a[1]);const r=this.tr([_t(t[2]),_t(t[3])]);c[2]=Tt(r.x+a[0]),c[3]=Tt(r.y+a[1]),c[4]=t[4]+s+(a[2]||0),c[5]=t[5]+s+(a[2]||0)}else if(h||u){e.originalVolume||(e.originalVolume=(h||u).slice(0));const r=h||u,i=e.originalVolume,o=n.vec3.transformMat4(qi,i,t.matrix),c=Bn(zi,o),l=this.tr([c[0]+a[0],c[1]+a[1]]);c[0]=l.x,c[1]=l.y,c[2]+=s+(a[2]||0),Cn(r,Tt(c[0]),Tt(c[1]),c[2])}e.jn=!0;try{t.extent=this.boundingVolumeToExtent(t)}catch(t){console.error(t)}}Qn(t){const e=t.boundingVolume,n=this.kt(t.Rt),r=n.heightOffset||0,s=n.coordOffset||oo;return e.coordOffset[0]!==s[0]||e.coordOffset[1]!==s[1]||e.heightOffset!==r}Wn(t){return void 0===t.geometricError||!t.boundingVolume}Xn(t){let e=t.parent;for(;e&&e.Yn&&!(e.Qt<=t.Qt);)e.Qt=t.Qt,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.Fn()}}onTilesetLoad(t,e,r){if(!t)return void console.warn("invalid tileset at : "+r);const s=(t.asset&&t.asset.gltfUpAxis||e&&e.le||"Y").toUpperCase();t.root.baseUrl=r.substring(0,r.lastIndexOf("/")+1);const i=r.indexOf("realspace/")>-1;0===e.bn&&t.asset&&t.asset.s3mType&&i&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root.le=s,e){const r=e.boundingVolume;yt(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",r&&(e.boundingVolume=r);const s=t.root.transform||n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);if(e.parent)o||(e.matrix=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.parent.matrix,s));else{const t=this.kt(e.Rt);t.ecefTransform?e.matrix=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t.ecefTransform,s):e.matrix=s}delete e.content,t.root.content&&(e.content=t.root.content),e.Yn=this.Wn(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.er(e)}this.Fn(),this.fire("loadtileset",{tileset:t,index:e&&e.Rt,url:r})}nr(t,e,n){if(!t.extent||!Fi)return!0;const r=t.extent;if(lo[0]=r.xmin,lo[1]=r.ymin,lo[2]=r.xmax,lo[3]=r.ymax,e){if(!Fi.bboxIntersect(lo,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||Fi.bboxInMask(lo,e))return!0}return!1}return!0}$n(t,e,n,r,s){if(!this.nr(t,r,s))return To.OUT_OF_FRUSTUM;if(t.Qt=1/0,0===t.bn||t.Yn)return this.er(t),To.VISIBLE;if(this.Zn(t),!this.rr(t,e,n))return To.OUT_OF_FRUSTUM;if(0===t.geometricError)return To.VISIBLE;let i=this.kt(t.Rt).maximumScreenSpaceError;null==i&&(i=16);let o=this.sr(t);return 0===o&&t.parent&&(o=.5*(t.parent.ir||0)),o>=i?To.VISIBLE:To.SCREEN_ERROR_TOO_SMALL}Pe(t,e){e||(e=new s.Point(0,0));const n=this.getMap();return n.coordToPointAtRes(t,n.getGLRes(),e)}rr(t,e,n){const r=t.id;let s=this.Un[r];const{boundingVolume:i}=t,o=i.region,a=i.box,h=i.sphere,u=this.ar(t.Rt),l=this.getRenderer();s&&s.version===u.version||(o?s=this.Un[r]=this.cr(t):a?s=this.Un[r]=this.hr(t):h&&(s=this.Un[r]=this.ur(t)),s.version=u.version,t.te&&(l.Oe(t.te),delete t.te));return this.kt(t.Rt).debug&&(this.Un[r].node=t,l.Me(t)),s.obbox?function(t,e,n){_(t);for(var r=0;r<6;r++)if(!T(c[r],e))return!1;return!0}(n,s.obbox):!!h&&function(t,e,n){_(t);for(var r=e[0],s=-e[1],i=0;i<6;i++)if(A(c[i],r)<s)return!1;return!0}(n,s.sphereBox)}cr(t){const e=this.getMap(),r=e.getGLRes(),i=t.boundingVolume.region;let{ws:o,en:a}=function(t){const e=t[0],n=t[1],r=t[2],s=t[3],i=t[4],o=t[5],a=Cn([],e,n,i),c=Cn([],r,s,o),h=Bn(a,a),u=Bn(c,c);return{ws:h,en:u}}(i);o=new s.Coordinate(o),a=new s.Coordinate(a);const c=e.coordToPointAtRes(o,r);c.z=e.altitudeToPoint(o.z,r);const h=e.coordToPointAtRes(a,r);h.z=e.altitudeToPoint(a.z,r);const u=[h.x,c.y,h.z,h.x,h.y,h.z,c.x,h.y,h.z,c.x,c.y,h.z,h.x,c.y,c.z,h.x,h.y,c.z,c.x,h.y,c.z,c.x,c.y,c.z],l=[(u[0]+u[18])/2,(u[1]+u[19])/2,(u[2]+u[20])/2],f=this.ar(t.Rt);t!==f||f.lr||(f.lr=l);const d=this.ke([],t),m=n.mat4.exactEquals(io,d);if(!m){n.vec3.transformMat4(l,l,d);const t=qi;for(let e=0;e<u.length;e+=3){let r=n.vec3.set(t,u[e],u[e+1],u[e+2]);m||(r=n.vec3.transformMat4(r,r,d)),u[e]=r[0],u[e+1]=r[1],u[e+2]=r[2]}}const p=e.pointAtResToCoord(new s.Point(l),r);p.z=(o.z+a.z)/2;const g=this.dr(u,l);for(let t=0;t<u.length;t++)u[t]-=l[t%3];return{obbox:g,boxPosition:u,boxCenter:l,boxCoord:p}}hr(t){const e=this.getRenderer(),r=this.getMap(),s="identity"===r.getProjection().code.toLowerCase(),i=r.getGLRes(),{boxCenter:o,boxCoord:a}=this.mr(t),c=t.boundingVolume.box,h=function(t,e,n){return function(t,e,n,r,s,i,o,a,c,h,u,l,f,d,m,p,g){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]=u||0,t[7]=0,t[8]=r||0,t[9]=a||0,t[10]=l||0,t[11]=0,t[12]=s||0,t[13]=c||0,t[14]=f||0,t[15]=g,t}(t,e[0],e[3],e[6],n[0],e[1],e[4],e[7],n[1],e[2],e[5],e[8],n[2],0,0,0,1)}([],this.pr(c,t.matrix),c),u=this.ke([],t),l=n.mat4.exactEquals(io,u);l||n.vec3.transformMat4(o,o,u);const f=[],d=qi;for(let t=0;t<fo.length;t+=3){d[0]=fo[t],d[1]=fo[t+1],d[2]=fo[t+2],n.vec3.transformMat4(d,d,h),Bn(d,d),s&&e.Rn(d,d);const o=Zi.set(d[0],d[1],d[2]);r.coordToPointAtRes(o,i,Qi);let a=n.vec3.set(d,Qi.x,Qi.y,r.altitudeToPoint(o.z,i));l||(a=n.vec3.transformMat4(a,a,u)),f[t]=a[0],f[t+1]=a[1],f[t+2]=a[2]}const m=this.dr(f,o);for(let t=0;t<f.length;t++)f[t]-=o[t%3];return{obbox:m,boxPosition:f,boxCenter:o,boxCoord:a}}ur(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),i=t.boundingVolume.sphere,o=i;let a=qi;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:Bn(a,o),r&&n.Rn(a,a);const c=new s.Coordinate(a),h=this.Pe(c,Qi).toArray();h[2]=e.altitudeToPoint(c.z,e.getGLRes());const u=this.gr(c);return{boxCenter:h,boxCoord:c,sphereBox:[h,i[3]*u[2]]}}dr(t,e){const r=bo(Vi,t,0,1,4,5),s=bo(Ji,t,0,3,4,7),i=bo($i,t,0,1,2,3);return[...e,...n.vec3.sub(qi,r,e),...n.vec3.sub(zi,s,e),...n.vec3.sub(Hi,i,e)]}mr(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),i=e.getGLRes(),o=t.boundingVolume.box.slice(0,3);Bn(o,o),r&&n.Rn(o,o);const a=new s.Coordinate(o),c=e.coordToPointAtRes(a,i);return{boxCenter:[c.x,c.y,e.altitudeToPoint(a.z,i)],boxCoord:a}}ke(t,e){const r=this.ar(e.Rt),s=this.kt(e.Rt),i=r.lr,o=n.mat4.fromTranslation(eo,n.vec3.set(qi,-i[0],-i[1],-i[2])),a=n.mat4.fromTranslation(no,i),c=s.rotation||ao,h=n.quat.fromEuler(Yi,...c),u=s.scale;let l;l=Array.isArray(u)?n.vec3.set(ho,u[0],u[1],u[2]):u&&n.vec3.set(ho,u,u,u)||co;const f=n.mat4.fromRotationTranslationScale(ro,h,uo,l);return t=n.mat4.multiply(t,f,o),n.mat4.multiply(t,a,t)}er(t){const e=this.kt(t.Rt);if(!t.boundingVolume||this.yr(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,s=t.boundingVolume.sphere;let i=null;n?i=this.br(t).boxCenter:r?i=this.wr(t).boxCenter:s&&(i=this.ur(t).boxCenter);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.vr=[a[0]||0,a[1]||0],t.Tr=o,t.lr=i}yr(t,e){if(!t.vr)return!1;const n=e.coordOffset||oo;return t.vr[0]===n[0]&&t.vr[1]===n[1]&&t.Tr===(e.heightOffset||0)}wr(t){return this.Zn(t),this.cr(t)}br(t){return this.Zn(t),this.mr(t)}pr(t,e){let r=t.slice(3,12);const s=n.mat3.fromMat4(to,e);return r=n.mat3.multiply(r,s,r),r}gr(t){const e=this.getMap(),r=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let s;return s=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:r.y/100,n.vec3.set(Ki,r.x/100*1.01,r.y/100*1.01,s),Ki}tr(t){Array.isArray(t)&&(t=new s.Coordinate(t));let e=this.options.offset;if(bt(e)&&(e=e.call(this,Array.isArray(t)?new s.Coordinate(t):t)),e[0]||e[1]){const n=this.getMap(),r=n.getGLRes(),s=n.coordToPointAtRes(t,r);return Qi.set(e[0],e[1]),s._sub(Qi),n.pointAtResToCoord(s,r)}return t}ar(t){return this._n[t]}Vn(t){const e=this.kt(t).maxExtent;if(!e)return null;const n=this._n[t];return n.maxExtent||(n.maxExtent=new s.Extent(e).convertTo((t=>this.Pe(t)))),n.maxExtent}sr(t){const e=this.Gn,r=t.geometricError;if(0===r)return t.ir=0,0;const s=this.kt(t.Rt);let i=s.scale||1;if(Array.isArray(i)&&(i=n.vec3.length(i)),s.ecefTransform){const t=n.mat4.getScaling(Xi,s.ecefTransform);i*=n.vec3.len(t)}const o=this.getMap();let a;t.boundingVolume.region?a=function(t,e,n){t._r||(t._r=new Bi(t.boundingVolume.region));return t._r.distanceToCamera(e,n)}(t,this.Hn,this.zn):t.boundingVolume.sphere?a=po(t.boundingVolume,this.Hn):t.boundingVolume.box&&(a=go(t.boundingVolume,this.Hn));const c=Math.max(Math.abs(a),1e-7),h=r*i*o.height/(c*e);return t.Qt=a,t.ir=h,h}Fn(){const t=this.getRenderer();t&&t.setToRedraw()}Ae(t){return this.Un[t]}identify(t,e={}){const n=this.getMap(),r=this.getRenderer();if(!n||!r)return[];Array.isArray(t)&&(t=new s.Coordinate(t));const i=n.coordToContainerPoint(t);return this.identifyAtPoint(i,e)}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.Be():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.Ut||(this.Ut=[]),this.Ut.push(t),this)}En(){if(this.Ut){for(let t=0;t<this.Ut.length;t++)this.highlight(this.Ut[t]);delete this.Ut}}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.Ft||(this.Ft=[]),this.Ft.push(t),this)}Mr(){if(this.Ft){for(let t=0;t<this.Ft.length;t++)this.showOnly(this.Ft[t]);delete this.Ft}}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.Fn(),this):this}setServiceDebug(t,e){const n=this.options.services[t];n&&(n.debug=e);return this.getRenderer()?(this.Fn(),this):this}qn(t){const e=this.getMap(),n=e.getGLRes();so.set(t[0],t[1]);const r=e.pointAtResToCoord(so,n);return"identity"===e.getProjection().code.toLowerCase()?(zi[0]=r.x,zi[1]=r.y,this.getRenderer().Pn(qi,zi),r.set(qi[0],qi[1]),r):r}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function po(t,e,r){let s=t.sphere;r&&(s=n.vec3.transformMat4([0,0,0],s,r));const i=n.vec3.dist(s,e),o=t.sphere[3];return i<o?0:i-o}function go(t,e,r){const s=t.box;let i=n.vec3.set(qi,s[0],s[1],s[2]);r&&(i=n.vec3.transformMat4([0,0,0],i,r));return di(i,n.mat3.set(to,s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],s[11]),e)}function yo(t,e,r){const s=(t=Mt(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,Yn:!0,service:r,visible:!!gt(r.visible)||r.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Rt:e,bn:0,domainKey:s}}function bo(t,e,r,s,i,o){const a=n.vec3.set(qi,e[3*r],e[3*r+1],e[3*r+2]),c=n.vec3.set(zi,e[3*s],e[3*s+1],e[3*s+2]),h=n.vec3.set(Hi,e[3*i],e[3*i+1],e[3*i+2]),u=n.vec3.set(Gi,e[3*o],e[3*o+1],e[3*o+2]);return t[0]=(a[0]+c[0]+h[0]+u[0])/4,t[1]=(a[1]+c[1]+h[1]+u[1])/4,t[2]=(a[2]+c[2]+h[2]+u[2])/4,t}function wo(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 vo(t,e){return Array.isArray(t)&&Array.isArray(e)?2===t.length?n.vec2.exactEquals(t,e):n.vec3.exactEquals(t,e):t===e}var To;mo.mergeOptions(ji),mo.registerRenderer("gl",ui),mo.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"}(To||(To={}));let _o=null;function Mo(){return _o||(_o={"image/crn":Gs.crn&&Gs.crn(),"image/ktx2":Gs.ktx2&&Gs.ktx2(),"image/cttf":Gs.ktx2&&Gs.ktx2(),"draco":Gs.draco&&Gs.draco()}),_o}class Ao{constructor(t,e,n){this.o=t,this.Ar=e||Pe,this.h=n,this.Or=Mo()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.Ir(t,e,n,r,s)):me.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Ir(t,s,n,r)}))}Ir(t,e,n,r,s){const i=s&&s.maxTextureSize,o=this.Sr(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.Ar(a,o.glb,{transferable:!0,requestImage:this.o,decoders:this.Or,supportedFormats:this.h,maxTextureSize:i})}catch(t){return Promise.resolve({error:t})}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}}))}Sr(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),u=s.getUint32(24,!0),l=28+e;h>=570425344?(l-=8,o=a,h=c,u=0,a=0,c=0):u>=570425344&&(l-=4,o=h,h=a,u=c,a=0,c=0);const f=[t];let d,m,p;if(a>0?(d=Kn(t,l,a),l+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(l+=c),h>0&&(m=Xn(t,l,h),l+=h,u>0)){const e=Yn(0,l,u);p=t.slice(e.offset,e.offset+e.byteLength),l+=u,f.push(p)}const g=d.BATCH_LENGTH,y={};if(d&&d.BATCH_ID){y.BATCH_ID=Zn(d.BATCH_ID,t,undefined.offset,g);const e=y.BATCH_ID.array&&y.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:p,b3dm:y,glb:{buffer:t,byteOffset:l,byteLength:s.byteLength+s.byteOffset-l}}}Er(){return null}}class Oo{constructor(t,e,n,r){this.o=t,this.Ar=e||Pe,this.h=n,this.Or=Mo(),this.Cr=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.Ir(t,e,n,r,s)):me.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Ir(t,s,n,r)}))}Ir(t,e,n,r,s){return this.Nr(t,e,n,r,s).then((({gltf:s,transferables:i})=>{const o=this.kr(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})}))}Nr(t,e,n,r,s){const i=s&&s.maxTextureSize,o={transferable:!0,requestImage:this.o,decoders:this.Or,supportedFormats:this.h,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=xt(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?me.getArrayBuffer(r,{}).then((t=>this.Rr(r,{buffer:t.data,byteOffset:0},o))):me.getJSON(r,{}).then((t=>this.Rr(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.Rr(t,r,o)}}Rr(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.Ar(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}}))}kr(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:u}=or(s,32+e,o),l={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;l.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;l.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Pr(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=Zn(a.BATCH_ID,t,c.offset,f);const e=l.BATCH_ID.array&&l.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Lr(new Uint16Array(t,e+c.offset,2*f))},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Lr(new Uint16Array(t,e+c.offset,2*f))},o.push(l.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;l.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).slice()},o.push(l.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;l.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(l.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:h,batchTableBin:u,featureTable:a,i3dm:l,transferables:o}}Lr(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)xo(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}Pr(t,e,n){return ir(new Float32Array(t.length),t,e,n)}Er(){return null}}function xo(t,e,n,r){if(t[0]=Io(e,r),t[1]=Io(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]))*So(e),t[1]=(1-Math.abs(e))*So(t[1])}return cn(t,t)}function Io(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 So(t){return t<0?-1:1}class Eo{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.Ir(t,e,n,r)):me.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Ir(t,s,n,r)}))}Ir(t,e,n,r){return this.Br(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}))}Br(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:u}=or(s,e+28,o),l=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.Ur||(this.Ur=Mo().draco),this.Ur(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.Dr(t,e.attributes,c.offset,d,o,l,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:sr(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?r.BATCH_ID=Zn(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=Co(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:u,featureTable:a,pnts:r,transferables:o}}))}const g=this.Dr(t,a,c.offset,d,o,l,f);if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?g.BATCH_ID=Zn(a.BATCH_ID,t,c.offset,d):g.BATCH_ID=Co(d);const e=g.BATCH_ID.array&&g.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:h,batchTableBin:u,featureTable:a,pnts:g,transferables:o})}Dr(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 u=h?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Pr(h||new Uint16Array(t,c+u,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}Pr(t,e,n){return ir(new Float32Array(t.length),t,e,n)}Er(){return null}}function Co(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:sr(e),array:n}}class No{constructor(t,e,n,r){this.h=n,this.o=t,this.Ar=e||Pe,this.Cr=r}load(t,e,n=0,r=0,s){return e?this.Ir(t,e,n,r,s):me.getArrayBuffer(t,{}).then((e=>{const s=e.data;return this.Ir(t,s,n,r)}))}Ir(t,e,n,r,s){r||(r=e.byteLength);const i=this.Fr(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new Ao(this.o,this.Ar,this.h);else if("i3dm"===i[n].magic)r=new Oo(this.o,this.Ar,this.h,this.Cr);else if("pnts"===i[n].magic)r=new Eo;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new No(this.o,this.Ar,this.h,this.Cr)}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})))}Fr(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=Jn(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(i.transcoders){const t=s.Map.VERSION;if(t.indexOf("1.0.0-beta")>=0||t.indexOf("1.0.0-alpha")>=0){const t=i.transcoders.inject(a);s.registerWorkerAdapter("@maptalks/3dtiles",t)}else s.registerWorkerAdapter("@maptalks/3dtiles",(function(){return i.transcoders.inject(a)}))}else s.registerWorkerAdapter("@maptalks/3dtiles",a);t.B3DMLoader=Ao,t.CMPTLoader=No,t.Geo3DTilesLayer=mo,t.Geo3DTilesUtil=Lt,t.Geo3DTransform=Gn,"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.102.1")}));
22
+ */(100,1),Ds=[0,0,0,1],Fs=[1,1,1];class js{constructor(t,e){this.ot=e,this.ct=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.ht=t,this.ut=new n.reshader.Renderer(t),this.lt={},this.ft={},this.dt={},this.gt={},this.yt={},this.bt={},this.wt=new n.reshader.Scene,this.vt=new n.reshader.Scene,this.Tt=new n.reshader.Scene,this._t=new n.reshader.Scene,this.Mt=new n.reshader.ResourceLoader(t.texture(2)),this.At=(...t)=>this.Ot.call(this,...t),this.xt=new n.reshader.KHRTechniquesWebglManager(this.ht,this.It(),this.Mt);const r=this.getMap();this.St=r.altitudeToPoint(100,r.getGLRes())/100}getI3DMMeshes(){return this.gt}getPNTSMeshes(){return this.dt}getB3DMMeshes(){return this.ft}getPaintedMeshes(){return this.Et}getMap(){return this.ot.getMap()}paint(t,e,r,s){const i=s&&s.renderTarget,o=s&&s.sceneFilter,a=this.getMap();if(!t.length||!a)return null;const c=this.Ct(),h=a.projViewMatrix,u=[],f=[],d=[],m=[],p=[];for(let r=0,i=t.length;r<i;r++){const i=t[r].data.node;let o=this.Nt(i);if(!o)continue;const a=this.ot.kt(i.Rt),c=a.debugNodes,g=a.heightOffset||0,y=a.coordOffset||fs;this.yt[i.id]&&(o=this.yt[i.id],o=St(o));let b=a.polygonOffset||is;bt(b)&&(b=b()),Array.isArray(o)||(u[0]=o,o=u);for(let a=0,u=o.length;a<u;a++){if(!o[a]||!o[a].isValid||!o[a].isValid())continue;const u=o[a].properties.magic;if(o[a].properties.heightOffset===g&&o[a].properties.coordOffset[0]===y[0]&&o[a].properties.coordOffset[1]===y[1]||(this.Pt(o[a]),o[a].Lt=n.mat4.copy([],o[a].localTransform)),o[a].Bt=i,"b3dm"===u){if(o[a].getBoundingBox&&!l(h,o[a].getBoundingBox()))continue;const{batchIdData:t,batchIdMap:e}=o[a].geometry.properties;if(t&&e){const t=o[a].properties.node.Rt;this.Ut&&this.Ut[t]?n.HighlightUtil.highlightMesh(this.ht,o[a],this.Ut[t],this.Dt,e):this.Ut&&this.Ut[t]||n.HighlightUtil.highlightMesh(this.ht,o[a],null,this.Dt,e),n.HighlightUtil.showOnly(this.ht,o[a],this.Ft&&this.Ft[t],this.jt,e)}if(c&&c.length&&c.indexOf(o[a].Bt.id)<0)continue;s&&s.bloom&&o[a].properties.hlBloomMesh&&(o[a].properties.hlBloomMesh.properties.depthFunc="always",o[a].properties.hlBloomMesh.properties.polygonOffset=b,d.push(o[a].properties.hlBloomMesh)),d.push(o[a])}else"pnts"===u?m.push(o[a]):"i3dm"===u&&p.push(o[a]);o[a].properties.isLeaf=!!e[i.id],o[a].properties.selectionDepth=255-t[r].selectionDepth,o[a].properties.polygonOffset=b,e[i.id]||f.push(o[a]),this.qt(o[a]),this.zt(o[a],i)}}let g=0;const y=this.xt.getExcludeFilter();n.ContextUtil.setIncludeUniformValues(c,s),g+=this.Ht(this.Gt,c,[o,ms,y],i,f,d,p),g+=this.Ht(this.Vt,c,[o,ps,y],i,f,d,p),this.xt.forEachShader(((t,e,n)=>{const r=this.Ct(n);g+=this.Ht(t,r,[o,e],i,f,d,p)})),this.vt.setMeshes(m);const b=this.Jt();return g+=this.ut.render(this.$t,b,this.vt,i&&i.fbo),this.Et={pntsMeshes:m,i3dmMeshes:p,b3dmMeshes:d},this._t.setMeshes(r),this.ut.render(this.Kt,c,this._t,i&&i.fbo),g}prepareRender(t){this.Xt(t)}Xt(t){t&&t.states&&t.states.includesChanged&&(this.Vt.dispose(),delete this.Vt,this.Gt.dispose(),delete this.Gt),this.Yt(t)}Ht(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.Wt(a),this.wt.setMeshes(h),c+=this.ut.render(t,e,this.wt,a),h.length=0,e.stencilEnable=!1),h.push(i[n])):(e.stencilEnable||(this.wt.setMeshes(h),c+=this.ut.render(t,e,this.wt,a),h.length=0,e.stencilEnable=!0),h.push(i[n])),n===i.length-1&&(e.stencilEnable&&this.Wt(a),this.wt.setMeshes(h),c+=this.ut.render(t,e,this.wt,a))}return this.wt.setMeshes(i.filter((t=>t.properties.isLeaf))),this.Tt.setMeshes(o),c+=this.ut.render(t,e,this.Tt,r&&r.fbo),c}Wt(t){this.ht.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.wt.getMeshes()}getCurrentI3DMMeshes(){return this.Tt.getMeshes()}Zt(t,e){return e.Bt.Qt-t.Bt.Qt}deleteTile(t){const e=t.node;e.te&&(e.te.geometry.dispose(),e.te.dispose(),delete e.te);const n=e.id;this.ee(n)}ee(t){const e=this.ft[t]||this.dt[t]||this.gt[t]||this.yt[t]||this.lt[t];this.yt[t]?this.ne(t):e&&(this.re(e),delete this.ft[t],delete this.dt[t],delete this.gt[t],delete this.lt[t])}ne(t){let e=this.yt[t];e=St(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.ee(n)}delete this.yt[t]}re(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.re(t[e]);else{n.HighlightUtil.showOnly(this.ht,t),n.HighlightUtil.highlightMesh(this.ht,t);const e=t.geometry.properties.url;if(e){const n=this.bt[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this.bt[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.ot;ns(t.getRenderer().canvas,t.getMap());for(const t in this.yt)this.ne(t);this.yt={};for(const t in this.ft)this.ee(t);this.ft={};for(const t in this.dt)this.ee(t);this.dt={};for(const t in this.gt)this.ee(t);this.gt={};for(const t in this.lt)this.ee(t);this.lt={},this.Gt&&(this.Gt.dispose(),delete this.Gt),this.Vt&&(this.Vt.dispose(),delete this.Vt),this.$t&&(this.$t.dispose(),delete this.$t),this.Kt&&(this.Kt.dispose(),delete this.Kt),this.xt.dispose(),this.picking&&this.picking.dispose()}Nt(t){return this.ft[t.id]||this.dt[t.id]||this.gt[t.id]||this.yt[t.id]}has(t){return this.Nt(t)||this.lt[t.id]}Pt(t){const e=t.properties.magic;"b3dm"===e?this.se(t):"i3dm"===e?this.ie(t):"pnts"===e&&this.oe(t)}createPntsMesh(t,e,r,s){if(this.dt[e]){const t=this.dt[e];return console.warn(`pnts mesh with id(${e}) was already created.`),s(null,{id:e,mesh:t}),t}const{pnts:i,featureTable:o,rootIdx:a,compressed_int16_params:c}=t,h=o.POINTS_LENGTH;i.BATCH_ID||(i.BATCH_ID=new Uint8Array(h),i.BATCH_ID.fill(0));const u=new n.reshader.Geometry(i,null,h,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});u.generateBuffers(this.ht);const l={};i.POSITION?l.HAS_POSITION=1:i.POSITION_QUANTIZED&&(l.HAS_POSITION_QUANTIZED=1),i.RGB?l.HAS_RGB=1:i.RGBA?l.HAS_RGBA=1:i.RGB565&&(l.HAS_RGB565=1),(i.NORMAL||i.NORMAL_OCT16P)&&(l.HAS_NORMAL=1,i.NORMAL_OCT16P&&(l.HAS_NORMAL_OCT16P=1)),this.ae(l,c),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:f,rtcCoord:d,projCenter:m}=t,p=this.ot.kt(a),g=new n.reshader.Mesh(u);g.properties.magic="pnts",g.properties.id=e,g.properties.node=r,g.properties.count=h,g.properties.batchTable=t.batchTable,g.properties.batchTableBin=t.batchTableBin,g.properties.serviceIndex=a,g.properties.rtcCoord=d,g.properties.rtcCenter=f,g.properties.projCenter=m,g.setDefines(l),g.setFunctionUniform("pointColor",(function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:p&&p.pointColor||[1,1,1,1]}));const y=this.getMap();let b=null,w=null;g.setFunctionUniform("pointSize",(function(){if(!p)return 2;if(Hr(p.pointSize)){const t=JSON.stringify(p.pointSize);t!==b&&(w=Gr(p.pointSize),b=t);return w(y.getZoom())}return p.pointSize||2}));let v=null,T=null;return g.setFunctionUniform("pointOpacity",(function(){if(!p)return 1;if(Hr(p.pointOpacity)){const t=JSON.stringify(p.pointOpacity);t!==v&&(T=Gr(p.pointOpacity),v=t);return T(y.getZoom())}return p.pointOpacity||1})),this.ce(g,c),this.oe(g),g.Lt=n.mat4.copy([],g.localTransform),this.dt[e]=g,s(null,{id:e,mesh:[g]}),[g]}oe(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:s}=t.properties;this.he(e,n,s,r.Rt),t.setLocalTransform(e)}createI3DMMesh(t,e,r,s){if(this.gt[e]){const t=this.gt[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.lt[e]||s(null,{id:e,mesh:t}),t}const i=this.ot.kt(r.Rt),o=this.ue(r.le),{i3dm:a,featureTable:c,gltf:h,batchTable:u,batchTableBin:l,count:f}=t,d=c.INSTANCES_LENGTH,{rtcCenter:m,rtcCoord:p,projCenter:g}=t,y=this.fe(As,r,m,p);pr(y,ls,y);const b=n.mat4.getRotation(Os,y);n.quat.normalize(b,b);const w=n.mat4.getScaling(xs,y),v=n.mat4.fromScaling(Is,w),T=this.de(Ss,g,r),_=this.me(Ns),M=this.pe(ks,p),A=n.vec3.div(Rs,M,_),O=n.mat4.fromScaling(Ps,A),{POSITION:x,NORMAL_UP:I,NORMAL_RIGHT:S,SCALE:E,SCALE_NON_UNIFORM:C}=a,N={"instance_vectorA":new Float32Array(4*d),"instance_vectorB":new Float32Array(4*d),"instance_vectorC":new Float32Array(4*d),"aPickingId":new Uint16Array(d)};for(let t=0;t<d;t++)N.aPickingId[t]=t;const k=new Float32Array(3),R=new Float32Array(3),P=[],L=new Float32Array(1),B=new Float32Array(3),U=[],D=[],F=[],j=[];!function(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?Pe.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)}}(x,((t,e)=>{I?(An(R,S,e),An(k,I,e),n.vec3.cross(P,R,k),n.vec3.normalize(P,P),It(U,R,0),It(U,k,1),It(U,P,2),n.quat.fromMat3(D,U),n.quat.normalize(D,D),n.quat.multiply(D,b,D)):n.quat.identity(D),E?(An(L,E,e),n.vec3.set(F,L[0],L[0],L[0])):C?(An(B,C,e),n.vec3.set(F,...B)):n.vec3.set(F,1,1,1),n.mat4.fromRotationTranslationScale(j,D,t,F),On(N.instance_vectorA,e,j,0),On(N.instance_vectorB,e,j,1),On(N.instance_vectorC,e,j,2)}));const q={};for(const t in N)q[t]={buffer:this.ht.buffer({dimension:N[t].length/d,data:N[t]}),divisor:1};const z=i.shader||"pbr";let H=0,G=!0;const V=[],J=[];return gn(h,((t,s,i,a)=>{const h=this.ge(t,s,i,a,r,!0,z,J),{geometry:b,material:w}=h;w&&!w.isReady()&&(G=!1,H++);const _=new n.reshader.InstancedMesh(q,d,b,w);h.refMeshes||(h.refMeshes=new Set,h.refMeshes.add(_.uuid)),_.properties.magic="i3dm",_.properties.id=e,_.properties.count=f,_.properties.batchTable=u,_.properties.batchTableBin=l,_.properties.serviceIndex=r.Rt,_.properties.rtcCoord=p,_.properties.rtcCenter=m,_.properties.projCenter=g,_.properties.node=r;const M=this.ye(t,b,w,r.Rt,a);t.compressed_int16_params&&this.ce(_,t.compressed_int16_params),this.be(_,t.attributes);const A=n.mat4.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.mat4.multiply(A,A,t.matrices[e]);n.mat4.multiply(A,o,A),n.mat4.multiply(A,O,A),c.EAST_NORTH_UP||I?n.mat4.multiply(A,v,A):n.mat4.multiply(A,y,A),_.setPositionMatrix(A),this.ie(_,T),_.setDefines(M),_.properties.polygonOffset={offset:0,factor:0},V.push(_),delete t.attributes,_.Lt=n.mat4.copy([],_.localTransform)})),qs(J),G?(this.gt[e]=V,s(null,{id:e,mesh:V})):(this.lt[e]={meshes:V,count:H},V.we=s),V}ie(t,e){const{rtcCoord:r,node:s,projCenter:i}=t.properties;e||(e=this.de(Ss,i,s));const o=this.ot.kt(s.Rt),a=t.localTransform||[];if(o.coordOffset){const t=this.ve(As,s.Rt,r);n.mat4.multiply(a,t,e)}else n.mat4.copy(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||fs}de(t,e,r){n.mat4.fromScaling(t,this.me(Ns));const s=this.Te(_s,e,r.Rt);return n.mat4.multiply(t,n.mat4.fromTranslation(Es,s),t),t}createB3DMMesh(t,e,r,i){if(t.gltf&&(t.gltf.transferables=null),this.ft[e]||this.lt[e]){const t=this.ft[e];return console.warn(`mesh with id(${e}) was already created.`),this.lt[e]||i(null,{id:e,mesh:t}),t}let o;if(r.maxExtent){const t=new s.Extent(r.maxExtent).convertTo((t=>this._pointToPrj(t)));o=[t.xmin,t.ymin,t.xmax,t.ymax]}const a=t.gltf,{projCenter:c}=a.extensions.MAPTALKS_RTC,{rtcCoord:h,center:u}=a.extensions.CESIUM_RTC,l=a.asset.sharePosition,f=this.ue(r.le),d=this._e(Ss,l,h,u,c,r),m=this.ot.kt(r.Rt);let p=m.shader||"pbr";if(m.unlit)p="phong";else if(a.materials)for(let t=0;t<a.materials.length;t++)if(a.materials[t]&&a.materials[t].extensions&&a.materials[t].extensions.KHR_materials_unlit){p="phong";break}const g=[],y=[];let b=0,w=!0;return gn(a,((s,i,a,v)=>{const T=this.ge(s,i,a,v,r,!1,p,g),{geometry:_,material:M}=T;M&&!M.isReady()&&(w=!1,b++);const A=new n.reshader.Mesh(_,M);T.refMeshes||(T.refMeshes=new Set,T.refMeshes.add(A.uuid)),A.properties.magic="b3dm",A.properties.id=e,A.properties.node=r,t.batchTable&&(A.properties.batchTable=t.batchTable,A.properties.batchTableBin=t.batchTableBin),A.properties.count=t.featureTable&&t.featureTable.BATCH_LENGTH||0,A.properties.serviceIndex=r.Rt;const O=this.ye(s,_,M,r.Rt,v);A.setDefines(O);const x=s.compressUniforms;if(x)for(const t in x)A.setUniform(t,x[t]);s.compressed_int16_params&&this.ce(A,s.compressed_int16_params),this.be(A,s.attributes),o&&(O.USE_MAX_EXTENT=1,A.setUniform("maxPrjExtent",o)),A.hasFunctionUniform("polygonOpacity")||A.setFunctionUniform("polygonOpacity",(function(){return vt(m.opacity)?m.opacity:1})),A.hasFunctionUniform("polygonFill")||A.setFunctionUniform("polygonFill",(function(){return Pt([],m.polygonFill||os)})),A.material.hasFunctionUniform("hsv")||A.material.setFunctionUniform("hsv",(function(){return m.hsv||as}));const I=n.mat4.identity([]);if(l&&s.matrices&&s.matrices.length)for(let t=0;t<s.matrices.length;t++)n.mat4.multiply(I,I,s.matrices[t]);l&&n.mat4.multiply(I,f,I),A.properties.node=r,A.properties.projCenter=c,A.properties.nodeMatrix=I,A.properties.isSharedPosition=l,A.properties.rtcCoord=h,A.properties.rtcCenter=u,this.se(A,d),y.push(A),delete s.attributes,A.Lt=n.mat4.copy([],A.localTransform)})),qs(g),w?(this.ft[e]=y,i(null,{id:e,mesh:y})):(this.lt[e]={meshes:y,count:b},y.we=i),y}Me(t){const e=this.ot.Ae(t.id);if(!e||t.te)return;let r,s,i,o;if(e.obbox)r=e.boxPosition,s=Bs,i=e.boxCenter,o=Fs;else if(e.sphereBox){const t=e.sphereBox[0],n=e.sphereBox[1];r=Us.vertices,s=Us.indices,i=t,o=[n,n,n]}const a=new n.reshader.Geometry({POSITION:r},s,0,{primitive:"lines",positionAttribute:"POSITION"}),c=new n.reshader.Mesh(a,new n.reshader.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),h=[];n.mat4.fromRotationTranslationScale(h,Ds,i,o),c.localTransform=h,c.Lt=n.mat4.copy([],h),c.properties.node=t,t.te=c}Oe(t){t.te&&(t.te.geometry.dispose(),t.te.dispose(),delete t.te)}ce(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)}se(t,e){const{isSharedPosition:r,rtcCoord:s,rtcCenter:i,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=this._e(e||Ss,r,s,i,o,c));const h=t.localTransform||n.mat4.identity([]);n.mat4.multiply(h,e,a);const u=this.ot.kt(c.Rt);if(u.coordOffset){const t=this.ve(As,c.Rt,s);n.mat4.multiply(h,t,h)}t.setLocalTransform(h),t.properties.heightOffset=u.heightOffset||0,t.properties.coordOffset=u.coordOffset&&u.coordOffset.slice(0)||fs}_e(t,e,r,s,i,o){if(e){const e=this.pe(ks,r),i=n.mat4.fromScaling(Ms,e),a=this.fe(As,o,s,r);n.mat4.multiply(t,a,i)}else this.he(t,r,i,o.Rt);return t}be(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)}}fe(t,e,r,s){const i=this.getMap(),o=this.ot.kt(e.Rt).heightOffset||0,a=e.matrix?n.mat4.copy(t,e.matrix):n.mat4.identity(t);if(r){pr(a,n.vec3.transformMat4(gs,r,a),a)}const c=function(t,e,n,r,s,i,o){e=nn(yr,e);const a=Cn(yr,e[0]*xr,e[1]*xr,e[2]),c=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(br,n),h=r.ellipsoid;let u;u=0===dn(c)?rn(wr,0,0,-6378137):Bn(wr,c),Ar.x=u[0],Ar.y=u[1];const l=r.project(Ar,Or);vr[0]=l.x/s,vr[1]=l.y/s,vr[2]=(u[2]+o)*i;const f=gr(a,h,Tr),d=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],h=e[7],u=e[8],l=e[9],f=e[10],d=e[11],m=e[12],p=e[13],g=e[14],y=e[15],b=n*a-r*o,w=n*c-s*o,v=n*h-i*o,T=r*c-s*a,_=r*h-i*a,M=s*h-i*c,A=u*p-l*m,O=u*g-f*m,x=u*y-d*m,I=l*g-f*p,S=l*y-d*p,E=f*y-d*g,C=b*E-w*S+v*I+T*x-_*O+M*A;return C?(C=1/C,t[0]=(a*E-c*S+h*I)*C,t[1]=(s*S-r*E-i*I)*C,t[2]=(p*M-g*_+y*T)*C,t[3]=(f*_-l*M-d*T)*C,t[4]=(c*x-o*E-h*O)*C,t[5]=(n*E-s*x+i*O)*C,t[6]=(g*v-m*M-y*w)*C,t[7]=(u*M-f*v+d*w)*C,t[8]=(o*S-a*x+h*A)*C,t[9]=(r*x-n*S-i*A)*C,t[10]=(m*_-p*v+y*b)*C,t[11]=(l*v-u*_-d*b)*C,t[12]=(a*O-o*I-c*A)*C,t[13]=(n*I-r*O+s*A)*C,t[14]=(p*w-m*T-g*b)*C,t[15]=(u*T-l*w+f*b)*C,t):null}(_r,f),m=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}(Mr,n);return pr(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],u=t[9],l=t[10],f=e[0],d=e[1],m=e[2],p=e[3],g=e[4],y=e[5],b=e[6],w=e[7],v=e[8],T=r*f+o*d+h*m,_=s*f+a*d+u*m,M=i*f+c*d+l*m,A=r*p+o*g+h*y,O=s*p+a*g+u*y,x=i*p+c*g+l*y,I=r*b+o*w+h*v,S=s*b+a*w+u*v,E=i*b+c*w+l*v;return n[0]=T,n[1]=_,n[2]=M,n[3]=0,n[4]=A,n[5]=O,n[6]=x,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}(d,m,t),vr,t),t}(a,s,a,i.getProjection(),i.getGLRes(),this.St,o),h=function(t,e){return rn(t,e[12],e[13],e[14]),t}(_s,c);let u=this.ot.options.offset;if(bt(u)){const t=this.ot.Ae(e.id).boxCoord;u=u.call(this.ot,t)}return n.vec3.set(Ts,u[0],u[1],0),n.vec3.sub(h,h,Ts),pr(c,h,c),c}ve(t,e,r){const s=this.ot.kt(e);if(!s.coordOffset)return null;const i=this.getMap(),o=i.getGLRes();ys.set(r[0],r[1]);const a=i.coordToPointAtRes(ys,o,ws),c=s.coordOffset,h=ys.set(r[0]+c[0],r[1]+c[1]),u=i.coordToPointAtRes(h,o,vs),l=u.x-a.x,f=u.y-a.y,d=this.St,m=n.vec3.set(Ts,l,f,(c[2]||0)*d);return n.mat4.fromTranslation(t,m)}createCMPTMesh(t,e,n,r){if(this.yt[e]){const t=this.yt[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.yt[e]=i,r(null,{id:e,mesh:i}),i}ye(t,e,n,r,s){const i=("phong"===(this.ot.kt(r).shader||"pbr")?this.Gt:this.Vt).getGeometryDefines(e);s.asset&&"S3M"===s.asset.generator&&this.xe(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.ot.Ie&&(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.ae(i,t.compressed_int16_params);return yt(i,t.compressDefines),i}ae(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))}qt(t){const e=this.ot.getRenderer();e&&e.updateMaskDefines(t)}xe(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)}ge(t,e,r,s,i,o,a,c){let h=!1;s.asset&&"S3M"===s.asset.generator&&(h=!0,s.extensions=s.extensions||{});const u=s.url+"-"+e+"-"+r;if(this.bt[u])return this.bt[u];let l,f;c.push(t);const d=s.materials&&s.materials[t.material],m=s.extensions&&s.extensions.KHR_techniques_webgl,p=this.ot.kt(i.Rt);if(m&&d.extensions&&d.extensions.KHR_techniques_webgl){const e=this.Se(t,s,o,h);l=e.material,f=e.geometry,p.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.Ee(t,o,Ls);const e=p.material;l=this.Ce(t.material,s,a,e||cs,c,p)}l&&(l.setFunctionUniform("alphaTest",(function(){const t=p.alphaTest;return gt(t)?.1:t})),l.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}))),l&&!l.isReady()?l.Ne=i.id:l||(l=new n.reshader.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const g={geometry:f,material:l};return f.properties.url=u,this.bt[u]=g,g}Se(t,e,n,r){const{geometry:s,material:i}=this.xt.createMesh(t,e,n,r);return{geometry:s,material:i}}Ee(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=Zr(this.ht,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.reshader.Geometry(a,c,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":Wr(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.ht,{excludeElementsInVAO:e}),h}he(t,e,r,s){const i=n.mat4.identity(t),o=this.me(hs);return this.Te(_s,r,s),n.mat4.translate(i,i,_s),n.mat4.scale(i,i,o),i}Te(t,e,r){const s=this.St;ys.x=e[0],ys.y=e[1];const i=this._prjToPoint(ys);let o=this.ot.options.offset;bt(o)&&(o=o.call(this.ot,ys));const a=this.ot.kt(r).heightOffset||0;return n.vec3.set(t,i.x-o[0],i.y-o[1],s*e[2]+s*a),t}zt(t,e){const r=this.ot.ke(Cs,e);t.localTransform=n.mat4.multiply(t.localTransform,r,t.Lt)}pe(t,e){const r=this.getMap();ys.x=e[0],ys.y=e[1];const s=r.distanceToPointAtRes(100,100,r.getGLRes(),ys),i=this.St;return n.vec3.set(t,s.x/100,s.y/100,i),t}Yt(t){if(this.Vt)return;const e={x:0,y:0,width:()=>this.ct?this.ct.width:1,height:()=>this.ct?this.ct.height:1},r=[],s=[];this.$t=new n.reshader.MeshShader({vert:xn,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)=>n.mat4.multiply(s,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,e)=>n.mat3.fromMat4(r,e.modelMatrix)}],extraCommandProps:{viewport:e,blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,func:"<"}}});const i={},o=[];n.ContextUtil.fillIncludes(i,o,t);const a=this.It();this.Gt=new n.reshader.PhongShader({uniforms:o,defines:i,extraCommandProps:a}),this.Vt=new n.reshader.pbr.StandardShader({uniforms:o,defines:i,extraCommandProps:a}),this.Kt=new n.reshader.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.ct?this.ct.width:1,height:()=>this.ct?this.ct.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const c=this.ot;es(c.getRenderer().canvas,this.ht,c.getMap()),this.picking=new n.reshader.FBORayPicking(this.ut,{vert:this.Vt.vert,extraCommandProps:a,uniforms:this.Vt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.Re=new n.reshader.FBORayPicking(this.ut,{vert:xn,extraCommandProps:a,uniforms:this.$t.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}It(){return{viewport:{x:0,y:0,width:()=>this.ct?this.ct.width:1,height:()=>this.ct?this.ct.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,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}}}Jt(t){const e=this.getMap(),r=e.getLightManager(),s=(r&&r.getDirectionalLight()||{}).direction||[1,1,-1],i=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:i,lightDir:n.vec3.normalize(ds,s)}}Ct(){const t=this.getMap(),e=this.ot,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:s}=rs(n),i=ss(t,r,s),o=this.ot.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,yt(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}),yt(i,a),i}Ce(t,e,r,s,i,o){const a=e.materials&&e.materials[t];if(!a||!a.baseColorTexture&&!a.pbrMetallicRoughness)return null;const c=yt({},s);if(a.baseColorTexture){const t=e.textures[a.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.R(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.R(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.R(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.R(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 r=e.textures[t.baseColorTexture.index];if(r&&r.image&&r.image.color)c.baseColorFactor=c.baseColorFactor?n.vec4.multiply(c.baseColorFactor,c.baseColorFactor,r.image.color):r.image.color;else{const t=this.R(r,i);t&&(c.baseColorTexture=t,c.baseColorTexture.getREGLTexture(this.ht))}}if(gt(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),gt(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),a.metallicRoughnessTexture){const t=this.R(e.textures[a.metallicRoughnessTexture.index],i);t&&(c.metallicRoughnessTexture=t)}}}if(a.s3mMaterial)return new n.reshader.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.reshader.PhongMaterial(c);return t.unlit=void 0===o.unlit||!!o.unlit,t}let h=new n.reshader.pbr.StandardMaterial(c);"phong"===r&&(h=n.reshader.PhongMaterial.convertFrom(h));const u=a.pbrMetallicRoughness,l=u&&u.baseColorTexture&&u.baseColorTexture.extensions;return l&&l.KHR_texture_transform&&(h.set("khr_offset",l.KHR_texture_transform.offset||[0,0]),h.set("khr_rotation",l.KHR_texture_transform.rotation||0),h.set("khr_scale",l.KHR_texture_transform.scale||[1,1])),h.doubleSided=!(!o.doubleSided&&!a.doubleSided),h.once("complete",this.At),h}R(t,e){if(!t)return null;const r={type:t.type?Xr(t.type):"uint8",format:t.format?Yr(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=Jr(i.magFilter)),i.minFilter&&(r.min=$r(i.minFilter)),i.wrapS&&(r.wrapS=Kr(i.wrapS)),i.wrapT&&(r.wrapT=Kr(i.wrapT))),new n.reshader.Texture2D(r,this.Mt)}Ot({target:t}){const e=t.Ne,n=this.lt[e];if(n.count--,!n.count){const t=n.meshes;this.ft[e]=t,delete this.lt[e];const r=t.we;delete t.we,r(null,{mesh:n.meshes,id:e})}}me(t){const e=1/this.getMap().getGLRes(),n=this.St;return t[0]=t[1]=e,t[2]=n,t}Pe(t){return this.ot.Pe(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(),bs)}ue(t){return"Y"===t?Qr:"X"===t?ts:us}pick(t,e,n=3){const r=this.ot;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const s=[],i=this.Ct(),o=this.Le(this.picking,i,this.wt,t,e,n);o&&s.push(o);const a=this.Le(this.picking,i,this.Tt,t,e,n);a&&s.push(a);const c=this.Jt(),h=this.Le(this.Re,c,this.vt,t,e,n);return h&&s.push(h),s}Le(t,e,n,r,s,i){if(!n.getMeshes().length)return null;const o=this.ot,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:u,point:l,coordinate:f}=c,d=(0===h||h)&&t.getMeshAt(h);if(!d||!d.geometry)return null;const m=d.properties;l&&l.length&&(l[0]=Math.round(1e5*l[0])/1e5,l[1]=Math.round(1e5*l[1])/1e5,l[2]=Math.round(1e5*l[2])/1e5);const p={batchId:u},g=o.options.services,y=g&&g[d.properties.serviceIndex];if(y&&y.debug&&(p.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=u;for(const s in t)void 0!==t[s].byteOffset?p[s]=Qn(t[s],e,n,r):p[s]=t[s][r]}return{service:d.properties.serviceIndex,data:p,point:l,coordinate:f}}highlight(t){this.Ut=t;const e=this.ot.getRenderer();this.Dt=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.Ut=null;const t=this.ot.getRenderer();this.Dt=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Ft=t;const e=this.ot.getRenderer();this.jt=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Ft=null;const t=this.ot.getRenderer();this.jt=t.getFrameTimestamp(),t.setToRedraw(!0)}Be(){if(!this.Et)return[];const t={},e=[];for(const n in this.Et){const r=this.Et[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 qs(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 zs=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")},Hs=zs(),Gs=Hs.gl_trans__coders=Hs.gl_trans__coders||{};function Vs(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}Gs.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=Hs.gl_trans__coders=Hs.gl_trans__coders||{};let i=`${r}\n const _____getGlobal = ${zs.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},Gs.registerTranscoder=function(t,e){Gs[t]=e},Gs.getTranscoder=function(t){return Gs[t]};const Js=[];class $s{constructor(t,e,n,r,s){this.ot=r,this.Ue=t,this.Rt=e,this.De=s,this.Fe=n.version,t.indexOf("i3s:tileset:")<0?(this.Fe<=1.6?this.je="root":this.je=0,n.version=this.Fe):(this.je=t.substring(12),this.Fe>1.6&&(this.je=parseInt(this.je))),this.Ue=t,this.qe=n}load(){const t=this.qe,e=t.layerScene.baseUrl;if(this.Fe<=1.6)return t[this.je]&&t[this.je].lodSelection?(this.ze=t[this.je],this.He()):new Promise((n=>{let r=e+"/nodes/"+this.je;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.De(this.Rt,r,(()=>{this.ze=t[this.je],n(this.He())}))}));if(this.Fe>=1.7){if(t[this.je])return this.ze=t[this.je],this.He();const n=Math.floor(this.je/t.nodesPerPage);return new Promise((r=>{let s=e+"/nodepages/"+n;t.layerScene.eslpk&&(s+=".json"),this.De(this.Rt,s,(()=>{this.ze=t[this.je],r(this.He())}))}))}return null}getTileset(){return this.Ge}getChildrenURL(){return this.Ve}He(){const t=this.qe,e=t.layerScene.baseUrl,n=this.ze.children,r=[],s={};if(n)for(let i=0;i<n.length;i++)if(this.Fe<=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.De(this.Rt,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.De(this.Rt,r,(()=>{n()}))})),r.push(s[a]))}return r.length?Promise.all(r).then((()=>this.Je())):this.Je()}Je(){return Promise.resolve(this.$e())}Ke(t){Vs(this.qe,t)}$e(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.Xe(this.ze,!0)}}Xe(t){const e=this.ot.getRenderer(),n=this.qe.projection,r=!n||n&&4326===n.wkid,s=this.Fe,i=this.qe,o=t,a=o.obb,c=o.mbs,h={};let u;if(c)u=rn([],c[0],c[1],c[2]),r||(u=e.Ye(u,u)),u=Ks([],u[0],u[1],u[2]),h.sphere=[...u,c[3]];else if(a){u=rn([],a.center[0],a.center[1],a.center[2]),r||(u=e.Ye(u,u)),u=Ks([],u[0],u[1],u[2]);const t=function(t,e,n){const r=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,h=n*o,u=r*o,l=r*a,f=s*o,d=s*a,m=s*c,p=i*o,g=i*a,y=i*c;return t[0]=1-l-m,t[3]=u-y,t[6]=f+g,t[1]=u+y,t[4]=1-h-m,t[7]=d-p,t[2]=f-g,t[5]=d+p,t[8]=1-h-l,t}([],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]}(u,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];rn(Js,n,s,i);const o=dn(Js);h.sphere=[...u,o]}let l=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){l=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&&(l=f/o.lodSelection[t].maxError);(l===1/0||isNaN(l))&&(l=1e5);const d=16*l,m=function(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}([]),p=m,g=o.children;let y;if(g){y=[];const t=this.qe;for(let e=0;e<g.length;e++){const n=s<=1.6?g[e].id:g[e];if(!t[n]){y=null;break}y.push(this.Xe(t[n]))}}const b={refine:"REPLACE",boundingVolume:h,transform:p,geometricError:d};return s<=1.6?t.lodSelection?t.geometryData&&(b.content={uri:"i3s:mesh:"+(t.id||t.index)}):b.content={uri:"i3s:tileset:"+(t.id||t.index)}:g&&g.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.ze}}function Ks(t,e,n,r){return Cn(t,Tt(e),Tt(n),r)}const Xs=!!Gs.ktx2,Ys=n.mat4.identity([]),Ws=(()=>{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 Zs(t){return t.indexOf("i3s:mesh")>=0}const Qs=9;function ti(t,e,n,r,s){const i=e.layerScene.eslpk,o=function(t,e){const n=e.substring(Qs);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,h=[];let u=!1;const l=Ys;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,o=(e.layerScene.store||{}).textureEncoding,l=t[f.definition],{geometryBuffers:m}=l;u=r&&2===m.length;const p=Gs.draco&&u?m[1]:m[0],g=Gs.draco&&u?1:0;let y=c+`/nodes/${f.resource}/geometries/`+g;i&&(y+=".bin");const b={geometry:{url:y,info:p}};if(s&&Ws&&u&&!Gs.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const w=e.layerScene.materialDefinitions,v=e.layerScene.textureSetDefinitions;let T,_=0;if(d&&(_=w[d.definition]),w){T=function(t,e,n,r,s,i,o){const a=JSON.parse(JSON.stringify(e));return ei(t,a,n,r,s,i,o),a}(o,_,v,c,d.resource,n,e.layerScene.eslpk)}else T={pbrMetallicRoughness:{metallicFactor:0}};b.material=T,h.push(b)}return{dracoCompression:u,meshes:h,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:l}}function ei(t,e,n,r,s,i,o){for(const a in e)if(e[a]&&e[a].textureSetDefinitionId>=0){const c=n[e[a].textureSetDefinitionId],h="images/"+c.formats[0].format,u=ri(c.formats,i,t),l={url:r+`/nodes/${s}/textures/${u.name}`,factor:void 0===e[a].factor?1:e[a].factor,format:u.format,mimeType:h};if(o){let t="";switch(u.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=u.format}l.url+="."+t}e[a]=l}else wt(e[a])&&ei(t,e[a],n,r,s,i,o)}const ni={"image/jpeg":"jpg","image/jpg":"jpg","image/png":"jpg","image/vnd-ms.dds":"dds","image/ktx":"jpg"};function ri(t,e,n){if(n&&n.length){const e=n[n.length-1],r=ni[e];if(r)for(let e=0,n=t.length;e<n;e++){if(t[e].format===r)return t[e]}else console.error("i3s not find texture format type from:",ni,"current textureEncoding:",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&&Xs)return t[n]}return null}const si=new s.Coordinate(0,0),ii=new s.Coordinate(0,0),oi=new Set,ai=[],ci=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.We(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.We(t,e),this}We(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*(s.Browser.mobile?32:1024)*1024,(t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)}));let hi=0;class ui extends(n.MaskRendererMixin(s.renderer.CanvasRenderer)){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>ci.max&&ci.setMaxSize(e),this.tileCache=ci,hi++,this.tilesLoading={},this.Ze={},this.Qe=[],this.De=(...t)=>this.tn.call(this,...t)}getAnalysisMeshes(){if(!this.painter)return ai;const t=this.painter.getPaintedMeshes();if(!t)return ai;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:s}=t;return n.length&&kt(e,n.filter((t=>!(!t||!t.geometry)))),r.length&&kt(e,r.filter((t=>!(!t||!t.geometry)))),s.length&&kt(e,s.filter((t=>!(!t||!t.geometry)))),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.Qe.length||super.needToRedraw())}getFrameTimestamp(){return this.nn}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.nn=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.rn(),this.sn(e);const{selectedTiles:o,leaves:a,requests:c}=this.an(r,s);c.length&&this.loadTiles(c),this.cn(o,a,e),this.hn(),c.length||this.completeRender()}an(t,e){let n=[];this.un();let r=0;const s=this.ln(),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 u=this.getCachedTile(c.id);if(this.dn(c.id)?(r++,h=a=!0,this.tilesLoading[c.id].current=!0):u?(this.getTileOpacity(u)<1&&(h=a=!0),o=!0,s.selected=!0,s.data=u):this.painter.has(c)||(h=a=!0,n.push(c)),!h)continue;if(this.mn(s))o=!0;else{this.pn(s).length&&(o=!0)}}let c=[],h={};if(o&&({selectedTiles:c,leaves:h}=this.gn(t)),n.length>1&&(n.sort(li),s)){const t=s-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c,leaves:h}}gn(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.yn===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.yn=s.length}for(let t=0;t<o.length;t++)s.push(o[t])}return{selectedTiles:e,leaves:n}}mn(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}pn(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.bn+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.wn(s[i],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else s[i].bn<=n&&r.push(s[i])}}return e}cn(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.kt(s.Rt);s.te&&i.debug&&!Array.isArray(i.debug)&&r.push(s.te)}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.Ae(t),n=e&&e.node;n&&n.te&&r.push(n.te)}}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}),this.tileCache.shrink()}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.vn(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.Rt,r=this.Tn[n];return new $s(e,n,r,this.layer,this.De).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Bt(e)&&!Zs(e)&&(e=t.baseUrl+e),this.vn(e,null,t),null}vn(t,e,r){let s=this.h;s||(s=n.reshader.Util.getSupportedFormats(this.gl.gl||this.gl),this.h=s);const i=this.layer.kt(r.Rt);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._n[r.Rt]),arraybuffer:e,rootIdx:r.Rt,upAxis:r.le,transform:r.matrix,supportedFormats:s};if(Zs(t)){const e=this.Tn[r.Rt];if(o.projection=e.projection,o.i3sInfo=ti(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=yt({},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.Qe.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}Me(t){this.painter&&this.painter.Me(t)}Oe(t){this.painter&&this.painter.Oe(t)}sn(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.Qe.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.Qe.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Mn(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Mn(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Mn(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Mn(t,e,n,r)})),n++}}Mn(t,e,n,r){if(n)this.onTileError(n,e);else{const n=this.An(r);e.memorySize=n,this.onTileLoad(t,e)}}An(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.An(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.On(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.Ie=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.xn(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)||oi.has(i)||(console.warn("failed to load 3d tile: "+r),console.warn(t),oi.add(i)),delete this.tilesLoading[e.id],(!this.layer.options.onlyCacheNoContentTileWhenError||t&&!s.Util.isNoContentHttpCode(t.status))&&this.In(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]&&e[n].isValid&&e[n].isValid()&&t.push(e[n]);const n=this.painter.getCurrentI3DMMeshes();for(const e in n)n[e]&&n[e].isValid&&n[e].isValid()&&t.push(n[e]);return t}In(t,e){const n={loadTime:s.Util.now(),current:!0,error:e,node:t};n.renderer=this,this.tileCache.add(t.id,n)}On(t){const e={loadTime:s.Util.now(),current:!0,node:t};e.renderer=this,this.tileCache.add(t.id,e)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.Ze[e]}un(){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},r=this.canvas.gl&&this.canvas.gl.wrap;r?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.Sn(this.canvas,e)),this.regl=this.regl||n.createREGL({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),this.prepareWorker(),r&&(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 js(this.regl,t),this.layer.En(),this.layer.fire("contextcreate",{regl:this.regl})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new $e("@maptalks/3dtiles",t.id,n.reshader.Util.supportNPOT(this.regl)));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=yt({},r),delete r.offset;const s=t.options.spatialReference;r.projection=s&&s.coordType||s&&s.projection||t.getSpatialReference().getProjection().code;const i=this.layer.getId();e.addLayer(i,r,(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),hi--,hi||ci.reset(),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.hn(!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}hn(t){this.Cn||(this.Cn=Date.now());const e=Date.now();if(!t&&e-this.Cn<this.layer.options.retireInterval)return;this.Cn=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]]}ln(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}Sn(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}dn(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 Wn(t,e,0,n)}rn(){if(!this.Nn)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.Nn){const s=this.Nn[r];if("pending"===s.status)continue;s.status="pending";const i=s.rootIdx,o=Ut(this.layer.kt(i).fetchOptions);if(n.push(me.getJSON(r,o).then((t=>{delete this.Nn[r];const e=this.Tn[i];if(e){t.nodes?Vs(e,t.nodes):(e[t.id]=t,Vs(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)}tn(t,e,n){this.Nn||(this.Nn={}),this.Nn[e]=this.Nn[e]||[],this.Nn[e].rootIdx=t,this.Nn[e].push(n),this.setToRedraw()}xn(t,e,n){this.Tn||(this.Tn=[]);const r=e.Rt;this.Tn[r]||(this.Tn[r]={});const s=this.Tn[r],i=this.layer.kt(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),t.spatialReference&&4490===t.spatialReference.wkid&&(console.warn("i3s spatialReference is 4490,auto set spatialReference to 4326,This may cause some location issues, please ensure that your service is 4326"),t.spatialReference.wkid=4326),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 $s(s,n,i,t,o).load()}(this.layer,t,r,0,n,s,this.De).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.Ut||(this.Ut=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Ut[n];r||(r=this.Ut[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Ut[e];n||(n=this.Ut[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.Ut)}cancelHighlight(t,e){if(!this.Ut)return;const n=this.Ut[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.Ut[t]=null),this.painter.highlight(this.Ut)}}cancelAllHighlight(){delete this.Ut,this.painter.cancelAllHighlight()}showOnly(t){if(this.Ft||(this.Ft=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Ft[n];r||(r=this.Ft[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Ft[e];n||(n=this.Ft[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.Ft)}cancelShowOnly(){delete this.Ft,this.painter.cancelShowOnly()}Be(){return this.painter?this.painter.Be():[]}Ye(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.kn();return si.set(e[0],e[1]),n.unproject(si,ii),t[0]=ii.x,t[1]=ii.y,t}return si.set(e[0],e[1]),n.getProjection().unproject(si,ii),t[0]=ii.x,t[1]=ii.y,t}Rn(t,e){const n=this.kn();return si.set(e[0],e[1]),n.project(si,ii),t[0]=ii.x,t[1]=ii.y,t}Pn(t,e){const n=this.kn();return si.set(e[0],e[1]),n.unproject(si,ii),t[0]=ii.x,t[1]=ii.y,t}kn(){const t=this.getMap().options.spatialReference.coordType;if(!t)throw new Error("Missing coordType in map spatialReference.");return this.Ln||(this.Ln=s.SpatialReference.getProjectionInstance(t)),this.Ln}}function li(t,e){return t.Qt-e.Qt}function fi(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function di(t,e,n){return Math.sqrt(function(t,e,n){const r=sn(mi,n,t),s=fi(pi,e,0),i=fi(gi,e,1),o=fi(yi,e,2),a=dn(s),c=dn(i),h=dn(o);cn(s,s),cn(i,i),cn(o,o);const u=bi;u[0]=hn(r,s),u[1]=hn(r,i),u[2]=hn(r,o);let l,f=0;u[0]<-a?(l=u[0]+a,f+=l*l):u[0]>a&&(l=u[0]-a,f+=l*l);u[1]<-c?(l=u[1]+c,f+=l*l):u[1]>c&&(l=u[1]-c,f+=l*l);u[2]<-h?(l=u[2]+h,f+=l*l):u[2]>h&&(l=u[2]-h,f+=l*l);return f}(t,e,n))}const mi=[],pi=[],gi=[],yi=[],bi=[];const wi=2*Math.PI;class vi{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+=wi,n<0&&(n+=wi)),(n>s||Vn(n,s,1e-14))&&(n<i||Vn(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 Ti=[0,0,1];function _i(t,e){return Cn(e,t[0],t[1],t[2])}class Mi{constructor(t,e){this.normal=n.vec3.copy([],t),this.distance=e}static fromPointNormal(t,e,r){const s=-n.vec3.dot(e,t);return n.vec3.copy(r.normal,e),r.distance=s,r}}const Ai=[],Oi=[],xi=[],Ii=[],Si=[],Ei=[],Ci=[],Ni=[],ki=[],Ri=[],Pi=new Mi([1,0,0],0),Li=[];class Bi{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new vi(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let r=0;if(!vi.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,s=this.northeastCornerCartesian,i=this.westNormal,o=this.southNormal,a=this.eastNormal,c=this.northNormal,h=n.vec3.subtract(Li,t,e),u=n.vec3.dot(h,i),l=n.vec3.dot(h,o),f=n.vec3.subtract(Li,t,s),d=n.vec3.dot(f,a),m=n.vec3.dot(f,c);u>0?r+=u*u:d>0&&(r+=d*d),l>0?r+=l*l:m>0&&(r+=m*m)}const s=e[2],i=this.minimumHeight,o=this.maximumHeight;if(s>o){const t=s-o;r+=t*t}else if(s<i){const t=i-s;r+=t*t}return Math.sqrt(r)}computeBox(t){const e=this;_i(vi.southwest(t,Oi),e.southwestCornerCartesian),_i(vi.northeast(t,Oi),e.northeastCornerCartesian),Ai[0]=t.west,Ai[1]=.5*(t.south+t.north),Ai[2]=0;const r=_i(Ai,xi),s=n.vec3.cross(Si,r,Ti);n.vec3.normalize(e.westNormal,s),Ai[0]=t.east;const i=_i(Ai,Ni),o=n.vec3.cross(Si,Ti,i);n.vec3.normalize(e.eastNormal,o);const a=n.vec3.subtract(Si,r,i),c=n.vec3.normalize(Ii,a),h=t.south;let u;if(h>0){Ai[0]=.5*(t.west+t.east),Ai[1]=h;const r=_i(Ai,ki);n.vec3.copy(Ri,c);const s=Mi.fromPointNormal(e.southwestCornerCartesian,e.westNormal,Pi);Ui(ki,Ri,s,e.southwestCornerCartesian),u=zn(r,Ei)}else u=Hn(vi.southeast(t,Oi),Ei);const l=n.vec3.cross(Ci,u,a);n.vec3.normalize(e.southNormal,l);const f=t.north;let d;if(f<0){Ai[0]=.5*(t.west+t.east),Ai[1]=f;const r=_i(Ai,ki);n.vec3.scale(Ri,c,-1);const s=Mi.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,Pi);Ui(ki,Ri,s,e.northeastCornerCartesian),d=zn(r,Ei)}else d=Hn(vi.northwest(t,Oi),Ei);const m=n.vec3.cross(Ci,a,d);n.vec3.normalize(e.northNormal,m)}}function Ui(t,e,r,s){const i=t,o=e,a=r.normal,c=n.vec3.dot(a,o);if(Math.abs(c)<1e-15)return;const h=(-r.distance-n.vec3.dot(a,i))/c;return h<0?void 0:(s=n.vec3.scale(s,o,h),n.vec3.add(s,i,s))}function Di(t){return[t.xmin,t.ymin,t.xmax,t.ymax]}const Fi=s.BBOXUtil,ji={"services":[],"maxGPUMemory":s.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"debug":!1,"meshLimitPerFrame":1,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"onlyCacheNoContentTileWhenError":!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"]},qi=[0,0,0],zi=[0,0,0],Hi=[0,0,0],Gi=[0,0,0],Vi=[0,0,0],Ji=[0,0,0],$i=[0,0,0],Ki=[1,1,1],Xi=[1,1,1],Yi=[0,0,0,0],Wi=[],Zi=new s.Coordinate(0,0),Qi=new s.Point(0,0),to=[0,0,0,0,0,0,0,0,0],eo=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],no=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ro=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],so=new s.Point(0,0),io=n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),oo=[0,0],ao=[0,0,0],co=[1,1,1],ho=[0,0,0],uo=[0,0,0],lo=[0,0,0,0],fo=[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 mo extends(n.MaskLayerMixin(s.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new mo(t.id,t.options):null}static getEnuTransform(t,e=[1,1,1],r=[0,0,0]){const s=Cn([],t[0]*Math.PI/180,t[1]*Math.PI/180,t[2]||0),i=gr(s,null,[]),o=n.quat.fromEuler([0,0,0,0],...r),a=n.mat4.fromRotationTranslationScale([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o,[0,0,0],e);return n.mat4.multiply(a,i,a)}constructor(t,e){super(t,e),this.isGeo3DTilesLayer=!0,this.Bn(),this.Un=[]}Bn(){const t=this.options.services.map((t=>t.url));this.Dn=this.Dn||{},this._n=this._n||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.Dn[n];void 0===r&&(r=this.Dn[n]=this._n.length),this._n[r]=yo(n,r,this.options.services[e])}this.fire("rootready",{roots:this._n.slice(0)})}showService(t){return this.updateService(t,{visible:!0}),this}hideService(t){return this.updateService(t,{visible:!1}),this}setToRedraw(){return this.Fn(),this}addService(t){return this.options.services=this.options.services||[],this.options.services.push(t),this.Bn(),this.Fn(),this}updateService(t,e){if(!e)return this;const n=this.options.services;let r=!1;n&&n[t]&&(r=!(vo(n[t].coordOffset,e.coordOffset)&&vo(n[t].heightOffset,e.heightOffset)&&vo(n[t].scale,e.scale)&&vo(n[t].rotation,e.rotation)),yt(n[t],e));const s=n[t].url,i=this.Dn[s],o=this._n&&this._n[i];return o&&(gt(e.visible)||(o.visible=e.visible),r&&o.version++),this.Fn(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.Dn[n];this._n[r]&&(this._n[r]=null),delete this.Dn[n],e.splice(t,1)}return this.Fn(),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),i=s%r;return t.replace(e.domainKey,n[i])}}return t}getExtent(t){if(!t&&0!==t){const t=new s.Extent;for(let e=0;e<this._n.length;e++){const n=this._n[e];if(n&&n.boundingVolume){const e=this.boundingVolumeToExtent(n);t._combine(e)}}return t}const e=this._n[t];return e&&e.boundingVolume?this.boundingVolumeToExtent(e):null}boundingVolumeToExtent(t){const e=t.boundingVolume.jn?io:t.matrix,r=this.getMap(),i="identity"===r.getProjection().code.toLowerCase(),o=this.getRenderer();if(t.boundingVolume.region){const e=t.boundingVolume.region;return new s.Extent(_t(e[0]),_t(e[1]),_t(e[2]),_t(e[3]))}if(t.boundingVolume.sphere){const a=t.boundingVolume.sphere,c=Bn([],n.vec3.transformMat4([0,0,0],a,e));i&&o.Rn(c,c);const h=a[3],u=r.locate(c,-h,h),l=r.locate(c,h,-h);return new s.Extent(u,l)}if(t.boundingVolume.box){const a=t.boundingVolume.box,c=n.vec3.transformMat4([0,0,0],a,e),h=new s.Coordinate(Bn([],c));i&&o.Rn(h,h);const u=a.slice(3);n.mat3.multiply(u,n.mat3.fromMat4([0,0,0,0,0,0,0,0,0],t.matrix),u);const l=n.vec3.length(u.slice(0,3)),f=n.vec3.length(u.slice(3,6)),d=n.vec3.length(u.slice(6,9)),m=Math.max(l,f,d),p=r.locate(h,-m,m),g=r.locate(h,m,-m);return new s.Extent(p,g)}return null}getRootTiles(){return this._n}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Fn(),{tiles:Wi};const e=this.getMap(),r=e.cameraPosition,s=e.pointAtResToDistance(r[2],0,e.getGLRes()),i=this.qn(r);this.zn=this.zn||[0,0,0],n.vec3.set(this.zn,Tt(i.x),Tt(i.y),s),this.Hn=Cn(this.Hn||[],this.zn[0],this.zn[1],this.zn[2]),this.Gn=2*Math.tan(.5*Tt(e.getFov()));const o=e.projViewMatrix;let a;if(e.getPitch()<=80){const t=e.getExtent(),n=t.getWidth()/2,r=t.getHeight()/2;t.xmin-=n,t.ymin-=r,t.xmax+=n,t.ymax+=r,a=Di(t)}const c=(this.getMasks()||[]).filter((t=>t&&t instanceof n.ClipOutsideMask));c.forEach((t=>{if(!t.maskGeoJSON&&t.toGeoJSON)try{t.maskGeoJSON=t.toGeoJSON();const e=t.getExtent();t.maskGeoJSON.bbox=Di(e)}catch(t){console.error(t)}}));const h={children:[],level:-1};let u=h;const l=[];for(let e=0;e<this._n.length;e++){const n=this._n[e];if(!n||!n.visible)continue;const r=n.service,s=[n],i=this.Vn(e);for(;s.length>0;){const e=s.pop();for(e.id||this.Jn(e);u.level>=e.bn;)u=u.parent;const n=this.$n(e,i,o,a,c);if(e.service=r,!(n===To.VISIBLE||n!==To.OUT_OF_FRUSTUM&&this.options.alwaysShowTopTiles&&wo(e))){let t=u;for(;t&&!t.content;)t=t.parent;n===To.SCREEN_ERROR_TOO_SMALL&&t&&t.content&&this.Kn(l,t);continue}e.Qt<1/0&&this.Xn(e);const h=this.wn(e,u);u.children.push(h);const f=e.children,d=f&&f.length,m=h.content;if(m&&(!d||n===To.SCREEN_ERROR_TOO_SMALL)&&this.Kn(l,h),n!==To.SCREEN_ERROR_TOO_SMALL&&d){m&&"add"===e.refine&&this.Kn(l,h),u=h;const n=f[0].parent;let r=!1;for(let i=0,o=f.length;i<o;i++){if(n){const e=t.getCachedTile(f[i].id);if(e&&e.error&&404!==e.error.status)continue;r=!0}else{r=!0,f[i].parent=e,f[i].le=e.le,f[i].baseUrl=e.baseUrl;const t=f[i].content&&(f[i].content.url||f[i].content.uri);t&&(Ct(t)||t.indexOf("i3s:")>=0?f[i].baseUrl=e.baseUrl:Bt(t)?f[i].content.url=e.baseUrl+t:f[i].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}s.push(f[i])}!r&&m&&this.Kn(l,h)}}}return{root:h,tiles:l}}Kn(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 po(n,e,r)<=0;if(n.box)return 0===go(n,e,r)}return!1}(this.zn,this.Hn,n,r)||t.push(e)}wn(t,e){return{id:t.id,node:t,children:[],level:t.bn,parent:e,content:t.content&&t.content.url}}Jn(t){const e=this.getId();t.id=e+":"+s.Util.GUID(),t.matrix=t.transform||n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),t.Yn=this.Wn(t),t.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(t)||(t.matrix=n.mat4.multiply(t.matrix,t.parent.matrix,t.matrix)),t.Rt=t.parent.Rt,void 0===t.bn&&(t.bn=t.parent.bn+1),t.maxExtent=t.parent.maxExtent),t.refine=t.refine&&t.refine.toLowerCase()||"replace",t.content&&!t.content.url&&t.content.uri&&(t.content.url=t.content.uri)}kt(t){return this._n[t].service}Zn(t){const e=t.boundingVolume;if(!e||e.jn&&!this.Qn(t))return;const r=this.kt(t.Rt),s=r.heightOffset||0,i=this.options.offset,o=bt(i)||i[0]||i[1],a=r.coordOffset||oo;if(!Array.isArray(a))throw new Error("service.coordOffset must be an array");if(!e.jn&&(!t.boundingVolume||!s&&n.mat4.exactEquals(t.matrix,io)&&!o&&a===oo))return;e.box&&e.region&&delete e.region;const{region:c,box:h,sphere:u}=e;if(e.coordOffset=[a[0],a[1]],e.heightOffset=s,c){e.originalVolume||(e.originalVolume=c.slice(0));const t=e.originalVolume,n=this.tr([_t(t[0]),_t(t[1])]);c[0]=Tt(n.x+a[0]),c[1]=Tt(n.y+a[1]);const r=this.tr([_t(t[2]),_t(t[3])]);c[2]=Tt(r.x+a[0]),c[3]=Tt(r.y+a[1]),c[4]=t[4]+s+(a[2]||0),c[5]=t[5]+s+(a[2]||0)}else if(h||u){e.originalVolume||(e.originalVolume=(h||u).slice(0));const r=h||u,i=e.originalVolume,o=n.vec3.transformMat4(qi,i,t.matrix),c=Bn(zi,o),l=this.tr([c[0]+a[0],c[1]+a[1]]);c[0]=l.x,c[1]=l.y,c[2]+=s+(a[2]||0),Cn(r,Tt(c[0]),Tt(c[1]),c[2])}e.jn=!0;try{t.extent=this.boundingVolumeToExtent(t)}catch(t){console.error(t)}}Qn(t){const e=t.boundingVolume,n=this.kt(t.Rt),r=n.heightOffset||0,s=n.coordOffset||oo;return e.coordOffset[0]!==s[0]||e.coordOffset[1]!==s[1]||e.heightOffset!==r}Wn(t){return void 0===t.geometricError||!t.boundingVolume}Xn(t){let e=t.parent;for(;e&&e.Yn&&!(e.Qt<=t.Qt);)e.Qt=t.Qt,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.Fn()}}onTilesetLoad(t,e,r){if(!t)return void console.warn("invalid tileset at : "+r);const s=(t.asset&&t.asset.gltfUpAxis||e&&e.le||"Y").toUpperCase();t.root.baseUrl=r.substring(0,r.lastIndexOf("/")+1);const i=r.indexOf("realspace/")>-1;0===e.bn&&t.asset&&t.asset.s3mType&&i&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root.le=s,e){const r=e.boundingVolume,s=e.er;s&&delete e.er,yt(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",r&&(e.boundingVolume=r);let i=t.root.transform;if(s){const t=this.kt(e.Rt);t.ecefTransform&&(i=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t.ecefTransform,i||io))}i&&(e.parent?o||(e.matrix=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.parent.matrix,i)):e.matrix=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.matrix,i)),delete e.content,t.root.content&&(e.content=t.root.content),e.Yn=this.Wn(e);const a=e.content&&(e.content.url||e.content.uri);a&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),!o&&a&&!Ct(a)&&Bt(a)&&(e.content.url=e.baseUrl+a),t.root&&!e.parent&&this.nr(e)}this.Fn(),this.fire("loadtileset",{tileset:t,index:e&&e.Rt,url:r})}rr(t,e,n){if(!t.extent||!Fi)return!0;const r=t.extent;if(lo[0]=r.xmin,lo[1]=r.ymin,lo[2]=r.xmax,lo[3]=r.ymax,e){if(!Fi.bboxIntersect(lo,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||Fi.bboxInMask(lo,e))return!0}return!1}return!0}$n(t,e,n,r,s){if(!this.rr(t,r,s))return To.OUT_OF_FRUSTUM;if(t.Qt=1/0,0===t.bn||t.Yn)return this.nr(t),To.VISIBLE;if(this.Zn(t),!this.sr(t,e,n))return To.OUT_OF_FRUSTUM;if(0===t.geometricError)return To.VISIBLE;let i=this.kt(t.Rt).maximumScreenSpaceError;null==i&&(i=16);let o=this.ir(t);return 0===o&&t.parent&&(o=.5*(t.parent.ar||0)),o>=i?To.VISIBLE:To.SCREEN_ERROR_TOO_SMALL}Pe(t,e){e||(e=new s.Point(0,0));const n=this.getMap();return n.coordToPointAtRes(t,n.getGLRes(),e)}sr(t,e,n){const r=t.id;let s=this.Un[r];const{boundingVolume:i}=t,o=i.region,a=i.box,h=i.sphere,u=this.cr(t.Rt),l=this.getRenderer();s&&s.version===u.version||(o?s=this.Un[r]=this.hr(t):a?s=this.Un[r]=this.ur(t):h&&(s=this.Un[r]=this.lr(t)),s.version=u.version,t.te&&(l.Oe(t.te),delete t.te));return this.kt(t.Rt).debug&&(this.Un[r].node=t,l.Me(t)),s.obbox?function(t,e,n){_(t);for(var r=0;r<6;r++)if(!T(c[r],e))return!1;return!0}(n,s.obbox):!!h&&function(t,e,n){_(t);for(var r=e[0],s=-e[1],i=0;i<6;i++)if(A(c[i],r)<s)return!1;return!0}(n,s.sphereBox)}hr(t){const e=this.getMap(),r=e.getGLRes(),i=t.boundingVolume.region;let{ws:o,en:a}=function(t){const e=t[0],n=t[1],r=t[2],s=t[3],i=t[4],o=t[5],a=Cn([],e,n,i),c=Cn([],r,s,o),h=Bn(a,a),u=Bn(c,c);return{ws:h,en:u}}(i);o=new s.Coordinate(o),a=new s.Coordinate(a);const c=e.coordToPointAtRes(o,r);c.z=e.altitudeToPoint(o.z,r);const h=e.coordToPointAtRes(a,r);h.z=e.altitudeToPoint(a.z,r);const u=[h.x,c.y,h.z,h.x,h.y,h.z,c.x,h.y,h.z,c.x,c.y,h.z,h.x,c.y,c.z,h.x,h.y,c.z,c.x,h.y,c.z,c.x,c.y,c.z],l=[(u[0]+u[18])/2,(u[1]+u[19])/2,(u[2]+u[20])/2],f=this.cr(t.Rt);t!==f||f.dr||(f.dr=l);const d=this.ke([],t),m=n.mat4.exactEquals(io,d);if(!m){n.vec3.transformMat4(l,l,d);const t=qi;for(let e=0;e<u.length;e+=3){let r=n.vec3.set(t,u[e],u[e+1],u[e+2]);m||(r=n.vec3.transformMat4(r,r,d)),u[e]=r[0],u[e+1]=r[1],u[e+2]=r[2]}}const p=e.pointAtResToCoord(new s.Point(l),r);p.z=(o.z+a.z)/2;const g=this.mr(u,l);for(let t=0;t<u.length;t++)u[t]-=l[t%3];return{obbox:g,boxPosition:u,boxCenter:l,boxCoord:p}}ur(t){const e=this.getRenderer(),r=this.getMap(),s="identity"===r.getProjection().code.toLowerCase(),i=r.getGLRes(),{boxCenter:o,boxCoord:a}=this.pr(t),c=t.boundingVolume.box,h=function(t,e,n){return function(t,e,n,r,s,i,o,a,c,h,u,l,f,d,m,p,g){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]=u||0,t[7]=0,t[8]=r||0,t[9]=a||0,t[10]=l||0,t[11]=0,t[12]=s||0,t[13]=c||0,t[14]=f||0,t[15]=g,t}(t,e[0],e[3],e[6],n[0],e[1],e[4],e[7],n[1],e[2],e[5],e[8],n[2],0,0,0,1)}([],this.gr(c,t.matrix),c),u=this.ke([],t),l=n.mat4.exactEquals(io,u);l||n.vec3.transformMat4(o,o,u);const f=[],d=qi;for(let t=0;t<fo.length;t+=3){d[0]=fo[t],d[1]=fo[t+1],d[2]=fo[t+2],n.vec3.transformMat4(d,d,h),Bn(d,d),s&&e.Rn(d,d);const o=Zi.set(d[0],d[1],d[2]);r.coordToPointAtRes(o,i,Qi);let a=n.vec3.set(d,Qi.x,Qi.y,r.altitudeToPoint(o.z,i));l||(a=n.vec3.transformMat4(a,a,u)),f[t]=a[0],f[t+1]=a[1],f[t+2]=a[2]}const m=this.mr(f,o);for(let t=0;t<f.length;t++)f[t]-=o[t%3];return{obbox:m,boxPosition:f,boxCenter:o,boxCoord:a}}lr(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),i=t.boundingVolume.sphere,o=i;let a=qi;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:Bn(a,o),r&&n.Rn(a,a);const c=new s.Coordinate(a),h=this.Pe(c,Qi).toArray();h[2]=e.altitudeToPoint(c.z,e.getGLRes());const u=this.yr(c);return{boxCenter:h,boxCoord:c,sphereBox:[h,i[3]*u[2]]}}mr(t,e){const r=bo(Vi,t,0,1,4,5),s=bo(Ji,t,0,3,4,7),i=bo($i,t,0,1,2,3);return[...e,...n.vec3.sub(qi,r,e),...n.vec3.sub(zi,s,e),...n.vec3.sub(Hi,i,e)]}pr(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),i=e.getGLRes(),o=t.boundingVolume.box.slice(0,3);Bn(o,o),r&&n.Rn(o,o);const a=new s.Coordinate(o),c=e.coordToPointAtRes(a,i);return{boxCenter:[c.x,c.y,e.altitudeToPoint(a.z,i)],boxCoord:a}}ke(t,e){const r=this.cr(e.Rt),s=this.kt(e.Rt),i=r.dr,o=n.mat4.fromTranslation(eo,n.vec3.set(qi,-i[0],-i[1],-i[2])),a=n.mat4.fromTranslation(no,i),c=s.rotation||ao,h=n.quat.fromEuler(Yi,...c),u=s.scale;let l;l=Array.isArray(u)?n.vec3.set(ho,u[0],u[1],u[2]):u&&n.vec3.set(ho,u,u,u)||co;const f=n.mat4.fromRotationTranslationScale(ro,h,uo,l);return t=n.mat4.multiply(t,f,o),n.mat4.multiply(t,a,t)}nr(t){const e=this.kt(t.Rt);if(!t.boundingVolume||this.br(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,s=t.boundingVolume.sphere;let i=null;n?i=this.wr(t).boxCenter:r?i=this.vr(t).boxCenter:s&&(i=this.lr(t).boxCenter);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.Tr=[a[0]||0,a[1]||0],t._r=o,t.dr=i}br(t,e){if(!t.Tr)return!1;const n=e.coordOffset||oo;return t.Tr[0]===n[0]&&t.Tr[1]===n[1]&&t._r===(e.heightOffset||0)}vr(t){return this.Zn(t),this.hr(t)}wr(t){return this.Zn(t),this.pr(t)}gr(t,e){let r=t.slice(3,12);const s=n.mat3.fromMat4(to,e);return r=n.mat3.multiply(r,s,r),r}yr(t){const e=this.getMap(),r=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let s;return s=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:r.y/100,n.vec3.set(Ki,r.x/100*1.01,r.y/100*1.01,s),Ki}tr(t){Array.isArray(t)&&(t=new s.Coordinate(t));let e=this.options.offset;if(bt(e)&&(e=e.call(this,Array.isArray(t)?new s.Coordinate(t):t)),e[0]||e[1]){const n=this.getMap(),r=n.getGLRes(),s=n.coordToPointAtRes(t,r);return Qi.set(e[0],e[1]),s._sub(Qi),n.pointAtResToCoord(s,r)}return t}cr(t){return this._n[t]}Vn(t){const e=this.kt(t).maxExtent;if(!e)return null;const n=this._n[t];return n.maxExtent||(n.maxExtent=new s.Extent(e).convertTo((t=>this.Pe(t)))),n.maxExtent}ir(t){const e=this.Gn,r=t.geometricError;if(0===r)return t.ar=0,0;const s=this.kt(t.Rt);let i=s.scale||1;if(Array.isArray(i)&&(i=n.vec3.length(i)),s.ecefTransform){const t=n.mat4.getScaling(Xi,s.ecefTransform);i*=n.vec3.len(t)}const o=this.getMap();let a;t.boundingVolume.region?a=function(t,e,n){t.Mr||(t.Mr=new Bi(t.boundingVolume.region));return t.Mr.distanceToCamera(e,n)}(t,this.Hn,this.zn):t.boundingVolume.sphere?a=po(t.boundingVolume,this.Hn):t.boundingVolume.box&&(a=go(t.boundingVolume,this.Hn));const c=Math.max(Math.abs(a),1e-7),h=r*i*o.height/(c*e);return t.Qt=a,t.ar=h,h}Fn(){const t=this.getRenderer();t&&t.setToRedraw()}Ae(t){return this.Un[t]}identify(t,e={}){const n=this.getMap(),r=this.getRenderer();if(!n||!r)return[];Array.isArray(t)&&(t=new s.Coordinate(t));const i=n.coordToContainerPoint(t);return this.identifyAtPoint(i,e)}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.Be():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.Ut||(this.Ut=[]),this.Ut.push(t),this)}En(){if(this.Ut){for(let t=0;t<this.Ut.length;t++)this.highlight(this.Ut[t]);delete this.Ut}}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.Ft||(this.Ft=[]),this.Ft.push(t),this)}Ar(){if(this.Ft){for(let t=0;t<this.Ft.length;t++)this.showOnly(this.Ft[t]);delete this.Ft}}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.Fn(),this):this}setServiceDebug(t,e){const n=this.options.services[t];n&&(n.debug=e);return this.getRenderer()?(this.Fn(),this):this}qn(t){const e=this.getMap(),n=e.getGLRes();so.set(t[0],t[1]);const r=e.pointAtResToCoord(so,n);return"identity"===e.getProjection().code.toLowerCase()?(zi[0]=r.x,zi[1]=r.y,this.getRenderer().Pn(qi,zi),r.set(qi[0],qi[1]),r):r}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function po(t,e,r){let s=t.sphere;r&&(s=n.vec3.transformMat4([0,0,0],s,r));const i=n.vec3.dist(s,e),o=t.sphere[3];return i<o?0:i-o}function go(t,e,r){const s=t.box;let i=n.vec3.set(qi,s[0],s[1],s[2]);r&&(i=n.vec3.transformMat4([0,0,0],i,r));return di(i,n.mat3.set(to,s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],s[11]),e)}function yo(t,e,r){const s=(t=Mt(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,Yn:!0,service:r,visible:!!gt(r.visible)||r.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Rt:e,bn:0,er:!0,domainKey:s}}function bo(t,e,r,s,i,o){const a=n.vec3.set(qi,e[3*r],e[3*r+1],e[3*r+2]),c=n.vec3.set(zi,e[3*s],e[3*s+1],e[3*s+2]),h=n.vec3.set(Hi,e[3*i],e[3*i+1],e[3*i+2]),u=n.vec3.set(Gi,e[3*o],e[3*o+1],e[3*o+2]);return t[0]=(a[0]+c[0]+h[0]+u[0])/4,t[1]=(a[1]+c[1]+h[1]+u[1])/4,t[2]=(a[2]+c[2]+h[2]+u[2])/4,t}function wo(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 vo(t,e){return Array.isArray(t)&&Array.isArray(e)?2===t.length?n.vec2.exactEquals(t,e):n.vec3.exactEquals(t,e):t===e}var To;mo.mergeOptions(ji),mo.registerRenderer("gl",ui),mo.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"}(To||(To={}));let _o=null;function Mo(){return _o||(_o={"image/crn":Gs.crn&&Gs.crn(),"image/ktx2":Gs.ktx2&&Gs.ktx2(),"image/cttf":Gs.ktx2&&Gs.ktx2(),"draco":Gs.draco&&Gs.draco()}),_o}class Ao{constructor(t,e,n){this.o=t,this.Or=e||Pe,this.h=n,this.Ir=Mo()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.Sr(t,e,n,r,s)):me.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Sr(t,s,n,r)}))}Sr(t,e,n,r,s){const i=s&&s.maxTextureSize,o=this.Er(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.Or(a,o.glb,{transferable:!0,requestImage:this.o,decoders:this.Ir,supportedFormats:this.h,maxTextureSize:i})}catch(t){return Promise.resolve({error:t})}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}}))}Er(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),u=s.getUint32(24,!0),l=28+e;h>=570425344?(l-=8,o=a,h=c,u=0,a=0,c=0):u>=570425344&&(l-=4,o=h,h=a,u=c,a=0,c=0);const f=[t];let d,m,p;if(a>0?(d=Kn(t,l,a),l+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(l+=c),h>0&&(m=Xn(t,l,h),l+=h,u>0)){const e=Yn(0,l,u);p=t.slice(e.offset,e.offset+e.byteLength),l+=u,f.push(p)}const g=d.BATCH_LENGTH,y={};if(d&&d.BATCH_ID){y.BATCH_ID=Zn(d.BATCH_ID,t,undefined.offset,g);const e=y.BATCH_ID.array&&y.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:p,b3dm:y,glb:{buffer:t,byteOffset:l,byteLength:s.byteLength+s.byteOffset-l}}}Cr(){return null}}class Oo{constructor(t,e,n,r){this.o=t,this.Or=e||Pe,this.h=n,this.Ir=Mo(),this.Nr=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.Sr(t,e,n,r,s)):me.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Sr(t,s,n,r)}))}Sr(t,e,n,r,s){return this.kr(t,e,n,r,s).then((({gltf:s,transferables:i})=>{const o=this.Rr(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})}))}kr(t,e,n,r,s){const i=s&&s.maxTextureSize,o={transferable:!0,requestImage:this.o,decoders:this.Ir,supportedFormats:this.h,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=xt(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?me.getArrayBuffer(r,{}).then((t=>this.Pr(r,{buffer:t.data,byteOffset:0},o))):me.getJSON(r,{}).then((t=>this.Pr(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.Pr(t,r,o)}}Pr(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.Or(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}}))}Rr(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:u}=or(s,32+e,o),l={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;l.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;l.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Lr(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=Zn(a.BATCH_ID,t,c.offset,f);const e=l.BATCH_ID.array&&l.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Br(new Uint16Array(t,e+c.offset,2*f))},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Br(new Uint16Array(t,e+c.offset,2*f))},o.push(l.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;l.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).slice()},o.push(l.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;l.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(l.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:h,batchTableBin:u,featureTable:a,i3dm:l,transferables:o}}Br(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)xo(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}Lr(t,e,n){return ir(new Float32Array(t.length),t,e,n)}Cr(){return null}}function xo(t,e,n,r){if(t[0]=Io(e,r),t[1]=Io(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]))*So(e),t[1]=(1-Math.abs(e))*So(t[1])}return cn(t,t)}function Io(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 So(t){return t<0?-1:1}class Eo{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.Sr(t,e,n,r)):me.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.Sr(t,s,n,r)}))}Sr(t,e,n,r){return this.Ur(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}))}Ur(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:u}=or(s,e+28,o),l=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.Dr||(this.Dr=Mo().draco),this.Dr(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.Fr(t,e.attributes,c.offset,d,o,l,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:sr(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?r.BATCH_ID=Zn(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=Co(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:u,featureTable:a,pnts:r,transferables:o}}))}const g=this.Fr(t,a,c.offset,d,o,l,f);if(a.BATCH_ID||Object.keys(h).length){a.BATCH_ID?g.BATCH_ID=Zn(a.BATCH_ID,t,c.offset,d):g.BATCH_ID=Co(d);const e=g.BATCH_ID.array&&g.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:h,batchTableBin:u,featureTable:a,pnts:g,transferables:o})}Fr(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 u=h?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Lr(h||new Uint16Array(t,c+u,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}Lr(t,e,n){return ir(new Float32Array(t.length),t,e,n)}Cr(){return null}}function Co(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:sr(e),array:n}}class No{constructor(t,e,n,r){this.h=n,this.o=t,this.Or=e||Pe,this.Nr=r}load(t,e,n=0,r=0,s){return e?this.Sr(t,e,n,r,s):me.getArrayBuffer(t,{}).then((e=>{const s=e.data;return this.Sr(t,s,n,r)}))}Sr(t,e,n,r,s){r||(r=e.byteLength);const i=this.jr(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new Ao(this.o,this.Or,this.h);else if("i3dm"===i[n].magic)r=new Oo(this.o,this.Or,this.h,this.Nr);else if("pnts"===i[n].magic)r=new Eo;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new No(this.o,this.Or,this.h,this.Nr)}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})))}jr(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=Jn(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(i.transcoders){const t=s.Map.VERSION;if(t.indexOf("1.0.0-beta")>=0||t.indexOf("1.0.0-alpha")>=0){const t=i.transcoders.inject(a);s.registerWorkerAdapter("@maptalks/3dtiles",t)}else s.registerWorkerAdapter("@maptalks/3dtiles",(function(){return i.transcoders.inject(a)}))}else s.registerWorkerAdapter("@maptalks/3dtiles",a);t.B3DMLoader=Ao,t.CMPTLoader=No,t.Geo3DTilesLayer=mo,t.Geo3DTilesUtil=Lt,t.Geo3DTransform=Gn,"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.102.2")}));
23
23
  //# sourceMappingURL=maptalks.3dtiles.js.map