@maptalks/3dtiles 0.14.0 → 0.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @maptalks/3dtiles v0.14.
|
|
2
|
+
* @maptalks/3dtiles v0.14.1
|
|
3
3
|
* LICENSE : UNLICENSED
|
|
4
4
|
* (c) 2016-2022 maptalks.org
|
|
5
5
|
*/
|
|
6
|
-
import*as t from"maptalks";import*as e from"@maptalks/gl";import{reshader as r,mat4 as n,vec3 as i,mat3 as s,vec4 as a,quat as o,createREGL as l}from"@maptalks/gl";const c='function(t){var e=1e-6,r="undefined"!=typeof Float32Array?Float32Array:Array;function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function i(t,e,r){var n=e[0],i=e[1],s=e[2],o=e[3],a=e[4],f=e[5],c=e[6],l=e[7],u=e[8],h=e[9],y=e[10],d=e[11],b=e[12],A=e[13],m=e[14],w=e[15],p=r[0],_=r[1],U=r[2],g=r[3];return t[0]=p*n+_*a+U*u+g*b,t[1]=p*i+_*f+U*h+g*A,t[2]=p*s+_*c+U*y+g*m,t[3]=p*o+_*l+U*d+g*w,p=r[4],_=r[5],U=r[6],g=r[7],t[4]=p*n+_*a+U*u+g*b,t[5]=p*i+_*f+U*h+g*A,t[6]=p*s+_*c+U*y+g*m,t[7]=p*o+_*l+U*d+g*w,p=r[8],_=r[9],U=r[10],g=r[11],t[8]=p*n+_*a+U*u+g*b,t[9]=p*i+_*f+U*h+g*A,t[10]=p*s+_*c+U*y+g*m,t[11]=p*o+_*l+U*d+g*w,p=r[12],_=r[13],U=r[14],g=r[15],t[12]=p*n+_*a+U*u+g*b,t[13]=p*i+_*f+U*h+g*A,t[14]=p*s+_*c+U*y+g*m,t[15]=p*o+_*l+U*d+g*w,t}function s(){var t=new r(3);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function o(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function a(t,e,n){var i=new r(3);return i[0]=t,i[1]=e,i[2]=n,i}function f(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function c(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function l(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function u(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function h(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function y(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function d(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}function b(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+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 A(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function m(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[0],a=r[1],f=r[2];return t[0]=i*f-s*a,t[1]=s*o-n*f,t[2]=n*a-i*o,t}function w(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[3]*n+r[7]*i+r[11]*s+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/o,t}var p=u,_=h,U=o;function g(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}function T(){var t=new r(4);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function v(t,r,n,i){var s=r[0],o=r[1],a=r[2],f=r[3],c=n[0],l=n[1],u=n[2],h=n[3],y=void 0,d=void 0,b=void 0,A=void 0,m=void 0;return(d=s*c+o*l+a*u+f*h)<0&&(d=-d,c=-c,l=-l,u=-u,h=-h),1-d>e?(y=Math.acos(d),b=Math.sin(y),A=Math.sin((1-i)*y)/b,m=Math.sin(i*y)/b):(A=1-i,m=i),t[0]=A*s+m*c,t[1]=A*o+m*l,t[2]=A*a+m*u,t[3]=A*f+m*h,t}s(),function(){var t,e=(t=new r(4),r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var I,S=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};s(),a(1,0,0),a(0,1,0),T(),T(),I=new r(9),r!=Float32Array&&(I[1]=0,I[2]=0,I[3]=0,I[5]=0,I[6]=0,I[7]=0),I[0]=1,I[4]=1,I[8]=1;\n/*!\n * @maptalks/gltf-loader v0.25.7\n * LICENSE : UNLICENSED\n * (c) 2016-2022 maptalks.org\n */\nlet E=0;function O(t){return null==t}function k(t){return!O(t)}function x(t){for(let e=1;e<arguments.length;e++){const r=arguments[e];for(const e in r)t[e]=r[e]}return t}function F(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView\'s component type: "+t)}function B(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function D(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),r=e.length,n=new Uint8Array(r);for(let t=0;t<r;t++)n[t]=e.charCodeAt(t);return n.buffer}const R=[],M=[],L=[],N=[0,0,0],P=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),Z=[1,1,1];function C(t,e,r,n,i,s,o){const a=F(o);if((0===i||i===n*a.BYTES_PER_ELEMENT)&&s%a.BYTES_PER_ELEMENT==0){const i=new a(e,s,r*n);return t.set(i),t}const f=new Uint8Array(n*a.BYTES_PER_ELEMENT);for(let o=0;o<r;o++){let r=null;const c=new Uint8Array(e,i*o+s,n*a.BYTES_PER_ELEMENT);f.set(c),r=new a(f.buffer,0,n);for(let e=0;e<n;e++)t[o*n+e]=r[e]}return t}const z="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function V(t,e,r){const n=new Uint8Array(t,e,r);return z.decode(n)}const H={get:function(t,e={}){e||(e={});const r=new AbortController,n={signal:r.signal,method:e.method||"GET",referrerPolicy:"origin"};"POST"===e.method&&(O(e.body)||(n.body=JSON.stringify(e.body))),O(e.headers)||(n.headers=e.headers),O(e.credentials)||(n.credentials=e.credentials);const i=fetch(t,n).then((t=>{const r=this.t(t,e.responseType);return r.message?r:r.then((r=>"arraybuffer"===e.responseType?{data:r,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:r)).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 i.xhr=r,i},t:(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={})=>(e||(e={}),e.responseType="arraybuffer",H.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?H.jsonp(t):((e=e||{}).responseType="json",H.get(t,e))}};H.jsonp=function(t){const e="_maptalks_jsonp_"+E++;t.match(/\\?/)?t+="&callback="+e:t+="?callback="+e;let r=document.createElement("script");return r.type="text/javascript",r.src=t,new Promise((t=>{window[e]=function(n){document.getElementsByTagName("head")[0].removeChild(r),r=null,delete window[e],t(n)},document.getElementsByTagName("head")[0].appendChild(r)}))};class j{constructor(t,e,r){this.i=t,this.decoders=e,this.o=r,this.images={},this.l={}}requestImageFromBufferURI(t,e,r){if(this.buffers[t.id]){const n=this.buffers[t.id],i=this.u(e,n);return this.getImageByBuffer(i,r)}if(this.l[t.id])return this.l[t.id].then((()=>{const n=this.buffers[t.id],i=this.u(e,n);return this.getImageByBuffer(i,r)}));if(B(t.uri)){const n=this.buffers[t.id]=D(t.uri),i=this.u(e,n);return this.getImageByBuffer(i,r)}return this.l[t.id]=H.getArrayBuffer(t.uri,null).then((n=>{const i=this.buffers[t.id]=n.data,s=this.u(e,i);return this.getImageByBuffer(s,r)}))}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const r=this.decoders;if(r[e.mimeType])return r[e.mimeType](t,{supportedFormats:this.o});if("image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType)return console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null);{if("image/dxt1"===e.mimeType||"image/dxt1a"===e.mimeType||"image/dxt3"===e.mimeType||"image/dxt5"===e.mimeType)return Promise.resolve({width:e.extras.width,height:e.extras.height,data:new Uint8Array(t)});const r=new Blob([t]),n=URL.createObjectURL(r);return this.h(e.id,n)}}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;if(this.l[t.id])return this.l[t.id].then((()=>this.images[t.id]));return this.l[t.id]=this.h(t.id,e)}h(t,e){return new Promise(((r,n)=>{this.i(e,((i,s)=>{i?n(i):(URL.revokeObjectURL(e),this.images[t]=s,r(this.images[t]))}))}))}}const G=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class K{constructor(t,e,r){this.rootPath=t,this.gltf=e,this.A=!1,this.glbBuffer=r,this.buffers={},this.requests={},this.accessors={},this.m()}p(t,e){const r=this.gltf,n=r.accessors[e];if(void 0===n.bufferView)return this.accessors[n.id]=this._(t,e,null,0),Promise.resolve(this.accessors[n.id]);if(n&&this.accessors[n.id])return Promise.resolve(this.accessors[n.id]);const i=r.bufferViews[n.bufferView];return this.U(i).then((r=>{const{buffer:i,byteOffset:s}=r;return this.accessors[n.id]=this._(t,e,i,s)}))}U(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(B(e.uri)){const t=this.buffers[e.id]=D(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const r=e.uri.indexOf("blob:")>=0;t=e.uri.indexOf("://")>0||r?e.uri:this.rootPath+"/"+e.uri;return this.requests[e.id]=H.getArrayBuffer(t,null).then((n=>{r&&URL.revokeObjectURL(t);return{buffer:this.buffers[e.id]=n.data,byteOffset:0}}))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}_(t,e,r,n=0){const i=this.gltf,s=i.accessors[e],o=void 0!==s.bufferView?i.bufferViews[s.bufferView]:{},a=(o.byteOffset||0)+n,f=this.g(s.type),c=F(s.componentType),l=o.byteStride||0;const u={array:undefined,name:t,accessorName:e,byteLength:s.count*f*c.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:f};if(s.min&&(u.min=s.min),s.max&&(u.max=s.max),r)if(this.A)u.byteStride=l,u.byteOffset=a+(s.byteOffset||0),!l||l===f*c.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(u.array=this.T(r,s.count,f,a+(s.byteOffset||0),c),u.array.buffer.byteLength===u.byteLength&&(u.byteOffset=0)):u.array=new Uint8Array(r,a,o.byteLength);else if(s.interleaved){u.byteStride=0,u.byteOffset=0;const t=new c(s.count*f);u.array=C(t,r,s.count,f,l,a+(s.byteOffset||0),s.componentType)}else u.byteStride=0,u.array=this.T(r,s.count,f,a+(s.byteOffset||0),c),u.byteOffset=u.array.byteOffset;else{u.array=new c(s.count);const t=u.min||u.max;t&&(u.array[0]=t[0],u.array[1]=t[1],u.array[2]=t[2])}return u}m(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let r=0;r<t.length;r++)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0);else for(const e in t)for(const r in t)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0)}T(t,e,r,n,i){return n%i.BYTES_PER_ELEMENT!=0&&(t=t.slice(n,n+e*r*i.BYTES_PER_ELEMENT),n=0),new i(t,n,r*e)}g(t){const e=G.indexOf(t);return G[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,r=e.map((t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:r}=e;return this.U(e).then((n=>{const{buffer:i,byteOffset:s}=n,o=V(i,s+(e.byteOffset||0),r);return t.content=o,t}))}if(t.uri){if(B(t.uri)){const e=D(t.uri),r=V(e,0,e.byteLength);return t.content=r,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return H.get(e).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(r).then((()=>t))}}class q extends j{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=r,this.accessor=new K(t,e,r)}iterate(t,e){const r=this.gltf[e];if(!r)return;let n=0;for(const e in r)t(e,r[e],n++)}createNode(t){const e={};if(k(t.name)&&(e.name=t.name),k(t.children)&&(e.children=t.children),k(t.jointName)&&(e.jointName=t.jointName),k(t.matrix)&&(e.matrix=t.matrix),k(t.rotation)&&(e.rotation=t.rotation),k(t.scale)&&(e.scale=t.scale),k(t.translation)&&(e.translation=t.translation),k(t.extras)&&(e.extras=t.extras),k(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}(R,e.translation||N),n=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,f=i+i,c=r*o,l=n*o,u=n*a,h=i*o,y=i*a,d=i*f,b=s*o,A=s*a,m=s*f;return t[0]=1-u-d,t[1]=l+m,t[2]=h-A,t[3]=0,t[4]=l-m,t[5]=1-c-d,t[6]=y+b,t[7]=0,t[8]=h+A,t[9]=y-b,t[10]=1-c-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(M,e.rotation||P),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}(L,e.scale||Z);return i(s,n,s),i(t,r,s)}return n(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}v(t){const e={};for(const r in t){const n=t[r];let i,s;n.instanceTechnique&&n.instanceTechnique.values?(i=n.instanceTechnique,s=i.values.diffuse):(i=n,s=i.values.tex||i.values.diffuseTex||i.values.diffuse);const o={"baseColorTexture":{index:s}};n.name&&(o.name=n.name),n.extensions&&(o.extensions=n.extensions),n.extras&&(o.extras=n.extras),e[r]=o}return e}I(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 r=this.gltf.bufferViews[e.bufferView],n=(r.byteOffset||0)+this.glbBuffer.byteOffset,i=r.byteLength,s=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,n,i);return this.getImageByBuffer(s,t)}return this.requestExternalImage(t)}S(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.I(r).then((t=>{const n=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extras:r.extras},sampler:n}}))}getBaseColorTexture(t){const e=this.gltf.materials[t];let r,n;if(e.instanceTechnique&&e.instanceTechnique.values?(r=e.instanceTechnique,n=r.values.diffuse):(r=e,n=r.values.tex||r.values.diffuseTex||r.values.diffuse),void 0===n||void 0===this.gltf.textures)return null;const i=this.gltf.textures[n];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}}class $ extends j{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.glbBuffer=r,this.buffers={},this.requests={},this.accessor=new K(t,e,r)}iterate(t,e){const r=this.gltf[e];if(r)for(let e=0;e<r.length;e++)t(e,r[e],e)}createNode(t){const e={};return x(e,t),!k(t.weights)&&this.gltf.meshes&&k(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}S(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.I(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}};x(n,e);const i=k(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return i&&(n.sampler=i),"image/dxt1"===r.mimeType?n.format=33776:"image/dxt1a"===r.mimeType?n.format=33777:"image/dxt3"===r.mimeType?n.format=33778:"image/dxt5"===r.mimeType&&(n.format=33779),t.format&&(n.format=t.format),n}))}I(t){if(!k(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],r=this.gltf.buffers[e.buffer];if(r.uri)return this.requestImageFromBufferURI(r,e,t);if(this.glbBuffer)return this.O(e,t)}return null}O(t,e){const r=this.u(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(r,e)}u(t,e,r){r=r||0;const n=t.byteOffset+r,i=t.byteLength;return new Uint8Array(e,n,i)}k(t,e){const r=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)r[e]=String.fromCharCode(t[e]);r.join("");const n="data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(r)));return n}getAnimations(t){const e=[];return t.forEach((t=>{e.push(this.getSamplers(t.samplers))})),Promise.all(e).then((e=>{for(let r=0;r<e.length;r++)t[r].samplers=e[r];return t}))}getSamplers(t){const e=[];for(let r=0;r<t.length;r++)(k(t[r].input)||k(t[r].output))&&(e.push(this.accessor.p("input",t[r].input)),e.push(this.accessor.p("output",t[r].output)));return Promise.all(e).then((e=>{for(let r=0;r<e.length/2;r++)t[r].input=e[2*r],t[r].output=e[2*r+1],t[r].interpolation||(t[r].interpolation="LINEAR");return t}))}}const J="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null,Y=1313821514,X=5130562;class W{static read(t,e=0,r=0){r||(r=t.byteLength);const n=new DataView(t,e,r),i=n.getUint32(4,!0);if(1===i)return W.readV1(n,e);if(2===i)return W.readV2(t,e);throw new Error("Unsupported glb version : "+i)}static readV1(t,e){const r=t.getUint32(8,!0),n=t.getUint32(12,!0);if(r!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb\'s byte length.");const i=Q(t.buffer,20+e,n);return{json:JSON.parse(i),glbBuffer:{byteOffset:20+e+n,buffer:t.buffer,byteLength:r}}}static readV2(t,e){let r,n,i;const s=new DataView(t,e+12);let o=0;for(;o<s.byteLength;){const a=s.getUint32(o,!0);o+=4;const f=s.getUint32(o,!0);if(o+=4,f===Y)r=Q(t,e+12+o,a);else if(f===X){i=e+12+o,n=a;break}o+=a}return{json:JSON.parse(r),glbBuffer:{byteOffset:i,buffer:t,byteLength:n}}}}function Q(t,e,r){if(J){const n=new Uint8Array(t,e,r);return J.decode(n)}return function(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=tt[i>>3&7];if(!(64&i)||!r||n+r>e)return null;for(i&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;i=i<<6|63&e}}r+=String.fromCharCode(i)}return r}(new Uint8Array(t,e,r))}const tt=[1,1,1,1,2,2,3,0];const et=[0,0,0],rt=[0,0,0,1],nt=[1,1,1],it={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},st={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},ot={F(t,e,r,n,i,s,o,a){const c=k(t)?e.animations:[e.animations[0]],l={};for(let e=0;e<c.length;e++){const u=c[e],h=u.name||e;if(k(t)&&h!==t)continue;const y=u.channelsMap[r];if(y)for(let t=0;t<y.length;t++){const e=y[t];"translation"===e.target.path?(this.B(i,u.samplers[e.sampler],n,1),l.translation=f(et,i)):"rotation"===e.target.path?(this.D(s,u.samplers[e.sampler],n,1),l.rotation=S(rt,s)):"scale"===e.target.path?(this.B(o,u.samplers[e.sampler],n,1),l.scale=f(nt,o)):"weights"===e.target.path&&a&&(this.B(a,u.samplers[e.sampler],n,a.length),l.weights=a)}}return l},B(t,e,r,n){switch(e.interpolation){case"LINEAR":{const i=this.R(st,e,r,1*n);i&&(t=function(t,e,r,n){for(let i=0;i<t.length;i++)t[i]=e[i]+n*(r[i]-e[i]);return t}(t,i.PREVIOUS,i.NEXT,i.INTERPOLATION));break}case"STEP":{const i=this.R(st,e,r,1*n);i&&(t=function(t,e){for(let r=0;r<t.length;r++)t[r]=e[r];return t}(t,...i.PREVIOUS));break}case"CUBICSPLINE":{const i=this.R(st,e,r,3*n);i&&(t=this.M(t,i,e.input.array,3*n));break}}return t},D(t,e,r){switch(e.interpolation){case"LINEAR":{const n=this.R(st,e,r,1);n&&v(t,n.PREVIOUS,n.NEXT,n.INTERPOLATION);break}case"STEP":{const n=this.R(st,e,r,1);n&&(t=g(t,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.R(st,e,r,3);if(n){for(let t=0;t<n.PREVIOUS.length;t++)n.PREVIOUS[t]=Math.acos(n.PREVIOUS[t]),n.NEXT[t]=Math.acos(n.NEXT[t]);t=this.M(t,n,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},L(t,e){const r=t.length;let n,i,s,o=0,a=r-1,f=Math.floor((o+a)/2);for(;o<=r-1&&a>=0;){if(o===a)return null;if(t[f]<=e&&e<=t[f+1]){const r=t[f];return n=f,i=f+1,s=(e-r)/(t[f+1]-r),{preIndx:n,nextIndex:i,interpolation:s}}e<t[f]?(a=f,f=Math.floor((o+a)/2)):t[f+1]<e&&(o=f,f=Math.floor((o+a)/2))}return null},R(t,e,r,n){const i=e.input.array,s=e.output.array,o=e.output.itemSize;(r<i[0]||r>i[i.length-1])&&(r=Math.max(i[0],Math.min(i[i.length-1],r))),r===i[i.length-1]&&(r=i[0]);const a=this.L(i,r);if(!a||!a.nextIndex)return null;const{preIndx:f,nextIndex:c,interpolation:l}=a;t.PREINDEX=f,t.NEXTINDEX=c,t.INTERPOLATION=l;const u=o*n;return t.PREVIOUS=s.subarray(t.PREINDEX*u,(t.PREINDEX+1)*u),t.NEXT=s.subarray(t.NEXTINDEX*u,(t.NEXTINDEX+1)*u),t},M(t,e,r,n){const i=e.INTERPOLATION,s=r[e.PREINDEX],o=r[e.NEXTINDEX];for(let r=0;r<3;r++){const a=e.PREVIOUS[n+r],f=(o-s)*e.PREVIOUS[2*n+r],c=e.NEXT[3+r],l=(o-s)*e.NEXT[r],u=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*a+(Math.pow(i,3)-2*Math.pow(i,2)+i)*f+(2*-Math.pow(i,3)+3*Math.pow(i,2))*c+(Math.pow(i,3)-Math.pow(i,2))*l;t[r]=u}return t},getAnimationClip(t,e,r,n){const i=t.nodes[e]&&t.nodes[e].weights;c(et,...it.TRANSLATION),g(rt,...it.ROTATION),c(nt,...it.SCALE);return this.F(n,t,e,r,et,rt,nt,i)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach(((e,r)=>{let n=-1/0,i=1/0;const s=e.channels;for(let t=0;t<s.length;t++){const r=s[t],o=e.samplers[r.sampler].input.array;o[o.length-1]>n&&(n=o[o.length-1]),o[0]<i&&(i=o[0])}const o=e.name||r;t.timeSpan[o]={max:n,min:i}})),t.timeSpan},getTimeSpanByName(t,e){const r=this.getTimeSpan(t);return r?k(e)?r[e]:r[Object.keys(r)[0]]:null}};let at=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(on){}t&&"undefined"!=typeof createImageBitmap&&(at=!0)}const ft="undefined"==typeof document?null:document.createElement("canvas");class ct{constructor(t,e,r){if(this.options=r||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:r,glbBuffer:n}=W.read(e.buffer,e.byteOffset,e.byteLength);this.N(t,r,n)}else this.N(t,e);this.P=new K(this.rootPath,this.gltf,this.glbBuffer),this.Z()}Z(){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.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}C(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.P.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.V(t),r=this.H(),n=this.j(),i=this.C();return Promise.all([e,r,n,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 r=e[t];r.channelsMap={};for(let t=0;t<r.channels.length;t++){const e=r.channels[t];r.channelsMap[e.target.node]||(r.channelsMap[e.target.node]=[]),r.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:r}=this.gltf;for(let r=0;r<e.length;r++)e[r].uri&&e[r].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[r].uri});for(let e=0;e<r.length;e++)r[e].uri&&r[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:r[e].uri})}return t}static getAnimationClip(t,e,r,n){return ot.getAnimationClip(t,e,r,n)}static getAnimationTimeSpan(t,e){return ot.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return F(t)}static readInterleavedArray(t,e,r,n,i,s,o){return C(t,e,r,n,i,s,o)}N(t,e,r){this.gltf=e,this.glbBuffer=r,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=at?yt.bind(this):this.options.requestImage||lt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new $(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="buffer_"+r}),"buffers"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors")):(this.adapter=new q(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"))}G(t,e){if(t.children&&t.children.length>0){if(!(r=t.children[0],"number"==typeof r&&isFinite(r)||function(t){return!O(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}(t.children[0])))return t;const n=t.children.map((t=>{const r=e[t];return r.nodeIndex=t,this.G(r,e)}));t.children=n}var r;return t}V(t){return this.K(t).then((t=>{const e=this.scenes=[];let r;for(const e in t)t[e]=this.G(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate(((n,i,s)=>{const o={};i.name&&(o.name=i.name),i.nodes&&(o.nodes=i.nodes.map((e=>t[e]))),this.gltf.scene===n&&(r=s),e.push(o)}),"scenes");const n={asset:this.gltf.asset,scene:r,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins};if(this.gltf.extensions&&(n.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.v(this.gltf.materials);n.materials=t}return n}))}K(t){return this.q(t).then((()=>{const t=this.nodes={};return this.adapter.iterate(((e,r)=>{const n=this.adapter.createNode(r,this.meshes,this.skins);t[e]=n}),"nodes"),t}))}$(){this.skins=[];const t=[];return this.adapter.iterate(((e,r,n)=>{t.push(this.J(r).then((t=>{t.index=n,this.skins.push(t)})))}),"skins"),t}J(t){const e=t.inverseBindMatrices;return this.adapter.accessor.p("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 k(t)?this.adapter.getAnimations(t):null}q(t){this.meshes={};let e=[];return this.adapter.iterate(((r,n,i)=>{e.push(this.Y(n,t).then((t=>{t.index=i,this.meshes[r]=t})))}),"meshes"),e=e.concat(this.$()),Promise.all(e)}Y(t,e){const r=t.primitives.map((t=>this.X(t,e))).filter((t=>!!t));return Promise.all(r).then((e=>{const r={};return x(r,t),r.primitives=e,r}))}j(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const r in t)e.push(this.adapter.S(r));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++){const r=e[t].image.array;if(e[t]&&r){let t;t=r instanceof ImageBitmap?r:r.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const r={},n=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(r[n[t]]=e[t]);return r}return e}))}X(t,e){let r;const n=[],i=t.extensions;if(k(t.targets))for(let e=0;e<t.targets.length;e++){const r=t.targets[e];for(const t in r){const i=this.adapter.accessor.p(`morphTargets_${t}_${e}`,r[t]);i&&n.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],f=this.P.U(a).then((r=>{const{buffer:n,byteOffset:i}=r;let{byteOffset:s,byteLength:f}=a;s||(s=0);const c=new DataView(n,i+s,f),l={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(c,l).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));n.push(f),r=Promise.all(n)}else{const e=t.attributes;for(const t in e){const r=this.adapter.accessor.p(t,e[t]);r&&n.push(r)}if(k(t.indices)){const e=this.adapter.accessor.p("indices",t.indices);e&&n.push(e)}r=Promise.all(n)}return r.then((e=>{if(i&&i.KHR_draco_mesh_compression){const r=t.targets?t.targets.length:0;e[r]=e[r].concat(e.slice(0,r)),e=e[r]}let r,n;const s={attributes:e.reduce(((t,e)=>{if("indices"===e.name)r=e;else if(e.name.indexOf("morphTargets_")>-1)n=n||{},n[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0],{itemSize:n,array:i}=e,s=i.length/n;for(let e=0;e<s;e++)for(let s=0;s<n;s++){const o=e*n+s;i[o]<t[s]&&(t[s]=i[o]),i[o]>r[s]&&(r[s]=i[o])}if(e.quantization){const n=e.quantization,i=n.range/(1<<n.quantizationBits),s=n.minValues;y(t,t,i),l(t,t,s),y(r,r,i),l(r,r,s)}e.min=t,e.max=r}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 r&&(s.indices=r),n&&(s.morphTargets=n),s.mode=k(t.mode)?t.mode:4,k(t.extras)&&(s.extras=t.extras),s}))}}function lt(t,e){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!ft)return void e(new Error("There is no canvas to draw image!"));ft.width=r.width,ft.height=r.height;const t=ft.getContext("2d");t.drawImage(r,0,0,r.width,r.height);const n=t.getImageData(0,0,r.width,r.height),i={width:r.width,height:r.height,data:new Uint8Array(n.data)};e(null,i)},r.onerror=function(t){e(t)},r.src=t}let ut,ht;function yt(t,e){ut||(ut=new OffscreenCanvas(2,2),ht=ut.getContext("2d")),fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{let{width:r,height:n}=t;dt(r)||(r=bt(r)),dt(n)||(n=bt(n));const i=this.options.maxTextureSize;i&&(r=Math.min(i,r)),i&&(n=Math.min(i,n)),ut.width=r,ut.height=n,ht.drawImage(t,0,0,r,n),t.close();const s=ht.getImageData(0,0,r,n);e(null,{width:r,height:n,data:new Uint8Array(s.data)})})).catch((t=>{console.warn(t),e(t)}))}function dt(t){return 0==(t&t-1)&&0!==t}function bt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function At(t){return t*Math.PI/180}function mt(t){return t/Math.PI*180}function wt(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const pt=[1,1,1,1,2,2,3,0];function _t(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=pt[i>>3&7];if(!(64&i)||!r||n+r>e)return null;for(i&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;i=i<<6|63&e}}r+=String.fromCharCode(i)}return r}const Ut=new Array(3),gt=new Array(3),Tt=[40680631590769,40680631590769,40408299984661.445];const vt=[1/6378137,1/6378137,1/6356752.314245179],It=[1/40680631590769,1/40680631590769,1/40408299984661.445],St=new Array(3),Et=new Array(3),Ot=new Array(3);function kt(t,e){const r=It,n=function(t,e,r,n,i){const s=e[0],o=e[1],a=e[2],f=r[0],c=r[1],l=r[2],u=s*s*f*f,h=o*o*c*c,d=a*a*l*l,b=u+h+d,A=Math.sqrt(1/b),m=y(xt,e,A);if(b<i)return isFinite(A)?m:void 0;const w=n[0],p=n[1],_=n[2],U=Ft;U[0]=m[0]*w*2,U[1]=m[1]*p*2,U[2]=m[2]*_*2;let g,T,v,I,S,E,O,k,x,F,B,D=(1-A)*Bt(e)/(.5*Bt(U)),R=0;do{D-=R,v=1/(1+D*w),I=1/(1+D*p),S=1/(1+D*_),E=v*v,O=I*I,k=S*S,x=E*v,F=O*I,B=k*S,g=u*E+h*O+d*k-1,T=u*x*w+h*F*p+d*B*_;R=g/(-2*T)}while(Math.abs(g)>1e-12);return t[0]=s*v,t[1]=o*I,t[2]=a*S,t}(St,e,vt,r,.1);let i=_(Et,n,r);i=Dt(i,i);const s=p(Ot,e,n),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),f=wt(A(s,e))*Bt(s);return t[0]=mt(o),t[1]=mt(a),t[2]=f,t}const xt=new Array(3),Ft=new Array(3);function Bt(t){return o(t)}function Dt(t,e){const r=e[0],n=e[1],i=e[2];let s=r*r+n*n+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function Rt(t,e){let r="";for(let n=0;n<4;n++){const i=t.getUint8(e+n);r+=String.fromCharCode(i)}return r}const Mt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Lt(t,e,r){const n=new Uint8Array(t,e,r);return Mt?JSON.parse(Mt.decode(n)):JSON.parse(_t(n))}function Nt(t,e,r){const n=new Uint8Array(t,e,r);return Mt?JSON.parse(Mt.decode(n)):JSON.parse(_t(n))}function Pt(t,e,r){return{offset:e,byteLength:r}}function Zt(t,e,r,n){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:f}=function(t){return Vt[t]}(s),c=function(t){if(!t)return 1;return zt[t]}(o);return{byteStride:0,byteOffset:i+r,itemSize:c,count:n*c,componentType:f,array:new a(e,r+i,n*c)}}function Ct(t,e,r,n){t.componentType||(t.componentType="UNSIGNED_SHORT");const i=Zt(t,e,r,n);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}const zt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Vt={"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 Ht(t){for(let e in Vt)if(t===Vt[e].ctor)return Vt[e].type;throw new Error("unrecognized ctor:"+t)}function jt(t,e,r,n){const i=t,s=e.length/3;for(let t=0;t<s;t++)i[3*t]=e[3*t]/65535*n[0]+r[0],i[3*t+1]=e[3*t+1]/65535*n[1]+r[1],i[3*t+2]=e[3*t+2]/65535*n[2]+r[2];return i}function Gt(t,e,r){let n=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0);const a=t.buffer;let f,c,l={},u={};n>0&&(l=Lt(a,e,n),e+=n),i>0&&(f=function(t,e,r){return{offset:e,byteLength:r}}(0,e,i),e+=i),s>0&&(u=Nt(a,e,s),e+=s);const h=Pt(0,e,o);return c=a.slice(h.offset,h.offset+h.byteLength),r.push(c),{featureTable:l,featureTableBin:f,batchTable:u,batchTableBin:c}}var Kt={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},qt={},$t={east:[],north:[],up:[],west:[],south:[],down:[]},Jt=[],Yt=[],Xt=[];const Wt=[0,0,0];function Qt(t,e,r,n){r=r||0,n=n||r;var i=Math.abs(t-e);return i<=n||i<=r*Math.max(Math.abs(t),Math.abs(e))}const te=(ie={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"}}[ee="east"][re="north"],qt[se=ee+re]?ne=qt[se]:(ne=function(t,r,n){if(c=Wt,l=(a=t)[0],u=a[1],d=a[2],A=c[0],w=c[1],p=c[2],Math.abs(l-A)<=e*Math.max(1,Math.abs(l),Math.abs(A))&&Math.abs(u-w)<=e*Math.max(1,Math.abs(u),Math.abs(w))&&Math.abs(d-p)<=e*Math.max(1,Math.abs(d),Math.abs(p)))f(Jt,Kt[ee]),f(Yt,Kt[re]),f(Xt,Kt[ie]);else if(Qt(t[0],0,1e-14)&&Qt(t[1],0,1e-14)){var i=wt(t[2]);f(Jt,Kt[ee]),"east"!==ee&&"west"!==ee&&y(Jt,Jt,i),f(Yt,Kt[re]),"east"!==re&&"west"!==re&&y(Yt,Yt,i),f(Xt,Kt[ie]),"east"!==ie&&"west"!==ie&&y(Xt,Xt,i)}else{!function(t,e){h(e,t,It),b(e,e)}(t,$t.up);var s=$t.up,o=$t.east;o[0]=-t[1],o[1]=t[0],o[2]=0,b($t.east,o),m($t.north,s,o),y($t.down,$t.up,-1),y($t.west,$t.east,-1),y($t.south,$t.north,-1),Jt=$t[ee],Yt=$t[re],Xt=$t[ie]}var a,c,l,u,d,A,w,p;return n[0]=Jt[0],n[1]=Jt[1],n[2]=Jt[2],n[3]=0,n[4]=Yt[0],n[5]=Yt[1],n[6]=Yt[2],n[7]=0,n[8]=Xt[0],n[9]=Xt[1],n[10]=Xt[2],n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n},qt[se]=ne),ne);\n/*!\n * @maptalks/gl v0.67.5\n * LICENSE : UNLICENSED\n * (c) 2016-2022 maptalks.com\n */var ee,re,ne,ie,se;const oe=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")},ae=oe(),fe=ae.gl_trans__coders=ae.gl_trans__coders||{};fe.inject=function(t){const e=t.toString(),r=e.indexOf("{")+1,n=e.substring(0,r),i=ae.gl_trans__coders=ae.gl_trans__coders||{};let s=`${n}\\n const _____getGlobal = ${oe.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(n.length),s},fe.registerTranscoder=function(t,e){fe[t]=e},fe.getTranscoder=function(t){return fe[t]};class ce{constructor(t,e,r){this.i=t,this.W=e||ct,this.o=r,this.tt={"image/crn":fe.crn&&fe.crn(),"image/ktx2":fe.ktx2&&fe.ktx2(),"image/cttf":fe.ktx2&&fe.ktx2(),"draco":fe.draco&&fe.draco()}}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.et(t,e,r,n,i)):H.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.et(t,i,r,n)}))}et(t,e,r,n,i){const s=i&&i.maxTextureSize,o=this.rt(e,r,n,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),f=new this.W(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.tt,supportedFormats:this.o,maxTextureSize:s});return f.load().then((e=>{e.url=`${t}-${r}-${n}`;const i=f.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}}))}rt(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", url:"+n;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: "+n;return console.warn(t),{error:t}}let o,a=i.getUint32(12,!0),f=i.getUint32(16,!0),c=i.getUint32(20,!0),l=i.getUint32(24,!0),u=28+e;c>=570425344?(u-=8,o=a,c=f,l=0,a=0,f=0):l>=570425344&&(u-=4,o=c,c=a,l=f,a=0,f=0);const h=[t];let y,d,b;if(a>0?(y=Lt(t,u,a),u+=a,o=y.BATCH_LENGTH):y={"BATCH_LENGTH":o},f>0&&(u+=f),c>0&&(d=Nt(t,u,c),u+=c,l>0)){const e=Pt(0,u,l);b=t.slice(e.offset,e.offset+e.byteLength),u+=l,h.push(b)}const A=y.BATCH_LENGTH,m={};if(y&&y.BATCH_ID){m.BATCH_ID=Ct(y.BATCH_ID,t,undefined.offset,A);const e=m.BATCH_ID.array&&m.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:o,transferables:h,featureTable:y,batchTable:d,batchTableBin:b,b3dm:m,glb:{buffer:t,byteOffset:u,byteLength:i.byteLength+i.byteOffset-u}}}nt(){return null}}class le{constructor(t,e,r,n){this.i=t,this.W=e||ct,this.o=r,this.tt={"image/crn":fe.crn&&fe.crn(),"image/ktx2":fe.ktx2&&fe.ktx2(),"image/cttf":fe.ktx2&&fe.ktx2(),"draco":fe.draco&&fe.draco()},this.it=n}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.et(t,e,r,n,i)):H.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.et(t,i,r,n)}))}et(t,e,r,n,i){return this.st(t,e,r,n,i).then((({gltf:i,transferables:s})=>{const o=this.ot(e,r,n,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})}))}st(t,e,r,n,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.tt,supportedFormats:this.o,maxTextureSize:s},a=new DataView(e,r,n),f=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let n=_t(new Uint8Array(e,f+r,a.byteLength-f));-1==n.indexOf("://")&&(n=t.substring(0,t.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?H.getArrayBuffer(n,{}).then((t=>this.at(n,{buffer:t.data,byteOffset:0},o))):H.getJSON(n,{}).then((t=>this.at(n,t,o)))}{const n={buffer:e,byteOffset:f+r,byteLength:a.byteLength-f};return this.at(t,n,o)}}at(t,e,r){const n=t.substring(0,t.lastIndexOf("/")),i=new this.W(n,e,r);return i.load({skipAttributeTransform:!0}).then((r=>{let n=0,s=0;return e.buffer&&(n=e.byteOffset||0,s=e.byteLength||0),r.url=`${t}-${n}-${s}`,{transferables:i.transferables,gltf:r}}))}ot(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;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: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:f,batchTable:c,batchTableBin:l}=Gt(i,32+e,o),u={},h=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;u.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+f.offset,3*h).slice()},o.push(u.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,r=a.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=a.POSITION_QUANTIZED;u.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.ft(new Uint16Array(t,n+f.offset,3*h),e,r)},o.push(u.POSITION.array.buffer)}if(a.BATCH_ID){u.BATCH_ID=Ct(a.BATCH_ID,t,f.offset,h);const e=u.BATCH_ID.array&&u.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+f.offset,3*h).slice()},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+f.offset,3*h).slice()},o.push(u.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.ct(new Uint16Array(t,e+f.offset,2*h))},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.ct(new Uint16Array(t,e+f.offset,2*h))},o.push(u.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;u.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+f.offset,h).slice()},o.push(u.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;u.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+f.offset,3*h).slice()},o.push(u.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:c,batchTableBin:l,featureTable:a,i3dm:u,transferables:o}}ct(t){const e=t.length/2,r=new Float32Array(3*e),n=[];for(let i=0;i<e;i++)ue(n,t[2*i],t[2*i+1],65535),r[3*i]=n[0],r[3*i+1]=n[1],r[3*i+2]=n[2];return r}ft(t,e,r){return jt(new Float32Array(t.length),t,e,r)}nt(){return null}}function ue(t,e,r,n){if(t[0]=he(e,n),t[1]=he(r,n),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]))*ye(e),t[1]=(1-Math.abs(e))*ye(t[1])}return b(t,t)}function he(t,e){return function(t,e,r){return t<e?e:t>r?r:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function ye(t){return t<0?-1:1}class de{constructor(){}load(t,e,r=0,n=0){return e?(n||(n=e.byteLength),this.et(t,e,r,n)):H.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.et(t,i,r,n)}))}et(t,e,r,n){return this.lt(e,r,n,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}))}lt(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;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: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:f,batchTable:c,batchTableBin:l}=Gt(i,e+28,o),u=a.QUANTIZED_VOLUME_OFFSET,h=a.QUANTIZED_VOLUME_SCALE,y=a.POINTS_LENGTH;let d,b={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){b=a.extensions["3DTILES_draco_point_compression"],d=new DataView(t,b.byteOffset+f.offset,b.byteLength);const e={attributes:b.properties,useUniqueIDs:!1};return this.ut||(this.ut=fe.draco()),this.ut(d,e).then((e=>{const r=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||r.POSITION||r.POSITION_QUANTIZED||(r.POSITION=a.POSITION,r.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||r.RGB||r.RGBA||r.RGB565||(r.RGB=a.RGB,r.RGBA=a.RGBA,r.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||r.NORMAL||r.NORMAL_OCT16P||(r.NORMAL=a.NORMAL,r.NORMAL_OCT16P=a.NORMAL_OCT16P);const n=this.ht(t,e.attributes,f.offset,y,o,u,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;n.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Ht(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(c).length){a.BATCH_ID?n.BATCH_ID=Ct(a.BATCH_ID,t,f.offset,y):n.BATCH_ID=be(y);const e=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:y,batchTable:c,batchTableBin:l,featureTable:a,pnts:n,transferables:o}}))}const A=this.ht(t,a,f.offset,y,o,u,h);if(a.BATCH_ID||Object.keys(c).length){a.BATCH_ID?A.BATCH_ID=Ct(a.BATCH_ID,t,f.offset,y):A.BATCH_ID=be(y);const e=A.BATCH_ID.array&&A.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:y,batchTable:c,batchTableBin:l,featureTable:a,pnts:A,transferables:o})}ht(t,e,r,n,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const f=o?0:r;if(!o){const e=t.slice(s+f,s+f+3*n*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},i.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:f,array:c}=e.POSITION_QUANTIZED;f=f||0;const l=c?0:r;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this.ft(c||new Uint16Array(t,f+l,3*n),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const f=o?0:r;if(!o){const e=t.slice(s+f,s+f+4*n);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:n,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const f=o?0:r;if(!o){const e=t.slice(s+f,s+f+3*n);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const f=o?0:r;if(!o){const e=t.slice(s+f,s+f+2*n);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:n,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const f=o?0:r;if(!o){const e=t.slice(s+f,s+f+3*n*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:n,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 f=o?0:r;if(!o){const e=t.slice(s+f,s+f+2*n);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:n,componentType:5121,array:o},i.push(o.buffer)}return a}ft(t,e,r){return jt(new Float32Array(t.length),t,e,r)}nt(){return null}}function be(t){const e=(r=t)<256?Uint8Array:r<65536?Uint16Array:Uint32Array;var r;const n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Ht(e),array:n}}class Ae{constructor(t,e){this.i=t,this.W=e||ct}load(t,e,r=0,n=0,i){return e?this.et(t,e,r,n,i):H.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.et(t,i,r,n)}))}et(t,e,r,n,i){n||(n=e.byteLength);const s=this.yt(e,t,r,n),o=[];for(let r=0;r<s.length;r++){let n;if("b3dm"===s[r].magic)n=new ce(this.i,this.W);else if("i3dm"===s[r].magic)n=new le(this.i,this.W);else if("pnts"===s[r].magic)n=new de;else{if("cmpt"!==s[r].magic){console.warn("Unsupported magic in CMPT tile:",s[r].magic);continue}n=new Ae(this.i,this.W)}o.push(n.load(t,e,s[r].offset,s[r].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}yt(t,e,r,n){const i=new DataView(t,r,n),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 f=16;for(let e=0;e<a;e++){const e=Rt(i,f),n=i.getUint32(f+8,!0);o.push({magic:e,buffer:t,offset:f+r,byteLength:n}),f+=n}return o}}function me(t,e){if(t.scenes&&t.scenes.length)for(let r=0,n=t.scenes.length;r<n;r++){const n=t.scenes[r].nodes;for(let r=0,i=n.length;r<i;r++){const i=[];we(n[r],i,t,e)}}}function we(t,e,r,n){if(t.matrix&&e.push(t.matrix),t.children&&t.children.length)for(let i=0,s=t.children.length;i<s;i++)we(t.children[i],e,r,n);if(void 0!==t.mesh){const i=t.mesh,s=r.meshes[i];if(s){const t=e.slice(0),o=s.primitives;for(let e=0,s=o.length;e<s;e++){const s=o[e];s&&(s.matrices=t,n(s,i,e,r))}}}}function pe(t,e){let{componentType:r,byteOffset:n,byteStride:i,count:s,itemSize:o}=t;const a=t.array.buffer,f=r?ct.getTypedArrayCtor(r):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,i=i||0,s=s||t.array.length/o,(!i||i===o*f.BYTES_PER_ELEMENT)&&n%f.BYTES_PER_ELEMENT==0){const t=new f(a,n,s*o);for(let r=0;r<s*o;r+=o){e(new f(t.buffer,n+r*f.BYTES_PER_ELEMENT,o),r/o)}return}const c=new Uint8Array(o*f.BYTES_PER_ELEMENT);i||(i=o*f.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const r=new Uint8Array(a,i*t+n,o*f.BYTES_PER_ELEMENT);c.set(r);e(new f(c.buffer),t),r.set(c)}}const _e=[],Ue=[];function ge(t){const e={asset:{version:"1.0",gltfUpAxis:"Z",s3mType:t.dataType},geometricError:0,root:{boundingVolume:{},content:{uri:""},transform:[],geometricError:0,refine:"REPLACE",children:[]}},r=t.position.x,n=t.position.y,i=t.position.z,s=function(t,e,r,n){const i=Tt,s=Math.cos(r);Ut[0]=s*Math.cos(e),Ut[1]=s*Math.sin(e),Ut[2]=Math.sin(r),Dt(Ut,Ut),h(gt,i,Ut);const o=Math.sqrt(A(Ut,gt));var a,f,c;return f=gt,c=o,(a=gt)[0]=f[0]/c,a[1]=f[1]/c,a[2]=f[2]/c,y(Ut,Ut,n),l(t,gt,Ut)}([],At(r),At(n),i),o=te(s,null,[]);e.root.transform=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}([],o);const a=[];for(let r=0,n=t.tiles.length;r<n;r++)if(t.tiles[r].boundingbox){const n=t.tiles[r].boundingbox;c(_e,n.min.x,n.min.y,n.min.z),c(Ue,n.max.x,n.max.y,n.max.z);const i={center:[0,0,0],radius:0};Te(_e,Ue,i),e.root.children.push({boundingVolume:{sphere:[...i.center,i.radius]},content:{uri:t.tiles[r].url},geometricError:70,refine:"REPLACE"}),a.push(i)}else if(t.tiles[r].boundingsphere){const{boundingsphere:n}=t.tiles[r],i={center:[n.center.x,n.center.y,n.center.z],radius:n.radius};e.root.children.push({boundingVolume:{sphere:[...i.center,i.radius]},content:{uri:t.tiles[r].url},geometricError:70,refine:"REPLACE"}),a.push(i)}const b=function(t,e){if(0===t.length)return e;const r=t.length;if(1===r)return function(t,e){return f(e.center,t.center),e.radius=t.radius,e}(t[0],e);if(2===r)return function(t,e,r){const n=t.center,i=t.radius,s=e.center,o=e.radius,a=u(Ie,s,n),c=Ce(a);if(i>=c+o)return t.clone(r),r;if(o>=c+i)return e.clone(r),r;const h=.5*(i+c+o),d=y(Se,a,(-i+h)/c);return l(d,d,n),f(r.center,d),r.radius=h,r}(t[0],t[1],e);const n=[];for(let e=0;e<r;e++)n.push(t[e].center);const i=(e=function(t,e){if(0===t.length)return e.center=c(e.center,0,0,0),e.radius=0,e;const r=f(De,t[0]),n=f(Ee,r),i=f(Oe,r),s=f(ke,r),o=f(xe,r),a=f(Fe,r),l=f(Be,r),h=t.length;for(let e=1;e<h;e++){f(r,t[e]);const c=r[0],u=r[1],h=r[2];c<n[0]&&f(n,r),c>o[0]&&f(o,r),u<i[1]&&f(i,r),u>a[1]&&f(a,r),h<s[2]&&f(s,r),h>l[2]&&f(l,r)}const y=Ze(u(Re,o,n)),d=Ze(u(Re,a,i)),b=Ze(u(Re,l,s));let A=n,m=o,w=y;d>w&&(w=d,A=i,m=a);b>w&&(w=b,A=s,m=l);const p=Me;p[0]=.5*(A[0]+m[0]),p[1]=.5*(A[1]+m[1]),p[2]=.5*(A[2]+m[2]);let _=Ze(u(Re,m,p)),U=Math.sqrt(_);const g=Le;g[0]=n[0],g[1]=i[1],g[2]=s[2];const T=Ne;T[0]=o[0],T[1]=a[1],T[2]=l[2];const v=ve(g,T,Pe);let I=0;for(let e=0;e<h;e++){f(r,t[e]);const n=Ce(u(Re,r,v));n>I&&(I=n);const i=Ze(u(Re,r,p));if(i>_){const t=Math.sqrt(i);U=.5*(U+t),_=U*U;const e=t-U;p[0]=(U*p[0]+e*r[0])/t,p[1]=(U*p[1]+e*r[1])/t,p[2]=(U*p[2]+e*r[2])/t}}U<I?(f(e.center,p),e.radius=U):(f(e.center,v),e.radius=I);return e}(n,e)).center;let s=e.radius;for(let e=0;e<r;e++){const r=t[e];s=Math.max(s,d(i,r.center)+r.radius)}return e.radius=s,e}(a,{center:[0,0,0],radius:0});return e.root.boundingVolume.sphere=[...b.center,b.radius],e}function Te(t,e,r){var n=ve(t,e,r.center);return r.radius=d(n,e),r}function ve(t,e,r){return r[0]=.5*(t[0]+e[0]),r[1]=.5*(t[1]+e[1]),r[2]=.5*(t[2]+e[2]),r}const Ie=[],Se=[];const Ee=[],Oe=[],ke=[],xe=[],Fe=[],Be=[],De=[],Re=[],Me=[],Le=[],Ne=[],Pe=[];function Ze(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function Ce(t){return Math.hypot(t[0],t[1],t[2])}\n/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */function ze(t){let e=t.length;for(;--e>=0;)t[e]=0}const Ve=256,He=286,je=30,Ge=15,Ke=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),qe=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),$e=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Je=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ye=new Array(576);ze(Ye);const Xe=new Array(60);ze(Xe);const We=new Array(512);ze(We);const Qe=new Array(256);ze(Qe);const tr=new Array(29);ze(tr);const er=new Array(je);function rr(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}let nr,ir,sr;function or(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}ze(er);const ar=t=>t<256?We[t]:We[256+(t>>>7)],fr=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},cr=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,fr(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)},lr=(t,e,r)=>{cr(t,r[2*e],r[2*e+1])},ur=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},hr=(t,e,r)=>{const n=new Array(16);let i,s,o=0;for(i=1;i<=Ge;i++)n[i]=o=o+r[i-1]<<1;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=ur(n[e]++,e))}},yr=t=>{let e;for(e=0;e<He;e++)t.dyn_ltree[2*e]=0;for(e=0;e<je;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},dr=t=>{t.bi_valid>8?fr(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},br=(t,e,r,n)=>{const i=2*e,s=2*r;return t[i]<t[s]||t[i]===t[s]&&n[e]<=n[r]},Ar=(t,e,r)=>{const n=t.heap[r];let i=r<<1;for(;i<=t.heap_len&&(i<t.heap_len&&br(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!br(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n},mr=(t,e,r)=>{let n,i,s,o,a=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*a]<<8|t.pending_buf[t.d_buf+2*a+1],i=t.pending_buf[t.l_buf+a],a++,0===n?lr(t,i,e):(s=Qe[i],lr(t,s+Ve+1,e),o=Ke[s],0!==o&&(i-=tr[s],cr(t,i,o)),n--,s=ar(n),lr(t,s,r),o=qe[s],0!==o&&(n-=er[s],cr(t,n,o)))}while(a<t.last_lit);lr(t,256,e)},wr=(t,e)=>{const r=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,f,c=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<s;o++)0!==r[2*o]?(t.heap[++t.heap_len]=c=o,t.depth[o]=0):r[2*o+1]=0;for(;t.heap_len<2;)f=t.heap[++t.heap_len]=c<2?++c:0,r[2*f]=1,t.depth[f]=0,t.opt_len--,i&&(t.static_len-=n[2*f+1]);for(e.max_code=c,o=t.heap_len>>1;o>=1;o--)Ar(t,r,o);f=s;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Ar(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,r[2*f]=r[2*o]+r[2*a],t.depth[f]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,r[2*o+1]=r[2*a+1]=f,t.heap[1]=f++,Ar(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const r=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,f=e.stat_desc.max_length;let c,l,u,h,y,d,b=0;for(h=0;h<=Ge;h++)t.bl_count[h]=0;for(r[2*t.heap[t.heap_max]+1]=0,c=t.heap_max+1;c<573;c++)l=t.heap[c],h=r[2*r[2*l+1]+1]+1,h>f&&(h=f,b++),r[2*l+1]=h,l>n||(t.bl_count[h]++,y=0,l>=a&&(y=o[l-a]),d=r[2*l],t.opt_len+=d*(h+y),s&&(t.static_len+=d*(i[2*l+1]+y)));if(0!==b){do{for(h=f-1;0===t.bl_count[h];)h--;t.bl_count[h]--,t.bl_count[h+1]+=2,t.bl_count[f]--,b-=2}while(b>0);for(h=f;0!==h;h--)for(l=t.bl_count[h];0!==l;)u=t.heap[--c],u>n||(r[2*u+1]!==h&&(t.opt_len+=(h-r[2*u+1])*r[2*u],r[2*u+1]=h),l--)}})(t,e),hr(r,c,t.bl_count)},pr=(t,e,r)=>{let n,i,s=-1,o=e[1],a=0,f=7,c=4;for(0===o&&(f=138,c=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=e[2*(n+1)+1],++a<f&&i===o||(a<c?t.bl_tree[2*i]+=a:0!==i?(i!==s&&t.bl_tree[2*i]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,s=i,0===o?(f=138,c=3):i===o?(f=6,c=3):(f=7,c=4))},_r=(t,e,r)=>{let n,i,s=-1,o=e[1],a=0,f=7,c=4;for(0===o&&(f=138,c=3),n=0;n<=r;n++)if(i=o,o=e[2*(n+1)+1],!(++a<f&&i===o)){if(a<c)do{lr(t,i,t.bl_tree)}while(0!=--a);else 0!==i?(i!==s&&(lr(t,i,t.bl_tree),a--),lr(t,16,t.bl_tree),cr(t,a-3,2)):a<=10?(lr(t,17,t.bl_tree),cr(t,a-3,3)):(lr(t,18,t.bl_tree),cr(t,a-11,7));a=0,s=i,0===o?(f=138,c=3):i===o?(f=6,c=3):(f=7,c=4)}};let Ur=!1;const gr=(t,e,r,n)=>{cr(t,0+(n?1:0),3),((t,e,r,n)=>{dr(t),n&&(fr(t,r),fr(t,~r)),t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r})(t,e,r,!0)};var Tr=t=>{Ur||((()=>{let t,e,r,n,i;const s=new Array(16);for(r=0,n=0;n<28;n++)for(tr[n]=r,t=0;t<1<<Ke[n];t++)Qe[r++]=n;for(Qe[r-1]=n,i=0,n=0;n<16;n++)for(er[n]=i,t=0;t<1<<qe[n];t++)We[i++]=n;for(i>>=7;n<je;n++)for(er[n]=i<<7,t=0;t<1<<qe[n]-7;t++)We[256+i++]=n;for(e=0;e<=Ge;e++)s[e]=0;for(t=0;t<=143;)Ye[2*t+1]=8,t++,s[8]++;for(;t<=255;)Ye[2*t+1]=9,t++,s[9]++;for(;t<=279;)Ye[2*t+1]=7,t++,s[7]++;for(;t<=287;)Ye[2*t+1]=8,t++,s[8]++;for(hr(Ye,287,s),t=0;t<je;t++)Xe[2*t+1]=5,Xe[2*t]=ur(t,5);nr=new rr(Ye,Ke,257,He,Ge),ir=new rr(Xe,qe,0,je,Ge),sr=new rr(new Array(0),$e,0,19,7)})(),Ur=!0),t.l_desc=new or(t.dyn_ltree,nr),t.d_desc=new or(t.dyn_dtree,ir),t.bl_desc=new or(t.bl_tree,sr),t.bi_buf=0,t.bi_valid=0,yr(t)},vr=(t,e,r,n)=>{let i,s,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<Ve;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),wr(t,t.l_desc),wr(t,t.d_desc),o=(t=>{let e;for(pr(t,t.dyn_ltree,t.l_desc.max_code),pr(t,t.dyn_dtree,t.d_desc.max_code),wr(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*Je[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),i=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==e?gr(t,e,r,n):4===t.strategy||s===i?(cr(t,2+(n?1:0),3),mr(t,Ye,Xe)):(cr(t,4+(n?1:0),3),((t,e,r,n)=>{let i;for(cr(t,e-257,5),cr(t,r-1,5),cr(t,n-4,4),i=0;i<n;i++)cr(t,t.bl_tree[2*Je[i]+1],3);_r(t,t.dyn_ltree,e-1),_r(t,t.dyn_dtree,r-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),mr(t,t.dyn_ltree,t.dyn_dtree)),yr(t),n&&dr(t)},Ir={dt:Tr,bt:gr,At:vr,wt:(t,e,r)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(Qe[r]+Ve+1)]++,t.dyn_dtree[2*ar(e)]++),t.last_lit===t.lit_bufsize-1),_t:t=>{cr(t,2,3),lr(t,256,Ye),(t=>{16===t.bi_valid?(fr(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var Sr=(t,e,r,n)=>{let i=65535&t|0,s=t>>>16&65535|0,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{i=i+e[n++]|0,s=s+i|0}while(--o);i%=65521,s%=65521}return i|s<<16|0};const Er=new Uint32Array((()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e})());var Or=(t,e,r,n)=>{const i=Er,s=n+r;t^=-1;for(let r=n;r<s;r++)t=t>>>8^i[255&(t^e[r])];return-1^t},kr={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},xr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{dt:Fr,bt:Br,At:Dr,wt:Rr,_t:Mr}=Ir,{Z_NO_FLUSH:Lr,Z_PARTIAL_FLUSH:Nr,Z_FULL_FLUSH:Pr,Z_FINISH:Zr,Z_BLOCK:Cr,Z_OK:zr,Z_STREAM_END:Vr,Z_STREAM_ERROR:Hr,Z_DATA_ERROR:jr,Z_BUF_ERROR:Gr,Z_DEFAULT_COMPRESSION:Kr,Z_FILTERED:qr,Z_HUFFMAN_ONLY:$r,Z_RLE:Jr,Z_FIXED:Yr,Z_DEFAULT_STRATEGY:Xr,Z_UNKNOWN:Wr,Z_DEFLATED:Qr}=xr,tn=258,en=262,rn=103,nn=113,sn=666,on=(t,e)=>(t.msg=kr[e],e),an=t=>(t<<1)-(t>4?9:0),fn=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let cn=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask;const ln=t=>{const e=t.state;let r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},un=(t,e)=>{Dr(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,ln(t.strm)},hn=(t,e)=>{t.pending_buf[t.pending++]=e},yn=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},dn=(t,e,r,n)=>{let i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=Sr(t.adler,e,i,r):2===t.state.wrap&&(t.adler=Or(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},bn=(t,e)=>{let r,n,i=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match;const f=t.strstart>t.w_size-en?t.strstart-(t.w_size-en):0,c=t.window,l=t.w_mask,u=t.prev,h=t.strstart+tn;let y=c[s+o-1],d=c[s+o];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(r=e,c[r+o]===d&&c[r+o-1]===y&&c[r]===c[s]&&c[++r]===c[s+1]){s+=2,r++;do{}while(c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&s<h);if(n=tn-(h-s),s=h-tn,n>o){if(t.match_start=e,o=n,n>=a)break;y=c[s+o-1],d=c[s+o]}}}while((e=u[e&l])>f&&0!=--i);return o<=t.lookahead?o:t.lookahead},An=t=>{const e=t.w_size;let r,n,i,s,o;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-en)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,r=n;do{i=t.head[--r],t.head[r]=i>=e?i-e:0}while(--n);n=e,r=n;do{i=t.prev[--r],t.prev[r]=i>=e?i-e:0}while(--n);s+=e}if(0===t.strm.avail_in)break;if(n=dn(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=n,t.lookahead+t.insert>=3)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=cn(t,t.ins_h,t.window[o+1]);t.insert&&(t.ins_h=cn(t,t.ins_h,t.window[o+3-1]),t.prev[o&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=o,o++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<en&&0!==t.strm.avail_in)},mn=(t,e)=>{let r,n;for(;;){if(t.lookahead<en){if(An(t),t.lookahead<en&&e===Lr)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=cn(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-en&&(t.match_length=bn(t,r)),t.match_length>=3)if(n=Rr(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=cn(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=cn(t,t.ins_h,t.window[t.strstart+1]);else n=Rr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(un(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Zr?(un(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(un(t,!1),0===t.strm.avail_out)?1:2},wn=(t,e)=>{let r,n,i;for(;;){if(t.lookahead<en){if(An(t),t.lookahead<en&&e===Lr)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=cn(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-en&&(t.match_length=bn(t,r),t.match_length<=5&&(t.strategy===qr||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=Rr(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=cn(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(un(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=Rr(t,0,t.window[t.strstart-1]),n&&un(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=Rr(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Zr?(un(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(un(t,!1),0===t.strm.avail_out)?1:2};function pn(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}const _n=[new pn(0,0,0,0,((t,e)=>{let r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(An(t),0===t.lookahead&&e===Lr)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const n=t.block_start+r;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,un(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-en&&(un(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Zr?(un(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(un(t,!1),t.strm.avail_out),1)})),new pn(4,4,8,4,mn),new pn(4,5,16,8,mn),new pn(4,6,32,32,mn),new pn(4,4,16,16,wn),new pn(8,16,32,32,wn),new pn(8,16,128,128,wn),new pn(8,32,128,256,wn),new pn(32,128,258,1024,wn),new pn(32,258,258,4096,wn)];function Un(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Qr,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),fn(this.dyn_ltree),fn(this.dyn_dtree),fn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),fn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),fn(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const gn=t=>{if(!t||!t.state)return on(t,Hr);t.total_in=t.total_out=0,t.data_type=Wr;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:nn,t.adler=2===e.wrap?0:1,e.last_flush=Lr,Fr(e),zr},Tn=t=>{const e=gn(t);var r;return e===zr&&((r=t.state).window_size=2*r.w_size,fn(r.head),r.max_lazy_match=_n[r.level].max_lazy,r.good_match=_n[r.level].good_length,r.nice_match=_n[r.level].nice_length,r.max_chain_length=_n[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=2,r.match_available=0,r.ins_h=0),e},vn=(t,e,r,n,i,s)=>{if(!t)return Hr;let o=1;if(e===Kr&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==Qr||n<8||n>15||e<0||e>9||s<0||s>Yr)return on(t,Hr);8===n&&(n=9);const a=new Un;return t.state=a,a.strm=t,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=e,a.strategy=s,a.method=r,Tn(t)};var In=(t,e)=>{let r=e.length;if(!t||!t.state)return Hr;const n=t.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return Hr;if(1===i&&(t.adler=Sr(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(fn(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(r-n.w_size,r),0),e=t,r=n.w_size}const s=t.avail_in,o=t.next_in,a=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,An(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=cn(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,An(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=o,t.input=a,t.avail_in=s,n.wrap=i,zr},Sn={deflateInit:(t,e)=>vn(t,e,Qr,15,8,Xr),deflateInit2:vn,deflateReset:Tn,deflateResetKeep:gn,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?Hr:(t.state.gzhead=e,zr):Hr,deflate:(t,e)=>{let r,n;if(!t||!t.state||e>Cr||e<0)return t?on(t,Hr):Hr;const i=t.state;if(!t.output||!t.input&&0!==t.avail_in||i.status===sn&&e!==Zr)return on(t,0===t.avail_out?Gr:Hr);i.strm=t;const s=i.last_flush;if(i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,hn(i,31),hn(i,139),hn(i,8),i.gzhead?(hn(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),hn(i,255&i.gzhead.time),hn(i,i.gzhead.time>>8&255),hn(i,i.gzhead.time>>16&255),hn(i,i.gzhead.time>>24&255),hn(i,9===i.level?2:i.strategy>=$r||i.level<2?4:0),hn(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(hn(i,255&i.gzhead.extra.length),hn(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=Or(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(hn(i,0),hn(i,0),hn(i,0),hn(i,0),hn(i,0),hn(i,9===i.level?2:i.strategy>=$r||i.level<2?4:0),hn(i,3),i.status=nn);else{let e=Qr+(i.w_bits-8<<4)<<8,r=-1;r=i.strategy>=$r||i.level<2?0:i.level<6?1:6===i.level?2:3,e|=r<<6,0!==i.strstart&&(e|=32),e+=31-e%31,i.status=nn,yn(i,e),0!==i.strstart&&(yn(i,t.adler>>>16),yn(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(t.adler=Or(t.adler,i.pending_buf,i.pending-r,r)),ln(t),r=i.pending,i.pending!==i.pending_buf_size));)hn(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(t.adler=Or(t.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=Or(t.adler,i.pending_buf,i.pending-r,r)),ln(t),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,hn(i,n)}while(0!==n);i.gzhead.hcrc&&i.pending>r&&(t.adler=Or(t.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=Or(t.adler,i.pending_buf,i.pending-r,r)),ln(t),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,hn(i,n)}while(0!==n);i.gzhead.hcrc&&i.pending>r&&(t.adler=Or(t.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=rn)}else i.status=rn;if(i.status===rn&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&ln(t),i.pending+2<=i.pending_buf_size&&(hn(i,255&t.adler),hn(i,t.adler>>8&255),t.adler=0,i.status=nn)):i.status=nn),0!==i.pending){if(ln(t),0===t.avail_out)return i.last_flush=-1,zr}else if(0===t.avail_in&&an(e)<=an(s)&&e!==Zr)return on(t,Gr);if(i.status===sn&&0!==t.avail_in)return on(t,Gr);if(0!==t.avail_in||0!==i.lookahead||e!==Lr&&i.status!==sn){let r=i.strategy===$r?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(An(t),0===t.lookahead)){if(e===Lr)return 1;break}if(t.match_length=0,r=Rr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(un(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Zr?(un(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(un(t,!1),0===t.strm.avail_out)?1:2})(i,e):i.strategy===Jr?((t,e)=>{let r,n,i,s;const o=t.window;for(;;){if(t.lookahead<=tn){if(An(t),t.lookahead<=tn&&e===Lr)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=t.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){s=t.strstart+tn;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<s);t.match_length=tn-(s-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=Rr(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=Rr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(un(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Zr?(un(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(un(t,!1),0===t.strm.avail_out)?1:2})(i,e):_n[i.level].func(i,e);if(3!==r&&4!==r||(i.status=sn),1===r||3===r)return 0===t.avail_out&&(i.last_flush=-1),zr;if(2===r&&(e===Nr?Mr(i):e!==Cr&&(Br(i,0,0,!1),e===Pr&&(fn(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),ln(t),0===t.avail_out))return i.last_flush=-1,zr}return e!==Zr?zr:i.wrap<=0?Vr:(2===i.wrap?(hn(i,255&t.adler),hn(i,t.adler>>8&255),hn(i,t.adler>>16&255),hn(i,t.adler>>24&255),hn(i,255&t.total_in),hn(i,t.total_in>>8&255),hn(i,t.total_in>>16&255),hn(i,t.total_in>>24&255)):(yn(i,t.adler>>>16),yn(i,65535&t.adler)),ln(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?zr:Vr)},deflateEnd:t=>{if(!t||!t.state)return Hr;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==rn&&e!==nn&&e!==sn?on(t,Hr):(t.state=null,e===nn?on(t,jr):zr)},deflateSetDictionary:In,deflateInfo:"pako deflate (from Nodeca project)"};const En=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var On=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const e in r)En(r,e)&&(t[e]=r[e])}}return t},kn=t=>{let e=0;for(let r=0,n=t.length;r<n;r++)e+=t[r].length;const r=new Uint8Array(e);for(let e=0,n=0,i=t.length;e<i;e++){let i=t[e];r.set(i,n),n+=i.length}return r};let xn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){xn=!1}const Fn=new Uint8Array(256);for(let t=0;t<256;t++)Fn[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Fn[254]=Fn[254]=1;var Bn=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,n,i,s,o=t.length,a=0;for(i=0;i<o;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<o&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(a),s=0,i=0;s<a;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<o&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?e[s++]=r:r<2048?(e[s++]=192|r>>>6,e[s++]=128|63&r):r<65536?(e[s++]=224|r>>>12,e[s++]=128|r>>>6&63,e[s++]=128|63&r):(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63,e[s++]=128|r>>>6&63,e[s++]=128|63&r);return e},Dn=(t,e)=>{const r=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,i;const s=new Array(2*r);for(i=0,n=0;n<r;){let e=t[n++];if(e<128){s[i++]=e;continue}let o=Fn[e];if(o>4)s[i++]=65533,n+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&n<r;)e=e<<6|63&t[n++],o--;o>1?s[i++]=65533:e<65536?s[i++]=e:(e-=65536,s[i++]=55296|e>>10&1023,s[i++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&xn)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(t[n]);return r})(s,i)},Rn=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let r=e-1;for(;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+Fn[t[r]]>e?r:e};var Mn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Ln=Object.prototype.toString,{Z_NO_FLUSH:Nn,Z_SYNC_FLUSH:Pn,Z_FULL_FLUSH:Zn,Z_FINISH:Cn,Z_OK:zn,Z_STREAM_END:Vn,Z_DEFAULT_COMPRESSION:Hn,Z_DEFAULT_STRATEGY:jn,Z_DEFLATED:Gn}=xr;function Kn(t){this.options=On({level:Hn,method:Gn,chunkSize:16384,windowBits:15,memLevel:8,strategy:jn},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mn,this.strm.avail_out=0;let r=Sn.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==zn)throw new Error(kr[r]);if(e.header&&Sn.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Bn(e.dictionary):"[object ArrayBuffer]"===Ln.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,r=Sn.deflateSetDictionary(this.strm,t),r!==zn)throw new Error(kr[r]);this.Ut=!0}}function qn(t,e){const r=new Kn(e);if(r.push(t,!0),r.err)throw r.msg||kr[r.err];return r.result}Kn.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize;let i,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Cn:Nn,"string"==typeof t?r.input=Bn(t):"[object ArrayBuffer]"===Ln.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(s===Pn||s===Zn)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(i=Sn.deflate(r,s),i===Vn)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Sn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===zn;if(0!==r.avail_out){if(s>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},Kn.prototype.onData=function(t){this.chunks.push(t)},Kn.prototype.onEnd=function(t){t===zn&&(this.result=kn(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var $n={Deflate:Kn,deflate:qn,deflateRaw:function(t,e){return(e=e||{}).raw=!0,qn(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,qn(t,e)},constants:xr};var Jn=function(t,e){let r,n,i,s,o,a,f,c,l,u,h,y,d,b,A,m,w,p,_,U,g,T,v,I;const S=t.state;r=t.next_in,v=t.input,n=r+(t.avail_in-5),i=t.next_out,I=t.output,s=i-(e-t.avail_out),o=i+(t.avail_out-257),a=S.dmax,f=S.wsize,c=S.whave,l=S.wnext,u=S.window,h=S.hold,y=S.bits,d=S.lencode,b=S.distcode,A=(1<<S.lenbits)-1,m=(1<<S.distbits)-1;t:do{y<15&&(h+=v[r++]<<y,y+=8,h+=v[r++]<<y,y+=8),w=d[h&A];e:for(;;){if(p=w>>>24,h>>>=p,y-=p,p=w>>>16&255,0===p)I[i++]=65535&w;else{if(!(16&p)){if(0==(64&p)){w=d[(65535&w)+(h&(1<<p)-1)];continue e}if(32&p){S.mode=12;break t}t.msg="invalid literal/length code",S.mode=30;break t}_=65535&w,p&=15,p&&(y<p&&(h+=v[r++]<<y,y+=8),_+=h&(1<<p)-1,h>>>=p,y-=p),y<15&&(h+=v[r++]<<y,y+=8,h+=v[r++]<<y,y+=8),w=b[h&m];r:for(;;){if(p=w>>>24,h>>>=p,y-=p,p=w>>>16&255,!(16&p)){if(0==(64&p)){w=b[(65535&w)+(h&(1<<p)-1)];continue r}t.msg="invalid distance code",S.mode=30;break t}if(U=65535&w,p&=15,y<p&&(h+=v[r++]<<y,y+=8,y<p&&(h+=v[r++]<<y,y+=8)),U+=h&(1<<p)-1,U>a){t.msg="invalid distance too far back",S.mode=30;break t}if(h>>>=p,y-=p,p=i-s,U>p){if(p=U-p,p>c&&S.sane){t.msg="invalid distance too far back",S.mode=30;break t}if(g=0,T=u,0===l){if(g+=f-p,p<_){_-=p;do{I[i++]=u[g++]}while(--p);g=i-U,T=I}}else if(l<p){if(g+=f+l-p,p-=l,p<_){_-=p;do{I[i++]=u[g++]}while(--p);if(g=0,l<_){p=l,_-=p;do{I[i++]=u[g++]}while(--p);g=i-U,T=I}}}else if(g+=l-p,p<_){_-=p;do{I[i++]=u[g++]}while(--p);g=i-U,T=I}for(;_>2;)I[i++]=T[g++],I[i++]=T[g++],I[i++]=T[g++],_-=3;_&&(I[i++]=T[g++],_>1&&(I[i++]=T[g++]))}else{g=i-U;do{I[i++]=I[g++],I[i++]=I[g++],I[i++]=I[g++],_-=3}while(_>2);_&&(I[i++]=I[g++],_>1&&(I[i++]=I[g++]))}break}}break}}while(r<n&&i<o);_=y>>3,r-=_,y-=_<<3,h&=(1<<y)-1,t.next_in=r,t.next_out=i,t.avail_in=r<n?n-r+5:5-(r-n),t.avail_out=i<o?o-i+257:257-(i-o),S.hold=h,S.bits=y};const Yn=15,Xn=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Wn=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Qn=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ti=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ei=(t,e,r,n,i,s,o,a)=>{const f=a.bits;let c,l,u,h,y,d,b=0,A=0,m=0,w=0,p=0,_=0,U=0,g=0,T=0,v=0,I=null,S=0;const E=new Uint16Array(16),O=new Uint16Array(16);let k,x,F,B=null,D=0;for(b=0;b<=Yn;b++)E[b]=0;for(A=0;A<n;A++)E[e[r+A]]++;for(p=f,w=Yn;w>=1&&0===E[w];w--);if(p>w&&(p=w),0===w)return i[s++]=20971520,i[s++]=20971520,a.bits=1,0;for(m=1;m<w&&0===E[m];m++);for(p<m&&(p=m),g=1,b=1;b<=Yn;b++)if(g<<=1,g-=E[b],g<0)return-1;if(g>0&&(0===t||1!==w))return-1;for(O[1]=0,b=1;b<Yn;b++)O[b+1]=O[b]+E[b];for(A=0;A<n;A++)0!==e[r+A]&&(o[O[e[r+A]]++]=A);if(0===t?(I=B=o,d=19):1===t?(I=Xn,S-=257,B=Wn,D-=257,d=256):(I=Qn,B=ti,d=-1),v=0,A=0,b=m,y=s,_=p,U=0,u=-1,T=1<<p,h=T-1,1===t&&T>852||2===t&&T>592)return 1;for(;;){k=b-U,o[A]<d?(x=0,F=o[A]):o[A]>d?(x=B[D+o[A]],F=I[S+o[A]]):(x=96,F=0),c=1<<b-U,l=1<<_,m=l;do{l-=c,i[y+(v>>U)+l]=k<<24|x<<16|F|0}while(0!==l);for(c=1<<b-1;v&c;)c>>=1;if(0!==c?(v&=c-1,v+=c):v=0,A++,0==--E[b]){if(b===w)break;b=e[r+o[A]]}if(b>p&&(v&h)!==u){for(0===U&&(U=p),y+=m,_=b-U,g=1<<_;_+U<w&&(g-=E[_+U],!(g<=0));)_++,g<<=1;if(T+=1<<_,1===t&&T>852||2===t&&T>592)return 1;u=v&h,i[u]=p<<24|_<<16|y-s|0}}return 0!==v&&(i[y+v]=b-U<<24|64<<16|0),a.bits=p,0};const{Z_FINISH:ri,Z_BLOCK:ni,Z_TREES:ii,Z_OK:si,Z_STREAM_END:oi,Z_NEED_DICT:ai,Z_STREAM_ERROR:fi,Z_DATA_ERROR:ci,Z_MEM_ERROR:li,Z_BUF_ERROR:ui,Z_DEFLATED:hi}=xr,yi=12,di=30,bi=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Ai(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const mi=t=>{if(!t||!t.state)return fi;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,si},wi=t=>{if(!t||!t.state)return fi;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,mi(t)},pi=(t,e)=>{let r;if(!t||!t.state)return fi;const n=t.state;return e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?fi:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,wi(t))},_i=(t,e)=>{if(!t)return fi;const r=new Ai;t.state=r,r.window=null;const n=pi(t,e);return n!==si&&(t.state=null),n};let Ui,gi,Ti=!0;const vi=t=>{if(Ti){Ui=new Int32Array(512),gi=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ei(1,t.lens,0,288,Ui,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ei(2,t.lens,0,32,gi,0,t.work,{bits:5}),Ti=!1}t.lencode=Ui,t.lenbits=9,t.distcode=gi,t.distbits=5},Ii=(t,e,r,n)=>{let i;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(e.subarray(r-s.wsize,r),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>n&&(i=n),s.window.set(e.subarray(r-n,r-n+i),s.wnext),(n-=i)?(s.window.set(e.subarray(r-n,r),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0};var Si=(t,e)=>{let r,n,i,s,o,a,f,c,l,u,h,y,d,b,A,m,w,p,_,U,g,T,v=0;const I=new Uint8Array(4);let S,E;const O=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return fi;r=t.state,r.mode===yi&&(r.mode=13),o=t.next_out,i=t.output,f=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,c=r.hold,l=r.bits,u=a,h=f,T=si;t:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;l<16;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(2&r.wrap&&35615===c){r.check=0,I[0]=255&c,I[1]=c>>>8&255,r.check=Or(r.check,I,2,0),c=0,l=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){t.msg="incorrect header check",r.mode=di;break}if((15&c)!==hi){t.msg="unknown compression method",r.mode=di;break}if(c>>>=4,l-=4,g=8+(15&c),0===r.wbits)r.wbits=g;else if(g>r.wbits){t.msg="invalid window size",r.mode=di;break}r.dmax=1<<r.wbits,t.adler=r.check=1,r.mode=512&c?10:yi,c=0,l=0;break;case 2:for(;l<16;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(r.flags=c,(255&r.flags)!==hi){t.msg="unknown compression method",r.mode=di;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=di;break}r.head&&(r.head.text=c>>8&1),512&r.flags&&(I[0]=255&c,I[1]=c>>>8&255,r.check=Or(r.check,I,2,0)),c=0,l=0,r.mode=3;case 3:for(;l<32;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}r.head&&(r.head.time=c),512&r.flags&&(I[0]=255&c,I[1]=c>>>8&255,I[2]=c>>>16&255,I[3]=c>>>24&255,r.check=Or(r.check,I,4,0)),c=0,l=0,r.mode=4;case 4:for(;l<16;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&r.flags&&(I[0]=255&c,I[1]=c>>>8&255,r.check=Or(r.check,I,2,0)),c=0,l=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}r.length=c,r.head&&(r.head.extra_len=c),512&r.flags&&(I[0]=255&c,I[1]=c>>>8&255,r.check=Or(r.check,I,2,0)),c=0,l=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(y=r.length,y>a&&(y=a),y&&(r.head&&(g=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(s,s+y),g)),512&r.flags&&(r.check=Or(r.check,n,y,s)),a-=y,s+=y,r.length-=y),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===a)break t;y=0;do{g=n[s+y++],r.head&&g&&r.length<65536&&(r.head.name+=String.fromCharCode(g))}while(g&&y<a);if(512&r.flags&&(r.check=Or(r.check,n,y,s)),a-=y,s+=y,g)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===a)break t;y=0;do{g=n[s+y++],r.head&&g&&r.length<65536&&(r.head.comment+=String.fromCharCode(g))}while(g&&y<a);if(512&r.flags&&(r.check=Or(r.check,n,y,s)),a-=y,s+=y,g)break t}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;l<16;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(c!==(65535&r.check)){t.msg="header crc mismatch",r.mode=di;break}c=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=yi;break;case 10:for(;l<32;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}t.adler=r.check=bi(c),c=0,l=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=o,t.avail_out=f,t.next_in=s,t.avail_in=a,r.hold=c,r.bits=l,ai;t.adler=r.check=1,r.mode=yi;case yi:if(e===ni||e===ii)break t;case 13:if(r.last){c>>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}switch(r.last=1&c,c>>>=1,l-=1,3&c){case 0:r.mode=14;break;case 1:if(vi(r),r.mode=20,e===ii){c>>>=2,l-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=di}c>>>=2,l-=2;break;case 14:for(c>>>=7&l,l-=7&l;l<32;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if((65535&c)!=(c>>>16^65535)){t.msg="invalid stored block lengths",r.mode=di;break}if(r.length=65535&c,c=0,l=0,r.mode=15,e===ii)break t;case 15:r.mode=16;case 16:if(y=r.length,y){if(y>a&&(y=a),y>f&&(y=f),0===y)break t;i.set(n.subarray(s,s+y),o),a-=y,s+=y,f-=y,o+=y,r.length-=y;break}r.mode=yi;break;case 17:for(;l<14;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(r.nlen=257+(31&c),c>>>=5,l-=5,r.ndist=1+(31&c),c>>>=5,l-=5,r.ncode=4+(15&c),c>>>=4,l-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=di;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;l<3;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}r.lens[O[r.have++]]=7&c,c>>>=3,l-=3}for(;r.have<19;)r.lens[O[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},T=ei(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,T){t.msg="invalid code lengths set",r.mode=di;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;v=r.lencode[c&(1<<r.lenbits)-1],A=v>>>24,m=v>>>16&255,w=65535&v,!(A<=l);){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(w<16)c>>>=A,l-=A,r.lens[r.have++]=w;else{if(16===w){for(E=A+2;l<E;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(c>>>=A,l-=A,0===r.have){t.msg="invalid bit length repeat",r.mode=di;break}g=r.lens[r.have-1],y=3+(3&c),c>>>=2,l-=2}else if(17===w){for(E=A+3;l<E;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}c>>>=A,l-=A,g=0,y=3+(7&c),c>>>=3,l-=3}else{for(E=A+7;l<E;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}c>>>=A,l-=A,g=0,y=11+(127&c),c>>>=7,l-=7}if(r.have+y>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=di;break}for(;y--;)r.lens[r.have++]=g}}if(r.mode===di)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=di;break}if(r.lenbits=9,S={bits:r.lenbits},T=ei(1,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,T){t.msg="invalid literal/lengths set",r.mode=di;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},T=ei(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,T){t.msg="invalid distances set",r.mode=di;break}if(r.mode=20,e===ii)break t;case 20:r.mode=21;case 21:if(a>=6&&f>=258){t.next_out=o,t.avail_out=f,t.next_in=s,t.avail_in=a,r.hold=c,r.bits=l,Jn(t,h),o=t.next_out,i=t.output,f=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,c=r.hold,l=r.bits,r.mode===yi&&(r.back=-1);break}for(r.back=0;v=r.lencode[c&(1<<r.lenbits)-1],A=v>>>24,m=v>>>16&255,w=65535&v,!(A<=l);){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(m&&0==(240&m)){for(p=A,_=m,U=w;v=r.lencode[U+((c&(1<<p+_)-1)>>p)],A=v>>>24,m=v>>>16&255,w=65535&v,!(p+A<=l);){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}c>>>=p,l-=p,r.back+=p}if(c>>>=A,l-=A,r.back+=A,r.length=w,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=yi;break}if(64&m){t.msg="invalid literal/length code",r.mode=di;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(E=r.extra;l<E;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;v=r.distcode[c&(1<<r.distbits)-1],A=v>>>24,m=v>>>16&255,w=65535&v,!(A<=l);){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(0==(240&m)){for(p=A,_=m,U=w;v=r.distcode[U+((c&(1<<p+_)-1)>>p)],A=v>>>24,m=v>>>16&255,w=65535&v,!(p+A<=l);){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}c>>>=p,l-=p,r.back+=p}if(c>>>=A,l-=A,r.back+=A,64&m){t.msg="invalid distance code",r.mode=di;break}r.offset=w,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(E=r.extra;l<E;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=di;break}r.mode=25;case 25:if(0===f)break t;if(y=h-f,r.offset>y){if(y=r.offset-y,y>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=di;break}y>r.wnext?(y-=r.wnext,d=r.wsize-y):d=r.wnext-y,y>r.length&&(y=r.length),b=r.window}else b=i,d=o-r.offset,y=r.length;y>f&&(y=f),f-=y,r.length-=y;do{i[o++]=b[d++]}while(--y);0===r.length&&(r.mode=21);break;case 26:if(0===f)break t;i[o++]=r.length,f--,r.mode=21;break;case 27:if(r.wrap){for(;l<32;){if(0===a)break t;a--,c|=n[s++]<<l,l+=8}if(h-=f,t.total_out+=h,r.total+=h,h&&(t.adler=r.check=r.flags?Or(r.check,i,h,o-h):Sr(r.check,i,h,o-h)),h=f,(r.flags?c:bi(c))!==r.check){t.msg="incorrect data check",r.mode=di;break}c=0,l=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;l<32;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(c!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=di;break}c=0,l=0}r.mode=29;case 29:T=oi;break t;case di:T=ci;break t;case 31:return li;default:return fi}return t.next_out=o,t.avail_out=f,t.next_in=s,t.avail_in=a,r.hold=c,r.bits=l,(r.wsize||h!==t.avail_out&&r.mode<di&&(r.mode<27||e!==ri))&&Ii(t,t.output,t.next_out,h-t.avail_out),u-=t.avail_in,h-=t.avail_out,t.total_in+=u,t.total_out+=h,r.total+=h,r.wrap&&h&&(t.adler=r.check=r.flags?Or(r.check,i,h,t.next_out-h):Sr(r.check,i,h,t.next_out-h)),t.data_type=r.bits+(r.last?64:0)+(r.mode===yi?128:0)+(20===r.mode||15===r.mode?256:0),(0===u&&0===h||e===ri)&&T===si&&(T=ui),T},Ei={inflateReset:wi,inflateReset2:pi,inflateResetKeep:mi,inflateInit:t=>_i(t,15),inflateInit2:_i,inflate:Si,inflateEnd:t=>{if(!t||!t.state)return fi;let e=t.state;return e.window&&(e.window=null),t.state=null,si},inflateGetHeader:(t,e)=>{if(!t||!t.state)return fi;const r=t.state;return 0==(2&r.wrap)?fi:(r.head=e,e.done=!1,si)},inflateSetDictionary:(t,e)=>{const r=e.length;let n,i,s;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?fi:11===n.mode&&(i=1,i=Sr(i,e,r,0),i!==n.check)?ci:(s=Ii(t,e,r,r),s?(n.mode=31,li):(n.havedict=1,si))):fi},inflateInfo:"pako inflate (from Nodeca project)"};var Oi=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const ki=Object.prototype.toString,{Z_NO_FLUSH:xi,Z_FINISH:Fi,Z_OK:Bi,Z_STREAM_END:Di,Z_NEED_DICT:Ri,Z_STREAM_ERROR:Mi,Z_DATA_ERROR:Li,Z_MEM_ERROR:Ni}=xr;function Pi(t){this.options=On({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mn,this.strm.avail_out=0;let r=Ei.inflateInit2(this.strm,e.windowBits);if(r!==Bi)throw new Error(kr[r]);if(this.header=new Oi,Ei.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Bn(e.dictionary):"[object ArrayBuffer]"===ki.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=Ei.inflateSetDictionary(this.strm,e.dictionary),r!==Bi)))throw new Error(kr[r])}function Zi(t,e){const r=new Pi(e);if(r.push(t),r.err)throw r.msg||kr[r.err];return r.result}Pi.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Fi:xi,"[object ArrayBuffer]"===ki.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),s=Ei.inflate(r,o),s===Ri&&i&&(s=Ei.inflateSetDictionary(r,i),s===Bi?s=Ei.inflate(r,o):s===Li&&(s=Ri));r.avail_in>0&&s===Di&&r.state.wrap>0&&0!==t[r.next_in];)Ei.inflateReset(r),s=Ei.inflate(r,o);switch(s){case Mi:case Li:case Ri:case Ni:return this.onEnd(s),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||s===Di))if("string"===this.options.to){let t=Rn(r.output,r.next_out),e=r.next_out-t,i=Dn(r.output,t);r.next_out=e,r.avail_out=n-e,e&&r.output.set(r.output.subarray(t,t+e),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(s!==Bi||0!==a){if(s===Di)return s=Ei.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},Pi.prototype.onData=function(t){this.chunks.push(t)},Pi.prototype.onEnd=function(t){t===Bi&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=kn(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Ci={Inflate:Pi,inflate:Zi,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Zi(t,e)},ungzip:Zi,constants:xr};const{Deflate:zi,deflate:Vi,deflateRaw:Hi,gzip:ji}=$n,{Inflate:Gi,inflate:Ki,inflateRaw:qi,ungzip:$i}=Ci;var Ji={Deflate:zi,deflate:Vi,deflateRaw:Hi,gzip:ji,Inflate:Gi,inflate:Ki,inflateRaw:qi,ungzip:$i,constants:xr},Yi=5,Xi=11,Wi=13,Qi=14;function ts(t,e,r,n){var i=t|e<<8,s=i>>11&31,o=i>>5&63,a=31&i;return r[n+0]=s<<3|s>>2,r[n+1]=o<<2|o>>4,r[n+2]=a<<3|a>>2,r[n+3]=255,i}function es(t,e,r,n){var i=0;0!=(6&n)&&(i=8),function(t,e,r,n){for(var i=new Uint8Array(16),s=ts(e[r+0],e[r+1],i,0),o=ts(e[r+2],e[r+3],i,4),a=0;a<3;a++){var f=i[a],c=i[4+a];n&&s<=o?(i[8+a]=(f+c)/2,i[12+a]=0):(i[8+a]=(2*f+c)/3,i[12+a]=(f+2*c)/3)}i[11]=255,i[15]=n&&s<=o?0:255;var l=new Uint8Array(16);for(a=0;a<4;++a){var u=e[r+4+a];l[4*a+0]=3&u,l[4*a+1]=u>>2&3,l[4*a+2]=u>>4&3,l[4*a+3]=u>>6&3}for(a=0;a<16;++a)for(var h=4*l[a],y=0;y<4;++y)t[4*a+y]=i[h+y]}(t,e,r+i,0!=(1&n)),0!=(2&n)?function(t,e,r){for(var n=0;n<8;++n){var i=bytes[r+n],s=15&i,o=240&i;t[8*n+3]=s|s<<4,t[8*n+7]=o|o>>4}}(t,0,r):0!=(4&n)&&function(t,e,r){var n=e[r+0],i=e[r+1],s=new Uint8Array(8);if(s[0]=n,s[1]=i,n<=i){for(var o=1;o<5;++o)s[1+o]=((5-o)*n+o*i)/5;s[6]=0,s[7]=255}else for(o=1;o<7;++o)s[1+o]=((7-o)*n+o*i)/7;var a=new Uint8Array(16),f=(r+=2,0);for(o=0;o<2;++o){for(var c=0,l=0;l<3;++l)c|=e[r++]<<8*l;for(l=0;l<8;++l){var u=c>>3*l&7;a[f++]=u}}for(o=0;o<16;++o)t[4*o+3]=s[a[o]]}(t,e,r)}function rs(t){}function ns(){}rs.decode=function(t,e,r,n,i){if(null!=t&&null!=n&&0!=r&&0!=e){var s=0;1&(s=i>11||5===i?4:33)&&32&s?function(t,e,r,n){for(var i=new Uint16Array(4),s=t,o=0,a=0,f=0,c=0,l=0,u=0,h=0,y=0,d=0,b=e/4,A=r/4,m=0;m<A;m++)for(var w=0;w<b;w++)f=4*((A-m)*b+w),i[0]=n[f],i[1]=n[f+1],c=31&i[0],l=2016&i[0],u=63488&i[0],h=31&i[1],y=2016&i[1],d=63488&i[1],i[2]=5*c+3*h>>3|5*l+3*y>>3&2016|5*u+3*d>>3&63488,i[3]=5*h+3*c>>3|5*y+3*l>>3&2016|5*d+3*u>>3&63488,o=n[f+2],s[a=4*m*e+4*w]=i[3&o],s[a+1]=i[o>>2&3],s[a+2]=i[o>>4&3],s[a+3]=i[o>>6&3],s[a+=e]=i[o>>8&3],s[a+1]=i[o>>10&3],s[a+2]=i[o>>12&3],s[a+3]=i[o>>14],o=n[f+3],s[a+=e]=i[3&o],s[a+1]=i[o>>2&3],s[a+2]=i[o>>4&3],s[a+3]=i[o>>6&3],s[a+=e]=i[o>>8&3],s[a+1]=i[o>>10&3],s[a+2]=i[o>>12&3],s[a+3]=i[o>>14]}\n/*! @brief Decompresses an image in memory.\n\n @param rgba\t\tStorage for the decompressed pixels.\n @param width\tThe width of the source image.\n @param height\tThe height of the source image.\n @param blocks\tThe compressed DXT blocks.\n @param flags\tCompression flags.\n\n The decompressed pixels will be written as a contiguous array of width*height\n 16 rgba values, with each component as 1 byte each. In memory this is:\n\n { r1, g1, b1, a1, .... , rn, gn, bn, an } for n = width*height\n\n The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression,\n however, DXT1 will be used by default if none is specified. All other flags\n are ignored.\n\n Internally this function calls squish::Decompress for each block.\n */(t,e,r,n):function(t,e,r,n,i,s){for(var o=0!=(1&i)?8:16,a=0,f=0;f<r;f+=4)for(var c=0;c<e;c+=4){var l=new Uint8Array(64);es(l,n,a,i);for(var u=0,h=0;h<4;++h)for(var y=0;y<4;++y){var d=c+y,b=f+h;if(d<e&&b<r){var A=4*(e*(r-b)+d);if(s===Wi||s===Qi)t[A+2]=l[u++],t[A+1]=l[u++],t[A+0]=l[u++],t[A+3]=l[u++];else for(var m=0;m<4;++m)t[A++]=l[u++]}else u+=4}a+=o}}(t,e,r,n,s,i)}},ns.s3tc=!0,ns.pvrtc=!1,ns.etc1=!1;let is=1,ss=2;const os=10,as=11,fs=1,cs=2,ls=16,us=32;function hs(t,e,r){r=t.byteLength;return t=t.subarray(0,0+r),new TextDecoder("utf-8").decode(t)}function ys(t,e,r){let n=e.getUint32(r,!0);return r+=Uint32Array.BYTES_PER_ELEMENT,{string:hs(new Uint8Array(t,r,n)),bytesOffset:r+=n}}function ds(t,e,r,n){let i={},s=[],o=new Array(16);for(let t=0;t<16;t++)o[t]=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;i.matrix=o,i.skeletonNames=s;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<a;n++){let n=ys(t,e,r);s.push(n.string),r=n.bytesOffset}return n.push(i),r}function bs(t,e,r,n){let i={};i.rangeList=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,i.rangeMode=e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let s={};s.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,s.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,s.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;let o=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT,i.boundingSphere={center:s,radius:o};let a=ys(t,e,r),f=a.string;r=a.bytesOffset;let c=f.indexOf("Geometry");if(-1!==c){let t=f.substring(c);f=f.replace(t,"")}i.childTile=f,i.geodes=[];let l=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<l;n++)r=ds(t,e,r,i.geodes);return n.push(i),r}function As(t,e,r,n){let i=e.getUint32(r,!0);if(n.verticesCount=i,(r+=Uint32Array.BYTES_PER_ELEMENT)<=0)return r;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);o=s*Float32Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let a=i*s*Float32Array.BYTES_PER_ELEMENT,f=new Uint8Array(t,r,a);r+=a;let c=n.vertexAttributes,l=n.attrLocation;return l.aPosition=c.length,c.push({index:l.aPosition,typedArray:f,componentsPerAttribute:s,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function ms(t,e,r,n){let i=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,i<=0)return r;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let a=i*s*Float32Array.BYTES_PER_ELEMENT,f=new Uint8Array(t,r,a);r+=a;let c=n.vertexAttributes,l=n.attrLocation;return l.aNormal=c.length,c.push({index:l.aNormal,typedArray:f,componentsPerAttribute:s,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function ws(t,e,r,n){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s,o=n.verticesCount;if(i>0){e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=2*Uint8Array.BYTES_PER_ELEMENT;let n=i*Uint8Array.BYTES_PER_ELEMENT*4;s=new Uint8Array(t,r,n).slice(0,n),r+=n}else{s=new Uint8Array(4*o);for(let t=0;t<o;t++)s[4*t]=255,s[4*t+1]=255,s[4*t+2]=255,s[4*t+3]=255}let a=n.vertexAttributes,f=n.attrLocation;return f.aColor=a.length,a.push({index:f.aColor,typedArray:s,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),n.vertexColor=s,r}function ps(t,e,r,n){let i=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,i<=0)return r;e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=2*Uint8Array.BYTES_PER_ELEMENT;let s=i*Uint8Array.BYTES_PER_ELEMENT*4,o=new Uint8Array(t,r,s);r+=s;let a=n.vertexAttributes,f=n.attrLocation;return f.aSecondColor=a.length,a.push({index:f.aSecondColor,typedArray:o,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),r}function _s(t,e,r,n){let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let a=i*o*Float32Array.BYTES_PER_ELEMENT,f=new Uint8Array(t,r,a);r+=a;let c="aTexCoord"+s,l=n.vertexAttributes,u=n.attrLocation;u[c]=l.length,l.push({index:u[c],typedArray:f,componentsPerAttribute:o,componentDatatype:5126,offsetInBytes:0,strideInBytes:o*Float32Array.BYTES_PER_ELEMENT,normalize:!1})}return r}function Us(t,e,r,n){let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let s=n.vertexAttributes,o=n.attrLocation;for(let a=0;a<i;a++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let f=i*a*Float32Array.BYTES_PER_ELEMENT;if(17===a){let e=new Uint8Array(t,r,f);n.instanceCount=i,n.instanceMode=a,n.instanceBuffer=e,n.instanceIndex=1;let c,l=a*i*4,u=e.slice(0,l);n.vertexColorInstance=u,17===a?(c=17*Float32Array.BYTES_PER_ELEMENT,o.uv2=s.length,s.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:c,instanceDivisor:1}),o.uv3=s.length,s.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv4=s.length,s.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.secondary_colour=s.length,s.push({index:o.secondary_colour,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv6=s.length,s.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1})):29===a&&(c=29*Float32Array.BYTES_PER_ELEMENT,o.uv1=s.length,s.push({index:o.uv1,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:c,instanceDivisor:1,byteLength:f}),o.uv2=s.length,s.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv3=s.length,s.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv4=s.length,s.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv5=s.length,s.push({index:o.uv5,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv6=s.length,s.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:20*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv7=s.length,s.push({index:o.uv7,componentsPerAttribute:3,componentDatatype:5126,normalize:!1,offsetInBytes:24*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.secondary_colour=s.length,s.push({index:o.secondary_colour,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:27*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv9=s.length,s.push({index:o.uv9,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:28*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}))}else{let t=i*a;n.instanceBounds=new Float32Array(t);for(let i=0;i<t;i++)n.instanceBounds[i]=e.getFloat32(r+i*Float32Array.BYTES_PER_ELEMENT,!0)}r+=f}return r}function gs(t,e,r,n){return r=Us(t,e,r=_s(t,e,r=ps(t,e,r=ws(t,e,r=ms(t,e,r=As(t,e,r,n),n),n),n),n),n)}function Ts(t,e,r,n){let i=e.getUint32(r,!0);return n.compressOptions=i,r+=Uint32Array.BYTES_PER_ELEMENT,r=(i&fs)===fs?function(t,e,r,n){let i=e.getUint32(r,!0);if(n.verticesCount=i,(r+=Uint32Array.BYTES_PER_ELEMENT)<=0)return r;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);o=s*Int16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let a=e.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT;let f={};f.x=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,f.y=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,f.z=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,f.w=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.vertCompressConstant=a,n.minVerticesValue=f;let c=i*s*Int16Array.BYTES_PER_ELEMENT,l=new Uint8Array(t,r,c);r+=c;let u=n.vertexAttributes,h=n.attrLocation;return h.aPosition=u.length,u.push({index:h.aPosition,typedArray:l,componentsPerAttribute:s,componentDatatype:5122,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}(t,e,r,n):As(t,e,r,n),r=(i&cs)===cs?function(t,e,r,n){let i=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,i<=0)return r;e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=2*i*Int16Array.BYTES_PER_ELEMENT,a=new Uint8Array(t,r,o);r+=o;let f=n.vertexAttributes,c=n.attrLocation;return c.aNormal=f.length,f.push({index:c.aNormal,typedArray:a,componentsPerAttribute:2,componentDatatype:5122,offsetInBytes:0,strideInBytes:s,normalize:!1}),r}(t,e,r,n):ms(t,e,r,n),r=ps(t,e,r=ws(t,e,r,n),n),r=(i&ls)===ls?function(t,e,r,n){n.texCoordCompressConstant=[],n.minTexCoordValue=[];let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=e.getUint8(r,!0);r+=Uint8Array.BYTES_PER_ELEMENT,r+=3*Uint8Array.BYTES_PER_ELEMENT;let o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let f=e.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT,n.texCoordCompressConstant.push(f);let c={};c.x=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,c.y=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,c.z=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,c.w=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.minTexCoordValue.push(c);let l=o*a*Int16Array.BYTES_PER_ELEMENT,u=new Uint8Array(t,r,l),h=(r+=l)%4;0!==h&&(r+=4-h);let y="aTexCoord"+s,d=n.vertexAttributes,b=n.attrLocation;if(b[y]=d.length,d.push({index:b[y],typedArray:u,componentsPerAttribute:a,componentDatatype:5122,offsetInBytes:0,strideInBytes:a*Int16Array.BYTES_PER_ELEMENT,normalize:!1}),i){l=o*Float32Array.BYTES_PER_ELEMENT;let e=new Uint8Array(t,r,l);r+=l,n.texCoordZMatrix=!0,y="aTexCoordZ"+s,b[y]=d.length,d.push({index:b[y],typedArray:e,componentsPerAttribute:1,componentDatatype:5126,offsetInBytes:0,strideInBytes:Float32Array.BYTES_PER_ELEMENT,normalize:!1})}}return r}(t,e,r,n):_s(t,e,r,n),(i&us)===us&&(n.textureCoordIsW=!0),r=Us(t,e,r,n)}function vs(t,e,r,n){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i={},s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint8(r,!0);r+=Uint8Array.BYTES_PER_ELEMENT,e.getUint8(r,!0),r+=Uint8Array.BYTES_PER_ELEMENT;let a=e.getUint8(r,!0);if(r+=Uint8Array.BYTES_PER_ELEMENT,r+=Uint8Array.BYTES_PER_ELEMENT,s>0){let e,n=null;1===o||3===o?(e=s*Uint32Array.BYTES_PER_ELEMENT,n=new Uint8Array(t,r,e)):(e=s*Uint16Array.BYTES_PER_ELEMENT,n=new Uint8Array(t,r,e),s%2!=0&&(e+=2)),i.indicesTypedArray=n,r+=e}i.indicesCount=s,i.indexType=o,i.primitiveType=a;let f=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<f;n++){let n=ys(t,e,r),s=n.string;r=n.bytesOffset,i.materialCode=s}if(0!==r%4){r+=4-r%4}n.push(i)}return r}let Is={red:0,green:0,blue:0,alpha:0};function Ss(t,e,r){let n=t.vertexAttributes,i=t.attrLocation,s=n.length;i[1===r?"instanceId":"batchId"]=s,n.push({index:s,typedArray:e,componentsPerAttribute:1,componentDatatype:5126,offsetInBytes:0,strideInBytes:0,instanceDivisor:r})}function Es(t,e,r){var n=r*(4*e+e%4),i=n+o,s=new DataView(t),o=0;s.setUint16(o,19778,!0),o+=2,s.setUint32(o,i,!0),o+=4,s.setUint32(o,0,!0),o+=4,s.setUint32(o,122,!0),o+=4,s.setUint32(o,108,!0),o+=4,s.setUint32(o,e,!0),o+=4,s.setUint32(o,r,!0),o+=4,s.setUint16(o,1,!0),o+=2,s.setUint16(o,32,!0),o+=2,s.setUint32(o,this.compress,!0),o+=4,s.setUint32(o,n,!0),o+=4,s.setUint32(o,2835,!0),o+=4,s.setUint32(o,2835,!0),o+=4,s.setUint8(o,0,!0),o+=4,s.setUint32(o,0,!0),o+=4,s.setUint32(o,16711680,!0),o+=4,s.setUint32(o,65280,!0),o+=4,s.setUint32(o,255,!0),o+=4,s.setUint32(o,4278190080,!0),o+=4,s.setUint32(o,1466527264,!0),o+=4}function Os(t){for(var e,r,n,i,s=t.buffer,o=t.bytesOffset,a=ns.parseBuffer(s,o),f=a.geoPackage,c=a.groupNode.pageLods,l=[],u=[],h=[],y=[],d=0,b=c[0].geodes[0].matrix,A={},m=0;m<a.materials.material.length;m++)A[a.materials.material[m].material.id]=a.materials.material[m].material;var w={x:0,y:0,z:0},p=Number.MAX_VALUE,_=Number.MAX_VALUE,U=Number.MAX_VALUE,g=Number.MIN_VALUE,T=Number.MIN_VALUE,v=Number.MIN_VALUE;for(var I in f){var S=f[I].vertexPackage;e=S.verticesCount;s=S.vertexAttributes[0].typedArray.buffer;var E=S.vertexAttributes[0].typedArray.byteOffset,O=S.vertexAttributes[0].componentsPerAttribute;n=new Float32Array(s,S.vertexAttributes[0].offsetInBytes+E,e*O),i=new Float32Array(3*e);for(m=0;m<e;m++){var k=n[m*O],x=n[m*O+1],F=n[m*O+2];ns.multiplyByPoint(b,{x:k,y:x,z:F},w),i[3*m]=w.x,i[3*m+1]=w.y,i[3*m+2]=w.z,p=Math.min(p,i[3*m]),_=Math.min(_,i[3*m+1]),U=Math.min(U,i[3*m+2]),g=Math.max(g,i[3*m]),T=Math.max(T,i[3*m+1]),v=Math.max(v,i[3*m+2])}l.push(i);var B=S.attrLocation.aTexCoord0;if(B){const t=S.vertexAttributes[B];var D=t.componentsPerAttribute,R=new Float32Array(s,t.offsetInBytes+t.typedArray.byteOffset,e*D),M=new Float32Array(2*e);for(m=0;m<e;m++)M[2*m]=R[m*D],M[2*m+1]=R[m*D+1];h.push(M)}else h.push(void 0);var L=f[I].arrIndexPackage[0].indicesTypedArray;r=new Uint16Array(L.buffer,(f[I].arrIndexPackage[0].bytesOffset||0)+L.byteOffset,f[I].arrIndexPackage[0].indicesCount),u.push(r),r.length,d+=e;var N=f[I].arrIndexPackage[0].materialCode;y.push(A[N])}var P=[p,_,U],Z=[g,T,v],C=function(t,e,r,n,i,s,o,a,f,c,l,u){return new Promise((function(a,h){!function(t,e,r,n,i,s,o,f,c,l,u,h){if(0===t||void 0===r||0===r.length)return{buffers:[],bufferViews:[],accessors:[],meshes:[],nodes:[],nodesInScene:[]};for(var y=[],d=[],b=[],A=[],m=[],w=[],p=0,_=0,U=0,g=0,T=0,v=0;v<r.length;v++){var I=e?e[v]:void 0,S=r?r[v]:void 0,E=n?n[v]:void 0,O=i?i[v]:void 0,k=s?s[v]:void 0;I&&(t=I.length);var x=new Uint32Array(t);if(I)for(var F=0;F<t;++F)x[F]=I[F];else for(F=0;F<t;++F)x[F]=F;var B=new Blob([x],{type:"application/binary"}),D=URL.createObjectURL(B),R=t,M=S.subarray(0,3*R),L=new Blob([M],{type:"application/binary"}),N=URL.createObjectURL(L),P=E?E.subarray(0,3*R):null,Z=null;if(P){var C=new Blob([P],{type:"application/binary"});Z=URL.createObjectURL(C)}var z=O?O.subarray(0,2*R):null,V=null;if(z){var H=new Blob([z],{type:"application/binary"});V=URL.createObjectURL(H)}var j=k?k.subarray(0,4*R):null,G=null,K=null;if(j){var q=j.length;G=new Float32Array(q);for(var $=0;$<q;++$)G[$]=j[$]/255;var J=new Blob([G],{type:"application/binary"});K=URL.createObjectURL(J)}var Y={};Y.POSITION=T,y.push({uri:N,byteLength:M.byteLength}),d.push({buffer:T,byteOffset:0,byteLength:M.byteLength,target:34962}),b.push({bufferView:T,byteOffset:0,componentType:5126,count:M.length/3,type:"VEC3",max:l,min:c}),Z&&(p=++T,Y.NORMAL=p,y.push({uri:Z,byteLength:P.byteLength}),d.push({buffer:p,byteOffset:0,byteLength:P.byteLength,target:34962}),b.push({bufferView:p,byteOffset:0,componentType:5126,count:P.length/3,type:"VEC3",max:[0,0,0],min:[0,0,0]})),V&&(_=++T,Y.TEXCOORD_0=_,y.push({uri:V,byteLength:z.byteLength}),d.push({buffer:_,byteOffset:0,byteLength:z.byteLength,target:34962}),b.push({bufferView:_,byteOffset:0,componentType:5126,count:z.length/2,type:"VEC2",max:[0,0],min:[0,0]})),K&&(U=++T,Y.COLOR_0=U,y.push({uri:K,byteLength:G.byteLength}),d.push({buffer:U,byteOffset:0,byteLength:G.byteLength,target:34962}),b.push({bufferView:U,byteOffset:0,componentType:5126,count:U.length/4,type:"VEC4",max:[0,0,0,0],min:[0,0,0,0]})),g=++T,y.push({uri:D,byteLength:x.byteLength}),d.push({buffer:g,byteOffset:0,byteLength:x.byteLength,target:34963}),b.push({bufferView:g,byteOffset:0,componentType:5125,count:t,type:"SCALAR",max:[0],min:[0]}),A.push({primitives:[{attributes:Y,indices:g,material:v}]}),w.push(v),m.push({mesh:v}),T++}var X=[],W=[],Q=new Array(u.length),tt=0,et=0,rt=0,nt=[],it=new Promise((function(t,e){for(var r=0;r<h.length;r++)!function(e){var r=h[e].textureunitstates[0];if(r){rt++;var n=h[e].textureunitstates[0].textureunitstate.id,i=o[n],s=i.arrayBufferView,a=null,f=i.nFormat;a=f>Xi||f===Yi?new Uint8Array(122+i.width*i.height*4):new Uint16Array(61+i.width*i.height),rs.decode(a.subarray(122),i.width,i.height,s,f),Es(a.buffer,i.width,i.height);var c=new Blob([a],{type:"image/bmp"}),l=URL.createObjectURL(c);y.push({uri:l,byteLength:a.byteLength}),d.push({buffer:y.length-1,byteOffset:0,byteLength:a.byteLength,target:34962}),W.push({"mimeType":"image/bmp","bufferView":d.length-1}),X.push({sampler:0,source:tt++}),nt.push(c),nt.length===rt&&t()}Q.push({pbrMetallicRoughness:{metallicFactor:0,baseColorTexture:r?{index:et++,texCoord:0}:void 0},doubleSided:!0,name:n})}(r)})),st={scene:0,scenes:[{nodes:w}],nodes:m,meshes:A,buffers:y,bufferViews:d,accessors:b,materials:Q,textures:X,images:W,samplers:[{magFilter:9729,minFilter:9729,wrapS:10497,wrapT:10497}],asset:{version:"2.0"}};0===rt&&a(st),it.then((function(){a(st)}))}(t,e,r,n,i,s,o,0,f,c,l,u)}))}(d,u,l,null,h,null,a.texturePackage,0,P,Z,[],y);return C.then((function(t){var e=function(t){var e=(new TextEncoder).encode(JSON.stringify(t)),r=new Uint8Array(e.byteLength+20),n={magic:new Uint8Array(r.buffer,0,4),version:new Uint32Array(r.buffer,4,1),length:new Uint32Array(r.buffer,8,1),chunkLength:new Uint32Array(r.buffer,12,1),chunkType:new Uint32Array(r.buffer,16,1),chunkData:new Uint8Array(r.buffer,20,e.byteLength)};return n.magic[0]="g".charCodeAt(),n.magic[1]="l".charCodeAt(),n.magic[2]="T".charCodeAt(),n.magic[3]="F".charCodeAt(),n.version[0]=2,n.length[0]=r.byteLength,n.chunkLength[0]=e.byteLength,n.chunkType[0]=1313821514,n.chunkData.set(e),r}(t),r=function(t,e,r){var n=new TextEncoder,i=n.encode(t),s=i.byteLength,o=28+s,a=n.encode(e),f=(o+a.byteLength)%8,c=a.byteLength+f,l=a.byteLength,u=c,h=o+c,y=r.byteLength,d=new Uint8Array(28+(s+c+y)),b={magic:new Uint8Array(d.buffer,0,4),version:new Uint32Array(d.buffer,4,1),byteLength:new Uint32Array(d.buffer,8,1),featureTableJSONByteLength:new Uint32Array(d.buffer,12,1),featureTableBinaryByteLength:new Uint32Array(d.buffer,16,1),batchTableJSONByteLength:new Uint32Array(d.buffer,20,1),batchTableBinaryByteLength:new Uint32Array(d.buffer,24,1),featureTable:new Uint8Array(d.buffer,28,s),batchTable:new Uint8Array(d.buffer,o,c),binaryGLTF:new Uint8Array(d.buffer,h,y)};b.magic[0]="b".charCodeAt(),b.magic[1]="3".charCodeAt(),b.magic[2]="d".charCodeAt(),b.magic[3]="m".charCodeAt(),b.version[0]=1,b.byteLength[0]=d.byteLength,b.featureTable.set(i),b.featureTableJSONByteLength[0]=s,b.featureTableBinaryByteLength[0]=0,b.batchTable.set(a);for(var A=l;A<u;++A)b.batchTable[A]=32;return b.batchTableJSONByteLength[0]=c,b.batchTableBinaryByteLength[0]=0,b.binaryGLTF.set(r),d}(JSON.stringify({BATCH_LENGTH:0}),JSON.stringify({}),e);return{b3dmBuffer:r,pageLods:c}}))}ns.parseBuffer=function(t,e){var r={version:void 0,groupNode:void 0,geoPackage:{},matrials:void 0,texturePackage:{}};r.byteLength=t.byteLength,r.buffer=t;const n=new DataView(t);e=0;var i=n.getUint32(e,!0);return e=function(t,e,r,n){let i={},s=[];e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<o;n++)r=bs(t,e,r,s);i.pageLods=s;let a=r%4;return 0!==a&&(r+=4-a),n.groupNode=i,r}(t,n,e+=Uint32Array.BYTES_PER_ELEMENT,r),e=function(t,e,r,n){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=ys(t,e,r),s=i.string,o=(r=i.bytesOffset)%4;0!==o&&(r+=4-o);let a=e.getUint32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT;let f={vertexAttributes:[],attrLocation:{},instanceCount:0,instanceMode:0,instanceIndex:-1};a===is?r=gs(t,e,r,f):a===ss&&(r=Ts(t,e,r,f));let c,l=[];r=vs(t,e,r,l),2===l.length&&13===l[1].primitiveType&&l[1].indicesCount>=3&&(c=S3MEdgeProcessor.createEdgeDataByIndices(f,l[1])),n[s]={vertexPackage:f,arrIndexPackage:l,edgeGeometry:c}}return r+=e.getUint32(r,!0),r+Uint32Array.BYTES_PER_ELEMENT}(t,n,e,r.geoPackage),e=function(t,e,r,n){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=ys(t,e,r),s=i.string,o=(r=i.bytesOffset)%4;0!==o&&(r+=4-o),e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let f=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let l=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let u=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let h=new Uint8Array(t,r,l);r+=l;let y=u===os||u===as?33776:33779;if(22===c&&(y=36196),!ns.s3tc&&(33776===y||33779===y)){let t=new Uint8Array(a*f*4);rs.decode(t,a,f,h,u),h=t,c=0,y=u===os||u===os?273:4369}n[s]={id:s,width:a,height:f,compressType:c,nFormat:u,internalFormat:y,arrayBufferView:h}}return r}(t,n,e,r.texturePackage),e=function(t,e,r,n){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=hs(new Uint8Array(t,r,i));return r+=i,n.materials=JSON.parse(s),r}(t,n,e,r),function(t,e,r,n,i,s){if(1==(1&n)){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let n=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let o=0;o<n;o++){let n=ys(t,e,r),o=n.string;r=n.bytesOffset;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let f={};if(i[o].pickInfo=f,-1==i[o].vertexPackage.instanceIndex){let t=new Float32Array(i[o].vertexPackage.verticesCount);for(let n=0;n<a;n++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=[];for(let i=0;i<s;i++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT,t.fill(n,i,i+s),o.push({vertexColorOffset:i,vertexColorCount:s,batchId:n})}f[i]=o}Ss(i[o].vertexPackage,t,void 0)}else{let t=i[o].vertexPackage.instanceCount,n=i[o].vertexPackage.instanceBuffer,c=i[o].vertexPackage.instanceMode,l=new Float32Array(t),u=[];for(let t=0;t<a;t++){let t=e.getUint32(r,!0);u.push(t),r+=Uint32Array.BYTES_PER_ELEMENT;let n=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let t=0;t<n;t++)e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT,3===s&&(e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT)}let h=17===c?16:28;h*=Float32Array.BYTES_PER_ELEMENT;for(let e=0;e<t;e++){l[e]=e;let t=e*c*Float32Array.BYTES_PER_ELEMENT+h;Cesium.Color.unpack(n,t,Is);let r=2===s?u[e]:Is.red+256*Is.green+65536*Is.blue;void 0===f[r]&&(f[r]={vertexColorCount:1,instanceIds:[],vertexColorOffset:e}),f[r].instanceIds.push(e)}Ss(i[o].vertexPackage,l,1)}}}}(t,n,e,i,r.geoPackage,r.version),r},ns.multiplyByPoint=function(t,e,r){var n=e.x,i=e.y,s=e.z,o=t[0]*n+t[4]*i+t[8]*s+t[12],a=t[1]*n+t[5]*i+t[9]*s+t[13],f=t[2]*n+t[6]*i+t[10]*s+t[14];return r.x=o,r.y=a,r.z=f,r};const ks=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],xs=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],Fs="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let Bs,Ds,Rs=!1;if("undefined"!=typeof OffscreenCanvas){try{Ds=new OffscreenCanvas(2,2).getContext("2d")}catch(on){}Ds&&"undefined"!=typeof createImageBitmap&&(Rs=!0)}const Ms=n([]),Ls=[0,0,0],Ns=[],Ps=[];class Zs{constructor(t,e,r,n){this.id=t,this.options=e,this.gt=this.requestImage.bind(this),this.Tt=r,this.vt={},n(null,{},[])}It(t){this.St||(this.Et=new de,this.St=new ce(this.gt,ct,t),this.Ot=new le(this.gt,ct,t))}requestImage(t,e){Rs?fetch(t).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{Bs.width=t.width,Bs.height=t.height,Ds.drawImage(t,0,0);const r=Ds.getImageData(0,0,Bs.width,Bs.height);e(null,{width:t.width,height:t.height,data:new Uint8Array(r.data)})})):this.Tt("requestImage",{url:t},null,e)}loadTile(t,e){this.It(t.supportedFormats);const r=t.url,n=t.arraybuffer;if(n){delete this.vt[r];const i=new DataView(n),s=Rt(i,0);if("{"===s[0]||" "===s[0]||"<"===s[0]){const t=function(t,e,r){if(Fs){const n=new Uint8Array(t,e,r);return Fs.decode(n)}return _t(new Uint8Array(t,e,r))}(n,0,n.byteLength);let r=JSON.parse(t);r=this.kt(r),e(null,r)}else{const o=i.getFloat32(0,!0);1===o||2===o?this.xt(n,r,t,e):this.Ft(n,r,t,s,e)}}else{const n=this.options.services[t.rootIdx];let i=n.urlParams;i&&(i=(r.indexOf("?")>0?"&":"?")+i);let s=H.getArrayBuffer(r+(i||""),n.fetchOptions);const o=s.xhr;s=s.then((n=>{delete this.vt[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this.vt[r],e(t)})),this.vt[r]=o}}Ft(t,e,r,n,i){const s=this.options.services[r.rootIdx];if("b3dm"===n){this.St.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{if(t.error)return void i(t);const{content:e,transferables:n}=this.Bt(t,r);i(null,e,n)})).catch((t=>{i(t)}))}else if("pnts"===n){const n=r.transform;this.Et.load(e,t).then((t=>{const{content:e,transferables:s}=this.Dt(t,n,r.rootIdx);i(null,e,s)}))}else if("i3dm"===n){const n=r.transform;this.Ot.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{const{content:e,transferables:s}=this.Dt(t,n,r.rootIdx);i(null,e,s)}))}else if("cmpt"===n){new Ae(this.gt,ct).load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{const{content:e,transferables:n}=this.Rt(t,r);i(null,e,n)})).catch((t=>{i(t)}))}}xt(t,e,r,n){let i=0;const s=new DataView(t).getFloat32(i,!0);i+=Float32Array.BYTES_PER_ELEMENT,s>=2&&(i+=Uint32Array.BYTES_PER_ELEMENT),i+=Uint32Array.BYTES_PER_ELEMENT;const o=function(t,e){var r=new Uint8Array(t,e);return Ji.inflate(r).buffer}(t,i);Os({buffer:o,bytesOffset:0}).then((t=>{this.Ft(t.b3dmBuffer.buffer,e,r,"b3dm",((e,r,i)=>{if(e)n(e);else{if(t.pageLods){const e=this.Mt(t.pageLods);e.length&&(r.children=e)}n(e,r,i)}}))}))}Mt(t){const e=[];for(let r=0;r<t.length;r++){const n=t[r];if(!n.childTile)continue;const i={boundingVolume:{sphere:[n.boundingSphere.center.x,n.boundingSphere.center.y,n.boundingSphere.center.z,n.boundingSphere.radius]},content:{uri:n.childTile},geometricError:n.boundingSphere.radius/n.rangeList*16,refine:"REPLACE"};e.push(i)}return e}kt(t){return t.dataType&&t.position?ge(t):t}Rt(t,e){const{tiles:r}=t,n={magic:"cmpt",content:[]},i=[];for(let t=0;t<r.length;t++){const{magic:s}=r[t];if("b3dm"===s){const{content:s,transferables:o}=this.Bt(r[t],e);Vs(i,o),n.content.push(s)}else if("i3dm"===s||"pnts"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:f}=this.Dt(r[t],s,o);Vs(i,f),n.content.push(a)}else if("cmpt"===s){const{content:s,transferables:o}=this.Rt(r[t],e);Vs(i,o),n.content.push(s)}}return{content:n,transferables:i}}Bt(t,e){const{gltf:r,transferables:n,featureTable:i}=t;return this.Lt(t.gltf),this.convertCoordinates(r,i,e.upAxis,e.transform),delete t.transferables,{content:t,transferables:n}}Dt(t,e,r){const{featureTable:n}=t,i=t.pnts||t.i3dm;let s=n&&n.RTC_CENTER||[0,0,0];if(n.EAST_NORTH_UP&&!i.NORMAL_UP&&!i.NORMAL_UP_OCT32P){const e=new Float32Array(3*i.POSITION.array.length),r=[],n=[],o=[];pe(i.POSITION,((t,i)=>{l(o,t,s),te(o,null,r),function(t,e){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]}(n,r);!function(t,e){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]}(e.subarray(9*i,9*(i+1)),n)})),i.INSTANCE_ROTATION={byteStride:0,byteOffset:0,itemSize:9,componentType:5126,array:e},t.transferables.push(e.buffer)}const o={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Cs(i.POSITION.array,3,s,Ms,o);const a=zs(o),c=f([],a),u=[1/0,1/0,1/0],h=[-1/0,-1/0,-1/0];pe(i.POSITION,(t=>{t[0]=t[0]+s[0]-c[0],t[1]=t[1]+s[1]-c[1],t[2]=t[2]+s[2]-c[2],t[0]<u[0]&&(u[0]=t[0]),t[1]<u[1]&&(u[1]=t[1]),t[2]<u[2]&&(u[2]=t[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])})),i.POSITION.min=u,i.POSITION.max=h,e&&w(a,a,e);const y=this.Nt(a);t.rtcCenter=c,t.rtcCoord=y,t.rootIdx=r;const d=t.transferables;return delete t.transferables,{content:t,transferables:d}}Lt(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const r=e[t].image&&e[t].image.array;if(r&&r.length){const n=r[0],i=r[1],s=r[2],o=r[3];let a=!0;for(let t=4;t<r.length;t+=4)if(r[t]!==n||r[t+1]!==i||r[t+2]!==s||r[t+3]!==o){a=!1;break}a&&(e[t].image.color=[n/255,i/255,s/255,o/255],delete e[t].image.array)}}}abortTileLoading(t,e){const r=this.vt[t.url];r&&r.abort(),delete this.vt[t.url],e(null)}convertCoordinates(t,e,r,s){let o=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center,a=ks;"X"===(r=r&&r.toUpperCase())?a=xs:"Z"===r&&(a=Ms),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),o&&(t.extensions.CESIUM_RTC.center=o);const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};me(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=n(Ns);if(t.matrices)for(let r=t.matrices.length-1;r>=0;r--)i(e,e,t.matrices[r]);const r=t.attributes.POSITION.array,s=t.attributes.POSITION.itemSize;i(e,a,e),Cs(r,s,o||Ls,e,c)}));const l=zs(c),u=f([],l);s&&w(l,l,s),t.extensions.CESIUM_RTC.coord=this.Nt(l),o||(me(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 r=n(Ns);if(t.matrices)for(let e=t.matrices.length-1;e>=0;e--)i(r,r,t.matrices[e]);i(r,a,r);const s=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],f=e[6],c=e[7],l=e[8],u=e[9],h=e[10],y=e[11],d=e[12],b=e[13],A=e[14],m=e[15],w=r*a-n*o,p=r*f-i*o,_=r*c-s*o,U=n*f-i*a,g=n*c-s*a,T=i*c-s*f,v=l*b-u*d,I=l*A-h*d,S=l*m-y*d,E=u*A-h*b,O=u*m-y*b,k=h*m-y*A,x=w*k-p*O+_*E+U*S-g*I+T*v;return x?(x=1/x,t[0]=(a*k-f*O+c*E)*x,t[1]=(i*O-n*k-s*E)*x,t[2]=(b*T-A*g+m*U)*x,t[3]=(h*g-u*T-y*U)*x,t[4]=(f*S-o*k-c*I)*x,t[5]=(r*k-i*S+s*I)*x,t[6]=(A*_-d*T-m*p)*x,t[7]=(l*T-h*_+y*p)*x,t[8]=(o*O-a*S+c*v)*x,t[9]=(n*S-r*O-s*v)*x,t[10]=(d*g-b*_+m*w)*x,t[11]=(u*_-l*g-y*w)*x,t[12]=(a*I-o*E-f*v)*x,t[13]=(r*E-n*I+i*v)*x,t[14]=(b*p-d*U-A*w)*x,t[15]=(l*U-u*p+h*w)*x,t):null}(Ps,r),o=[1/0,1/0,1/0],f=[-1/0,-1/0,-1/0];pe(e,(t=>{w(t,t,r),t[0]=t[0]-u[0],t[1]=t[1]-u[1],t[2]=t[2]-u[2],w(t,t,s),t[0]<o[0]&&(o[0]=t[0]),t[1]<o[1]&&(o[1]=t[1]),t[2]<o[2]&&(o[2]=t[2]),t[0]>f[0]&&(f[0]=t[0]),t[1]>f[1]&&(f[1]=t[1]),t[2]>f[2]&&(f[2]=t[2])})),e.min=o,e.max=f,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=u)}Nt(t){return 0===U(t)?c([],0,0,-6378137):kt([],t)}onRemove(){}}function Cs(t,e,r,n,i){const s=[];for(let o=0,a=t.length;o<a;o+=e){const{xmin:a,ymin:f,xmax:u,ymax:h,hmin:y,hmax:d}=i;c(s,t[o],t[o+1],t[o+2]),w(s,s,n);const b=l(s,r,s);b[0]<a&&(i.xmin=b[0]),b[0]>u&&(i.xmax=b[0]),b[1]<f&&(i.ymin=b[1]),b[1]>h&&(i.ymax=b[1]),e>2&&(b[2]<y&&(i.hmin=b[2]),b[2]>d&&(i.hmax=b[2]))}}function zs(t){const{xmax:e,ymax:r,xmin:n,ymin:i,hmin:s,hmax:o}=t,a=[(n+e)/2,(i+r)/2,(s+o)/2];return e===-1/0&&(a[0]=0),r===-1/0&&(a[1]=0),o===-1/0&&(a[2]=0),isNaN(a[2])&&(a[2]=0),a}function Vs(t,e){for(let r=0;r<e.length;r++)t.indexOf(e[r])<0&&t.push(e[r])}let Hs=0;class js{constructor(t){this.workerId=t,this.workers={},this.Pt={}}addLayer({actorId:t,mapId:e,layerId:r,params:n},i){if(this.Zt(e,r))return;const s=this.Ct(e,r),o=n.options,a=this.send.bind(this,t);this.workers[s]=new Zs(r,o,a,i)}removeLayer({mapId:t,layerId:e},r){const n=this.Zt(t,e),i=this.Ct(t,e);delete this.workers[i],n&&n.onRemove(r)}loadTile({mapId:t,layerId:e,params:r},n){const i=this.Zt(t,e);i&&i.loadTile(r,n)}abortTileLoading({mapId:t,layerId:e,params:r},n){const i=this.Zt(t,e);i&&i.abortTileLoading(r,n)}receive(t){const e=t.callback,r=this.Pt[e];delete this.Pt[e],r&&t.error?r(new Error(t.error)):r&&r(null,t.data)}send(t,e,r,n,i){const s=i?`${t}-${Hs++}`:null;i&&(this.Pt[s]=i),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:r,callback:String(s)},n||[])}Ct(t,e){return`${t}-${e}`}Zt(t,e){const r=this.Ct(t,e);return this.workers[r]}}t.initialize=function(){},t.onmessage=function(t,e){const r=t.data;this.dispatcher||(this.dispatcher=new js(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[r.command]({actorId:r.actorId,mapId:r.mapId,layerId:r.layerId,params:r.params},((t,r,n)=>{e(t,r,n)}))},Object.defineProperty(t,"zt",{value:!0})}';for(
|
|
6
|
+
import*as t from"maptalks";import*as e from"@maptalks/gl";import{reshader as r,mat4 as n,vec3 as i,mat3 as s,vec4 as a,quat as o,createREGL as l}from"@maptalks/gl";const c='function(t){var e=1e-6,r="undefined"!=typeof Float32Array?Float32Array:Array;function n(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function i(t,e,r){var n=e[0],i=e[1],s=e[2],o=e[3],a=e[4],f=e[5],c=e[6],l=e[7],u=e[8],h=e[9],y=e[10],d=e[11],b=e[12],A=e[13],m=e[14],w=e[15],p=r[0],_=r[1],U=r[2],g=r[3];return t[0]=p*n+_*a+U*u+g*b,t[1]=p*i+_*f+U*h+g*A,t[2]=p*s+_*c+U*y+g*m,t[3]=p*o+_*l+U*d+g*w,p=r[4],_=r[5],U=r[6],g=r[7],t[4]=p*n+_*a+U*u+g*b,t[5]=p*i+_*f+U*h+g*A,t[6]=p*s+_*c+U*y+g*m,t[7]=p*o+_*l+U*d+g*w,p=r[8],_=r[9],U=r[10],g=r[11],t[8]=p*n+_*a+U*u+g*b,t[9]=p*i+_*f+U*h+g*A,t[10]=p*s+_*c+U*y+g*m,t[11]=p*o+_*l+U*d+g*w,p=r[12],_=r[13],U=r[14],g=r[15],t[12]=p*n+_*a+U*u+g*b,t[13]=p*i+_*f+U*h+g*A,t[14]=p*s+_*c+U*y+g*m,t[15]=p*o+_*l+U*d+g*w,t}function s(){var t=new r(3);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function o(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function a(t,e,n){var i=new r(3);return i[0]=t,i[1]=e,i[2]=n,i}function f(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function c(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function l(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function u(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function h(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function y(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function d(t,e){var r=e[0]-t[0],n=e[1]-t[1],i=e[2]-t[2];return Math.sqrt(r*r+n*n+i*i)}function b(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+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 A(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function m(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[0],a=r[1],f=r[2];return t[0]=i*f-s*a,t[1]=s*o-n*f,t[2]=n*a-i*o,t}function w(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[3]*n+r[7]*i+r[11]*s+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*i+r[8]*s+r[12])/o,t[1]=(r[1]*n+r[5]*i+r[9]*s+r[13])/o,t[2]=(r[2]*n+r[6]*i+r[10]*s+r[14])/o,t}var p=u,_=h,U=o;function g(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}function T(){var t=new r(4);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function v(t,r,n,i){var s=r[0],o=r[1],a=r[2],f=r[3],c=n[0],l=n[1],u=n[2],h=n[3],y=void 0,d=void 0,b=void 0,A=void 0,m=void 0;return(d=s*c+o*l+a*u+f*h)<0&&(d=-d,c=-c,l=-l,u=-u,h=-h),1-d>e?(y=Math.acos(d),b=Math.sin(y),A=Math.sin((1-i)*y)/b,m=Math.sin(i*y)/b):(A=1-i,m=i),t[0]=A*s+m*c,t[1]=A*o+m*l,t[2]=A*a+m*u,t[3]=A*f+m*h,t}s(),function(){var t,e=(t=new r(4),r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var I,S=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};s(),a(1,0,0),a(0,1,0),T(),T(),I=new r(9),r!=Float32Array&&(I[1]=0,I[2]=0,I[3]=0,I[5]=0,I[6]=0,I[7]=0),I[0]=1,I[4]=1,I[8]=1;\n/*!\n * @maptalks/gltf-loader v0.25.8\n * LICENSE : UNLICENSED\n * (c) 2016-2022 maptalks.org\n */\nlet E=0;function O(t){return null==t}function k(t){return!O(t)}function x(t){for(let e=1;e<arguments.length;e++){const r=arguments[e];for(const e in r)t[e]=r[e]}return t}function F(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView\'s component type: "+t)}function B(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function D(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),r=e.length,n=new Uint8Array(r);for(let t=0;t<r;t++)n[t]=e.charCodeAt(t);return n.buffer}const R=[],M=[],L=[],N=[0,0,0],P=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),Z=[1,1,1];function C(t,e,r,n,i,s,o){const a=F(o);if((0===i||i===n*a.BYTES_PER_ELEMENT)&&s%a.BYTES_PER_ELEMENT==0){const i=new a(e,s,r*n);return t.set(i),t}const f=new Uint8Array(n*a.BYTES_PER_ELEMENT);for(let o=0;o<r;o++){let r=null;const c=new Uint8Array(e,i*o+s,n*a.BYTES_PER_ELEMENT);f.set(c),r=new a(f.buffer,0,n);for(let e=0;e<n;e++)t[o*n+e]=r[e]}return t}const z="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function V(t,e,r){const n=new Uint8Array(t,e,r);return z.decode(n)}const H={get:function(t,e={}){e||(e={});const r=new AbortController,n={signal:r.signal,method:e.method||"GET",referrerPolicy:"origin"};"POST"===e.method&&(O(e.body)||(n.body=JSON.stringify(e.body))),O(e.headers)||(n.headers=e.headers),O(e.credentials)||(n.credentials=e.credentials);const i=fetch(t,n).then((t=>{const r=this.t(t,e.responseType);return r.message?r:r.then((r=>"arraybuffer"===e.responseType?{data:r,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:r)).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 i.xhr=r,i},t:(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={})=>(e||(e={}),e.responseType="arraybuffer",H.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?H.jsonp(t):((e=e||{}).responseType="json",H.get(t,e))}};H.jsonp=function(t){const e="_maptalks_jsonp_"+E++;t.match(/\\?/)?t+="&callback="+e:t+="?callback="+e;let r=document.createElement("script");return r.type="text/javascript",r.src=t,new Promise((t=>{window[e]=function(n){document.getElementsByTagName("head")[0].removeChild(r),r=null,delete window[e],t(n)},document.getElementsByTagName("head")[0].appendChild(r)}))};class j{constructor(t,e,r){this.i=t,this.decoders=e,this.o=r,this.images={},this.l={}}requestImageFromBufferURI(t,e,r){if(this.buffers[t.id]){const n=this.buffers[t.id],i=this.u(e,n);return this.getImageByBuffer(i,r)}if(this.l[t.id])return this.l[t.id].then((()=>{const n=this.buffers[t.id],i=this.u(e,n);return this.getImageByBuffer(i,r)}));if(B(t.uri)){const n=this.buffers[t.id]=D(t.uri),i=this.u(e,n);return this.getImageByBuffer(i,r)}return this.l[t.id]=H.getArrayBuffer(t.uri,null).then((n=>{const i=this.buffers[t.id]=n.data,s=this.u(e,i);return this.getImageByBuffer(s,r)}))}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const r=this.decoders;if(r[e.mimeType])return r[e.mimeType](t,{supportedFormats:this.o});if("image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType)return console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null);{const r=new Blob([t],{type:e.mimeType}),n=URL.createObjectURL(r);return this.h(e.id,n)}}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;if(this.l[t.id])return this.l[t.id].then((()=>this.images[t.id]));return this.l[t.id]=this.h(t.id,e)}h(t,e){return new Promise(((r,n)=>{this.i(e,((i,s)=>{i?n(i):(URL.revokeObjectURL(e),this.images[t]=s,r(this.images[t]))}))}))}}const G=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class K{constructor(t,e,r){this.rootPath=t,this.gltf=e,this.A=!1,this.glbBuffer=r,this.buffers={},this.requests={},this.accessors={},this.m()}p(t,e){const r=this.gltf,n=r.accessors[e];if(void 0===n.bufferView)return this.accessors[n.id]=this._(t,e,null,0),Promise.resolve(this.accessors[n.id]);if(n&&this.accessors[n.id])return Promise.resolve(this.accessors[n.id]);const i=r.bufferViews[n.bufferView];return this.U(i).then((r=>{const{buffer:i,byteOffset:s}=r;return this.accessors[n.id]=this._(t,e,i,s)}))}U(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(B(e.uri)){const t=this.buffers[e.id]=D(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const r=e.uri.indexOf("blob:")>=0;t=e.uri.indexOf("://")>0||r?e.uri:this.rootPath+"/"+e.uri;return this.requests[e.id]=H.getArrayBuffer(t,null).then((n=>{r&&URL.revokeObjectURL(t);return{buffer:this.buffers[e.id]=n.data,byteOffset:0}}))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}_(t,e,r,n=0){const i=this.gltf,s=i.accessors[e],o=void 0!==s.bufferView?i.bufferViews[s.bufferView]:{},a=(o.byteOffset||0)+n,f=this.g(s.type),c=F(s.componentType),l=o.byteStride||0;const u={array:undefined,name:t,accessorName:e,byteLength:s.count*f*c.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:f};if(s.min&&(u.min=s.min),s.max&&(u.max=s.max),r)if(this.A)u.byteStride=l,u.byteOffset=a+(s.byteOffset||0),!l||l===f*c.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(u.array=this.T(r,s.count,f,a+(s.byteOffset||0),c),u.array.buffer.byteLength===u.byteLength&&(u.byteOffset=0)):u.array=new Uint8Array(r,a,o.byteLength);else if(s.interleaved){u.byteStride=0,u.byteOffset=0;const t=new c(s.count*f);u.array=C(t,r,s.count,f,l,a+(s.byteOffset||0),s.componentType)}else u.byteStride=0,u.array=this.T(r,s.count,f,a+(s.byteOffset||0),c),u.byteOffset=u.array.byteOffset;else{u.array=new c(s.count);const t=u.min||u.max;t&&(u.array[0]=t[0],u.array[1]=t[1],u.array[2]=t[2])}return u}m(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let r=0;r<t.length;r++)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0);else for(const e in t)for(const r in t)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0)}T(t,e,r,n,i){return n%i.BYTES_PER_ELEMENT!=0&&(t=t.slice(n,n+e*r*i.BYTES_PER_ELEMENT),n=0),new i(t,n,r*e)}g(t){const e=G.indexOf(t);return G[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,r=e.map((t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:r}=e;return this.U(e).then((n=>{const{buffer:i,byteOffset:s}=n,o=V(i,s+(e.byteOffset||0),r);return t.content=o,t}))}if(t.uri){if(B(t.uri)){const e=D(t.uri),r=V(e,0,e.byteLength);return t.content=r,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return H.get(e).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(r).then((()=>t))}}class q extends j{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=r,this.accessor=new K(t,e,r)}iterate(t,e){const r=this.gltf[e];if(!r)return;let n=0;for(const e in r)t(e,r[e],n++)}createNode(t){const e={};if(k(t.name)&&(e.name=t.name),k(t.children)&&(e.children=t.children),k(t.jointName)&&(e.jointName=t.jointName),k(t.matrix)&&(e.matrix=t.matrix),k(t.rotation)&&(e.rotation=t.rotation),k(t.scale)&&(e.scale=t.scale),k(t.translation)&&(e.translation=t.translation),k(t.extras)&&(e.extras=t.extras),k(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}(R,e.translation||N),n=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,f=i+i,c=r*o,l=n*o,u=n*a,h=i*o,y=i*a,d=i*f,b=s*o,A=s*a,m=s*f;return t[0]=1-u-d,t[1]=l+m,t[2]=h-A,t[3]=0,t[4]=l-m,t[5]=1-c-d,t[6]=y+b,t[7]=0,t[8]=h+A,t[9]=y-b,t[10]=1-c-u,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(M,e.rotation||P),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}(L,e.scale||Z);return i(s,n,s),i(t,r,s)}return n(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}v(t){const e={};for(const r in t){const n=t[r];let i,s;n.instanceTechnique&&n.instanceTechnique.values?(i=n.instanceTechnique,s=i.values.diffuse):(i=n,s=i.values.tex||i.values.diffuseTex||i.values.diffuse);const o={"baseColorTexture":{index:s}};n.name&&(o.name=n.name),n.extensions&&(o.extensions=n.extensions),n.extras&&(o.extras=n.extras),e[r]=o}return e}I(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 r=this.gltf.bufferViews[e.bufferView],n=(r.byteOffset||0)+this.glbBuffer.byteOffset,i=r.byteLength,s=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,n,i);return this.getImageByBuffer(s,t)}return this.requestExternalImage(t)}S(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.I(r).then((t=>{const n=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extras:r.extras},sampler:n}}))}getBaseColorTexture(t){const e=this.gltf.materials[t];let r,n;if(e.instanceTechnique&&e.instanceTechnique.values?(r=e.instanceTechnique,n=r.values.diffuse):(r=e,n=r.values.tex||r.values.diffuseTex||r.values.diffuse),void 0===n||void 0===this.gltf.textures)return null;const i=this.gltf.textures[n];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}}class $ extends j{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.glbBuffer=r,this.buffers={},this.requests={},this.accessor=new K(t,e,r)}iterate(t,e){const r=this.gltf[e];if(r)for(let e=0;e<r.length;e++)t(e,r[e],e)}createNode(t){const e={};return x(e,t),!k(t.weights)&&this.gltf.meshes&&k(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}S(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.I(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}};x(n,e);const i=k(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return i&&(n.sampler=i),t.format&&(n.format=t.format),n}))}I(t){if(!k(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],r=this.gltf.buffers[e.buffer];if(r.uri)return this.requestImageFromBufferURI(r,e,t);if(this.glbBuffer)return this.O(e,t)}return null}O(t,e){const r=this.u(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(r,e)}u(t,e,r){r=r||0;const n=t.byteOffset+r,i=t.byteLength;return new Uint8Array(e,n,i)}k(t,e){const r=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)r[e]=String.fromCharCode(t[e]);r.join("");const n="data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(r)));return n}getAnimations(t){const e=[];return t.forEach((t=>{e.push(this.getSamplers(t.samplers))})),Promise.all(e).then((e=>{for(let r=0;r<e.length;r++)t[r].samplers=e[r];return t}))}getSamplers(t){const e=[];for(let r=0;r<t.length;r++)(k(t[r].input)||k(t[r].output))&&(e.push(this.accessor.p("input",t[r].input)),e.push(this.accessor.p("output",t[r].output)));return Promise.all(e).then((e=>{for(let r=0;r<e.length/2;r++)t[r].input=e[2*r],t[r].output=e[2*r+1],t[r].interpolation||(t[r].interpolation="LINEAR");return t}))}}const J="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null,Y=1313821514,X=5130562;class W{static read(t,e=0,r=0){r||(r=t.byteLength);const n=new DataView(t,e,r),i=n.getUint32(4,!0);if(1===i)return W.readV1(n,e);if(2===i)return W.readV2(t,e);throw new Error("Unsupported glb version : "+i)}static readV1(t,e){const r=t.getUint32(8,!0),n=t.getUint32(12,!0);if(r!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb\'s byte length.");const i=Q(t.buffer,20+e,n);return{json:JSON.parse(i),glbBuffer:{byteOffset:20+e+n,buffer:t.buffer,byteLength:r}}}static readV2(t,e){let r,n,i;const s=new DataView(t,e+12);let o=0;for(;o<s.byteLength;){const a=s.getUint32(o,!0);o+=4;const f=s.getUint32(o,!0);if(o+=4,f===Y)r=Q(t,e+12+o,a);else if(f===X){i=e+12+o,n=a;break}o+=a}return{json:JSON.parse(r),glbBuffer:{byteOffset:i,buffer:t,byteLength:n}}}}function Q(t,e,r){if(J){const n=new Uint8Array(t,e,r);return J.decode(n)}return function(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=tt[i>>3&7];if(!(64&i)||!r||n+r>e)return null;for(i&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;i=i<<6|63&e}}r+=String.fromCharCode(i)}return r}(new Uint8Array(t,e,r))}const tt=[1,1,1,1,2,2,3,0];const et=[0,0,0],rt=[0,0,0,1],nt=[1,1,1],it={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},st={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},ot={F(t,e,r,n,i,s,o,a){const c=k(t)?e.animations:[e.animations[0]],l={};for(let e=0;e<c.length;e++){const u=c[e],h=u.name||e;if(k(t)&&h!==t)continue;const y=u.channelsMap[r];if(y)for(let t=0;t<y.length;t++){const e=y[t];"translation"===e.target.path?(this.B(i,u.samplers[e.sampler],n,1),l.translation=f(et,i)):"rotation"===e.target.path?(this.D(s,u.samplers[e.sampler],n,1),l.rotation=S(rt,s)):"scale"===e.target.path?(this.B(o,u.samplers[e.sampler],n,1),l.scale=f(nt,o)):"weights"===e.target.path&&a&&(this.B(a,u.samplers[e.sampler],n,a.length),l.weights=a)}}return l},B(t,e,r,n){switch(e.interpolation){case"LINEAR":{const i=this.R(st,e,r,1*n);i&&(t=function(t,e,r,n){for(let i=0;i<t.length;i++)t[i]=e[i]+n*(r[i]-e[i]);return t}(t,i.PREVIOUS,i.NEXT,i.INTERPOLATION));break}case"STEP":{const i=this.R(st,e,r,1*n);i&&(t=function(t,e){for(let r=0;r<t.length;r++)t[r]=e[r];return t}(t,...i.PREVIOUS));break}case"CUBICSPLINE":{const i=this.R(st,e,r,3*n);i&&(t=this.M(t,i,e.input.array,3*n));break}}return t},D(t,e,r){switch(e.interpolation){case"LINEAR":{const n=this.R(st,e,r,1);n&&v(t,n.PREVIOUS,n.NEXT,n.INTERPOLATION);break}case"STEP":{const n=this.R(st,e,r,1);n&&(t=g(t,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.R(st,e,r,3);if(n){for(let t=0;t<n.PREVIOUS.length;t++)n.PREVIOUS[t]=Math.acos(n.PREVIOUS[t]),n.NEXT[t]=Math.acos(n.NEXT[t]);t=this.M(t,n,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},L(t,e){const r=t.length;let n,i,s,o=0,a=r-1,f=Math.floor((o+a)/2);for(;o<=r-1&&a>=0;){if(o===a)return null;if(t[f]<=e&&e<=t[f+1]){const r=t[f];return n=f,i=f+1,s=(e-r)/(t[f+1]-r),{preIndx:n,nextIndex:i,interpolation:s}}e<t[f]?(a=f,f=Math.floor((o+a)/2)):t[f+1]<e&&(o=f,f=Math.floor((o+a)/2))}return null},R(t,e,r,n){const i=e.input.array,s=e.output.array,o=e.output.itemSize;(r<i[0]||r>i[i.length-1])&&(r=Math.max(i[0],Math.min(i[i.length-1],r))),r===i[i.length-1]&&(r=i[0]);const a=this.L(i,r);if(!a||!a.nextIndex)return null;const{preIndx:f,nextIndex:c,interpolation:l}=a;t.PREINDEX=f,t.NEXTINDEX=c,t.INTERPOLATION=l;const u=o*n;return t.PREVIOUS=s.subarray(t.PREINDEX*u,(t.PREINDEX+1)*u),t.NEXT=s.subarray(t.NEXTINDEX*u,(t.NEXTINDEX+1)*u),t},M(t,e,r,n){const i=e.INTERPOLATION,s=r[e.PREINDEX],o=r[e.NEXTINDEX];for(let r=0;r<3;r++){const a=e.PREVIOUS[n+r],f=(o-s)*e.PREVIOUS[2*n+r],c=e.NEXT[3+r],l=(o-s)*e.NEXT[r],u=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*a+(Math.pow(i,3)-2*Math.pow(i,2)+i)*f+(2*-Math.pow(i,3)+3*Math.pow(i,2))*c+(Math.pow(i,3)-Math.pow(i,2))*l;t[r]=u}return t},getAnimationClip(t,e,r,n){const i=t.nodes[e]&&t.nodes[e].weights;c(et,...it.TRANSLATION),g(rt,...it.ROTATION),c(nt,...it.SCALE);return this.F(n,t,e,r,et,rt,nt,i)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach(((e,r)=>{let n=-1/0,i=1/0;const s=e.channels;for(let t=0;t<s.length;t++){const r=s[t],o=e.samplers[r.sampler].input.array;o[o.length-1]>n&&(n=o[o.length-1]),o[0]<i&&(i=o[0])}const o=e.name||r;t.timeSpan[o]={max:n,min:i}})),t.timeSpan},getTimeSpanByName(t,e){const r=this.getTimeSpan(t);return r?k(e)?r[e]:r[Object.keys(r)[0]]:null}};let at=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(on){}t&&"undefined"!=typeof createImageBitmap&&(at=!0)}const ft="undefined"==typeof document?null:document.createElement("canvas");class ct{constructor(t,e,r){if(this.options=r||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:r,glbBuffer:n}=W.read(e.buffer,e.byteOffset,e.byteLength);this.N(t,r,n)}else this.N(t,e);this.P=new K(this.rootPath,this.gltf,this.glbBuffer),this.Z()}Z(){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.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}C(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.P.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.V(t),r=this.H(),n=this.j(),i=this.C();return Promise.all([e,r,n,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 r=e[t];r.channelsMap={};for(let t=0;t<r.channels.length;t++){const e=r.channels[t];r.channelsMap[e.target.node]||(r.channelsMap[e.target.node]=[]),r.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:r}=this.gltf;for(let r=0;r<e.length;r++)e[r].uri&&e[r].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[r].uri});for(let e=0;e<r.length;e++)r[e].uri&&r[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:r[e].uri})}return t}static getAnimationClip(t,e,r,n){return ot.getAnimationClip(t,e,r,n)}static getAnimationTimeSpan(t,e){return ot.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return F(t)}static readInterleavedArray(t,e,r,n,i,s,o){return C(t,e,r,n,i,s,o)}N(t,e,r){this.gltf=e,this.glbBuffer=r,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=at?yt.bind(this):this.options.requestImage||lt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new $(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="buffer_"+r}),"buffers"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors")):(this.adapter=new q(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"))}G(t,e){if(t.children&&t.children.length>0){if(!(r=t.children[0],"number"==typeof r&&isFinite(r)||function(t){return!O(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}(t.children[0])))return t;const n=t.children.map((t=>{const r=e[t];return r.nodeIndex=t,this.G(r,e)}));t.children=n}var r;return t}V(t){return this.K(t).then((t=>{const e=this.scenes=[];let r;for(const e in t)t[e]=this.G(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate(((n,i,s)=>{const o={};i.name&&(o.name=i.name),i.nodes&&(o.nodes=i.nodes.map((e=>t[e]))),this.gltf.scene===n&&(r=s),e.push(o)}),"scenes");const n={asset:this.gltf.asset,scene:r,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins};if(this.gltf.extensions&&(n.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.v(this.gltf.materials);n.materials=t}return n}))}K(t){return this.q(t).then((()=>{const t=this.nodes={};return this.adapter.iterate(((e,r)=>{const n=this.adapter.createNode(r,this.meshes,this.skins);t[e]=n}),"nodes"),t}))}$(){this.skins=[];const t=[];return this.adapter.iterate(((e,r,n)=>{t.push(this.J(r).then((t=>{t.index=n,this.skins.push(t)})))}),"skins"),t}J(t){const e=t.inverseBindMatrices;return this.adapter.accessor.p("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 k(t)?this.adapter.getAnimations(t):null}q(t){this.meshes={};let e=[];return this.adapter.iterate(((r,n,i)=>{e.push(this.Y(n,t).then((t=>{t.index=i,this.meshes[r]=t})))}),"meshes"),e=e.concat(this.$()),Promise.all(e)}Y(t,e){const r=t.primitives.map((t=>this.X(t,e))).filter((t=>!!t));return Promise.all(r).then((e=>{const r={};return x(r,t),r.primitives=e,r}))}j(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const r in t)e.push(this.adapter.S(r));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++){const r=e[t].image.array;if(e[t]&&r){let t;t=r instanceof ImageBitmap?r:r.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const r={},n=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(r[n[t]]=e[t]);return r}return e}))}X(t,e){let r;const n=[],i=t.extensions;if(k(t.targets))for(let e=0;e<t.targets.length;e++){const r=t.targets[e];for(const t in r){const i=this.adapter.accessor.p(`morphTargets_${t}_${e}`,r[t]);i&&n.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],f=this.P.U(a).then((r=>{const{buffer:n,byteOffset:i}=r;let{byteOffset:s,byteLength:f}=a;s||(s=0);const c=new DataView(n,i+s,f),l={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(c,l).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));n.push(f),r=Promise.all(n)}else{const e=t.attributes;for(const t in e){const r=this.adapter.accessor.p(t,e[t]);r&&n.push(r)}if(k(t.indices)){const e=this.adapter.accessor.p("indices",t.indices);e&&n.push(e)}r=Promise.all(n)}return r.then((e=>{if(i&&i.KHR_draco_mesh_compression){const r=t.targets?t.targets.length:0;e[r]=e[r].concat(e.slice(0,r)),e=e[r]}let r,n;const s={attributes:e.reduce(((t,e)=>{if("indices"===e.name)r=e;else if(e.name.indexOf("morphTargets_")>-1)n=n||{},n[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0],{itemSize:n,array:i}=e,s=i.length/n;for(let e=0;e<s;e++)for(let s=0;s<n;s++){const o=e*n+s;i[o]<t[s]&&(t[s]=i[o]),i[o]>r[s]&&(r[s]=i[o])}if(e.quantization){const n=e.quantization,i=n.range/(1<<n.quantizationBits),s=n.minValues;y(t,t,i),l(t,t,s),y(r,r,i),l(r,r,s)}e.min=t,e.max=r}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 r&&(s.indices=r),n&&(s.morphTargets=n),s.mode=k(t.mode)?t.mode:4,k(t.extras)&&(s.extras=t.extras),s}))}}function lt(t,e){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!ft)return void e(new Error("There is no canvas to draw image!"));ft.width=r.width,ft.height=r.height;const t=ft.getContext("2d");t.drawImage(r,0,0,r.width,r.height);const n=t.getImageData(0,0,r.width,r.height),i={width:r.width,height:r.height,data:new Uint8Array(n.data)};e(null,i)},r.onerror=function(t){e(t)},r.src=t}let ut,ht;function yt(t,e){ut||(ut=new OffscreenCanvas(2,2),ht=ut.getContext("2d")),fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{let{width:r,height:n}=t;dt(r)||(r=bt(r)),dt(n)||(n=bt(n));const i=this.options.maxTextureSize;i&&(r=Math.min(i,r)),i&&(n=Math.min(i,n)),ut.width=r,ut.height=n,ht.drawImage(t,0,0,r,n),t.close();const s=ht.getImageData(0,0,r,n);e(null,{width:r,height:n,data:new Uint8Array(s.data)})})).catch((t=>{console.warn(t),e(t)}))}function dt(t){return 0==(t&t-1)&&0!==t}function bt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function At(t){return t*Math.PI/180}function mt(t){return t/Math.PI*180}function wt(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const pt=[1,1,1,1,2,2,3,0];function _t(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=pt[i>>3&7];if(!(64&i)||!r||n+r>e)return null;for(i&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;i=i<<6|63&e}}r+=String.fromCharCode(i)}return r}const Ut=new Array(3),gt=new Array(3),Tt=[40680631590769,40680631590769,40408299984661.445];const vt=[1/6378137,1/6378137,1/6356752.314245179],It=[1/40680631590769,1/40680631590769,1/40408299984661.445],St=new Array(3),Et=new Array(3),Ot=new Array(3);function kt(t,e){const r=It,n=function(t,e,r,n,i){const s=e[0],o=e[1],a=e[2],f=r[0],c=r[1],l=r[2],u=s*s*f*f,h=o*o*c*c,d=a*a*l*l,b=u+h+d,A=Math.sqrt(1/b),m=y(xt,e,A);if(b<i)return isFinite(A)?m:void 0;const w=n[0],p=n[1],_=n[2],U=Ft;U[0]=m[0]*w*2,U[1]=m[1]*p*2,U[2]=m[2]*_*2;let g,T,v,I,S,E,O,k,x,F,B,D=(1-A)*Bt(e)/(.5*Bt(U)),R=0;do{D-=R,v=1/(1+D*w),I=1/(1+D*p),S=1/(1+D*_),E=v*v,O=I*I,k=S*S,x=E*v,F=O*I,B=k*S,g=u*E+h*O+d*k-1,T=u*x*w+h*F*p+d*B*_;R=g/(-2*T)}while(Math.abs(g)>1e-12);return t[0]=s*v,t[1]=o*I,t[2]=a*S,t}(St,e,vt,r,.1);let i=_(Et,n,r);i=Dt(i,i);const s=p(Ot,e,n),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),f=wt(A(s,e))*Bt(s);return t[0]=mt(o),t[1]=mt(a),t[2]=f,t}const xt=new Array(3),Ft=new Array(3);function Bt(t){return o(t)}function Dt(t,e){const r=e[0],n=e[1],i=e[2];let s=r*r+n*n+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function Rt(t,e){let r="";for(let n=0;n<4;n++){const i=t.getUint8(e+n);r+=String.fromCharCode(i)}return r}const Mt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Lt(t,e,r){const n=new Uint8Array(t,e,r);return Mt?JSON.parse(Mt.decode(n)):JSON.parse(_t(n))}function Nt(t,e,r){const n=new Uint8Array(t,e,r);return Mt?JSON.parse(Mt.decode(n)):JSON.parse(_t(n))}function Pt(t,e,r){return{offset:e,byteLength:r}}function Zt(t,e,r,n){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:f}=function(t){return Vt[t]}(s),c=function(t){if(!t)return 1;return zt[t]}(o);return{byteStride:0,byteOffset:i+r,itemSize:c,count:n*c,componentType:f,array:new a(e,r+i,n*c)}}function Ct(t,e,r,n){t.componentType||(t.componentType="UNSIGNED_SHORT");const i=Zt(t,e,r,n);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}const zt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Vt={"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 Ht(t){for(let e in Vt)if(t===Vt[e].ctor)return Vt[e].type;throw new Error("unrecognized ctor:"+t)}function jt(t,e,r,n){const i=t,s=e.length/3;for(let t=0;t<s;t++)i[3*t]=e[3*t]/65535*n[0]+r[0],i[3*t+1]=e[3*t+1]/65535*n[1]+r[1],i[3*t+2]=e[3*t+2]/65535*n[2]+r[2];return i}function Gt(t,e,r){let n=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0);const a=t.buffer;let f,c,l={},u={};n>0&&(l=Lt(a,e,n),e+=n),i>0&&(f=function(t,e,r){return{offset:e,byteLength:r}}(0,e,i),e+=i),s>0&&(u=Nt(a,e,s),e+=s);const h=Pt(0,e,o);return c=a.slice(h.offset,h.offset+h.byteLength),r.push(c),{featureTable:l,featureTableBin:f,batchTable:u,batchTableBin:c}}var Kt={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},qt={},$t={east:[],north:[],up:[],west:[],south:[],down:[]},Jt=[],Yt=[],Xt=[];const Wt=[0,0,0];function Qt(t,e,r,n){r=r||0,n=n||r;var i=Math.abs(t-e);return i<=n||i<=r*Math.max(Math.abs(t),Math.abs(e))}const te=(ie={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"}}[ee="east"][re="north"],qt[se=ee+re]?ne=qt[se]:(ne=function(t,r,n){if(c=Wt,l=(a=t)[0],u=a[1],d=a[2],A=c[0],w=c[1],p=c[2],Math.abs(l-A)<=e*Math.max(1,Math.abs(l),Math.abs(A))&&Math.abs(u-w)<=e*Math.max(1,Math.abs(u),Math.abs(w))&&Math.abs(d-p)<=e*Math.max(1,Math.abs(d),Math.abs(p)))f(Jt,Kt[ee]),f(Yt,Kt[re]),f(Xt,Kt[ie]);else if(Qt(t[0],0,1e-14)&&Qt(t[1],0,1e-14)){var i=wt(t[2]);f(Jt,Kt[ee]),"east"!==ee&&"west"!==ee&&y(Jt,Jt,i),f(Yt,Kt[re]),"east"!==re&&"west"!==re&&y(Yt,Yt,i),f(Xt,Kt[ie]),"east"!==ie&&"west"!==ie&&y(Xt,Xt,i)}else{!function(t,e){h(e,t,It),b(e,e)}(t,$t.up);var s=$t.up,o=$t.east;o[0]=-t[1],o[1]=t[0],o[2]=0,b($t.east,o),m($t.north,s,o),y($t.down,$t.up,-1),y($t.west,$t.east,-1),y($t.south,$t.north,-1),Jt=$t[ee],Yt=$t[re],Xt=$t[ie]}var a,c,l,u,d,A,w,p;return n[0]=Jt[0],n[1]=Jt[1],n[2]=Jt[2],n[3]=0,n[4]=Yt[0],n[5]=Yt[1],n[6]=Yt[2],n[7]=0,n[8]=Xt[0],n[9]=Xt[1],n[10]=Xt[2],n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n},qt[se]=ne),ne);\n/*!\n * @maptalks/gl v0.67.10\n * LICENSE : UNLICENSED\n * (c) 2016-2022 maptalks.com\n */var ee,re,ne,ie,se;const oe=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")},ae=oe(),fe=ae.gl_trans__coders=ae.gl_trans__coders||{};fe.inject=function(t){const e=t.toString(),r=e.indexOf("{")+1,n=e.substring(0,r),i=ae.gl_trans__coders=ae.gl_trans__coders||{};let s=`${n}\\n const _____getGlobal = ${oe.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(n.length),s},fe.registerTranscoder=function(t,e){fe[t]=e},fe.getTranscoder=function(t){return fe[t]};class ce{constructor(t,e,r){this.i=t,this.W=e||ct,this.o=r,this.tt={"image/crn":fe.crn&&fe.crn(),"image/ktx2":fe.ktx2&&fe.ktx2(),"image/cttf":fe.ktx2&&fe.ktx2(),"draco":fe.draco&&fe.draco()}}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.et(t,e,r,n,i)):H.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.et(t,i,r,n)}))}et(t,e,r,n,i){const s=i&&i.maxTextureSize,o=this.rt(e,r,n,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),f=new this.W(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.tt,supportedFormats:this.o,maxTextureSize:s});return f.load().then((e=>{e.url=`${t}-${r}-${n}`;const i=f.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}}))}rt(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", url:"+n;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: "+n;return console.warn(t),{error:t}}let o,a=i.getUint32(12,!0),f=i.getUint32(16,!0),c=i.getUint32(20,!0),l=i.getUint32(24,!0),u=28+e;c>=570425344?(u-=8,o=a,c=f,l=0,a=0,f=0):l>=570425344&&(u-=4,o=c,c=a,l=f,a=0,f=0);const h=[t];let y,d,b;if(a>0?(y=Lt(t,u,a),u+=a,o=y.BATCH_LENGTH):y={"BATCH_LENGTH":o},f>0&&(u+=f),c>0&&(d=Nt(t,u,c),u+=c,l>0)){const e=Pt(0,u,l);b=t.slice(e.offset,e.offset+e.byteLength),u+=l,h.push(b)}const A=y.BATCH_LENGTH,m={};if(y&&y.BATCH_ID){m.BATCH_ID=Ct(y.BATCH_ID,t,undefined.offset,A);const e=m.BATCH_ID.array&&m.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:o,transferables:h,featureTable:y,batchTable:d,batchTableBin:b,b3dm:m,glb:{buffer:t,byteOffset:u,byteLength:i.byteLength+i.byteOffset-u}}}nt(){return null}}class le{constructor(t,e,r,n){this.i=t,this.W=e||ct,this.o=r,this.tt={"image/crn":fe.crn&&fe.crn(),"image/ktx2":fe.ktx2&&fe.ktx2(),"image/cttf":fe.ktx2&&fe.ktx2(),"draco":fe.draco&&fe.draco()},this.it=n}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.et(t,e,r,n,i)):H.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.et(t,i,r,n)}))}et(t,e,r,n,i){return this.st(t,e,r,n,i).then((({gltf:i,transferables:s})=>{const o=this.ot(e,r,n,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})}))}st(t,e,r,n,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.tt,supportedFormats:this.o,maxTextureSize:s},a=new DataView(e,r,n),f=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let n=_t(new Uint8Array(e,f+r,a.byteLength-f));-1==n.indexOf("://")&&(n=t.substring(0,t.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?H.getArrayBuffer(n,{}).then((t=>this.at(n,{buffer:t.data,byteOffset:0},o))):H.getJSON(n,{}).then((t=>this.at(n,t,o)))}{const n={buffer:e,byteOffset:f+r,byteLength:a.byteLength-f};return this.at(t,n,o)}}at(t,e,r){const n=t.substring(0,t.lastIndexOf("/")),i=new this.W(n,e,r);return i.load({skipAttributeTransform:!0}).then((r=>{let n=0,s=0;return e.buffer&&(n=e.byteOffset||0,s=e.byteLength||0),r.url=`${t}-${n}-${s}`,{transferables:i.transferables,gltf:r}}))}ot(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;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: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:f,batchTable:c,batchTableBin:l}=Gt(i,32+e,o),u={},h=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;u.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+f.offset,3*h).slice()},o.push(u.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,r=a.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=a.POSITION_QUANTIZED;u.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.ft(new Uint16Array(t,n+f.offset,3*h),e,r)},o.push(u.POSITION.array.buffer)}if(a.BATCH_ID){u.BATCH_ID=Ct(a.BATCH_ID,t,f.offset,h);const e=u.BATCH_ID.array&&u.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+f.offset,3*h).slice()},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+f.offset,3*h).slice()},o.push(u.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.ct(new Uint16Array(t,e+f.offset,2*h))},o.push(u.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.ct(new Uint16Array(t,e+f.offset,2*h))},o.push(u.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;u.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+f.offset,h).slice()},o.push(u.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;u.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+f.offset,3*h).slice()},o.push(u.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:c,batchTableBin:l,featureTable:a,i3dm:u,transferables:o}}ct(t){const e=t.length/2,r=new Float32Array(3*e),n=[];for(let i=0;i<e;i++)ue(n,t[2*i],t[2*i+1],65535),r[3*i]=n[0],r[3*i+1]=n[1],r[3*i+2]=n[2];return r}ft(t,e,r){return jt(new Float32Array(t.length),t,e,r)}nt(){return null}}function ue(t,e,r,n){if(t[0]=he(e,n),t[1]=he(r,n),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]))*ye(e),t[1]=(1-Math.abs(e))*ye(t[1])}return b(t,t)}function he(t,e){return function(t,e,r){return t<e?e:t>r?r:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function ye(t){return t<0?-1:1}class de{constructor(){}load(t,e,r=0,n=0){return e?(n||(n=e.byteLength),this.et(t,e,r,n)):H.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.et(t,i,r,n)}))}et(t,e,r,n){return this.lt(e,r,n,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}))}lt(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;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: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:f,batchTable:c,batchTableBin:l}=Gt(i,e+28,o),u=a.QUANTIZED_VOLUME_OFFSET,h=a.QUANTIZED_VOLUME_SCALE,y=a.POINTS_LENGTH;let d,b={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){b=a.extensions["3DTILES_draco_point_compression"],d=new DataView(t,b.byteOffset+f.offset,b.byteLength);const e={attributes:b.properties,useUniqueIDs:!1};return this.ut||(this.ut=fe.draco()),this.ut(d,e).then((e=>{const r=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||r.POSITION||r.POSITION_QUANTIZED||(r.POSITION=a.POSITION,r.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||r.RGB||r.RGBA||r.RGB565||(r.RGB=a.RGB,r.RGBA=a.RGBA,r.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||r.NORMAL||r.NORMAL_OCT16P||(r.NORMAL=a.NORMAL,r.NORMAL_OCT16P=a.NORMAL_OCT16P);const n=this.ht(t,e.attributes,f.offset,y,o,u,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;n.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Ht(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(c).length){a.BATCH_ID?n.BATCH_ID=Ct(a.BATCH_ID,t,f.offset,y):n.BATCH_ID=be(y);const e=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:y,batchTable:c,batchTableBin:l,featureTable:a,pnts:n,transferables:o}}))}const A=this.ht(t,a,f.offset,y,o,u,h);if(a.BATCH_ID||Object.keys(c).length){a.BATCH_ID?A.BATCH_ID=Ct(a.BATCH_ID,t,f.offset,y):A.BATCH_ID=be(y);const e=A.BATCH_ID.array&&A.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:y,batchTable:c,batchTableBin:l,featureTable:a,pnts:A,transferables:o})}ht(t,e,r,n,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const f=o?0:r;if(!o){const e=t.slice(s+f,s+f+3*n*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},i.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:f,array:c}=e.POSITION_QUANTIZED;f=f||0;const l=c?0:r;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this.ft(c||new Uint16Array(t,f+l,3*n),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const f=o?0:r;if(!o){const e=t.slice(s+f,s+f+4*n);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:n,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const f=o?0:r;if(!o){const e=t.slice(s+f,s+f+3*n);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const f=o?0:r;if(!o){const e=t.slice(s+f,s+f+2*n);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:n,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const f=o?0:r;if(!o){const e=t.slice(s+f,s+f+3*n*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:n,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 f=o?0:r;if(!o){const e=t.slice(s+f,s+f+2*n);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:n,componentType:5121,array:o},i.push(o.buffer)}return a}ft(t,e,r){return jt(new Float32Array(t.length),t,e,r)}nt(){return null}}function be(t){const e=(r=t)<256?Uint8Array:r<65536?Uint16Array:Uint32Array;var r;const n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Ht(e),array:n}}class Ae{constructor(t,e){this.i=t,this.W=e||ct}load(t,e,r=0,n=0,i){return e?this.et(t,e,r,n,i):H.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.et(t,i,r,n)}))}et(t,e,r,n,i){n||(n=e.byteLength);const s=this.yt(e,t,r,n),o=[];for(let r=0;r<s.length;r++){let n;if("b3dm"===s[r].magic)n=new ce(this.i,this.W);else if("i3dm"===s[r].magic)n=new le(this.i,this.W);else if("pnts"===s[r].magic)n=new de;else{if("cmpt"!==s[r].magic){console.warn("Unsupported magic in CMPT tile:",s[r].magic);continue}n=new Ae(this.i,this.W)}o.push(n.load(t,e,s[r].offset,s[r].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}yt(t,e,r,n){const i=new DataView(t,r,n),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 f=16;for(let e=0;e<a;e++){const e=Rt(i,f),n=i.getUint32(f+8,!0);o.push({magic:e,buffer:t,offset:f+r,byteLength:n}),f+=n}return o}}function me(t,e){if(t.scenes&&t.scenes.length)for(let r=0,n=t.scenes.length;r<n;r++){const n=t.scenes[r].nodes;for(let r=0,i=n.length;r<i;r++){const i=[];we(n[r],i,t,e)}}}function we(t,e,r,n){if(t.matrix&&e.push(t.matrix),t.children&&t.children.length)for(let i=0,s=t.children.length;i<s;i++)we(t.children[i],e,r,n);if(void 0!==t.mesh){const i=t.mesh,s=r.meshes[i];if(s){const t=e.slice(0),o=s.primitives;for(let e=0,s=o.length;e<s;e++){const s=o[e];s&&(s.matrices=t,n(s,i,e,r))}}}}function pe(t,e){let{componentType:r,byteOffset:n,byteStride:i,count:s,itemSize:o}=t;const a=t.array.buffer,f=r?ct.getTypedArrayCtor(r):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,i=i||0,s=s||t.array.length/o,(!i||i===o*f.BYTES_PER_ELEMENT)&&n%f.BYTES_PER_ELEMENT==0){const t=new f(a,n,s*o);for(let r=0;r<s*o;r+=o){e(new f(t.buffer,n+r*f.BYTES_PER_ELEMENT,o),r/o)}return}const c=new Uint8Array(o*f.BYTES_PER_ELEMENT);i||(i=o*f.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const r=new Uint8Array(a,i*t+n,o*f.BYTES_PER_ELEMENT);c.set(r);e(new f(c.buffer),t),r.set(c)}}const _e=[],Ue=[];function ge(t){const e={asset:{version:"1.0",gltfUpAxis:"Z",s3mType:t.dataType},geometricError:0,root:{boundingVolume:{},content:{uri:""},transform:[],geometricError:0,refine:"REPLACE",children:[]}},r=t.position.x,n=t.position.y,i=t.position.z,s=function(t,e,r,n){const i=Tt,s=Math.cos(r);Ut[0]=s*Math.cos(e),Ut[1]=s*Math.sin(e),Ut[2]=Math.sin(r),Dt(Ut,Ut),h(gt,i,Ut);const o=Math.sqrt(A(Ut,gt));var a,f,c;return f=gt,c=o,(a=gt)[0]=f[0]/c,a[1]=f[1]/c,a[2]=f[2]/c,y(Ut,Ut,n),l(t,gt,Ut)}([],At(r),At(n),i),o=te(s,null,[]);e.root.transform=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}([],o);const a=[];for(let r=0,n=t.tiles.length;r<n;r++)if(t.tiles[r].boundingbox){const n=t.tiles[r].boundingbox;c(_e,n.min.x,n.min.y,n.min.z),c(Ue,n.max.x,n.max.y,n.max.z);const i={center:[0,0,0],radius:0};Te(_e,Ue,i),e.root.children.push({boundingVolume:{sphere:[...i.center,i.radius]},content:{uri:t.tiles[r].url},geometricError:70,refine:"REPLACE"}),a.push(i)}else if(t.tiles[r].boundingsphere){const{boundingsphere:n}=t.tiles[r],i={center:[n.center.x,n.center.y,n.center.z],radius:n.radius};e.root.children.push({boundingVolume:{sphere:[...i.center,i.radius]},content:{uri:t.tiles[r].url},geometricError:70,refine:"REPLACE"}),a.push(i)}const b=function(t,e){if(0===t.length)return e;const r=t.length;if(1===r)return function(t,e){return f(e.center,t.center),e.radius=t.radius,e}(t[0],e);if(2===r)return function(t,e,r){const n=t.center,i=t.radius,s=e.center,o=e.radius,a=u(Ie,s,n),c=Ce(a);if(i>=c+o)return t.clone(r),r;if(o>=c+i)return e.clone(r),r;const h=.5*(i+c+o),d=y(Se,a,(-i+h)/c);return l(d,d,n),f(r.center,d),r.radius=h,r}(t[0],t[1],e);const n=[];for(let e=0;e<r;e++)n.push(t[e].center);const i=(e=function(t,e){if(0===t.length)return e.center=c(e.center,0,0,0),e.radius=0,e;const r=f(De,t[0]),n=f(Ee,r),i=f(Oe,r),s=f(ke,r),o=f(xe,r),a=f(Fe,r),l=f(Be,r),h=t.length;for(let e=1;e<h;e++){f(r,t[e]);const c=r[0],u=r[1],h=r[2];c<n[0]&&f(n,r),c>o[0]&&f(o,r),u<i[1]&&f(i,r),u>a[1]&&f(a,r),h<s[2]&&f(s,r),h>l[2]&&f(l,r)}const y=Ze(u(Re,o,n)),d=Ze(u(Re,a,i)),b=Ze(u(Re,l,s));let A=n,m=o,w=y;d>w&&(w=d,A=i,m=a);b>w&&(w=b,A=s,m=l);const p=Me;p[0]=.5*(A[0]+m[0]),p[1]=.5*(A[1]+m[1]),p[2]=.5*(A[2]+m[2]);let _=Ze(u(Re,m,p)),U=Math.sqrt(_);const g=Le;g[0]=n[0],g[1]=i[1],g[2]=s[2];const T=Ne;T[0]=o[0],T[1]=a[1],T[2]=l[2];const v=ve(g,T,Pe);let I=0;for(let e=0;e<h;e++){f(r,t[e]);const n=Ce(u(Re,r,v));n>I&&(I=n);const i=Ze(u(Re,r,p));if(i>_){const t=Math.sqrt(i);U=.5*(U+t),_=U*U;const e=t-U;p[0]=(U*p[0]+e*r[0])/t,p[1]=(U*p[1]+e*r[1])/t,p[2]=(U*p[2]+e*r[2])/t}}U<I?(f(e.center,p),e.radius=U):(f(e.center,v),e.radius=I);return e}(n,e)).center;let s=e.radius;for(let e=0;e<r;e++){const r=t[e];s=Math.max(s,d(i,r.center)+r.radius)}return e.radius=s,e}(a,{center:[0,0,0],radius:0});return e.root.boundingVolume.sphere=[...b.center,b.radius],e}function Te(t,e,r){var n=ve(t,e,r.center);return r.radius=d(n,e),r}function ve(t,e,r){return r[0]=.5*(t[0]+e[0]),r[1]=.5*(t[1]+e[1]),r[2]=.5*(t[2]+e[2]),r}const Ie=[],Se=[];const Ee=[],Oe=[],ke=[],xe=[],Fe=[],Be=[],De=[],Re=[],Me=[],Le=[],Ne=[],Pe=[];function Ze(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function Ce(t){return Math.hypot(t[0],t[1],t[2])}\n/*! pako 2.0.4 https://github.com/nodeca/pako @license (MIT AND Zlib) */function ze(t){let e=t.length;for(;--e>=0;)t[e]=0}const Ve=256,He=286,je=30,Ge=15,Ke=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),qe=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),$e=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Je=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ye=new Array(576);ze(Ye);const Xe=new Array(60);ze(Xe);const We=new Array(512);ze(We);const Qe=new Array(256);ze(Qe);const tr=new Array(29);ze(tr);const er=new Array(je);function rr(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}let nr,ir,sr;function or(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}ze(er);const ar=t=>t<256?We[t]:We[256+(t>>>7)],fr=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},cr=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,fr(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)},lr=(t,e,r)=>{cr(t,r[2*e],r[2*e+1])},ur=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},hr=(t,e,r)=>{const n=new Array(16);let i,s,o=0;for(i=1;i<=Ge;i++)n[i]=o=o+r[i-1]<<1;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=ur(n[e]++,e))}},yr=t=>{let e;for(e=0;e<He;e++)t.dyn_ltree[2*e]=0;for(e=0;e<je;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0},dr=t=>{t.bi_valid>8?fr(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},br=(t,e,r,n)=>{const i=2*e,s=2*r;return t[i]<t[s]||t[i]===t[s]&&n[e]<=n[r]},Ar=(t,e,r)=>{const n=t.heap[r];let i=r<<1;for(;i<=t.heap_len&&(i<t.heap_len&&br(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!br(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n},mr=(t,e,r)=>{let n,i,s,o,a=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*a]<<8|t.pending_buf[t.d_buf+2*a+1],i=t.pending_buf[t.l_buf+a],a++,0===n?lr(t,i,e):(s=Qe[i],lr(t,s+Ve+1,e),o=Ke[s],0!==o&&(i-=tr[s],cr(t,i,o)),n--,s=ar(n),lr(t,s,r),o=qe[s],0!==o&&(n-=er[s],cr(t,n,o)))}while(a<t.last_lit);lr(t,256,e)},wr=(t,e)=>{const r=e.dyn_tree,n=e.stat_desc.static_tree,i=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,f,c=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<s;o++)0!==r[2*o]?(t.heap[++t.heap_len]=c=o,t.depth[o]=0):r[2*o+1]=0;for(;t.heap_len<2;)f=t.heap[++t.heap_len]=c<2?++c:0,r[2*f]=1,t.depth[f]=0,t.opt_len--,i&&(t.static_len-=n[2*f+1]);for(e.max_code=c,o=t.heap_len>>1;o>=1;o--)Ar(t,r,o);f=s;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Ar(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,r[2*f]=r[2*o]+r[2*a],t.depth[f]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,r[2*o+1]=r[2*a+1]=f,t.heap[1]=f++,Ar(t,r,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const r=e.dyn_tree,n=e.max_code,i=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,f=e.stat_desc.max_length;let c,l,u,h,y,d,b=0;for(h=0;h<=Ge;h++)t.bl_count[h]=0;for(r[2*t.heap[t.heap_max]+1]=0,c=t.heap_max+1;c<573;c++)l=t.heap[c],h=r[2*r[2*l+1]+1]+1,h>f&&(h=f,b++),r[2*l+1]=h,l>n||(t.bl_count[h]++,y=0,l>=a&&(y=o[l-a]),d=r[2*l],t.opt_len+=d*(h+y),s&&(t.static_len+=d*(i[2*l+1]+y)));if(0!==b){do{for(h=f-1;0===t.bl_count[h];)h--;t.bl_count[h]--,t.bl_count[h+1]+=2,t.bl_count[f]--,b-=2}while(b>0);for(h=f;0!==h;h--)for(l=t.bl_count[h];0!==l;)u=t.heap[--c],u>n||(r[2*u+1]!==h&&(t.opt_len+=(h-r[2*u+1])*r[2*u],r[2*u+1]=h),l--)}})(t,e),hr(r,c,t.bl_count)},pr=(t,e,r)=>{let n,i,s=-1,o=e[1],a=0,f=7,c=4;for(0===o&&(f=138,c=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=e[2*(n+1)+1],++a<f&&i===o||(a<c?t.bl_tree[2*i]+=a:0!==i?(i!==s&&t.bl_tree[2*i]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,s=i,0===o?(f=138,c=3):i===o?(f=6,c=3):(f=7,c=4))},_r=(t,e,r)=>{let n,i,s=-1,o=e[1],a=0,f=7,c=4;for(0===o&&(f=138,c=3),n=0;n<=r;n++)if(i=o,o=e[2*(n+1)+1],!(++a<f&&i===o)){if(a<c)do{lr(t,i,t.bl_tree)}while(0!=--a);else 0!==i?(i!==s&&(lr(t,i,t.bl_tree),a--),lr(t,16,t.bl_tree),cr(t,a-3,2)):a<=10?(lr(t,17,t.bl_tree),cr(t,a-3,3)):(lr(t,18,t.bl_tree),cr(t,a-11,7));a=0,s=i,0===o?(f=138,c=3):i===o?(f=6,c=3):(f=7,c=4)}};let Ur=!1;const gr=(t,e,r,n)=>{cr(t,0+(n?1:0),3),((t,e,r,n)=>{dr(t),n&&(fr(t,r),fr(t,~r)),t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r})(t,e,r,!0)};var Tr=t=>{Ur||((()=>{let t,e,r,n,i;const s=new Array(16);for(r=0,n=0;n<28;n++)for(tr[n]=r,t=0;t<1<<Ke[n];t++)Qe[r++]=n;for(Qe[r-1]=n,i=0,n=0;n<16;n++)for(er[n]=i,t=0;t<1<<qe[n];t++)We[i++]=n;for(i>>=7;n<je;n++)for(er[n]=i<<7,t=0;t<1<<qe[n]-7;t++)We[256+i++]=n;for(e=0;e<=Ge;e++)s[e]=0;for(t=0;t<=143;)Ye[2*t+1]=8,t++,s[8]++;for(;t<=255;)Ye[2*t+1]=9,t++,s[9]++;for(;t<=279;)Ye[2*t+1]=7,t++,s[7]++;for(;t<=287;)Ye[2*t+1]=8,t++,s[8]++;for(hr(Ye,287,s),t=0;t<je;t++)Xe[2*t+1]=5,Xe[2*t]=ur(t,5);nr=new rr(Ye,Ke,257,He,Ge),ir=new rr(Xe,qe,0,je,Ge),sr=new rr(new Array(0),$e,0,19,7)})(),Ur=!0),t.l_desc=new or(t.dyn_ltree,nr),t.d_desc=new or(t.dyn_dtree,ir),t.bl_desc=new or(t.bl_tree,sr),t.bi_buf=0,t.bi_valid=0,yr(t)},vr=(t,e,r,n)=>{let i,s,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<Ve;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),wr(t,t.l_desc),wr(t,t.d_desc),o=(t=>{let e;for(pr(t,t.dyn_ltree,t.l_desc.max_code),pr(t,t.dyn_dtree,t.d_desc.max_code),wr(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*Je[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),i=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==e?gr(t,e,r,n):4===t.strategy||s===i?(cr(t,2+(n?1:0),3),mr(t,Ye,Xe)):(cr(t,4+(n?1:0),3),((t,e,r,n)=>{let i;for(cr(t,e-257,5),cr(t,r-1,5),cr(t,n-4,4),i=0;i<n;i++)cr(t,t.bl_tree[2*Je[i]+1],3);_r(t,t.dyn_ltree,e-1),_r(t,t.dyn_dtree,r-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),mr(t,t.dyn_ltree,t.dyn_dtree)),yr(t),n&&dr(t)},Ir={dt:Tr,bt:gr,At:vr,wt:(t,e,r)=>(t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(Qe[r]+Ve+1)]++,t.dyn_dtree[2*ar(e)]++),t.last_lit===t.lit_bufsize-1),_t:t=>{cr(t,2,3),lr(t,256,Ye),(t=>{16===t.bi_valid?(fr(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var Sr=(t,e,r,n)=>{let i=65535&t|0,s=t>>>16&65535|0,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{i=i+e[n++]|0,s=s+i|0}while(--o);i%=65521,s%=65521}return i|s<<16|0};const Er=new Uint32Array((()=>{let t,e=[];for(var r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e})());var Or=(t,e,r,n)=>{const i=Er,s=n+r;t^=-1;for(let r=n;r<s;r++)t=t>>>8^i[255&(t^e[r])];return-1^t},kr={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},xr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{dt:Fr,bt:Br,At:Dr,wt:Rr,_t:Mr}=Ir,{Z_NO_FLUSH:Lr,Z_PARTIAL_FLUSH:Nr,Z_FULL_FLUSH:Pr,Z_FINISH:Zr,Z_BLOCK:Cr,Z_OK:zr,Z_STREAM_END:Vr,Z_STREAM_ERROR:Hr,Z_DATA_ERROR:jr,Z_BUF_ERROR:Gr,Z_DEFAULT_COMPRESSION:Kr,Z_FILTERED:qr,Z_HUFFMAN_ONLY:$r,Z_RLE:Jr,Z_FIXED:Yr,Z_DEFAULT_STRATEGY:Xr,Z_UNKNOWN:Wr,Z_DEFLATED:Qr}=xr,tn=258,en=262,rn=103,nn=113,sn=666,on=(t,e)=>(t.msg=kr[e],e),an=t=>(t<<1)-(t>4?9:0),fn=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let cn=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask;const ln=t=>{const e=t.state;let r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+r),t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))},un=(t,e)=>{Dr(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,ln(t.strm)},hn=(t,e)=>{t.pending_buf[t.pending++]=e},yn=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},dn=(t,e,r,n)=>{let i=t.avail_in;return i>n&&(i=n),0===i?0:(t.avail_in-=i,e.set(t.input.subarray(t.next_in,t.next_in+i),r),1===t.state.wrap?t.adler=Sr(t.adler,e,i,r):2===t.state.wrap&&(t.adler=Or(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},bn=(t,e)=>{let r,n,i=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match;const f=t.strstart>t.w_size-en?t.strstart-(t.w_size-en):0,c=t.window,l=t.w_mask,u=t.prev,h=t.strstart+tn;let y=c[s+o-1],d=c[s+o];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(r=e,c[r+o]===d&&c[r+o-1]===y&&c[r]===c[s]&&c[++r]===c[s+1]){s+=2,r++;do{}while(c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&c[++s]===c[++r]&&s<h);if(n=tn-(h-s),s=h-tn,n>o){if(t.match_start=e,o=n,n>=a)break;y=c[s+o-1],d=c[s+o]}}}while((e=u[e&l])>f&&0!=--i);return o<=t.lookahead?o:t.lookahead},An=t=>{const e=t.w_size;let r,n,i,s,o;do{if(s=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-en)){t.window.set(t.window.subarray(e,e+e),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,n=t.hash_size,r=n;do{i=t.head[--r],t.head[r]=i>=e?i-e:0}while(--n);n=e,r=n;do{i=t.prev[--r],t.prev[r]=i>=e?i-e:0}while(--n);s+=e}if(0===t.strm.avail_in)break;if(n=dn(t.strm,t.window,t.strstart+t.lookahead,s),t.lookahead+=n,t.lookahead+t.insert>=3)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=cn(t,t.ins_h,t.window[o+1]);t.insert&&(t.ins_h=cn(t,t.ins_h,t.window[o+3-1]),t.prev[o&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=o,o++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<en&&0!==t.strm.avail_in)},mn=(t,e)=>{let r,n;for(;;){if(t.lookahead<en){if(An(t),t.lookahead<en&&e===Lr)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=cn(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-en&&(t.match_length=bn(t,r)),t.match_length>=3)if(n=Rr(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=cn(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=cn(t,t.ins_h,t.window[t.strstart+1]);else n=Rr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(un(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Zr?(un(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(un(t,!1),0===t.strm.avail_out)?1:2},wn=(t,e)=>{let r,n,i;for(;;){if(t.lookahead<en){if(An(t),t.lookahead<en&&e===Lr)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=cn(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-en&&(t.match_length=bn(t,r),t.match_length<=5&&(t.strategy===qr||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=Rr(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=cn(t,t.ins_h,t.window[t.strstart+3-1]),r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(un(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=Rr(t,0,t.window[t.strstart-1]),n&&un(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=Rr(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Zr?(un(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(un(t,!1),0===t.strm.avail_out)?1:2};function pn(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}const _n=[new pn(0,0,0,0,((t,e)=>{let r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(An(t),0===t.lookahead&&e===Lr)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;const n=t.block_start+r;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,un(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-en&&(un(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Zr?(un(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(un(t,!1),t.strm.avail_out),1)})),new pn(4,4,8,4,mn),new pn(4,5,16,8,mn),new pn(4,6,32,32,mn),new pn(4,4,16,16,wn),new pn(8,16,32,32,wn),new pn(8,16,128,128,wn),new pn(8,32,128,256,wn),new pn(32,128,258,1024,wn),new pn(32,258,258,4096,wn)];function Un(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Qr,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),fn(this.dyn_ltree),fn(this.dyn_dtree),fn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),fn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),fn(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const gn=t=>{if(!t||!t.state)return on(t,Hr);t.total_in=t.total_out=0,t.data_type=Wr;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:nn,t.adler=2===e.wrap?0:1,e.last_flush=Lr,Fr(e),zr},Tn=t=>{const e=gn(t);var r;return e===zr&&((r=t.state).window_size=2*r.w_size,fn(r.head),r.max_lazy_match=_n[r.level].max_lazy,r.good_match=_n[r.level].good_length,r.nice_match=_n[r.level].nice_length,r.max_chain_length=_n[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=2,r.match_available=0,r.ins_h=0),e},vn=(t,e,r,n,i,s)=>{if(!t)return Hr;let o=1;if(e===Kr&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==Qr||n<8||n>15||e<0||e>9||s<0||s>Yr)return on(t,Hr);8===n&&(n=9);const a=new Un;return t.state=a,a.strm=t,a.wrap=o,a.gzhead=null,a.w_bits=n,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=i+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<i+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.d_buf=1*a.lit_bufsize,a.l_buf=3*a.lit_bufsize,a.level=e,a.strategy=s,a.method=r,Tn(t)};var In=(t,e)=>{let r=e.length;if(!t||!t.state)return Hr;const n=t.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return Hr;if(1===i&&(t.adler=Sr(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(fn(n.head),n.strstart=0,n.block_start=0,n.insert=0);let t=new Uint8Array(n.w_size);t.set(e.subarray(r-n.w_size,r),0),e=t,r=n.w_size}const s=t.avail_in,o=t.next_in,a=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,An(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=cn(n,n.ins_h,n.window[t+3-1]),n.prev[t&n.w_mask]=n.head[n.ins_h],n.head[n.ins_h]=t,t++}while(--e);n.strstart=t,n.lookahead=2,An(n)}return n.strstart+=n.lookahead,n.block_start=n.strstart,n.insert=n.lookahead,n.lookahead=0,n.match_length=n.prev_length=2,n.match_available=0,t.next_in=o,t.input=a,t.avail_in=s,n.wrap=i,zr},Sn={deflateInit:(t,e)=>vn(t,e,Qr,15,8,Xr),deflateInit2:vn,deflateReset:Tn,deflateResetKeep:gn,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?Hr:(t.state.gzhead=e,zr):Hr,deflate:(t,e)=>{let r,n;if(!t||!t.state||e>Cr||e<0)return t?on(t,Hr):Hr;const i=t.state;if(!t.output||!t.input&&0!==t.avail_in||i.status===sn&&e!==Zr)return on(t,0===t.avail_out?Gr:Hr);i.strm=t;const s=i.last_flush;if(i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,hn(i,31),hn(i,139),hn(i,8),i.gzhead?(hn(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),hn(i,255&i.gzhead.time),hn(i,i.gzhead.time>>8&255),hn(i,i.gzhead.time>>16&255),hn(i,i.gzhead.time>>24&255),hn(i,9===i.level?2:i.strategy>=$r||i.level<2?4:0),hn(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(hn(i,255&i.gzhead.extra.length),hn(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=Or(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(hn(i,0),hn(i,0),hn(i,0),hn(i,0),hn(i,0),hn(i,9===i.level?2:i.strategy>=$r||i.level<2?4:0),hn(i,3),i.status=nn);else{let e=Qr+(i.w_bits-8<<4)<<8,r=-1;r=i.strategy>=$r||i.level<2?0:i.level<6?1:6===i.level?2:3,e|=r<<6,0!==i.strstart&&(e|=32),e+=31-e%31,i.status=nn,yn(i,e),0!==i.strstart&&(yn(i,t.adler>>>16),yn(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(r=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>r&&(t.adler=Or(t.adler,i.pending_buf,i.pending-r,r)),ln(t),r=i.pending,i.pending!==i.pending_buf_size));)hn(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(t.adler=Or(t.adler,i.pending_buf,i.pending-r,r)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=Or(t.adler,i.pending_buf,i.pending-r,r)),ln(t),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,hn(i,n)}while(0!==n);i.gzhead.hcrc&&i.pending>r&&(t.adler=Or(t.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){r=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>r&&(t.adler=Or(t.adler,i.pending_buf,i.pending-r,r)),ln(t),r=i.pending,i.pending===i.pending_buf_size)){n=1;break}n=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,hn(i,n)}while(0!==n);i.gzhead.hcrc&&i.pending>r&&(t.adler=Or(t.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=rn)}else i.status=rn;if(i.status===rn&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&ln(t),i.pending+2<=i.pending_buf_size&&(hn(i,255&t.adler),hn(i,t.adler>>8&255),t.adler=0,i.status=nn)):i.status=nn),0!==i.pending){if(ln(t),0===t.avail_out)return i.last_flush=-1,zr}else if(0===t.avail_in&&an(e)<=an(s)&&e!==Zr)return on(t,Gr);if(i.status===sn&&0!==t.avail_in)return on(t,Gr);if(0!==t.avail_in||0!==i.lookahead||e!==Lr&&i.status!==sn){let r=i.strategy===$r?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(An(t),0===t.lookahead)){if(e===Lr)return 1;break}if(t.match_length=0,r=Rr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(un(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Zr?(un(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(un(t,!1),0===t.strm.avail_out)?1:2})(i,e):i.strategy===Jr?((t,e)=>{let r,n,i,s;const o=t.window;for(;;){if(t.lookahead<=tn){if(An(t),t.lookahead<=tn&&e===Lr)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(i=t.strstart-1,n=o[i],n===o[++i]&&n===o[++i]&&n===o[++i])){s=t.strstart+tn;do{}while(n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&n===o[++i]&&i<s);t.match_length=tn-(s-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=Rr(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=Rr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(un(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Zr?(un(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(un(t,!1),0===t.strm.avail_out)?1:2})(i,e):_n[i.level].func(i,e);if(3!==r&&4!==r||(i.status=sn),1===r||3===r)return 0===t.avail_out&&(i.last_flush=-1),zr;if(2===r&&(e===Nr?Mr(i):e!==Cr&&(Br(i,0,0,!1),e===Pr&&(fn(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),ln(t),0===t.avail_out))return i.last_flush=-1,zr}return e!==Zr?zr:i.wrap<=0?Vr:(2===i.wrap?(hn(i,255&t.adler),hn(i,t.adler>>8&255),hn(i,t.adler>>16&255),hn(i,t.adler>>24&255),hn(i,255&t.total_in),hn(i,t.total_in>>8&255),hn(i,t.total_in>>16&255),hn(i,t.total_in>>24&255)):(yn(i,t.adler>>>16),yn(i,65535&t.adler)),ln(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?zr:Vr)},deflateEnd:t=>{if(!t||!t.state)return Hr;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==rn&&e!==nn&&e!==sn?on(t,Hr):(t.state=null,e===nn?on(t,jr):zr)},deflateSetDictionary:In,deflateInfo:"pako deflate (from Nodeca project)"};const En=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var On=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(const e in r)En(r,e)&&(t[e]=r[e])}}return t},kn=t=>{let e=0;for(let r=0,n=t.length;r<n;r++)e+=t[r].length;const r=new Uint8Array(e);for(let e=0,n=0,i=t.length;e<i;e++){let i=t[e];r.set(i,n),n+=i.length}return r};let xn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){xn=!1}const Fn=new Uint8Array(256);for(let t=0;t<256;t++)Fn[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Fn[254]=Fn[254]=1;var Bn=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,n,i,s,o=t.length,a=0;for(i=0;i<o;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<o&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),a+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(a),s=0,i=0;s<a;i++)r=t.charCodeAt(i),55296==(64512&r)&&i+1<o&&(n=t.charCodeAt(i+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),i++)),r<128?e[s++]=r:r<2048?(e[s++]=192|r>>>6,e[s++]=128|63&r):r<65536?(e[s++]=224|r>>>12,e[s++]=128|r>>>6&63,e[s++]=128|63&r):(e[s++]=240|r>>>18,e[s++]=128|r>>>12&63,e[s++]=128|r>>>6&63,e[s++]=128|63&r);return e},Dn=(t,e)=>{const r=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,i;const s=new Array(2*r);for(i=0,n=0;n<r;){let e=t[n++];if(e<128){s[i++]=e;continue}let o=Fn[e];if(o>4)s[i++]=65533,n+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&n<r;)e=e<<6|63&t[n++],o--;o>1?s[i++]=65533:e<65536?s[i++]=e:(e-=65536,s[i++]=55296|e>>10&1023,s[i++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&xn)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let r="";for(let n=0;n<e;n++)r+=String.fromCharCode(t[n]);return r})(s,i)},Rn=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let r=e-1;for(;r>=0&&128==(192&t[r]);)r--;return r<0||0===r?e:r+Fn[t[r]]>e?r:e};var Mn=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Ln=Object.prototype.toString,{Z_NO_FLUSH:Nn,Z_SYNC_FLUSH:Pn,Z_FULL_FLUSH:Zn,Z_FINISH:Cn,Z_OK:zn,Z_STREAM_END:Vn,Z_DEFAULT_COMPRESSION:Hn,Z_DEFAULT_STRATEGY:jn,Z_DEFLATED:Gn}=xr;function Kn(t){this.options=On({level:Hn,method:Gn,chunkSize:16384,windowBits:15,memLevel:8,strategy:jn},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mn,this.strm.avail_out=0;let r=Sn.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==zn)throw new Error(kr[r]);if(e.header&&Sn.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Bn(e.dictionary):"[object ArrayBuffer]"===Ln.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,r=Sn.deflateSetDictionary(this.strm,t),r!==zn)throw new Error(kr[r]);this.Ut=!0}}function qn(t,e){const r=new Kn(e);if(r.push(t,!0),r.err)throw r.msg||kr[r.err];return r.result}Kn.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize;let i,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Cn:Nn,"string"==typeof t?r.input=Bn(t):"[object ArrayBuffer]"===Ln.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;)if(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),(s===Pn||s===Zn)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(i=Sn.deflate(r,s),i===Vn)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=Sn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===zn;if(0!==r.avail_out){if(s>0&&r.next_out>0)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else if(0===r.avail_in)break}else this.onData(r.output)}return!0},Kn.prototype.onData=function(t){this.chunks.push(t)},Kn.prototype.onEnd=function(t){t===zn&&(this.result=kn(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var $n={Deflate:Kn,deflate:qn,deflateRaw:function(t,e){return(e=e||{}).raw=!0,qn(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,qn(t,e)},constants:xr};var Jn=function(t,e){let r,n,i,s,o,a,f,c,l,u,h,y,d,b,A,m,w,p,_,U,g,T,v,I;const S=t.state;r=t.next_in,v=t.input,n=r+(t.avail_in-5),i=t.next_out,I=t.output,s=i-(e-t.avail_out),o=i+(t.avail_out-257),a=S.dmax,f=S.wsize,c=S.whave,l=S.wnext,u=S.window,h=S.hold,y=S.bits,d=S.lencode,b=S.distcode,A=(1<<S.lenbits)-1,m=(1<<S.distbits)-1;t:do{y<15&&(h+=v[r++]<<y,y+=8,h+=v[r++]<<y,y+=8),w=d[h&A];e:for(;;){if(p=w>>>24,h>>>=p,y-=p,p=w>>>16&255,0===p)I[i++]=65535&w;else{if(!(16&p)){if(0==(64&p)){w=d[(65535&w)+(h&(1<<p)-1)];continue e}if(32&p){S.mode=12;break t}t.msg="invalid literal/length code",S.mode=30;break t}_=65535&w,p&=15,p&&(y<p&&(h+=v[r++]<<y,y+=8),_+=h&(1<<p)-1,h>>>=p,y-=p),y<15&&(h+=v[r++]<<y,y+=8,h+=v[r++]<<y,y+=8),w=b[h&m];r:for(;;){if(p=w>>>24,h>>>=p,y-=p,p=w>>>16&255,!(16&p)){if(0==(64&p)){w=b[(65535&w)+(h&(1<<p)-1)];continue r}t.msg="invalid distance code",S.mode=30;break t}if(U=65535&w,p&=15,y<p&&(h+=v[r++]<<y,y+=8,y<p&&(h+=v[r++]<<y,y+=8)),U+=h&(1<<p)-1,U>a){t.msg="invalid distance too far back",S.mode=30;break t}if(h>>>=p,y-=p,p=i-s,U>p){if(p=U-p,p>c&&S.sane){t.msg="invalid distance too far back",S.mode=30;break t}if(g=0,T=u,0===l){if(g+=f-p,p<_){_-=p;do{I[i++]=u[g++]}while(--p);g=i-U,T=I}}else if(l<p){if(g+=f+l-p,p-=l,p<_){_-=p;do{I[i++]=u[g++]}while(--p);if(g=0,l<_){p=l,_-=p;do{I[i++]=u[g++]}while(--p);g=i-U,T=I}}}else if(g+=l-p,p<_){_-=p;do{I[i++]=u[g++]}while(--p);g=i-U,T=I}for(;_>2;)I[i++]=T[g++],I[i++]=T[g++],I[i++]=T[g++],_-=3;_&&(I[i++]=T[g++],_>1&&(I[i++]=T[g++]))}else{g=i-U;do{I[i++]=I[g++],I[i++]=I[g++],I[i++]=I[g++],_-=3}while(_>2);_&&(I[i++]=I[g++],_>1&&(I[i++]=I[g++]))}break}}break}}while(r<n&&i<o);_=y>>3,r-=_,y-=_<<3,h&=(1<<y)-1,t.next_in=r,t.next_out=i,t.avail_in=r<n?n-r+5:5-(r-n),t.avail_out=i<o?o-i+257:257-(i-o),S.hold=h,S.bits=y};const Yn=15,Xn=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Wn=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Qn=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ti=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ei=(t,e,r,n,i,s,o,a)=>{const f=a.bits;let c,l,u,h,y,d,b=0,A=0,m=0,w=0,p=0,_=0,U=0,g=0,T=0,v=0,I=null,S=0;const E=new Uint16Array(16),O=new Uint16Array(16);let k,x,F,B=null,D=0;for(b=0;b<=Yn;b++)E[b]=0;for(A=0;A<n;A++)E[e[r+A]]++;for(p=f,w=Yn;w>=1&&0===E[w];w--);if(p>w&&(p=w),0===w)return i[s++]=20971520,i[s++]=20971520,a.bits=1,0;for(m=1;m<w&&0===E[m];m++);for(p<m&&(p=m),g=1,b=1;b<=Yn;b++)if(g<<=1,g-=E[b],g<0)return-1;if(g>0&&(0===t||1!==w))return-1;for(O[1]=0,b=1;b<Yn;b++)O[b+1]=O[b]+E[b];for(A=0;A<n;A++)0!==e[r+A]&&(o[O[e[r+A]]++]=A);if(0===t?(I=B=o,d=19):1===t?(I=Xn,S-=257,B=Wn,D-=257,d=256):(I=Qn,B=ti,d=-1),v=0,A=0,b=m,y=s,_=p,U=0,u=-1,T=1<<p,h=T-1,1===t&&T>852||2===t&&T>592)return 1;for(;;){k=b-U,o[A]<d?(x=0,F=o[A]):o[A]>d?(x=B[D+o[A]],F=I[S+o[A]]):(x=96,F=0),c=1<<b-U,l=1<<_,m=l;do{l-=c,i[y+(v>>U)+l]=k<<24|x<<16|F|0}while(0!==l);for(c=1<<b-1;v&c;)c>>=1;if(0!==c?(v&=c-1,v+=c):v=0,A++,0==--E[b]){if(b===w)break;b=e[r+o[A]]}if(b>p&&(v&h)!==u){for(0===U&&(U=p),y+=m,_=b-U,g=1<<_;_+U<w&&(g-=E[_+U],!(g<=0));)_++,g<<=1;if(T+=1<<_,1===t&&T>852||2===t&&T>592)return 1;u=v&h,i[u]=p<<24|_<<16|y-s|0}}return 0!==v&&(i[y+v]=b-U<<24|64<<16|0),a.bits=p,0};const{Z_FINISH:ri,Z_BLOCK:ni,Z_TREES:ii,Z_OK:si,Z_STREAM_END:oi,Z_NEED_DICT:ai,Z_STREAM_ERROR:fi,Z_DATA_ERROR:ci,Z_MEM_ERROR:li,Z_BUF_ERROR:ui,Z_DEFLATED:hi}=xr,yi=12,di=30,bi=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Ai(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const mi=t=>{if(!t||!t.state)return fi;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,si},wi=t=>{if(!t||!t.state)return fi;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,mi(t)},pi=(t,e)=>{let r;if(!t||!t.state)return fi;const n=t.state;return e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?fi:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,wi(t))},_i=(t,e)=>{if(!t)return fi;const r=new Ai;t.state=r,r.window=null;const n=pi(t,e);return n!==si&&(t.state=null),n};let Ui,gi,Ti=!0;const vi=t=>{if(Ti){Ui=new Int32Array(512),gi=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(ei(1,t.lens,0,288,Ui,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;ei(2,t.lens,0,32,gi,0,t.work,{bits:5}),Ti=!1}t.lencode=Ui,t.lenbits=9,t.distcode=gi,t.distbits=5},Ii=(t,e,r,n)=>{let i;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),n>=s.wsize?(s.window.set(e.subarray(r-s.wsize,r),0),s.wnext=0,s.whave=s.wsize):(i=s.wsize-s.wnext,i>n&&(i=n),s.window.set(e.subarray(r-n,r-n+i),s.wnext),(n-=i)?(s.window.set(e.subarray(r-n,r),0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=i))),0};var Si=(t,e)=>{let r,n,i,s,o,a,f,c,l,u,h,y,d,b,A,m,w,p,_,U,g,T,v=0;const I=new Uint8Array(4);let S,E;const O=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return fi;r=t.state,r.mode===yi&&(r.mode=13),o=t.next_out,i=t.output,f=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,c=r.hold,l=r.bits,u=a,h=f,T=si;t:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;l<16;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(2&r.wrap&&35615===c){r.check=0,I[0]=255&c,I[1]=c>>>8&255,r.check=Or(r.check,I,2,0),c=0,l=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&c)<<8)+(c>>8))%31){t.msg="incorrect header check",r.mode=di;break}if((15&c)!==hi){t.msg="unknown compression method",r.mode=di;break}if(c>>>=4,l-=4,g=8+(15&c),0===r.wbits)r.wbits=g;else if(g>r.wbits){t.msg="invalid window size",r.mode=di;break}r.dmax=1<<r.wbits,t.adler=r.check=1,r.mode=512&c?10:yi,c=0,l=0;break;case 2:for(;l<16;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(r.flags=c,(255&r.flags)!==hi){t.msg="unknown compression method",r.mode=di;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=di;break}r.head&&(r.head.text=c>>8&1),512&r.flags&&(I[0]=255&c,I[1]=c>>>8&255,r.check=Or(r.check,I,2,0)),c=0,l=0,r.mode=3;case 3:for(;l<32;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}r.head&&(r.head.time=c),512&r.flags&&(I[0]=255&c,I[1]=c>>>8&255,I[2]=c>>>16&255,I[3]=c>>>24&255,r.check=Or(r.check,I,4,0)),c=0,l=0,r.mode=4;case 4:for(;l<16;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}r.head&&(r.head.xflags=255&c,r.head.os=c>>8),512&r.flags&&(I[0]=255&c,I[1]=c>>>8&255,r.check=Or(r.check,I,2,0)),c=0,l=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}r.length=c,r.head&&(r.head.extra_len=c),512&r.flags&&(I[0]=255&c,I[1]=c>>>8&255,r.check=Or(r.check,I,2,0)),c=0,l=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(y=r.length,y>a&&(y=a),y&&(r.head&&(g=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(s,s+y),g)),512&r.flags&&(r.check=Or(r.check,n,y,s)),a-=y,s+=y,r.length-=y),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===a)break t;y=0;do{g=n[s+y++],r.head&&g&&r.length<65536&&(r.head.name+=String.fromCharCode(g))}while(g&&y<a);if(512&r.flags&&(r.check=Or(r.check,n,y,s)),a-=y,s+=y,g)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===a)break t;y=0;do{g=n[s+y++],r.head&&g&&r.length<65536&&(r.head.comment+=String.fromCharCode(g))}while(g&&y<a);if(512&r.flags&&(r.check=Or(r.check,n,y,s)),a-=y,s+=y,g)break t}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;l<16;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(c!==(65535&r.check)){t.msg="header crc mismatch",r.mode=di;break}c=0,l=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=yi;break;case 10:for(;l<32;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}t.adler=r.check=bi(c),c=0,l=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=o,t.avail_out=f,t.next_in=s,t.avail_in=a,r.hold=c,r.bits=l,ai;t.adler=r.check=1,r.mode=yi;case yi:if(e===ni||e===ii)break t;case 13:if(r.last){c>>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}switch(r.last=1&c,c>>>=1,l-=1,3&c){case 0:r.mode=14;break;case 1:if(vi(r),r.mode=20,e===ii){c>>>=2,l-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=di}c>>>=2,l-=2;break;case 14:for(c>>>=7&l,l-=7&l;l<32;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if((65535&c)!=(c>>>16^65535)){t.msg="invalid stored block lengths",r.mode=di;break}if(r.length=65535&c,c=0,l=0,r.mode=15,e===ii)break t;case 15:r.mode=16;case 16:if(y=r.length,y){if(y>a&&(y=a),y>f&&(y=f),0===y)break t;i.set(n.subarray(s,s+y),o),a-=y,s+=y,f-=y,o+=y,r.length-=y;break}r.mode=yi;break;case 17:for(;l<14;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(r.nlen=257+(31&c),c>>>=5,l-=5,r.ndist=1+(31&c),c>>>=5,l-=5,r.ncode=4+(15&c),c>>>=4,l-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=di;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;l<3;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}r.lens[O[r.have++]]=7&c,c>>>=3,l-=3}for(;r.have<19;)r.lens[O[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},T=ei(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,T){t.msg="invalid code lengths set",r.mode=di;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;v=r.lencode[c&(1<<r.lenbits)-1],A=v>>>24,m=v>>>16&255,w=65535&v,!(A<=l);){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(w<16)c>>>=A,l-=A,r.lens[r.have++]=w;else{if(16===w){for(E=A+2;l<E;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(c>>>=A,l-=A,0===r.have){t.msg="invalid bit length repeat",r.mode=di;break}g=r.lens[r.have-1],y=3+(3&c),c>>>=2,l-=2}else if(17===w){for(E=A+3;l<E;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}c>>>=A,l-=A,g=0,y=3+(7&c),c>>>=3,l-=3}else{for(E=A+7;l<E;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}c>>>=A,l-=A,g=0,y=11+(127&c),c>>>=7,l-=7}if(r.have+y>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=di;break}for(;y--;)r.lens[r.have++]=g}}if(r.mode===di)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=di;break}if(r.lenbits=9,S={bits:r.lenbits},T=ei(1,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,T){t.msg="invalid literal/lengths set",r.mode=di;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},T=ei(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,T){t.msg="invalid distances set",r.mode=di;break}if(r.mode=20,e===ii)break t;case 20:r.mode=21;case 21:if(a>=6&&f>=258){t.next_out=o,t.avail_out=f,t.next_in=s,t.avail_in=a,r.hold=c,r.bits=l,Jn(t,h),o=t.next_out,i=t.output,f=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,c=r.hold,l=r.bits,r.mode===yi&&(r.back=-1);break}for(r.back=0;v=r.lencode[c&(1<<r.lenbits)-1],A=v>>>24,m=v>>>16&255,w=65535&v,!(A<=l);){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(m&&0==(240&m)){for(p=A,_=m,U=w;v=r.lencode[U+((c&(1<<p+_)-1)>>p)],A=v>>>24,m=v>>>16&255,w=65535&v,!(p+A<=l);){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}c>>>=p,l-=p,r.back+=p}if(c>>>=A,l-=A,r.back+=A,r.length=w,0===m){r.mode=26;break}if(32&m){r.back=-1,r.mode=yi;break}if(64&m){t.msg="invalid literal/length code",r.mode=di;break}r.extra=15&m,r.mode=22;case 22:if(r.extra){for(E=r.extra;l<E;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}r.length+=c&(1<<r.extra)-1,c>>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;v=r.distcode[c&(1<<r.distbits)-1],A=v>>>24,m=v>>>16&255,w=65535&v,!(A<=l);){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(0==(240&m)){for(p=A,_=m,U=w;v=r.distcode[U+((c&(1<<p+_)-1)>>p)],A=v>>>24,m=v>>>16&255,w=65535&v,!(p+A<=l);){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}c>>>=p,l-=p,r.back+=p}if(c>>>=A,l-=A,r.back+=A,64&m){t.msg="invalid distance code",r.mode=di;break}r.offset=w,r.extra=15&m,r.mode=24;case 24:if(r.extra){for(E=r.extra;l<E;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}r.offset+=c&(1<<r.extra)-1,c>>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=di;break}r.mode=25;case 25:if(0===f)break t;if(y=h-f,r.offset>y){if(y=r.offset-y,y>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=di;break}y>r.wnext?(y-=r.wnext,d=r.wsize-y):d=r.wnext-y,y>r.length&&(y=r.length),b=r.window}else b=i,d=o-r.offset,y=r.length;y>f&&(y=f),f-=y,r.length-=y;do{i[o++]=b[d++]}while(--y);0===r.length&&(r.mode=21);break;case 26:if(0===f)break t;i[o++]=r.length,f--,r.mode=21;break;case 27:if(r.wrap){for(;l<32;){if(0===a)break t;a--,c|=n[s++]<<l,l+=8}if(h-=f,t.total_out+=h,r.total+=h,h&&(t.adler=r.check=r.flags?Or(r.check,i,h,o-h):Sr(r.check,i,h,o-h)),h=f,(r.flags?c:bi(c))!==r.check){t.msg="incorrect data check",r.mode=di;break}c=0,l=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;l<32;){if(0===a)break t;a--,c+=n[s++]<<l,l+=8}if(c!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=di;break}c=0,l=0}r.mode=29;case 29:T=oi;break t;case di:T=ci;break t;case 31:return li;default:return fi}return t.next_out=o,t.avail_out=f,t.next_in=s,t.avail_in=a,r.hold=c,r.bits=l,(r.wsize||h!==t.avail_out&&r.mode<di&&(r.mode<27||e!==ri))&&Ii(t,t.output,t.next_out,h-t.avail_out),u-=t.avail_in,h-=t.avail_out,t.total_in+=u,t.total_out+=h,r.total+=h,r.wrap&&h&&(t.adler=r.check=r.flags?Or(r.check,i,h,t.next_out-h):Sr(r.check,i,h,t.next_out-h)),t.data_type=r.bits+(r.last?64:0)+(r.mode===yi?128:0)+(20===r.mode||15===r.mode?256:0),(0===u&&0===h||e===ri)&&T===si&&(T=ui),T},Ei={inflateReset:wi,inflateReset2:pi,inflateResetKeep:mi,inflateInit:t=>_i(t,15),inflateInit2:_i,inflate:Si,inflateEnd:t=>{if(!t||!t.state)return fi;let e=t.state;return e.window&&(e.window=null),t.state=null,si},inflateGetHeader:(t,e)=>{if(!t||!t.state)return fi;const r=t.state;return 0==(2&r.wrap)?fi:(r.head=e,e.done=!1,si)},inflateSetDictionary:(t,e)=>{const r=e.length;let n,i,s;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?fi:11===n.mode&&(i=1,i=Sr(i,e,r,0),i!==n.check)?ci:(s=Ii(t,e,r,r),s?(n.mode=31,li):(n.havedict=1,si))):fi},inflateInfo:"pako inflate (from Nodeca project)"};var Oi=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const ki=Object.prototype.toString,{Z_NO_FLUSH:xi,Z_FINISH:Fi,Z_OK:Bi,Z_STREAM_END:Di,Z_NEED_DICT:Ri,Z_STREAM_ERROR:Mi,Z_DATA_ERROR:Li,Z_MEM_ERROR:Ni}=xr;function Pi(t){this.options=On({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Mn,this.strm.avail_out=0;let r=Ei.inflateInit2(this.strm,e.windowBits);if(r!==Bi)throw new Error(kr[r]);if(this.header=new Oi,Ei.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Bn(e.dictionary):"[object ArrayBuffer]"===ki.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=Ei.inflateSetDictionary(this.strm,e.dictionary),r!==Bi)))throw new Error(kr[r])}function Zi(t,e){const r=new Pi(e);if(r.push(t),r.err)throw r.msg||kr[r.err];return r.result}Pi.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize,i=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Fi:xi,"[object ArrayBuffer]"===ki.call(t)?r.input=new Uint8Array(t):r.input=t,r.next_in=0,r.avail_in=r.input.length;;){for(0===r.avail_out&&(r.output=new Uint8Array(n),r.next_out=0,r.avail_out=n),s=Ei.inflate(r,o),s===Ri&&i&&(s=Ei.inflateSetDictionary(r,i),s===Bi?s=Ei.inflate(r,o):s===Li&&(s=Ri));r.avail_in>0&&s===Di&&r.state.wrap>0&&0!==t[r.next_in];)Ei.inflateReset(r),s=Ei.inflate(r,o);switch(s){case Mi:case Li:case Ri:case Ni:return this.onEnd(s),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||s===Di))if("string"===this.options.to){let t=Rn(r.output,r.next_out),e=r.next_out-t,i=Dn(r.output,t);r.next_out=e,r.avail_out=n-e,e&&r.output.set(r.output.subarray(t,t+e),0),this.onData(i)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(s!==Bi||0!==a){if(s===Di)return s=Ei.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},Pi.prototype.onData=function(t){this.chunks.push(t)},Pi.prototype.onEnd=function(t){t===Bi&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=kn(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Ci={Inflate:Pi,inflate:Zi,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Zi(t,e)},ungzip:Zi,constants:xr};const{Deflate:zi,deflate:Vi,deflateRaw:Hi,gzip:ji}=$n,{Inflate:Gi,inflate:Ki,inflateRaw:qi,ungzip:$i}=Ci;var Ji={Deflate:zi,deflate:Vi,deflateRaw:Hi,gzip:ji,Inflate:Gi,inflate:Ki,inflateRaw:qi,ungzip:$i,constants:xr},Yi=5,Xi=11,Wi=13,Qi=14;function ts(t,e,r,n){var i=t|e<<8,s=i>>11&31,o=i>>5&63,a=31&i;return r[n+0]=s<<3|s>>2,r[n+1]=o<<2|o>>4,r[n+2]=a<<3|a>>2,r[n+3]=255,i}function es(t,e,r,n){var i=0;0!=(6&n)&&(i=8),function(t,e,r,n){for(var i=new Uint8Array(16),s=ts(e[r+0],e[r+1],i,0),o=ts(e[r+2],e[r+3],i,4),a=0;a<3;a++){var f=i[a],c=i[4+a];n&&s<=o?(i[8+a]=(f+c)/2,i[12+a]=0):(i[8+a]=(2*f+c)/3,i[12+a]=(f+2*c)/3)}i[11]=255,i[15]=n&&s<=o?0:255;var l=new Uint8Array(16);for(a=0;a<4;++a){var u=e[r+4+a];l[4*a+0]=3&u,l[4*a+1]=u>>2&3,l[4*a+2]=u>>4&3,l[4*a+3]=u>>6&3}for(a=0;a<16;++a)for(var h=4*l[a],y=0;y<4;++y)t[4*a+y]=i[h+y]}(t,e,r+i,0!=(1&n)),0!=(2&n)?function(t,e,r){for(var n=0;n<8;++n){var i=bytes[r+n],s=15&i,o=240&i;t[8*n+3]=s|s<<4,t[8*n+7]=o|o>>4}}(t,0,r):0!=(4&n)&&function(t,e,r){var n=e[r+0],i=e[r+1],s=new Uint8Array(8);if(s[0]=n,s[1]=i,n<=i){for(var o=1;o<5;++o)s[1+o]=((5-o)*n+o*i)/5;s[6]=0,s[7]=255}else for(o=1;o<7;++o)s[1+o]=((7-o)*n+o*i)/7;var a=new Uint8Array(16),f=(r+=2,0);for(o=0;o<2;++o){for(var c=0,l=0;l<3;++l)c|=e[r++]<<8*l;for(l=0;l<8;++l){var u=c>>3*l&7;a[f++]=u}}for(o=0;o<16;++o)t[4*o+3]=s[a[o]]}(t,e,r)}function rs(t){}function ns(){}rs.decode=function(t,e,r,n,i){if(null!=t&&null!=n&&0!=r&&0!=e){var s=0;1&(s=i>11||5===i?4:33)&&32&s?function(t,e,r,n){for(var i=new Uint16Array(4),s=t,o=0,a=0,f=0,c=0,l=0,u=0,h=0,y=0,d=0,b=e/4,A=r/4,m=0;m<A;m++)for(var w=0;w<b;w++)f=4*((A-m)*b+w),i[0]=n[f],i[1]=n[f+1],c=31&i[0],l=2016&i[0],u=63488&i[0],h=31&i[1],y=2016&i[1],d=63488&i[1],i[2]=5*c+3*h>>3|5*l+3*y>>3&2016|5*u+3*d>>3&63488,i[3]=5*h+3*c>>3|5*y+3*l>>3&2016|5*d+3*u>>3&63488,o=n[f+2],s[a=4*m*e+4*w]=i[3&o],s[a+1]=i[o>>2&3],s[a+2]=i[o>>4&3],s[a+3]=i[o>>6&3],s[a+=e]=i[o>>8&3],s[a+1]=i[o>>10&3],s[a+2]=i[o>>12&3],s[a+3]=i[o>>14],o=n[f+3],s[a+=e]=i[3&o],s[a+1]=i[o>>2&3],s[a+2]=i[o>>4&3],s[a+3]=i[o>>6&3],s[a+=e]=i[o>>8&3],s[a+1]=i[o>>10&3],s[a+2]=i[o>>12&3],s[a+3]=i[o>>14]}\n/*! @brief Decompresses an image in memory.\n\n @param rgba\t\tStorage for the decompressed pixels.\n @param width\tThe width of the source image.\n @param height\tThe height of the source image.\n @param blocks\tThe compressed DXT blocks.\n @param flags\tCompression flags.\n\n The decompressed pixels will be written as a contiguous array of width*height\n 16 rgba values, with each component as 1 byte each. In memory this is:\n\n { r1, g1, b1, a1, .... , rn, gn, bn, an } for n = width*height\n\n The flags parameter should specify either kDxt1, kDxt3 or kDxt5 compression,\n however, DXT1 will be used by default if none is specified. All other flags\n are ignored.\n\n Internally this function calls squish::Decompress for each block.\n */(t,e,r,n):function(t,e,r,n,i,s){for(var o=0!=(1&i)?8:16,a=0,f=0;f<r;f+=4)for(var c=0;c<e;c+=4){var l=new Uint8Array(64);es(l,n,a,i);for(var u=0,h=0;h<4;++h)for(var y=0;y<4;++y){var d=c+y,b=f+h;if(d<e&&b<r){var A=4*(e*(r-b)+d);if(s===Wi||s===Qi)t[A+2]=l[u++],t[A+1]=l[u++],t[A+0]=l[u++],t[A+3]=l[u++];else for(var m=0;m<4;++m)t[A++]=l[u++]}else u+=4}a+=o}}(t,e,r,n,s,i)}},ns.s3tc=!0,ns.pvrtc=!1,ns.etc1=!1;let is=1,ss=2;const os=10,as=11,fs=1,cs=2,ls=16,us=32;function hs(t,e,r){r=t.byteLength;return t=t.subarray(0,0+r),new TextDecoder("utf-8").decode(t)}function ys(t,e,r){let n=e.getUint32(r,!0);return r+=Uint32Array.BYTES_PER_ELEMENT,{string:hs(new Uint8Array(t,r,n)),bytesOffset:r+=n}}function ds(t,e,r,n){let i={},s=[],o=new Array(16);for(let t=0;t<16;t++)o[t]=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;i.matrix=o,i.skeletonNames=s;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<a;n++){let n=ys(t,e,r);s.push(n.string),r=n.bytesOffset}return n.push(i),r}function bs(t,e,r,n){let i={};i.rangeList=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,i.rangeMode=e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let s={};s.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,s.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,s.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;let o=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT,i.boundingSphere={center:s,radius:o};let a=ys(t,e,r),f=a.string;r=a.bytesOffset;let c=f.indexOf("Geometry");if(-1!==c){let t=f.substring(c);f=f.replace(t,"")}i.childTile=f,i.geodes=[];let l=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<l;n++)r=ds(t,e,r,i.geodes);return n.push(i),r}function As(t,e,r,n){let i=e.getUint32(r,!0);if(n.verticesCount=i,(r+=Uint32Array.BYTES_PER_ELEMENT)<=0)return r;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);o=s*Float32Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let a=i*s*Float32Array.BYTES_PER_ELEMENT,f=new Uint8Array(t,r,a);r+=a;let c=n.vertexAttributes,l=n.attrLocation;return l.aPosition=c.length,c.push({index:l.aPosition,typedArray:f,componentsPerAttribute:s,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function ms(t,e,r,n){let i=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,i<=0)return r;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let a=i*s*Float32Array.BYTES_PER_ELEMENT,f=new Uint8Array(t,r,a);r+=a;let c=n.vertexAttributes,l=n.attrLocation;return l.aNormal=c.length,c.push({index:l.aNormal,typedArray:f,componentsPerAttribute:s,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function ws(t,e,r,n){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s,o=n.verticesCount;if(i>0){e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=2*Uint8Array.BYTES_PER_ELEMENT;let n=i*Uint8Array.BYTES_PER_ELEMENT*4;s=new Uint8Array(t,r,n).slice(0,n),r+=n}else{s=new Uint8Array(4*o);for(let t=0;t<o;t++)s[4*t]=255,s[4*t+1]=255,s[4*t+2]=255,s[4*t+3]=255}let a=n.vertexAttributes,f=n.attrLocation;return f.aColor=a.length,a.push({index:f.aColor,typedArray:s,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),n.vertexColor=s,r}function ps(t,e,r,n){let i=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,i<=0)return r;e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=2*Uint8Array.BYTES_PER_ELEMENT;let s=i*Uint8Array.BYTES_PER_ELEMENT*4,o=new Uint8Array(t,r,s);r+=s;let a=n.vertexAttributes,f=n.attrLocation;return f.aSecondColor=a.length,a.push({index:f.aSecondColor,typedArray:o,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),r}function _s(t,e,r,n){let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let a=i*o*Float32Array.BYTES_PER_ELEMENT,f=new Uint8Array(t,r,a);r+=a;let c="aTexCoord"+s,l=n.vertexAttributes,u=n.attrLocation;u[c]=l.length,l.push({index:u[c],typedArray:f,componentsPerAttribute:o,componentDatatype:5126,offsetInBytes:0,strideInBytes:o*Float32Array.BYTES_PER_ELEMENT,normalize:!1})}return r}function Us(t,e,r,n){let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let s=n.vertexAttributes,o=n.attrLocation;for(let a=0;a<i;a++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let f=i*a*Float32Array.BYTES_PER_ELEMENT;if(17===a){let e=new Uint8Array(t,r,f);n.instanceCount=i,n.instanceMode=a,n.instanceBuffer=e,n.instanceIndex=1;let c,l=a*i*4,u=e.slice(0,l);n.vertexColorInstance=u,17===a?(c=17*Float32Array.BYTES_PER_ELEMENT,o.uv2=s.length,s.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:c,instanceDivisor:1}),o.uv3=s.length,s.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv4=s.length,s.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.secondary_colour=s.length,s.push({index:o.secondary_colour,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv6=s.length,s.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1})):29===a&&(c=29*Float32Array.BYTES_PER_ELEMENT,o.uv1=s.length,s.push({index:o.uv1,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:c,instanceDivisor:1,byteLength:f}),o.uv2=s.length,s.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv3=s.length,s.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv4=s.length,s.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv5=s.length,s.push({index:o.uv5,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv6=s.length,s.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:20*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv7=s.length,s.push({index:o.uv7,componentsPerAttribute:3,componentDatatype:5126,normalize:!1,offsetInBytes:24*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.secondary_colour=s.length,s.push({index:o.secondary_colour,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:27*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}),o.uv9=s.length,s.push({index:o.uv9,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:28*Float32Array.BYTES_PER_ELEMENT,strideInBytes:c,instanceDivisor:1}))}else{let t=i*a;n.instanceBounds=new Float32Array(t);for(let i=0;i<t;i++)n.instanceBounds[i]=e.getFloat32(r+i*Float32Array.BYTES_PER_ELEMENT,!0)}r+=f}return r}function gs(t,e,r,n){return r=Us(t,e,r=_s(t,e,r=ps(t,e,r=ws(t,e,r=ms(t,e,r=As(t,e,r,n),n),n),n),n),n)}function Ts(t,e,r,n){let i=e.getUint32(r,!0);return n.compressOptions=i,r+=Uint32Array.BYTES_PER_ELEMENT,r=(i&fs)===fs?function(t,e,r,n){let i=e.getUint32(r,!0);if(n.verticesCount=i,(r+=Uint32Array.BYTES_PER_ELEMENT)<=0)return r;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);o=s*Int16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let a=e.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT;let f={};f.x=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,f.y=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,f.z=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,f.w=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.vertCompressConstant=a,n.minVerticesValue=f;let c=i*s*Int16Array.BYTES_PER_ELEMENT,l=new Uint8Array(t,r,c);r+=c;let u=n.vertexAttributes,h=n.attrLocation;return h.aPosition=u.length,u.push({index:h.aPosition,typedArray:l,componentsPerAttribute:s,componentDatatype:5122,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}(t,e,r,n):As(t,e,r,n),r=(i&cs)===cs?function(t,e,r,n){let i=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,i<=0)return r;e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=2*i*Int16Array.BYTES_PER_ELEMENT,a=new Uint8Array(t,r,o);r+=o;let f=n.vertexAttributes,c=n.attrLocation;return c.aNormal=f.length,f.push({index:c.aNormal,typedArray:a,componentsPerAttribute:2,componentDatatype:5122,offsetInBytes:0,strideInBytes:s,normalize:!1}),r}(t,e,r,n):ms(t,e,r,n),r=ps(t,e,r=ws(t,e,r,n),n),r=(i&ls)===ls?function(t,e,r,n){n.texCoordCompressConstant=[],n.minTexCoordValue=[];let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=e.getUint8(r,!0);r+=Uint8Array.BYTES_PER_ELEMENT,r+=3*Uint8Array.BYTES_PER_ELEMENT;let o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let f=e.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT,n.texCoordCompressConstant.push(f);let c={};c.x=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,c.y=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,c.z=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,c.w=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.minTexCoordValue.push(c);let l=o*a*Int16Array.BYTES_PER_ELEMENT,u=new Uint8Array(t,r,l),h=(r+=l)%4;0!==h&&(r+=4-h);let y="aTexCoord"+s,d=n.vertexAttributes,b=n.attrLocation;if(b[y]=d.length,d.push({index:b[y],typedArray:u,componentsPerAttribute:a,componentDatatype:5122,offsetInBytes:0,strideInBytes:a*Int16Array.BYTES_PER_ELEMENT,normalize:!1}),i){l=o*Float32Array.BYTES_PER_ELEMENT;let e=new Uint8Array(t,r,l);r+=l,n.texCoordZMatrix=!0,y="aTexCoordZ"+s,b[y]=d.length,d.push({index:b[y],typedArray:e,componentsPerAttribute:1,componentDatatype:5126,offsetInBytes:0,strideInBytes:Float32Array.BYTES_PER_ELEMENT,normalize:!1})}}return r}(t,e,r,n):_s(t,e,r,n),(i&us)===us&&(n.textureCoordIsW=!0),r=Us(t,e,r,n)}function vs(t,e,r,n){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i={},s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint8(r,!0);r+=Uint8Array.BYTES_PER_ELEMENT,e.getUint8(r,!0),r+=Uint8Array.BYTES_PER_ELEMENT;let a=e.getUint8(r,!0);if(r+=Uint8Array.BYTES_PER_ELEMENT,r+=Uint8Array.BYTES_PER_ELEMENT,s>0){let e,n=null;1===o||3===o?(e=s*Uint32Array.BYTES_PER_ELEMENT,n=new Uint8Array(t,r,e)):(e=s*Uint16Array.BYTES_PER_ELEMENT,n=new Uint8Array(t,r,e),s%2!=0&&(e+=2)),i.indicesTypedArray=n,r+=e}i.indicesCount=s,i.indexType=o,i.primitiveType=a;let f=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<f;n++){let n=ys(t,e,r),s=n.string;r=n.bytesOffset,i.materialCode=s}if(0!==r%4){r+=4-r%4}n.push(i)}return r}let Is={red:0,green:0,blue:0,alpha:0};function Ss(t,e,r){let n=t.vertexAttributes,i=t.attrLocation,s=n.length;i[1===r?"instanceId":"batchId"]=s,n.push({index:s,typedArray:e,componentsPerAttribute:1,componentDatatype:5126,offsetInBytes:0,strideInBytes:0,instanceDivisor:r})}function Es(t,e,r){var n=r*(4*e+e%4),i=n+o,s=new DataView(t),o=0;s.setUint16(o,19778,!0),o+=2,s.setUint32(o,i,!0),o+=4,s.setUint32(o,0,!0),o+=4,s.setUint32(o,122,!0),o+=4,s.setUint32(o,108,!0),o+=4,s.setUint32(o,e,!0),o+=4,s.setUint32(o,r,!0),o+=4,s.setUint16(o,1,!0),o+=2,s.setUint16(o,32,!0),o+=2,s.setUint32(o,this.compress,!0),o+=4,s.setUint32(o,n,!0),o+=4,s.setUint32(o,2835,!0),o+=4,s.setUint32(o,2835,!0),o+=4,s.setUint8(o,0,!0),o+=4,s.setUint32(o,0,!0),o+=4,s.setUint32(o,16711680,!0),o+=4,s.setUint32(o,65280,!0),o+=4,s.setUint32(o,255,!0),o+=4,s.setUint32(o,4278190080,!0),o+=4,s.setUint32(o,1466527264,!0),o+=4}function Os(t){for(var e,r,n,i,s=t.buffer,o=t.bytesOffset,a=ns.parseBuffer(s,o),f=a.geoPackage,c=a.groupNode.pageLods,l=[],u=[],h=[],y=[],d=0,b=c[0].geodes[0].matrix,A={},m=0;m<a.materials.material.length;m++)A[a.materials.material[m].material.id]=a.materials.material[m].material;var w={x:0,y:0,z:0},p=Number.MAX_VALUE,_=Number.MAX_VALUE,U=Number.MAX_VALUE,g=Number.MIN_VALUE,T=Number.MIN_VALUE,v=Number.MIN_VALUE;for(var I in f){var S=f[I].vertexPackage;e=S.verticesCount;s=S.vertexAttributes[0].typedArray.buffer;var E=S.vertexAttributes[0].typedArray.byteOffset,O=S.vertexAttributes[0].componentsPerAttribute;n=new Float32Array(s,S.vertexAttributes[0].offsetInBytes+E,e*O),i=new Float32Array(3*e);for(m=0;m<e;m++){var k=n[m*O],x=n[m*O+1],F=n[m*O+2];ns.multiplyByPoint(b,{x:k,y:x,z:F},w),i[3*m]=w.x,i[3*m+1]=w.y,i[3*m+2]=w.z,p=Math.min(p,i[3*m]),_=Math.min(_,i[3*m+1]),U=Math.min(U,i[3*m+2]),g=Math.max(g,i[3*m]),T=Math.max(T,i[3*m+1]),v=Math.max(v,i[3*m+2])}l.push(i);var B=S.attrLocation.aTexCoord0;if(B){const t=S.vertexAttributes[B];var D=t.componentsPerAttribute,R=new Float32Array(s,t.offsetInBytes+t.typedArray.byteOffset,e*D),M=new Float32Array(2*e);for(m=0;m<e;m++)M[2*m]=R[m*D],M[2*m+1]=R[m*D+1];h.push(M)}else h.push(void 0);var L=f[I].arrIndexPackage[0].indicesTypedArray;r=new Uint16Array(L.buffer,(f[I].arrIndexPackage[0].bytesOffset||0)+L.byteOffset,f[I].arrIndexPackage[0].indicesCount),u.push(r),r.length,d+=e;var N=f[I].arrIndexPackage[0].materialCode;y.push(A[N])}var P=[p,_,U],Z=[g,T,v],C=function(t,e,r,n,i,s,o,a,f,c,l,u){return new Promise((function(a,h){!function(t,e,r,n,i,s,o,f,c,l,u,h){if(0===t||void 0===r||0===r.length)return{buffers:[],bufferViews:[],accessors:[],meshes:[],nodes:[],nodesInScene:[]};for(var y=[],d=[],b=[],A=[],m=[],w=[],p=0,_=0,U=0,g=0,T=0,v=0;v<r.length;v++){var I=e?e[v]:void 0,S=r?r[v]:void 0,E=n?n[v]:void 0,O=i?i[v]:void 0,k=s?s[v]:void 0;I&&(t=I.length);var x=new Uint32Array(t);if(I)for(var F=0;F<t;++F)x[F]=I[F];else for(F=0;F<t;++F)x[F]=F;var B=new Blob([x],{type:"application/binary"}),D=URL.createObjectURL(B),R=t,M=S.subarray(0,3*R),L=new Blob([M],{type:"application/binary"}),N=URL.createObjectURL(L),P=E?E.subarray(0,3*R):null,Z=null;if(P){var C=new Blob([P],{type:"application/binary"});Z=URL.createObjectURL(C)}var z=O?O.subarray(0,2*R):null,V=null;if(z){var H=new Blob([z],{type:"application/binary"});V=URL.createObjectURL(H)}var j=k?k.subarray(0,4*R):null,G=null,K=null;if(j){var q=j.length;G=new Float32Array(q);for(var $=0;$<q;++$)G[$]=j[$]/255;var J=new Blob([G],{type:"application/binary"});K=URL.createObjectURL(J)}var Y={};Y.POSITION=T,y.push({uri:N,byteLength:M.byteLength}),d.push({buffer:T,byteOffset:0,byteLength:M.byteLength,target:34962}),b.push({bufferView:T,byteOffset:0,componentType:5126,count:M.length/3,type:"VEC3",max:l,min:c}),Z&&(p=++T,Y.NORMAL=p,y.push({uri:Z,byteLength:P.byteLength}),d.push({buffer:p,byteOffset:0,byteLength:P.byteLength,target:34962}),b.push({bufferView:p,byteOffset:0,componentType:5126,count:P.length/3,type:"VEC3",max:[0,0,0],min:[0,0,0]})),V&&(_=++T,Y.TEXCOORD_0=_,y.push({uri:V,byteLength:z.byteLength}),d.push({buffer:_,byteOffset:0,byteLength:z.byteLength,target:34962}),b.push({bufferView:_,byteOffset:0,componentType:5126,count:z.length/2,type:"VEC2",max:[0,0],min:[0,0]})),K&&(U=++T,Y.COLOR_0=U,y.push({uri:K,byteLength:G.byteLength}),d.push({buffer:U,byteOffset:0,byteLength:G.byteLength,target:34962}),b.push({bufferView:U,byteOffset:0,componentType:5126,count:U.length/4,type:"VEC4",max:[0,0,0,0],min:[0,0,0,0]})),g=++T,y.push({uri:D,byteLength:x.byteLength}),d.push({buffer:g,byteOffset:0,byteLength:x.byteLength,target:34963}),b.push({bufferView:g,byteOffset:0,componentType:5125,count:t,type:"SCALAR",max:[0],min:[0]}),A.push({primitives:[{attributes:Y,indices:g,material:v}]}),w.push(v),m.push({mesh:v}),T++}var X=[],W=[],Q=new Array(u.length),tt=0,et=0,rt=0,nt=[],it=new Promise((function(t,e){for(var r=0;r<h.length;r++)!function(e){var r=h[e].textureunitstates[0];if(r){rt++;var n=h[e].textureunitstates[0].textureunitstate.id,i=o[n],s=i.arrayBufferView,a=null,f=i.nFormat;a=f>Xi||f===Yi?new Uint8Array(122+i.width*i.height*4):new Uint16Array(61+i.width*i.height),rs.decode(a.subarray(122),i.width,i.height,s,f),Es(a.buffer,i.width,i.height);var c=new Blob([a],{type:"image/bmp"}),l=URL.createObjectURL(c);y.push({uri:l,byteLength:a.byteLength}),d.push({buffer:y.length-1,byteOffset:0,byteLength:a.byteLength,target:34962}),W.push({"mimeType":"image/bmp","bufferView":d.length-1}),X.push({sampler:0,source:tt++}),nt.push(c),nt.length===rt&&t()}Q.push({pbrMetallicRoughness:{metallicFactor:0,baseColorTexture:r?{index:et++,texCoord:0}:void 0},doubleSided:!0,name:n})}(r)})),st={scene:0,scenes:[{nodes:w}],nodes:m,meshes:A,buffers:y,bufferViews:d,accessors:b,materials:Q,textures:X,images:W,samplers:[{magFilter:9729,minFilter:9729,wrapS:10497,wrapT:10497}],asset:{version:"2.0"}};0===rt&&a(st),it.then((function(){a(st)}))}(t,e,r,n,i,s,o,0,f,c,l,u)}))}(d,u,l,null,h,null,a.texturePackage,0,P,Z,[],y);return C.then((function(t){var e=function(t){var e=(new TextEncoder).encode(JSON.stringify(t)),r=new Uint8Array(e.byteLength+20),n={magic:new Uint8Array(r.buffer,0,4),version:new Uint32Array(r.buffer,4,1),length:new Uint32Array(r.buffer,8,1),chunkLength:new Uint32Array(r.buffer,12,1),chunkType:new Uint32Array(r.buffer,16,1),chunkData:new Uint8Array(r.buffer,20,e.byteLength)};return n.magic[0]="g".charCodeAt(),n.magic[1]="l".charCodeAt(),n.magic[2]="T".charCodeAt(),n.magic[3]="F".charCodeAt(),n.version[0]=2,n.length[0]=r.byteLength,n.chunkLength[0]=e.byteLength,n.chunkType[0]=1313821514,n.chunkData.set(e),r}(t),r=function(t,e,r){var n=new TextEncoder,i=n.encode(t),s=i.byteLength,o=28+s,a=n.encode(e),f=(o+a.byteLength)%8,c=a.byteLength+f,l=a.byteLength,u=c,h=o+c,y=r.byteLength,d=new Uint8Array(28+(s+c+y)),b={magic:new Uint8Array(d.buffer,0,4),version:new Uint32Array(d.buffer,4,1),byteLength:new Uint32Array(d.buffer,8,1),featureTableJSONByteLength:new Uint32Array(d.buffer,12,1),featureTableBinaryByteLength:new Uint32Array(d.buffer,16,1),batchTableJSONByteLength:new Uint32Array(d.buffer,20,1),batchTableBinaryByteLength:new Uint32Array(d.buffer,24,1),featureTable:new Uint8Array(d.buffer,28,s),batchTable:new Uint8Array(d.buffer,o,c),binaryGLTF:new Uint8Array(d.buffer,h,y)};b.magic[0]="b".charCodeAt(),b.magic[1]="3".charCodeAt(),b.magic[2]="d".charCodeAt(),b.magic[3]="m".charCodeAt(),b.version[0]=1,b.byteLength[0]=d.byteLength,b.featureTable.set(i),b.featureTableJSONByteLength[0]=s,b.featureTableBinaryByteLength[0]=0,b.batchTable.set(a);for(var A=l;A<u;++A)b.batchTable[A]=32;return b.batchTableJSONByteLength[0]=c,b.batchTableBinaryByteLength[0]=0,b.binaryGLTF.set(r),d}(JSON.stringify({BATCH_LENGTH:0}),JSON.stringify({}),e);return{b3dmBuffer:r,pageLods:c}}))}ns.parseBuffer=function(t,e){var r={version:void 0,groupNode:void 0,geoPackage:{},matrials:void 0,texturePackage:{}};r.byteLength=t.byteLength,r.buffer=t;const n=new DataView(t);e=0;var i=n.getUint32(e,!0);return e=function(t,e,r,n){let i={},s=[];e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<o;n++)r=bs(t,e,r,s);i.pageLods=s;let a=r%4;return 0!==a&&(r+=4-a),n.groupNode=i,r}(t,n,e+=Uint32Array.BYTES_PER_ELEMENT,r),e=function(t,e,r,n){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=ys(t,e,r),s=i.string,o=(r=i.bytesOffset)%4;0!==o&&(r+=4-o);let a=e.getUint32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT;let f={vertexAttributes:[],attrLocation:{},instanceCount:0,instanceMode:0,instanceIndex:-1};a===is?r=gs(t,e,r,f):a===ss&&(r=Ts(t,e,r,f));let c,l=[];r=vs(t,e,r,l),2===l.length&&13===l[1].primitiveType&&l[1].indicesCount>=3&&(c=S3MEdgeProcessor.createEdgeDataByIndices(f,l[1])),n[s]={vertexPackage:f,arrIndexPackage:l,edgeGeometry:c}}return r+=e.getUint32(r,!0),r+Uint32Array.BYTES_PER_ELEMENT}(t,n,e,r.geoPackage),e=function(t,e,r,n){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let s=0;s<i;s++){let i=ys(t,e,r),s=i.string,o=(r=i.bytesOffset)%4;0!==o&&(r+=4-o),e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let f=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let l=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let u=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let h=new Uint8Array(t,r,l);r+=l;let y=u===os||u===as?33776:33779;if(22===c&&(y=36196),!ns.s3tc&&(33776===y||33779===y)){let t=new Uint8Array(a*f*4);rs.decode(t,a,f,h,u),h=t,c=0,y=u===os||u===os?273:4369}n[s]={id:s,width:a,height:f,compressType:c,nFormat:u,internalFormat:y,arrayBufferView:h}}return r}(t,n,e,r.texturePackage),e=function(t,e,r,n){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=hs(new Uint8Array(t,r,i));return r+=i,n.materials=JSON.parse(s),r}(t,n,e,r),function(t,e,r,n,i,s){if(1==(1&n)){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let n=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let o=0;o<n;o++){let n=ys(t,e,r),o=n.string;r=n.bytesOffset;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let f={};if(i[o].pickInfo=f,-1==i[o].vertexPackage.instanceIndex){let t=new Float32Array(i[o].vertexPackage.verticesCount);for(let n=0;n<a;n++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=[];for(let i=0;i<s;i++){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT,t.fill(n,i,i+s),o.push({vertexColorOffset:i,vertexColorCount:s,batchId:n})}f[i]=o}Ss(i[o].vertexPackage,t,void 0)}else{let t=i[o].vertexPackage.instanceCount,n=i[o].vertexPackage.instanceBuffer,c=i[o].vertexPackage.instanceMode,l=new Float32Array(t),u=[];for(let t=0;t<a;t++){let t=e.getUint32(r,!0);u.push(t),r+=Uint32Array.BYTES_PER_ELEMENT;let n=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let t=0;t<n;t++)e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT,3===s&&(e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT)}let h=17===c?16:28;h*=Float32Array.BYTES_PER_ELEMENT;for(let e=0;e<t;e++){l[e]=e;let t=e*c*Float32Array.BYTES_PER_ELEMENT+h;Cesium.Color.unpack(n,t,Is);let r=2===s?u[e]:Is.red+256*Is.green+65536*Is.blue;void 0===f[r]&&(f[r]={vertexColorCount:1,instanceIds:[],vertexColorOffset:e}),f[r].instanceIds.push(e)}Ss(i[o].vertexPackage,l,1)}}}}(t,n,e,i,r.geoPackage,r.version),r},ns.multiplyByPoint=function(t,e,r){var n=e.x,i=e.y,s=e.z,o=t[0]*n+t[4]*i+t[8]*s+t[12],a=t[1]*n+t[5]*i+t[9]*s+t[13],f=t[2]*n+t[6]*i+t[10]*s+t[14];return r.x=o,r.y=a,r.z=f,r};const ks=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],xs=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],Fs="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let Bs,Ds,Rs=!1;if("undefined"!=typeof OffscreenCanvas){try{Ds=new OffscreenCanvas(2,2).getContext("2d")}catch(on){}Ds&&"undefined"!=typeof createImageBitmap&&(Rs=!0)}const Ms=n([]),Ls=[0,0,0],Ns=[],Ps=[];class Zs{constructor(t,e,r,n){this.id=t,this.options=e,this.gt=this.requestImage.bind(this),this.Tt=r,this.vt={},n(null,{},[])}It(t){this.St||(this.Et=new de,this.St=new ce(this.gt,ct,t),this.Ot=new le(this.gt,ct,t))}requestImage(t,e){Rs?fetch(t).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{Bs.width=t.width,Bs.height=t.height,Ds.drawImage(t,0,0);const r=Ds.getImageData(0,0,Bs.width,Bs.height);e(null,{width:t.width,height:t.height,data:new Uint8Array(r.data)})})):this.Tt("requestImage",{url:t},null,e)}loadTile(t,e){this.It(t.supportedFormats);const r=t.url,n=t.arraybuffer;if(n){delete this.vt[r];const i=new DataView(n),s=Rt(i,0);if("{"===s[0]||" "===s[0]||"<"===s[0]){const t=function(t,e,r){if(Fs){const n=new Uint8Array(t,e,r);return Fs.decode(n)}return _t(new Uint8Array(t,e,r))}(n,0,n.byteLength);let r=JSON.parse(t);r=this.kt(r),e(null,r)}else{const o=i.getFloat32(0,!0);1===o||2===o?this.xt(n,r,t,e):this.Ft(n,r,t,s,e)}}else{const n=this.options.services[t.rootIdx];let i=n.urlParams;i&&(i=(r.indexOf("?")>0?"&":"?")+i);let s=H.getArrayBuffer(r+(i||""),n.fetchOptions);const o=s.xhr;s=s.then((n=>{delete this.vt[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this.vt[r],e(t)})),this.vt[r]=o}}Ft(t,e,r,n,i){const s=this.options.services[r.rootIdx];if("b3dm"===n){this.St.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{if(t.error)return void i(t);const{content:e,transferables:n}=this.Bt(t,r);i(null,e,n)})).catch((t=>{i(t)}))}else if("pnts"===n){const n=r.transform;this.Et.load(e,t).then((t=>{const{content:e,transferables:s}=this.Dt(t,n,r.rootIdx);i(null,e,s)}))}else if("i3dm"===n){const n=r.transform;this.Ot.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{const{content:e,transferables:s}=this.Dt(t,n,r.rootIdx);i(null,e,s)}))}else if("cmpt"===n){new Ae(this.gt,ct).load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{const{content:e,transferables:n}=this.Rt(t,r);i(null,e,n)})).catch((t=>{i(t)}))}}xt(t,e,r,n){let i=0;const s=new DataView(t).getFloat32(i,!0);i+=Float32Array.BYTES_PER_ELEMENT,s>=2&&(i+=Uint32Array.BYTES_PER_ELEMENT),i+=Uint32Array.BYTES_PER_ELEMENT;const o=function(t,e){var r=new Uint8Array(t,e);return Ji.inflate(r).buffer}(t,i);Os({buffer:o,bytesOffset:0}).then((t=>{this.Ft(t.b3dmBuffer.buffer,e,r,"b3dm",((e,r,i)=>{if(e)n(e);else{if(t.pageLods){const e=this.Mt(t.pageLods);e.length&&(r.children=e)}n(e,r,i)}}))}))}Mt(t){const e=[];for(let r=0;r<t.length;r++){const n=t[r];if(!n.childTile)continue;const i={boundingVolume:{sphere:[n.boundingSphere.center.x,n.boundingSphere.center.y,n.boundingSphere.center.z,n.boundingSphere.radius]},content:{uri:n.childTile},geometricError:n.boundingSphere.radius/n.rangeList*16,refine:"REPLACE"};e.push(i)}return e}kt(t){return t.dataType&&t.position?ge(t):t}Rt(t,e){const{tiles:r}=t,n={magic:"cmpt",content:[]},i=[];for(let t=0;t<r.length;t++){const{magic:s}=r[t];if("b3dm"===s){const{content:s,transferables:o}=this.Bt(r[t],e);Vs(i,o),n.content.push(s)}else if("i3dm"===s||"pnts"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:f}=this.Dt(r[t],s,o);Vs(i,f),n.content.push(a)}else if("cmpt"===s){const{content:s,transferables:o}=this.Rt(r[t],e);Vs(i,o),n.content.push(s)}}return{content:n,transferables:i}}Bt(t,e){const{gltf:r,transferables:n,featureTable:i}=t;return this.Lt(t.gltf),this.convertCoordinates(r,i,e.upAxis,e.transform),delete t.transferables,{content:t,transferables:n}}Dt(t,e,r){const{featureTable:n}=t,i=t.pnts||t.i3dm;let s=n&&n.RTC_CENTER||[0,0,0];if(n.EAST_NORTH_UP&&!i.NORMAL_UP&&!i.NORMAL_UP_OCT32P){const e=new Float32Array(3*i.POSITION.array.length),r=[],n=[],o=[];pe(i.POSITION,((t,i)=>{l(o,t,s),te(o,null,r),function(t,e){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]}(n,r);!function(t,e){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]}(e.subarray(9*i,9*(i+1)),n)})),i.INSTANCE_ROTATION={byteStride:0,byteOffset:0,itemSize:9,componentType:5126,array:e},t.transferables.push(e.buffer)}const o={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Cs(i.POSITION.array,3,s,Ms,o);const a=zs(o),c=f([],a),u=[1/0,1/0,1/0],h=[-1/0,-1/0,-1/0];pe(i.POSITION,(t=>{t[0]=t[0]+s[0]-c[0],t[1]=t[1]+s[1]-c[1],t[2]=t[2]+s[2]-c[2],t[0]<u[0]&&(u[0]=t[0]),t[1]<u[1]&&(u[1]=t[1]),t[2]<u[2]&&(u[2]=t[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])})),i.POSITION.min=u,i.POSITION.max=h,e&&w(a,a,e);const y=this.Nt(a);t.rtcCenter=c,t.rtcCoord=y,t.rootIdx=r;const d=t.transferables;return delete t.transferables,{content:t,transferables:d}}Lt(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const r=e[t].image&&e[t].image.array;if(r&&r.length){const n=r[0],i=r[1],s=r[2],o=r[3];let a=!0;for(let t=4;t<r.length;t+=4)if(r[t]!==n||r[t+1]!==i||r[t+2]!==s||r[t+3]!==o){a=!1;break}a&&(e[t].image.color=[n/255,i/255,s/255,o/255],delete e[t].image.array)}}}abortTileLoading(t,e){const r=this.vt[t.url];r&&r.abort(),delete this.vt[t.url],e(null)}convertCoordinates(t,e,r,s){let o=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center,a=ks;"X"===(r=r&&r.toUpperCase())?a=xs:"Z"===r&&(a=Ms),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),o&&(t.extensions.CESIUM_RTC.center=o);const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};me(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=n(Ns);if(t.matrices)for(let r=t.matrices.length-1;r>=0;r--)i(e,e,t.matrices[r]);const r=t.attributes.POSITION.array,s=t.attributes.POSITION.itemSize;i(e,a,e),Cs(r,s,o||Ls,e,c)}));const l=zs(c),u=f([],l);s&&w(l,l,s),t.extensions.CESIUM_RTC.coord=this.Nt(l),o||(me(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 r=n(Ns);if(t.matrices)for(let e=t.matrices.length-1;e>=0;e--)i(r,r,t.matrices[e]);i(r,a,r);const s=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],f=e[6],c=e[7],l=e[8],u=e[9],h=e[10],y=e[11],d=e[12],b=e[13],A=e[14],m=e[15],w=r*a-n*o,p=r*f-i*o,_=r*c-s*o,U=n*f-i*a,g=n*c-s*a,T=i*c-s*f,v=l*b-u*d,I=l*A-h*d,S=l*m-y*d,E=u*A-h*b,O=u*m-y*b,k=h*m-y*A,x=w*k-p*O+_*E+U*S-g*I+T*v;return x?(x=1/x,t[0]=(a*k-f*O+c*E)*x,t[1]=(i*O-n*k-s*E)*x,t[2]=(b*T-A*g+m*U)*x,t[3]=(h*g-u*T-y*U)*x,t[4]=(f*S-o*k-c*I)*x,t[5]=(r*k-i*S+s*I)*x,t[6]=(A*_-d*T-m*p)*x,t[7]=(l*T-h*_+y*p)*x,t[8]=(o*O-a*S+c*v)*x,t[9]=(n*S-r*O-s*v)*x,t[10]=(d*g-b*_+m*w)*x,t[11]=(u*_-l*g-y*w)*x,t[12]=(a*I-o*E-f*v)*x,t[13]=(r*E-n*I+i*v)*x,t[14]=(b*p-d*U-A*w)*x,t[15]=(l*U-u*p+h*w)*x,t):null}(Ps,r),o=[1/0,1/0,1/0],f=[-1/0,-1/0,-1/0];pe(e,(t=>{w(t,t,r),t[0]=t[0]-u[0],t[1]=t[1]-u[1],t[2]=t[2]-u[2],w(t,t,s),t[0]<o[0]&&(o[0]=t[0]),t[1]<o[1]&&(o[1]=t[1]),t[2]<o[2]&&(o[2]=t[2]),t[0]>f[0]&&(f[0]=t[0]),t[1]>f[1]&&(f[1]=t[1]),t[2]>f[2]&&(f[2]=t[2])})),e.min=o,e.max=f,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=u)}Nt(t){return 0===U(t)?c([],0,0,-6378137):kt([],t)}onRemove(){}}function Cs(t,e,r,n,i){const s=[];for(let o=0,a=t.length;o<a;o+=e){const{xmin:a,ymin:f,xmax:u,ymax:h,hmin:y,hmax:d}=i;c(s,t[o],t[o+1],t[o+2]),w(s,s,n);const b=l(s,r,s);b[0]<a&&(i.xmin=b[0]),b[0]>u&&(i.xmax=b[0]),b[1]<f&&(i.ymin=b[1]),b[1]>h&&(i.ymax=b[1]),e>2&&(b[2]<y&&(i.hmin=b[2]),b[2]>d&&(i.hmax=b[2]))}}function zs(t){const{xmax:e,ymax:r,xmin:n,ymin:i,hmin:s,hmax:o}=t,a=[(n+e)/2,(i+r)/2,(s+o)/2];return e===-1/0&&(a[0]=0),r===-1/0&&(a[1]=0),o===-1/0&&(a[2]=0),isNaN(a[2])&&(a[2]=0),a}function Vs(t,e){for(let r=0;r<e.length;r++)t.indexOf(e[r])<0&&t.push(e[r])}let Hs=0;class js{constructor(t){this.workerId=t,this.workers={},this.Pt={}}addLayer({actorId:t,mapId:e,layerId:r,params:n},i){if(this.Zt(e,r))return;const s=this.Ct(e,r),o=n.options,a=this.send.bind(this,t);this.workers[s]=new Zs(r,o,a,i)}removeLayer({mapId:t,layerId:e},r){const n=this.Zt(t,e),i=this.Ct(t,e);delete this.workers[i],n&&n.onRemove(r)}loadTile({mapId:t,layerId:e,params:r},n){const i=this.Zt(t,e);i&&i.loadTile(r,n)}abortTileLoading({mapId:t,layerId:e,params:r},n){const i=this.Zt(t,e);i&&i.abortTileLoading(r,n)}receive(t){const e=t.callback,r=this.Pt[e];delete this.Pt[e],r&&t.error?r(new Error(t.error)):r&&r(null,t.data)}send(t,e,r,n,i){const s=i?`${t}-${Hs++}`:null;i&&(this.Pt[s]=i),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:r,callback:String(s)},n||[])}Ct(t,e){return`${t}-${e}`}Zt(t,e){const r=this.Ct(t,e);return this.workers[r]}}t.initialize=function(){},t.onmessage=function(t,e){const r=t.data;this.dispatcher||(this.dispatcher=new js(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[r.command]({actorId:r.actorId,mapId:r.mapId,layerId:r.layerId,params:r.params},((t,r,n)=>{e(t,r,n)}))},Object.defineProperty(t,"zt",{value:!0})}';for(
|
|
7
7
|
/*!
|
|
8
8
|
* Contains code from THREE.js
|
|
9
9
|
* MIT License
|
|
10
10
|
* https://github.com/mrdoob/three.js
|
|
11
11
|
*/
|
|
12
|
-
var h=[],f=0;f<6;f++)h[f]=[];var u=[];function d(t,e,r){m(t);for(var n=0;n<6;n++)if(!r||"0"!==r.charAt(n)){var i=h[n];if(u[0]=i[0]>0?e[1][0]:e[0][0],u[1]=i[1]>0?e[1][1]:e[0][1],u[2]=i[2]>0?e[1][2]:e[0][2],
|
|
12
|
+
var h=[],f=0;f<6;f++)h[f]=[];var u=[];function d(t,e,r){m(t);for(var n=0;n<6;n++)if(!r||"0"!==r.charAt(n)){var i=h[n];if(u[0]=i[0]>0?e[1][0]:e[0][0],u[1]=i[1]>0?e[1][1]:e[0][1],u[2]=i[2]>0?e[1][2]:e[0][2],_(i,u)<0)return!1}return!0}function y(t,e){var r=e,n=t,i=e,s=n[0],a=n[1],o=n[2],l=Math.abs(s*i[3]+a*i[6]+o*i[9])+Math.abs(s*i[4]+a*i[7]+o*i[10])+Math.abs(s*i[5]+a*i[8]+o*i[11]),c=_(t,r);return!(c<=-l)}function m(t){var e=t,r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],f=e[8],u=e[9],d=e[10],y=e[11],m=e[12],_=e[13],p=e[14],g=e[15];b(h[0],s-r,c-a,y-f,g-m),b(h[1],s+r,c+a,y+f,g+m),b(h[2],s+n,c+o,y+u,g+_),b(h[3],s-n,c-o,y-u,g-_),b(h[4],s-i,c-l,y-d,g-p),b(h[5],s+i,c+l,y+d,g+p)}function b(t,e,r,n,i){var s=1/Math.sqrt(e*e+r*r+n*n);return t[0]=e*s,t[1]=r*s,t[2]=n*s,t[3]=i*s,t}function _(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]}function p(t){return null==t}function g(t){for(let e=1;e<arguments.length;e++){const r=arguments[e];for(const e in r)t[e]=r[e]}return t}function w(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function E(t){return t*Math.PI/180}function T(t){return t/Math.PI*180}function A(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function v(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const x=[1,1,1,1,2,2,3,0];function S(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=x[i>>3&7];if(!(64&i)||!r||n+r>e)return null;for(i&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;i=i<<6|63&e}}r+=String.fromCharCode(i)}return r}function U(t,e,r){return t[3*r]=e[0],t[3*r+1]=e[1],t[3*r+2]=e[2],t}function O(t){return t.flat?t.flat(1/0):t.reduce(((t,e)=>t.concat(e)),[])}function I(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function L(t){return 0===t.indexOf("data:")}function M(t){const e=t.indexOf("base64,"),r=t.substring(e+7),n=window.atob(r),i=n.length,s=new Uint8Array(i);for(let t=0;t<i;t++)s[t]=n.charCodeAt(t);return s.buffer}var R=Object.freeze({__proto__:null,isNil:p,extend:g,isFunction:w,toRadian:E,toDegree:T,getAbsoluteURL:A,sign:v,stringFromUTF8Array:S,setColumn3:U,flatArr:O,getBatchIdArrayType:I,isBase64:L,base64URLToArrayBuffer:M}),N="undefined"!=typeof Float32Array?Float32Array:Array;function B(t,e,r){var n=e[0],i=e[1],s=e[2],a=e[3],o=e[4],l=e[5],c=e[6],h=e[7],f=e[8],u=e[9],d=e[10],y=e[11],m=e[12],b=e[13],_=e[14],p=e[15],g=r[0],w=r[1],E=r[2],T=r[3];return t[0]=g*n+w*o+E*f+T*m,t[1]=g*i+w*l+E*u+T*b,t[2]=g*s+w*c+E*d+T*_,t[3]=g*a+w*h+E*y+T*p,g=r[4],w=r[5],E=r[6],T=r[7],t[4]=g*n+w*o+E*f+T*m,t[5]=g*i+w*l+E*u+T*b,t[6]=g*s+w*c+E*d+T*_,t[7]=g*a+w*h+E*y+T*p,g=r[8],w=r[9],E=r[10],T=r[11],t[8]=g*n+w*o+E*f+T*m,t[9]=g*i+w*l+E*u+T*b,t[10]=g*s+w*c+E*d+T*_,t[11]=g*a+w*h+E*y+T*p,g=r[12],w=r[13],E=r[14],T=r[15],t[12]=g*n+w*o+E*f+T*m,t[13]=g*i+w*l+E*u+T*b,t[14]=g*s+w*c+E*d+T*_,t[15]=g*a+w*h+E*y+T*p,t}function P(){var t=new N(3);return N!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function k(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function C(t,e,r){var n=new N(3);return n[0]=t,n[1]=e,n[2]=r,n}function D(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function z(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function F(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function Y(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function H(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function V(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function Z(t,e){var r=e[0],n=e[1],i=e[2],s=r*r+n*n+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 G(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function j(t,e,r){var n=e[0],i=e[1],s=e[2],a=r[0],o=r[1],l=r[2];return t[0]=i*l-s*o,t[1]=s*a-n*l,t[2]=n*o-i*a,t}var q=Y,$=H,X=k;function K(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}function J(){var t=new N(4);return N!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function W(t,e,r,n){var i=e[0],s=e[1],a=e[2],o=e[3],l=r[0],c=r[1],h=r[2],f=r[3],u=void 0,d=void 0,y=void 0,m=void 0,b=void 0;return(d=i*l+s*c+a*h+o*f)<0&&(d=-d,l=-l,c=-c,h=-h,f=-f),1-d>1e-6?(u=Math.acos(d),y=Math.sin(u),m=Math.sin((1-n)*u)/y,b=Math.sin(n*u)/y):(m=1-n,b=n),t[0]=m*i+b*l,t[1]=m*s+b*c,t[2]=m*a+b*h,t[3]=m*o+b*f,t}P(),function(){var t,e=(t=new N(4),N!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var Q,tt=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};P(),C(1,0,0),C(0,1,0),J(),J(),Q=new N(9),N!=Float32Array&&(Q[1]=0,Q[2]=0,Q[3]=0,Q[5]=0,Q[6]=0,Q[7]=0),Q[0]=1,Q[4]=1,Q[8]=1;
|
|
13
13
|
/*!
|
|
14
|
-
* @maptalks/gltf-loader v0.25.
|
|
14
|
+
* @maptalks/gltf-loader v0.25.8
|
|
15
15
|
* LICENSE : UNLICENSED
|
|
16
16
|
* (c) 2016-2022 maptalks.org
|
|
17
17
|
*/
|
|
18
|
-
let et=0;function rt(t){return null==t}function nt(t){return!rt(t)}function it(t){for(let e=1;e<arguments.length;e++){const r=arguments[e];for(const e in r)t[e]=r[e]}return t}function st(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 at(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function ot(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),r=e.length,n=new Uint8Array(r);for(let t=0;t<r;t++)n[t]=e.charCodeAt(t);return n.buffer}const lt=[],ct=[],ht=[],ft=[0,0,0],ut=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),dt=[1,1,1];function yt(t,e,r,n,i,s,a){const o=st(a);if((0===i||i===n*o.BYTES_PER_ELEMENT)&&s%o.BYTES_PER_ELEMENT==0){const i=new o(e,s,r*n);return t.set(i),t}const l=new Uint8Array(n*o.BYTES_PER_ELEMENT);for(let a=0;a<r;a++){let r=null;const c=new Uint8Array(e,i*a+s,n*o.BYTES_PER_ELEMENT);l.set(c),r=new o(l.buffer,0,n);for(let e=0;e<n;e++)t[a*n+e]=r[e]}return t}const mt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function bt(t,e,r){const n=new Uint8Array(t,e,r);return mt.decode(n)}const pt={get:function(t,e={}){e||(e={});const r=new AbortController,n={signal:r.signal,method:e.method||"GET",referrerPolicy:"origin"};"POST"===e.method&&(rt(e.body)||(n.body=JSON.stringify(e.body))),rt(e.headers)||(n.headers=e.headers),rt(e.credentials)||(n.credentials=e.credentials);const i=fetch(t,n).then((t=>{const r=this.t(t,e.responseType);return r.message?r:r.then((r=>"arraybuffer"===e.responseType?{data:r,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:r)).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 i.xhr=r,i},t:(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={})=>(e||(e={}),e.responseType="arraybuffer",pt.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?pt.jsonp(t):((e=e||{}).responseType="json",pt.get(t,e))}};pt.jsonp=function(t){const e="_maptalks_jsonp_"+et++;t.match(/\?/)?t+="&callback="+e:t+="?callback="+e;let r=document.createElement("script");return r.type="text/javascript",r.src=t,new Promise((t=>{window[e]=function(n){document.getElementsByTagName("head")[0].removeChild(r),r=null,delete window[e],t(n)},document.getElementsByTagName("head")[0].appendChild(r)}))};class _t{constructor(t,e,r){this.i=t,this.decoders=e,this.o=r,this.images={},this.l={}}requestImageFromBufferURI(t,e,r){if(this.buffers[t.id]){const n=this.buffers[t.id],i=this.h(e,n);return this.getImageByBuffer(i,r)}if(this.l[t.id])return this.l[t.id].then((()=>{const n=this.buffers[t.id],i=this.h(e,n);return this.getImageByBuffer(i,r)}));if(at(t.uri)){const n=this.buffers[t.id]=ot(t.uri),i=this.h(e,n);return this.getImageByBuffer(i,r)}return this.l[t.id]=pt.getArrayBuffer(t.uri,null).then((n=>{const i=this.buffers[t.id]=n.data,s=this.h(e,i);return this.getImageByBuffer(s,r)}))}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const r=this.decoders;if(r[e.mimeType])return r[e.mimeType](t,{supportedFormats:this.o});if("image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType)return console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null);{if("image/dxt1"===e.mimeType||"image/dxt1a"===e.mimeType||"image/dxt3"===e.mimeType||"image/dxt5"===e.mimeType)return Promise.resolve({width:e.extras.width,height:e.extras.height,data:new Uint8Array(t)});const r=new Blob([t]),n=URL.createObjectURL(r);return this.u(e.id,n)}}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;if(this.l[t.id])return this.l[t.id].then((()=>this.images[t.id]));return this.l[t.id]=this.u(t.id,e)}u(t,e){return new Promise(((r,n)=>{this.i(e,((i,s)=>{i?n(i):(URL.revokeObjectURL(e),this.images[t]=s,r(this.images[t]))}))}))}}const gt=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class wt{constructor(t,e,r){this.rootPath=t,this.gltf=e,this.m=!1,this.glbBuffer=r,this.buffers={},this.requests={},this.accessors={},this.p()}_(t,e){const r=this.gltf,n=r.accessors[e];if(void 0===n.bufferView)return this.accessors[n.id]=this.g(t,e,null,0),Promise.resolve(this.accessors[n.id]);if(n&&this.accessors[n.id])return Promise.resolve(this.accessors[n.id]);const i=r.bufferViews[n.bufferView];return this.T(i).then((r=>{const{buffer:i,byteOffset:s}=r;return this.accessors[n.id]=this.g(t,e,i,s)}))}T(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(at(e.uri)){const t=this.buffers[e.id]=ot(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const r=e.uri.indexOf("blob:")>=0;t=e.uri.indexOf("://")>0||r?e.uri:this.rootPath+"/"+e.uri;return this.requests[e.id]=pt.getArrayBuffer(t,null).then((n=>{r&&URL.revokeObjectURL(t);return{buffer:this.buffers[e.id]=n.data,byteOffset:0}}))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}g(t,e,r,n=0){const i=this.gltf,s=i.accessors[e],a=void 0!==s.bufferView?i.bufferViews[s.bufferView]:{},o=(a.byteOffset||0)+n,l=this.A(s.type),c=st(s.componentType),h=a.byteStride||0;const f={array:undefined,name:t,accessorName:e,byteLength:s.count*l*c.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:l};if(s.min&&(f.min=s.min),s.max&&(f.max=s.max),r)if(this.m)f.byteStride=h,f.byteOffset=o+(s.byteOffset||0),!h||h===l*c.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(f.array=this.v(r,s.count,l,o+(s.byteOffset||0),c),f.array.buffer.byteLength===f.byteLength&&(f.byteOffset=0)):f.array=new Uint8Array(r,o,a.byteLength);else if(s.interleaved){f.byteStride=0,f.byteOffset=0;const t=new c(s.count*l);f.array=yt(t,r,s.count,l,h,o+(s.byteOffset||0),s.componentType)}else f.byteStride=0,f.array=this.v(r,s.count,l,o+(s.byteOffset||0),c),f.byteOffset=f.array.byteOffset;else{f.array=new c(s.count);const t=f.min||f.max;t&&(f.array[0]=t[0],f.array[1]=t[1],f.array[2]=t[2])}return f}p(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let r=0;r<t.length;r++)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0);else for(const e in t)for(const r in t)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0)}v(t,e,r,n,i){return n%i.BYTES_PER_ELEMENT!=0&&(t=t.slice(n,n+e*r*i.BYTES_PER_ELEMENT),n=0),new i(t,n,r*e)}A(t){const e=gt.indexOf(t);return gt[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,r=e.map((t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:r}=e;return this.T(e).then((n=>{const{buffer:i,byteOffset:s}=n,a=bt(i,s+(e.byteOffset||0),r);return t.content=a,t}))}if(t.uri){if(at(t.uri)){const e=ot(t.uri),r=bt(e,0,e.byteLength);return t.content=r,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return pt.get(e).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(r).then((()=>t))}}class Et extends _t{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=r,this.accessor=new wt(t,e,r)}iterate(t,e){const r=this.gltf[e];if(!r)return;let n=0;for(const e in r)t(e,r[e],n++)}createNode(t){const e={};if(nt(t.name)&&(e.name=t.name),nt(t.children)&&(e.children=t.children),nt(t.jointName)&&(e.jointName=t.jointName),nt(t.matrix)&&(e.matrix=t.matrix),nt(t.rotation)&&(e.rotation=t.rotation),nt(t.scale)&&(e.scale=t.scale),nt(t.translation)&&(e.translation=t.translation),nt(t.extras)&&(e.extras=t.extras),nt(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}(lt,e.translation||ft),n=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=r+r,o=n+n,l=i+i,c=r*a,h=n*a,f=n*o,u=i*a,d=i*o,y=i*l,m=s*a,b=s*o,p=s*l;return t[0]=1-f-y,t[1]=h+p,t[2]=u-b,t[3]=0,t[4]=h-p,t[5]=1-c-y,t[6]=d+m,t[7]=0,t[8]=u+b,t[9]=d-m,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(ct,e.rotation||ut),i=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}(ht,e.scale||dt);return B(i,n,i),B(t,r,i)}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}S(t){const e={};for(const r in t){const n=t[r];let i,s;n.instanceTechnique&&n.instanceTechnique.values?(i=n.instanceTechnique,s=i.values.diffuse):(i=n,s=i.values.tex||i.values.diffuseTex||i.values.diffuse);const a={"baseColorTexture":{index:s}};n.name&&(a.name=n.name),n.extensions&&(a.extensions=n.extensions),n.extras&&(a.extras=n.extras),e[r]=a}return e}U(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 r=this.gltf.bufferViews[e.bufferView],n=(r.byteOffset||0)+this.glbBuffer.byteOffset,i=r.byteLength,s=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,n,i);return this.getImageByBuffer(s,t)}return this.requestExternalImage(t)}O(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.U(r).then((t=>{const n=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extras:r.extras},sampler:n}}))}getBaseColorTexture(t){const e=this.gltf.materials[t];let r,n;if(e.instanceTechnique&&e.instanceTechnique.values?(r=e.instanceTechnique,n=r.values.diffuse):(r=e,n=r.values.tex||r.values.diffuseTex||r.values.diffuse),void 0===n||void 0===this.gltf.textures)return null;const i=this.gltf.textures[n];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}}class Tt extends _t{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.glbBuffer=r,this.buffers={},this.requests={},this.accessor=new wt(t,e,r)}iterate(t,e){const r=this.gltf[e];if(r)for(let e=0;e<r.length;e++)t(e,r[e],e)}createNode(t){const e={};return it(e,t),!nt(t.weights)&&this.gltf.meshes&&nt(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}O(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.U(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}};it(n,e);const i=nt(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return i&&(n.sampler=i),"image/dxt1"===r.mimeType?n.format=33776:"image/dxt1a"===r.mimeType?n.format=33777:"image/dxt3"===r.mimeType?n.format=33778:"image/dxt5"===r.mimeType&&(n.format=33779),t.format&&(n.format=t.format),n}))}U(t){if(!nt(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],r=this.gltf.buffers[e.buffer];if(r.uri)return this.requestImageFromBufferURI(r,e,t);if(this.glbBuffer)return this.I(e,t)}return null}I(t,e){const r=this.h(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(r,e)}h(t,e,r){r=r||0;const n=t.byteOffset+r,i=t.byteLength;return new Uint8Array(e,n,i)}L(t,e){const r=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)r[e]=String.fromCharCode(t[e]);r.join("");const n="data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(r)));return n}getAnimations(t){const e=[];return t.forEach((t=>{e.push(this.getSamplers(t.samplers))})),Promise.all(e).then((e=>{for(let r=0;r<e.length;r++)t[r].samplers=e[r];return t}))}getSamplers(t){const e=[];for(let r=0;r<t.length;r++)(nt(t[r].input)||nt(t[r].output))&&(e.push(this.accessor._("input",t[r].input)),e.push(this.accessor._("output",t[r].output)));return Promise.all(e).then((e=>{for(let r=0;r<e.length/2;r++)t[r].input=e[2*r],t[r].output=e[2*r+1],t[r].interpolation||(t[r].interpolation="LINEAR");return t}))}}const At="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null,vt=1313821514,xt=5130562;class St{static read(t,e=0,r=0){r||(r=t.byteLength);const n=new DataView(t,e,r),i=n.getUint32(4,!0);if(1===i)return St.readV1(n,e);if(2===i)return St.readV2(t,e);throw new Error("Unsupported glb version : "+i)}static readV1(t,e){const r=t.getUint32(8,!0),n=t.getUint32(12,!0);if(r!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const i=Ut(t.buffer,20+e,n);return{json:JSON.parse(i),glbBuffer:{byteOffset:20+e+n,buffer:t.buffer,byteLength:r}}}static readV2(t,e){let r,n,i;const s=new DataView(t,e+12);let a=0;for(;a<s.byteLength;){const o=s.getUint32(a,!0);a+=4;const l=s.getUint32(a,!0);if(a+=4,l===vt)r=Ut(t,e+12+a,o);else if(l===xt){i=e+12+a,n=o;break}a+=o}return{json:JSON.parse(r),glbBuffer:{byteOffset:i,buffer:t,byteLength:n}}}}function Ut(t,e,r){if(At){const n=new Uint8Array(t,e,r);return At.decode(n)}return function(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=Ot[i>>3&7];if(!(64&i)||!r||n+r>e)return null;for(i&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;i=i<<6|63&e}}r+=String.fromCharCode(i)}return r}(new Uint8Array(t,e,r))}const Ot=[1,1,1,1,2,2,3,0];const It=[0,0,0],Lt=[0,0,0,1],Mt=[1,1,1],Rt={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},Nt={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},Bt={M(t,e,r,n,i,s,a,o){const l=nt(t)?e.animations:[e.animations[0]],c={};for(let e=0;e<l.length;e++){const h=l[e],f=h.name||e;if(nt(t)&&f!==t)continue;const u=h.channelsMap[r];if(u)for(let t=0;t<u.length;t++){const e=u[t];"translation"===e.target.path?(this.R(i,h.samplers[e.sampler],n,1),c.translation=D(It,i)):"rotation"===e.target.path?(this.N(s,h.samplers[e.sampler],n,1),c.rotation=tt(Lt,s)):"scale"===e.target.path?(this.R(a,h.samplers[e.sampler],n,1),c.scale=D(Mt,a)):"weights"===e.target.path&&o&&(this.R(o,h.samplers[e.sampler],n,o.length),c.weights=o)}}return c},R(t,e,r,n){switch(e.interpolation){case"LINEAR":{const i=this.B(Nt,e,r,1*n);i&&(t=function(t,e,r,n){for(let i=0;i<t.length;i++)t[i]=e[i]+n*(r[i]-e[i]);return t}(t,i.PREVIOUS,i.NEXT,i.INTERPOLATION));break}case"STEP":{const i=this.B(Nt,e,r,1*n);i&&(t=function(t,e){for(let r=0;r<t.length;r++)t[r]=e[r];return t}(t,...i.PREVIOUS));break}case"CUBICSPLINE":{const i=this.B(Nt,e,r,3*n);i&&(t=this.P(t,i,e.input.array,3*n));break}}return t},N(t,e,r){switch(e.interpolation){case"LINEAR":{const n=this.B(Nt,e,r,1);n&&W(t,n.PREVIOUS,n.NEXT,n.INTERPOLATION);break}case"STEP":{const n=this.B(Nt,e,r,1);n&&(t=K(t,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.B(Nt,e,r,3);if(n){for(let t=0;t<n.PREVIOUS.length;t++)n.PREVIOUS[t]=Math.acos(n.PREVIOUS[t]),n.NEXT[t]=Math.acos(n.NEXT[t]);t=this.P(t,n,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},k(t,e){const r=t.length;let n,i,s,a=0,o=r-1,l=Math.floor((a+o)/2);for(;a<=r-1&&o>=0;){if(a===o)return null;if(t[l]<=e&&e<=t[l+1]){const r=t[l];return n=l,i=l+1,s=(e-r)/(t[l+1]-r),{preIndx:n,nextIndex:i,interpolation:s}}e<t[l]?(o=l,l=Math.floor((a+o)/2)):t[l+1]<e&&(a=l,l=Math.floor((a+o)/2))}return null},B(t,e,r,n){const i=e.input.array,s=e.output.array,a=e.output.itemSize;(r<i[0]||r>i[i.length-1])&&(r=Math.max(i[0],Math.min(i[i.length-1],r))),r===i[i.length-1]&&(r=i[0]);const o=this.k(i,r);if(!o||!o.nextIndex)return null;const{preIndx:l,nextIndex:c,interpolation:h}=o;t.PREINDEX=l,t.NEXTINDEX=c,t.INTERPOLATION=h;const f=a*n;return t.PREVIOUS=s.subarray(t.PREINDEX*f,(t.PREINDEX+1)*f),t.NEXT=s.subarray(t.NEXTINDEX*f,(t.NEXTINDEX+1)*f),t},P(t,e,r,n){const i=e.INTERPOLATION,s=r[e.PREINDEX],a=r[e.NEXTINDEX];for(let r=0;r<3;r++){const o=e.PREVIOUS[n+r],l=(a-s)*e.PREVIOUS[2*n+r],c=e.NEXT[3+r],h=(a-s)*e.NEXT[r],f=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*o+(Math.pow(i,3)-2*Math.pow(i,2)+i)*l+(2*-Math.pow(i,3)+3*Math.pow(i,2))*c+(Math.pow(i,3)-Math.pow(i,2))*h;t[r]=f}return t},getAnimationClip(t,e,r,n){const i=t.nodes[e]&&t.nodes[e].weights;z(It,...Rt.TRANSLATION),K(Lt,...Rt.ROTATION),z(Mt,...Rt.SCALE);return this.M(n,t,e,r,It,Lt,Mt,i)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach(((e,r)=>{let n=-1/0,i=1/0;const s=e.channels;for(let t=0;t<s.length;t++){const r=s[t],a=e.samplers[r.sampler].input.array;a[a.length-1]>n&&(n=a[a.length-1]),a[0]<i&&(i=a[0])}const a=e.name||r;t.timeSpan[a]={max:n,min:i}})),t.timeSpan},getTimeSpanByName(t,e){const r=this.getTimeSpan(t);return r?nt(e)?r[e]:r[Object.keys(r)[0]]:null}};let Pt=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(t){}t&&"undefined"!=typeof createImageBitmap&&(Pt=!0)}const kt="undefined"==typeof document?null:document.createElement("canvas");class Ct{constructor(t,e,r){if(this.options=r||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:r,glbBuffer:n}=St.read(e.buffer,e.byteOffset,e.byteLength);this.C(t,r,n)}else this.C(t,e);this.D=new wt(this.rootPath,this.gltf,this.glbBuffer),this.F()}F(){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.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}Y(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.D.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.H(t),r=this.V(),n=this.Z(),i=this.Y();return Promise.all([e,r,n,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 r=e[t];r.channelsMap={};for(let t=0;t<r.channels.length;t++){const e=r.channels[t];r.channelsMap[e.target.node]||(r.channelsMap[e.target.node]=[]),r.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:r}=this.gltf;for(let r=0;r<e.length;r++)e[r].uri&&e[r].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[r].uri});for(let e=0;e<r.length;e++)r[e].uri&&r[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:r[e].uri})}return t}static getAnimationClip(t,e,r,n){return Bt.getAnimationClip(t,e,r,n)}static getAnimationTimeSpan(t,e){return Bt.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return st(t)}static readInterleavedArray(t,e,r,n,i,s,a){return yt(t,e,r,n,i,s,a)}C(t,e,r){this.gltf=e,this.glbBuffer=r,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=Pt?Yt.bind(this):this.options.requestImage||Dt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new Tt(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="buffer_"+r}),"buffers"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors")):(this.adapter=new Et(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"))}G(t,e){if(t.children&&t.children.length>0){if(!(r=t.children[0],"number"==typeof r&&isFinite(r)||function(t){return!rt(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}(t.children[0])))return t;const n=t.children.map((t=>{const r=e[t];return r.nodeIndex=t,this.G(r,e)}));t.children=n}var r;return t}H(t){return this.j(t).then((t=>{const e=this.scenes=[];let r;for(const e in t)t[e]=this.G(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate(((n,i,s)=>{const a={};i.name&&(a.name=i.name),i.nodes&&(a.nodes=i.nodes.map((e=>t[e]))),this.gltf.scene===n&&(r=s),e.push(a)}),"scenes");const n={asset:this.gltf.asset,scene:r,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins};if(this.gltf.extensions&&(n.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.S(this.gltf.materials);n.materials=t}return n}))}j(t){return this.q(t).then((()=>{const t=this.nodes={};return this.adapter.iterate(((e,r)=>{const n=this.adapter.createNode(r,this.meshes,this.skins);t[e]=n}),"nodes"),t}))}$(){this.skins=[];const t=[];return this.adapter.iterate(((e,r,n)=>{t.push(this.X(r).then((t=>{t.index=n,this.skins.push(t)})))}),"skins"),t}X(t){const e=t.inverseBindMatrices;return this.adapter.accessor._("inverseBindMatrices",e).then((e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t)))}V(){const t=this.gltf.animations;return nt(t)?this.adapter.getAnimations(t):null}q(t){this.meshes={};let e=[];return this.adapter.iterate(((r,n,i)=>{e.push(this.K(n,t).then((t=>{t.index=i,this.meshes[r]=t})))}),"meshes"),e=e.concat(this.$()),Promise.all(e)}K(t,e){const r=t.primitives.map((t=>this.J(t,e))).filter((t=>!!t));return Promise.all(r).then((e=>{const r={};return it(r,t),r.primitives=e,r}))}Z(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const r in t)e.push(this.adapter.O(r));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++){const r=e[t].image.array;if(e[t]&&r){let t;t=r instanceof ImageBitmap?r:r.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const r={},n=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(r[n[t]]=e[t]);return r}return e}))}J(t,e){let r;const n=[],i=t.extensions;if(nt(t.targets))for(let e=0;e<t.targets.length;e++){const r=t.targets[e];for(const t in r){const i=this.adapter.accessor._(`morphTargets_${t}_${e}`,r[t]);i&&n.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:a}=i.KHR_draco_mesh_compression,o=this.gltf.bufferViews[s],l=this.D.T(o).then((r=>{const{buffer:n,byteOffset:i}=r;let{byteOffset:s,byteLength:l}=o;s||(s=0);const c=new DataView(n,i+s,l),h={attributes:a,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(c,h).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));n.push(l),r=Promise.all(n)}else{const e=t.attributes;for(const t in e){const r=this.adapter.accessor._(t,e[t]);r&&n.push(r)}if(nt(t.indices)){const e=this.adapter.accessor._("indices",t.indices);e&&n.push(e)}r=Promise.all(n)}return r.then((e=>{if(i&&i.KHR_draco_mesh_compression){const r=t.targets?t.targets.length:0;e[r]=e[r].concat(e.slice(0,r)),e=e[r]}let r,n;const s=e.reduce(((t,e)=>{if("indices"===e.name)r=e;else if(e.name.indexOf("morphTargets_")>-1)n=n||{},n[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0],{itemSize:n,array:i}=e,s=i.length/n;for(let e=0;e<s;e++)for(let s=0;s<n;s++){const a=e*n+s;i[a]<t[s]&&(t[s]=i[a]),i[a]>r[s]&&(r[s]=i[a])}if(e.quantization){const n=e.quantization,i=n.range/(1<<n.quantizationBits),s=n.minValues;V(t,t,i),F(t,t,s),V(r,r,i),F(r,r,s)}e.min=t,e.max=r}t[e.name]=e}return this.transferables&&e.array.buffer&&this.transferables.indexOf(e.array.buffer)<0&&this.transferables.push(e.array.buffer),t}),{}),a={attributes:s,material:t.material};return r&&(a.indices=r),n&&(a.morphTargets=n),a.mode=nt(t.mode)?t.mode:4,nt(t.extras)&&(a.extras=t.extras),a}))}}function Dt(t,e){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!kt)return void e(new Error("There is no canvas to draw image!"));kt.width=r.width,kt.height=r.height;const t=kt.getContext("2d");t.drawImage(r,0,0,r.width,r.height);const n=t.getImageData(0,0,r.width,r.height),i={width:r.width,height:r.height,data:new Uint8Array(n.data)};e(null,i)},r.onerror=function(t){e(t)},r.src=t}let zt,Ft;function Yt(t,e){zt||(zt=new OffscreenCanvas(2,2),Ft=zt.getContext("2d")),fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{let{width:r,height:n}=t;Ht(r)||(r=Vt(r)),Ht(n)||(n=Vt(n));const i=this.options.maxTextureSize;i&&(r=Math.min(i,r)),i&&(n=Math.min(i,n)),zt.width=r,zt.height=n,Ft.drawImage(t,0,0,r,n),t.close();const s=Ft.getImageData(0,0,r,n);e(null,{width:r,height:n,data:new Uint8Array(s.data)})})).catch((t=>{console.warn(t),e(t)}))}function Ht(t){return 0==(t&t-1)&&0!==t}function Vt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}const Zt="undefined"==typeof document?null:document.createElement("canvas");class Gt extends t.worker.Actor{constructor(t,e){super(t),this.mapId=e}initialize(t){t(null)}loadTile(t,e,r){let n=null;e&&e.arraybuffer&&(n=[e.arraybuffer]);const i={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(i,n,r)}abortTileLoading(t,e,r){const n={mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}};this.broadcast(n,null,r)}addLayer(t,e,r){const n={actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}};this.broadcast(n,null,r)}removeLayer(t,e){const r={mapId:this.mapId,layerId:t,command:"removeLayer"};this.broadcast(r,null,e)}requestImage({url:t},e){const r=new Image;r.onload=()=>{if(!this.isActive())return;if(!Zt)return void e(new Error("There is no canvas to draw image!"));const t=function(t){if(jt(t.width)&&jt(t.height))return t;let e=t.width,r=t.height;jt(e)||(e=qt(e));jt(r)||(r=qt(r));const n=document.createElement("canvas");n.width=e,n.height=r,n.getContext("2d").drawImage(t,0,0,e,r);const i=t.src,s=i.lastIndexOf("/")+1,a=i.substring(s);return console.warn(`Texture(${a})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${r})`),n}(r);Zt.width=t.width,Zt.height=t.height;const n=Zt.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),s={width:t.width,height:t.height,data:new Uint8Array(i.data)};e(null,s,[s.data.buffer])},r.onerror=function(t){e(t)},r.src=t}}function jt(t){return 0==(t&t-1)&&0!==t}function qt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}class $t{constructor(t,e){this.max=t,this.currentSize=0,this.onRemove=e,this.reset()}reset(){if(this.data){const t=this.data.values();for(const e of t)this.onRemove(e)}return this.data=new Map,this.currentSize=0,this}clear(){this.reset(),delete this.onRemove}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const r=this.data.get(t);r&&r.node&&r.node.memorySize&&(this.currentSize-=r.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){const t=this.data.keys();let e=t.next();for(;this.currentSize>this.max&&void 0!==e.value;){if(!this.data.get(e.value).current){const t=this.getAndRemove(e.value);t&&this.onRemove(t)}e=t.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const r=this.data.keys();for(let n of r)t[e++]=n;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 e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e),this}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const r of e){const e=r&&r.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t){const e=this.data.values();for(const r of e)r.current=t}}function Xt(t,e){if(t.scenes&&t.scenes.length)for(let r=0,n=t.scenes.length;r<n;r++){const n=t.scenes[r].nodes;for(let r=0,i=n.length;r<i;r++){const i=[];Kt(n[r],i,t,e)}}}function Kt(t,e,r,n){if(t.matrix&&e.push(t.matrix),t.children&&t.children.length)for(let i=0,s=t.children.length;i<s;i++)Kt(t.children[i],e,r,n);if(void 0!==t.mesh){const i=t.mesh,s=r.meshes[i];if(s){const t=e.slice(0),a=s.primitives;for(let e=0,s=a.length;e<s;e++){const s=a[e];s&&(s.matrices=t,n(s,i,e,r))}}}}function Jt(t,e,r){let{componentType:n,byteOffset:i,byteStride:s,itemSize:a}=e;const o=e.array.buffer,l=n?Ct.getTypedArrayCtor(n):e.array.constructor;if(i=void 0===i?e.array.byteOffset:i,s=s||0,!s||s===a*l.BYTES_PER_ELEMENT&&i%l.BYTES_PER_ELEMENT==0){const e=new l(o,i+r*a*l.BYTES_PER_ELEMENT,a);return t.set(e),t}s||(s=a*l.BYTES_PER_ELEMENT);const c=new Uint8Array(o,s*r+i,a*l.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(c),t}function Wt(t,e,r,n){t[4*e]=r[n],t[4*e+1]=r[n+4],t[4*e+2]=r[n+8],t[4*e+3]=r[n+12]}const Qt=new Array(3),te=new Array(3),ee=[40680631590769,40680631590769,40408299984661.445];function re(t,e,r,n){const i=ee,s=Math.cos(r);Qt[0]=s*Math.cos(e),Qt[1]=s*Math.sin(e),Qt[2]=Math.sin(r),ue(Qt,Qt),H(te,i,Qt);const a=Math.sqrt(G(Qt,te));var o,l,c;return l=te,c=a,(o=te)[0]=l[0]/c,o[1]=l[1]/c,o[2]=l[2]/c,V(Qt,Qt,n),F(t,te,Qt)}const ne=[1/6378137,1/6378137,1/6356752.314245179],ie=[1/40680631590769,1/40680631590769,1/40408299984661.445],se=new Array(3),ae=new Array(3),oe=new Array(3);function le(t,e){const r=ie,n=function(t,e,r,n,i){const s=e[0],a=e[1],o=e[2],l=r[0],c=r[1],h=r[2],f=s*s*l*l,u=a*a*c*c,d=o*o*h*h,y=f+u+d,m=Math.sqrt(1/y),b=V(ce,e,m);if(y<i)return isFinite(m)?b:void 0;const p=n[0],_=n[1],g=n[2],w=he;w[0]=b[0]*p*2,w[1]=b[1]*_*2,w[2]=b[2]*g*2;let E,T,A,v,x,S,U,O,I,L,M,R=(1-m)*fe(e)/(.5*fe(w)),N=0;do{R-=N,A=1/(1+R*p),v=1/(1+R*_),x=1/(1+R*g),S=A*A,U=v*v,O=x*x,I=S*A,L=U*v,M=O*x,E=f*S+u*U+d*O-1,T=f*I*p+u*L*_+d*M*g;N=E/(-2*T)}while(Math.abs(E)>1e-12);return t[0]=s*A,t[1]=a*v,t[2]=o*x,t}(se,e,ne,r,.1);let i=$(ae,n,r);i=ue(i,i);const s=q(oe,e,n),a=Math.atan2(i[1],i[0]),o=Math.asin(i[2]),l=v(G(s,e))*fe(s);return t[0]=T(a),t[1]=T(o),t[2]=l,t}const ce=new Array(3),he=new Array(3);function fe(t){return k(t)}function ue(t,e){const r=e[0],n=e[1],i=e[2];let s=r*r+n*n+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function de(t,e){return H(e,t,ie),Z(e,e)}var ye=Object.freeze({__proto__:null,radianToCartesian3:re,cartesian3ToDegree:le,normalizeCartesian:ue,geodeticSurfaceNormal:de});function me(t,e){let r="";for(let n=0;n<4;n++){const i=t.getUint8(e+n);r+=String.fromCharCode(i)}return r}const be="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function pe(t,e,r){const n=new Uint8Array(t,e,r);return be?JSON.parse(be.decode(n)):JSON.parse(S(n))}function _e(t,e,r){const n=new Uint8Array(t,e,r);return be?JSON.parse(be.decode(n)):JSON.parse(S(n))}function ge(t,e,r){return{offset:e,byteLength:r}}function we(t,e,r,n){const{byteOffset:i,componentType:s,type:a}=t,{ctor:o,type:l}=function(t){return Ae[t]}(s),c=function(t){if(!t)return 1;return Te[t]}(a);return{byteStride:0,byteOffset:i+r,itemSize:c,count:n*c,componentType:l,array:new o(e,r+i,n*c)}}function Ee(t,e,r,n){t.componentType||(t.componentType="UNSIGNED_SHORT");const i=we(t,e,r,n);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}const Te={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Ae={"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 ve(t){for(let e in Ae)if(t===Ae[e].ctor)return Ae[e].type;throw new Error("unrecognized ctor:"+t)}function xe(t,e,r,n){const i=t,s=e.length/3;for(let t=0;t<s;t++)i[3*t]=e[3*t]/65535*n[0]+r[0],i[3*t+1]=e[3*t+1]/65535*n[1]+r[1],i[3*t+2]=e[3*t+2]/65535*n[2]+r[2];return i}function Se(t,e,r){let n=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),a=t.getUint32(24,!0);const o=t.buffer;let l,c,h={},f={};n>0&&(h=pe(o,e,n),e+=n),i>0&&(l=function(t,e,r){return{offset:e,byteLength:r}}(0,e,i),e+=i),s>0&&(f=_e(o,e,s),e+=s);const u=ge(0,e,a);return c=o.slice(u.offset,u.offset+u.byteLength),r.push(c),{featureTable:h,featureTableBin:l,batchTable:f,batchTableBin:c}}var Ue={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Oe={},Ie={east:[],north:[],up:[],west:[],south:[],down:[]},Le=[],Me=[],Re=[];const Ne=[0,0,0];function Be(t,e,r,n){r=r||0,n=n||r;var i=Math.abs(t-e);return i<=n||i<=r*Math.max(Math.abs(t),Math.abs(e))}function Pe(t,e,r){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=e[0],r[13]=e[1],r[14]=e[2],r[15]=t[15],r}const ke=(Fe={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"}}[Ce="east"][De="north"],Oe[Ye=Ce+De]?ze=Oe[Ye]:(ze=function(t,e,r){if(o=Ne,l=(a=t)[0],c=a[1],h=a[2],f=o[0],u=o[1],d=o[2],Math.abs(l-f)<=1e-6*Math.max(1,Math.abs(l),Math.abs(f))&&Math.abs(c-u)<=1e-6*Math.max(1,Math.abs(c),Math.abs(u))&&Math.abs(h-d)<=1e-6*Math.max(1,Math.abs(h),Math.abs(d)))D(Le,Ue[Ce]),D(Me,Ue[De]),D(Re,Ue[Fe]);else if(Be(t[0],0,1e-14)&&Be(t[1],0,1e-14)){var n=v(t[2]);D(Le,Ue[Ce]),"east"!==Ce&&"west"!==Ce&&V(Le,Le,n),D(Me,Ue[De]),"east"!==De&&"west"!==De&&V(Me,Me,n),D(Re,Ue[Fe]),"east"!==Fe&&"west"!==Fe&&V(Re,Re,n)}else{de(t,Ie.up);var i=Ie.up,s=Ie.east;s[0]=-t[1],s[1]=t[0],s[2]=0,Z(Ie.east,s),j(Ie.north,i,s),V(Ie.down,Ie.up,-1),V(Ie.west,Ie.east,-1),V(Ie.south,Ie.north,-1),Le=Ie[Ce],Me=Ie[De],Re=Ie[Fe]}var a,o,l,c,h,f,u,d;return r[0]=Le[0],r[1]=Le[1],r[2]=Le[2],r[3]=0,r[4]=Me[0],r[5]=Me[1],r[6]=Me[2],r[7]=0,r[8]=Re[0],r[9]=Re[1],r[10]=Re[2],r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r},Oe[Ye]=ze),ze);var Ce,De,ze,Fe,Ye;const He=[],Ve=[],Ze=[],Ge=[],je=[],qe=[],$e=[],Xe={x:0,y:0},Ke={x:0,y:0},Je=Math.PI/180;const{getTextureMagFilter:We,getTextureMinFilter:Qe,getTextureWrap:tr,getMaterialType:er,getMaterialFormat:rr,getPrimitive:nr,getUniqueREGLBuffer:ir}=r.REGLHelper,sr=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],ar=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:or,logoutIBLResOnCanvas:lr,getIBLResOnCanvas:cr,getPBRUniforms:hr}=r.pbr.PBRUtils,fr={factor:0,units:0},ur={specularStrength:0,materialShininess:1},dr=[1,1,1],yr=n.identity([]),mr=t=>t.material instanceof r.PhongMaterial,br=t=>t.material instanceof r.pbr.StandardMaterial,pr=[!0,!0,!0,!0],_r=[],gr=new t.Coordinate(0,0),wr=[],Er=[],Tr={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT"};class Ar{constructor(e,n){this.W=n,this.tt=n.getRenderer().canvas,this.et=new t.SpatialReference,this.rt=e,this.nt=new r.Renderer(e),this.it={},this.st={},this.at={},this.ot={},this.lt={},this.ct={},this.ht={},this.ft=new r.Scene,this.ut=new r.Scene,this.dt=new r.Scene,this.yt=new r.Scene,this.bt=new r.ResourceLoader(e.texture(2)),this._t=this.gt.bind(this),this.wt=new r.PhongMaterial({"baseColorFactor":[1,1,1,1]}),this.Et(),this.Tt=new r.KHRTechniquesWebglManager(this.rt,this.At(),this.bt)}getI3DMMeshes(){return this.lt}getPNTSMeshes(){return this.ot}getB3DMMeshes(){return this.at}getMap(){return this.W.getMap()}paint(t,e,r,n){const i=this.getMap();if(!t.length||!i)return;const s=this.vt(),a=i.projViewMatrix,o=this.W.options.services,l=[];let c=[];for(let r=0,n=t.length;r<n;r++){let n=this.xt(t[r].data.node);if(!n){if(n=this.ct[t[r].data.node.id],!n)continue;n=O(n)}const i=t[r].node;let h=o[i.St].polygonOffset||fr;w(h)&&(h=h());const f=o[i.St].ambientLight;for(let o=0,u=n.length;o<u;o++)"b3dm"===n[o].properties.magic&&(n[o].getBoundingBox&&!d(a,n[o].getBoundingBox())||(n[o].properties.level=t[r].selectionDepth,n[o].properties.polygonOffset=h,Object.prototype.hasOwnProperty.call(n[o].uniforms,"ambientColor")||Object.defineProperty(n[o].uniforms,"ambientColor",{enumerable:!0,get:function(){return f||s.ambientColor}}),n[o].Ut=i,e[i.id]||l.push(n[o]),c.push(n[o])))}let h=0;const f=this.Tt.getExcludeFilter();h+=this.Ot(this.It,s,[r,mr,f],n,l,c),h+=this.Ot(this.Lt,s,[r,br,f],n,l,c),this.Tt.forEachShader(((t,e,i)=>{const s=this.vt(i);h+=this.Ot(t,s,[r,e],n,l,c)}));const u=[];for(const t in this.ot)u.push(this.ot[t]);this.ut.setMeshes(u);const y=this.Mt();return h+=this.nt.render(this.Rt,y,this.ut,n&&n.fbo),h}Ot(t,e,r,n,i,s){t.filter=r.filter((t=>!!t)),e.debug=!1,this.ft.setMeshes(i),e.stencilEnable=!1,e.debug=!1,e.cullFace="back",e.colorMask=pr;let a=0;this.ft.setMeshes(s),a+=this.nt.render(t,e,this.ft,n&&n.fbo),e.stencilEnable=!1;const o=[];for(const t in this.lt)o.push(...this.lt[t]);return this.dt.setMeshes(o),a+=this.nt.render(t,e,this.dt,n&&n.fbo),a}Nt(t,e){return e.Ut.Bt-t.Ut.Bt}paintRegion(t,e,r,n,i){const s=this.getMap();if(!t.length&&!e.length)return;const a=s.projViewMatrix,o=[];for(let r=0,n=(t=t.concat(e)).length;r<n;r++){const e=t[r].node,n=this.Pt(e);n&&(n.getBoundingBox&&!d(a,n.getBoundingBox())||o.push(n))}this.kt.filter=n,this.yt.setMeshes(o);const l=this.Ct(r);this.nt.render(this.kt,l,this.yt,i&&i.fbo)}deleteTile(t){const e=t.node.id;this.Dt(e)}Dt(t){const e=this.st[t];e&&(e.geometry.dispose(),e.dispose(),delete this.st[t]);let r=this.at[t]||this.ot[t]||this.lt[t]||this.ct[t]||this.it[t];this.ct[t]?this.zt(t):r&&(this.Ft(r),delete this.at[t],delete this.ot[t],delete this.lt[t],delete this.it[t])}zt(t){let e=this.ct[t];e=O(e);for(let t=0;t<e.length;t++){const{id:r}=e[t].properties;this.Dt(r)}delete this.ct[t]}Ft(t){if(Array.isArray(t))for(let e=0,r=t.length;e<r;e++)this.Ft(t[e]);else{const e=t.geometry.properties.url;if(e){const t=this.ht[e];t&&(t.refCount--,t.refCount<=0&&(t.geometry.dispose(),t.material.dispose(),delete this.ht[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.W;lr(t.getRenderer().canvas,t.getMap());for(const t in this.ct)this.zt(t);this.ct={};for(const t in this.at)this.Dt(t);this.at={};for(const t in this.ot)this.Dt(t);this.ot={};for(const t in this.lt)this.Dt(t);this.lt={};for(const t in this.it)this.Dt(t);this.it={};for(const t in this.st)this.Dt(t);this.st={},this.It&&(this.It.dispose(),delete this.It),this.Lt&&(this.Lt.dispose(),delete this.Lt),this.Rt&&(this.Rt.dispose(),delete this.Rt),this.kt&&(this.kt.dispose(),delete this.kt),this.Tt.dispose()}Pt(e){if(!e.boundingVolume||!e.boundingVolume.region)return null;if(this.st[e.id])return this.st[e.id];const i=e.boundingVolume.region;let s=new t.Coordinate(T(i[0]),T(i[1])),a=new t.Coordinate(T(i[2]),T(i[3]));s=this.Yt(s),a=this.Yt(a);const o=s.add(a).Ht(.5);s._sub(o),a._sub(o);const l=this.Vt(i[4],i[5]),c=l.x,h=l.y,f=[s.x,s.y,h,a.x,s.y,h,a.x,a.y,h,s.x,a.y,h,s.x,s.y,c,a.x,s.y,c,a.x,a.y,c,s.x,a.y,c],u=new r.Geometry({aPosition:f},[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],0,{primitive:"lines"});u.generateBuffers(this.rt);const d=new r.Mesh(u),y=n.identity([]);return d.setLocalTransform(n.translate(y,y,[o.x,o.y,0])),this.st[e.id]=d,d}xt(t){return this.at[t.id]}has(t){return this.xt(t)||this.ot[t.id]||this.lt[t.id]||this.ct[t.id]||this.it[t.id]}createPntsMesh(t,e,i,s){if(this.ot[e]){const t=this.ot[e];return console.warn(`pnts mesh with id(${e}) was already created.`),s(null,{id:e,mesh:t}),t}const{pnts:a,featureTable:o,rootIdx:l}=t,c=o.POINTS_LENGTH,h=new r.Geometry(a,null,c,{primitive:"points",positionAttribute:"POSITION"});h.generateBuffers(this.rt);const f={};a.POSITION?f.HAS_POSITION=1:a.POSITION_QUANTIZED&&(f.HAS_POSITION_QUANTIZED=1),a.RGB?f.HAS_RGB=1:a.RGBA?f.HAS_RGBA=1:a.RGB565&&(f.HAS_RGB565=1),(a.NORMAL||a.NORMAL_OCT16P)&&(f.HAS_NORMAL=1,a.NORMAL_OCT16P&&(f.HAS_NORMAL_OCT16P=1)),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:u,rtcCoord:d}=t,y=this.Zt(d),m=this.Gt(i,u,d);n.multiply(m,m,y);const b=this.W.options.services[l],p=new r.Mesh(h);return p.properties.magic="pnts",p.properties.id=e,p.properties.count=c,p.properties.batchTable=t.batchTable,p.properties.batchTableBin=t.batchTableBin,p.setDefines(f),Object.defineProperty(p.uniforms,"pointColor",{enumerable:!0,get:function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:b&&b.pointColor||[1,1,1,1]}}),Object.defineProperty(p.uniforms,"pointSize",{enumerable:!0,get:function(){return b&&b.pointSize||2}}),Object.defineProperty(p.uniforms,"pointOpacity",{enumerable:!0,get:function(){return b&&b.pointOpacity||1}}),p.setLocalTransform(m),this.ot[e]=p,s(null,{id:e,mesh:[p]}),[p]}createI3DMMesh(t,e,s,a){if(this.lt[e]){const t=this.lt[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.it[e]||a(null,{id:e,mesh:t}),t}const l=this.jt(s.qt),{i3dm:c,featureTable:h,gltf:f,batchTable:u,batchTableBin:d,count:y}=t,m=h.INSTANCES_LENGTH,{rtcCenter:b,rtcCoord:p}=t,_=this.Zt(p),g=this.Gt(s,b,p),{POSITION:w,NORMAL_UP:E,NORMAL_RIGHT:T,SCALE:A,SCALE_NON_UNIFORM:v,INSTANCE_ROTATION:x}=c,S={"instance_vectorA":new Float32Array(4*m),"instance_vectorB":new Float32Array(4*m),"instance_vectorC":new Float32Array(4*m)},O=new Float32Array(3),I=new Float32Array(3),L=[],M=new Float32Array(1),R=new Float32Array(3),N=[],B=[],P=[],k=[],C=new Float32Array(9);!function(t,e){let{componentType:r,byteOffset:n,byteStride:i,count:s,itemSize:a}=t;const o=t.array.buffer,l=r?Ct.getTypedArrayCtor(r):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,i=i||0,s=s||t.array.length/a,(!i||i===a*l.BYTES_PER_ELEMENT)&&n%l.BYTES_PER_ELEMENT==0){const t=new l(o,n,s*a);for(let r=0;r<s*a;r+=a)e(new l(t.buffer,n+r*l.BYTES_PER_ELEMENT,a),r/a);return}const c=new Uint8Array(a*l.BYTES_PER_ELEMENT);i||(i=a*l.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const r=new Uint8Array(o,i*t+n,a*l.BYTES_PER_ELEMENT);c.set(r),e(new l(c.buffer),t),r.set(c)}}(w,((t,e)=>{E?(Jt(I,T,e),Jt(O,E,e),i.cross(L,I,O),i.normalize(L,L),U(N,I,0),U(N,O,1),U(N,L,2),o.fromMat3(B,N)):x?(Jt(C,x,e),o.fromMat3(B,C)):o.identity(B),A?(Jt(M,A,e),i.set(P,M[0],M[0],M[0])):v?(Jt(R,v,e),i.set(P,...R)):i.set(P,1,1,1),n.fromRotationTranslationScale(k,B,t,P),Wt(S.instance_vectorA,e,k,0),Wt(S.instance_vectorB,e,k,1),Wt(S.instance_vectorC,e,k,2)}));const D={};for(const t in S)D[t]={buffer:this.rt.buffer({dimension:S[t].length/m,data:S[t]}),divisor:1};const z=this.W.options.services[s.St].shader||"phong";let F=0,Y=!0;const H=[];return Xt(f,((t,i,a,o)=>{let{geometry:c,material:h}=this.$t(t,i,a,o,s,!0,z);h&&!h.isReady()&&(Y=!1,F++);const f=new r.InstancedMesh(D,m,c,h);f.properties.magic="i3dm",f.properties.id=e,f.properties.count=y,f.properties.batchTable=u,f.properties.batchTableBin=d;const b=this.Xt(t,c,h,s.St),p=n.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.multiply(p,p,t.matrices[e]);n.multiply(p,l,p),f.setPositionMatrix(p),n.multiply(_,g,_),f.setLocalTransform(_),f.setDefines(b),f.properties.polygonOffset={offset:0,factor:0},H.push(f)})),Y?(this.lt[e]=H,a(null,{id:e,mesh:H})):(this.it[e]={meshes:H,count:F},H.Kt=a),H}createB3DMMesh(e,i,s,a){if(this.at[i]||this.it[i]){const t=this.at[i];return console.warn(`mesh with id(${i}) was already created.`),this.it[i]||a(null,{id:i,mesh:t}),t}let o;if(s.maxExtent){const e=new t.Extent(s.maxExtent).convertTo((t=>this._pointToPrj(t)));o=[e.xmin,e.ymin,e.xmax,e.ymax]}const l=this.jt(s.qt),c=e.gltf,{center:h,coord:f}=c.extensions.CESIUM_RTC,u=this.W.options.services[s.St].heightOffset||0;u&&(f[2]+=u);const d=this.Zt(f,s.St),y=this.W.options.services[s.St].shader||"phong",m=[];let b=0,p=!0;return Xt(c,((t,a,c,u)=>{let{geometry:_,material:g}=this.$t(t,a,c,u,s,!1,y);g&&!g.isReady()&&(p=!1,b++);const w=new r.Mesh(_,g);w.properties.magic="b3dm",w.properties.id=i,w.properties.batchTable=e.batchTable,w.properties.batchTableBin=e.batchTableBin,w.properties.count=e.featureTable.BATCH_LENGTH;const E=this.Xt(t,_,g,s.St);w.setDefines(E),o&&(E.USE_MAX_EXTENT=1,w.setUniform("maxPrjExtent",o));let T=n.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.multiply(T,T,t.matrices[e]);const A=this.Gt(s,h,f);n.multiply(T,l,T),n.multiply(T,d,T),n.multiply(T,A,T),w.setLocalTransform(T),m.push(w)})),p?(this.at[i]=m,a(null,{id:i,mesh:m})):(this.it[i]={meshes:m,count:b},m.Kt=a),m}Gt(e,r,s){const a=this.getMap(),o=this.W.options.services[e.St].heightOffset||0,l=new t.Coordinate(s),c=a.distanceToPointAtRes(100,0,a.getGLRes(),l).x/100;let h=e.matrix?n.copy([],e.matrix):n.identity([]);if(r){Pe(h,i.transformMat4(_r,r,h),h)}const f=function(t,e,r,n,i,s,a){e=D(He,e);const o=re(He,e[0]*Je,e[1]*Je,e[2]),l=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(Ve,r),c=n.ellipsoid;var h;h=0===X(l)?z(Ze,0,0,-6378137):le(Ze,l),Xe.x=h[0],Xe.y=h[1];const f=n.project(Xe,Ke);Ge[0]=f.x/i,Ge[1]=f.y/i,Ge[2]=(h[2]+a)*s;const u=ke(o,c,je),d=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],f=e[9],u=e[10],d=e[11],y=e[12],m=e[13],b=e[14],p=e[15],_=r*o-n*a,g=r*l-i*a,w=r*c-s*a,E=n*l-i*o,T=n*c-s*o,A=i*c-s*l,v=h*m-f*y,x=h*b-u*y,S=h*p-d*y,U=f*b-u*m,O=f*p-d*m,I=u*p-d*b,L=_*I-g*O+w*U+E*S-T*x+A*v;return L?(L=1/L,t[0]=(o*I-l*O+c*U)*L,t[1]=(i*O-n*I-s*U)*L,t[2]=(m*A-b*T+p*E)*L,t[3]=(u*T-f*A-d*E)*L,t[4]=(l*S-a*I-c*x)*L,t[5]=(r*I-i*S+s*x)*L,t[6]=(b*w-y*A-p*g)*L,t[7]=(h*A-u*w+d*g)*L,t[8]=(a*O-o*S+c*v)*L,t[9]=(n*S-r*O-s*v)*L,t[10]=(y*T-m*w+p*_)*L,t[11]=(f*w-h*T-d*_)*L,t[12]=(o*x-a*U-l*v)*L,t[13]=(r*U-n*x+i*v)*L,t[14]=(m*g-y*E-b*_)*L,t[15]=(h*E-f*g+u*_)*L,t):null}(qe,u),y=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}($e,r),m=function(t,e,r){var n=t[0],i=t[1],s=t[2],a=t[4],o=t[5],l=t[6],c=t[8],h=t[9],f=t[10],u=e[0],d=e[1],y=e[2],m=e[3],b=e[4],p=e[5],_=e[6],g=e[7],w=e[8],E=n*u+a*d+c*y,T=i*u+o*d+h*y,A=s*u+l*d+f*y,v=n*m+a*b+c*p,x=i*m+o*b+h*p,S=s*m+l*b+f*p,U=n*_+a*g+c*w,O=i*_+o*g+h*w,I=s*_+l*g+f*w;return r[0]=E,r[1]=T,r[2]=A,r[3]=0,r[4]=v,r[5]=x,r[6]=S,r[7]=0,r[8]=U,r[9]=O,r[10]=I,r[11]=0,r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r}(d,y,t);return Pe(t,Ge,m),t}(h,s,h,a.getProjection(),a.getGLRes(),c,o),u=function(t,e){return z(t,e[12],e[13],e[14]),t}(Er,f);let d=this.W.options.offset;if(w(d)){d=d(this.W.Jt(e.id).center)}return i.set(wr,d[0],d[1],0),i.sub(u,u,wr),Pe(f,u,f),f}createCMPTMesh(t,e,r,n){if(this.ct[e]){const t=this.ct[e];return console.warn(`mesh with id(${e}) was already created.`),n(null,{id:e,mesh:t}),t}const{content:i}=t,s=[];for(let t=0;t<i.length;t++){const{magic:n}=i[t],a=e+"."+t;"b3dm"===n?this.createB3DMMesh(i[t],a,r,((t,{mesh:e})=>{s.push(e)})):"i3dm"===n?this.createI3DMMesh(i[t],a,r,((t,{mesh:e})=>{s.push(e)})):"pnts"===n?this.createPntsMesh(i[t],a,r,((t,{mesh:e})=>{s.push(e)})):"cmpt"===n&&this.createCMPTMesh(i[t],a,r,((t,{mesh:e})=>{s.push(e)}))}return this.ct[e]=s,n(null,{id:e,mesh:s}),s}Xt(t,e,r,n){return("phong"===(this.W.options.services[n].shader||"phong")?this.It:this.Lt).getGeometryDefines(e)}$t(t,e,r,n,i,s,a){const o=n.url+"-"+e+"-"+r;if(this.ht[o])return this.ht[o].refCount++,this.ht[o];let l,c;const h=n.materials[t.material];if(n.extensions&&n.extensions.KHR_techniques_webgl&&h.extensions&&h.extensions.KHR_techniques_webgl){const e=this.Wt(t,n,s);l=e.material,c=e.geometry}else{c=this.Qt(t,s,Tr);const e=this.W.options.services[i.St].material;l=this.te(t.material,n,a,e||ur)}l&&!l.isReady()?l.ee=i.id:l||(l=this.wt);const f={refCount:1,geometry:c,material:l};return c.properties.url=o,this.ht[o]=f,f}Wt(t,e,r){const{geometry:n,material:i}=this.Tt.createMesh(t,e,r);return{geometry:n,material:i}}Qt(t,e,n){const i=t.attributes,s=n.COLOR_0;if(i[s]&&i[s]instanceof Float32Array){const t=new Uint8Array(i[s].length);for(let e=0;e<t.length;e++)t[e]=Math.round(255*i[s][e]);i[s]=t}const a={};for(const t in i){const e=ir(this.rt,i[t],{dimension:i[t].itemSize}),r=n[t]||t;a[r]={buffer:e},r===n.POSITION&&(a[r].array=i[t].array,a[r].min=i[t].min,a[r].max=i[t].max)}delete t.attributes;const o=new r.Geometry(a,t.indices.array?t.indices.array:t.indices,0,{positionAttribute:n.POSITION,normalAttribute:n.NORMAL,uv0Attribute:n.TEXCOORD_0,uv1Attribute:n.TEXCOORD_1,color0Attribute:n.COLOR_0,tangentAttribute:n.TANGENT,primitive:void 0===t.mode?"triangles":nr(t.mode)});return o.generateBuffers(this.rt,{excludeElementsInVAO:e}),o}Zt(t){const e=n.identity([]),r=this.getMap(),s=this.re();gr.x=t[0],gr.y=t[1];const a=r.distanceToPointAtRes(100,100,r.getGLRes(),gr);return i.set(s,a.x/100*1.01,a.y/100*1.01,a.y/100),n.scale(e,e,s),e}Et(){const t={x:0,y:0,width:()=>this.tt?this.tt.width:1,height:()=>this.tt?this.tt.height:1};this.kt=new r.MeshShader({vert:"attribute vec3 aPosition;\n\n\n\nuniform mat4 projViewModelMatrix;\n\n\n\nvoid main() {\n\n gl_Position = projViewModelMatrix * vec4(aPosition, 1.0);\n\n}\n\n",frag:"precision mediump float;\nuniform vec3 color;\nvoid main() {\n gl_FragColor = vec4(color, 1.0);\n}\n",uniforms:["color",{name:"projViewModelMatrix",type:"function",fn:(t,e)=>n.multiply([],e.projViewMatrix,e.modelMatrix)}],extraCommandProps:{viewport:t}});const e=[],i=[];this.Rt=new r.MeshShader({vert:"const 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\n\nvoid main() {\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_POSITION\n\n vec3 localPos = POSITION;\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\n\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n gl_PointSize = pointSize;\n\n}\n\n",frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n gl_FragColor = vColor;\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>n.multiply(i,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,r)=>s.fromMat4(e,r.modelMatrix)}],extraCommandProps:{viewport:t,blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,range:[0,1],func:"<"}}});const a=this.At();this.It=new r.PhongShader({extraCommandProps:a}),this.Lt=new r.pbr.StandardShader({extraCommandProps:a});const o=this.W;or(o.getRenderer().canvas,this.rt,o.getMap())}At(){return{viewport:{x:0,y:0,width:()=>this.tt?this.tt.width:1,height:()=>this.tt?this.tt.height:1},colorMask:(t,e)=>e.colorMask||pr,cull:{enable:!0,face:(t,e)=>e.cullFace},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:">=",ref:(t,e)=>e.meshProperties.level},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"keep"}},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}Ct(t){return{projViewMatrix:this.getMap().projViewMatrix,color:t&&t.color||[0,1,0]}}Mt(t){const e=this.getMap(),r=e.getLightManager(),n=(r&&r.getDirectionalLight()||{}).direction||[1,1,-1],s=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:s,lightDir:i.normalize(n,n)}}vt(){const t=this.getMap(),e=this.W.getRenderer().canvas,{iblTexes:r,dfgLUT:n}=cr(e),i=hr(t,r,n);return g(i,{lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[e.width,e.height],polygonFill:[1,1,1,1],polygonOpacity:1}),i}te(t,e,n,i){const s=e.materials[t];if(!s||!s.baseColorTexture&&!s.pbrMetallicRoughness)return null;const o=g({},i);if(s.baseColorTexture){const t=e.textures[s.baseColorTexture.index];let r;t&&!t.image.color&&(r=this.O(t)),o.baseColorFactor=t&&t.image.color||s.baseColorFactor||[1,1,1,1],r&&(o.baseColorTexture=r)}else{if(s.normalTexture){const t=this.O(e.textures[s.normalTexture.index]),r=s.normalTexture.scale||1;o.normalTexture=t,o.normalMapFactor=r}if(s.occlusionTexture){const t=this.O(e.textures[s.occlusionTexture.index]),r=s.occlusionTexture.strength||1;o.occlusionTexture=t,o.occlusionFactor=r}if(s.emissiveTexture){const t=this.O(e.textures[s.emissiveTexture.index]);o.emissiveTexture=t}s.emissiveFactor;const t=s.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(o.baseColorFactor=t.baseColorFactor),t.baseColorTexture){const r=e.textures[t.baseColorTexture.index];r.image.color?o.baseColorFactor=o.baseColorFactor?a.multiply(o.baseColorFactor,o.baseColorFactor,r.image.color):r.image.color:(o.baseColorTexture=this.O(r),o.baseColorTexture.getREGLTexture(this.rt))}if(_(t.metallicFactor)||(o.metallicFactor=t.metallicFactor),_(t.roughnessFactor)||(o.roughnessFactor=t.roughnessFactor),s.metallicRoughnessTexture){const t=this.O(e.textures[s.metallicRoughnessTexture.index]);o.metallicRoughnessTexture=t}}}let l=new r.pbr.StandardMaterial(o);return"phong"===n&&(l=r.PhongMaterial.convertFrom(l)),l.once("complete",this._t),l}O(t){const e={type:t.type?er(t.type):"uint8",format:t.format?rr(t.format):"rgba",flipY:!1},n=t.image;n.array?e.data=n.array:n.mipmap&&(e.mipmap=n.mipmap),e.width=n.width,e.height=n.height;const i=t.sampler||t.texture.sampler;return i&&(i.magFilter&&(e.mag=We(i.magFilter)),i.minFilter&&(e.min=Qe(i.minFilter)),i.wrapS&&(e.wrapS=tr(i.wrapS)),i.wrapT&&(e.wrapT=tr(i.wrapT))),new r.Texture2D(e,this.bt)}ne(t){const e=t.image,r=window.URL||window.webkitURL,n=new Blob([e.array],{type:e.mimeType});return r.createObjectURL(n)}gt({target:t}){const e=t.ee,r=this.it[e];if(r.count--,!r.count){const t=r.meshes;this.at[e]=t,delete this.it[e];const n=t.Kt;delete t.Kt,n(null,{mesh:r.meshes,id:e})}}re(){return dr}Yt(t){return this.W.Yt(t)}Vt(t,e){const r=this.getMap();return r.getGLZoom?r.distanceToPoint(t,e,r.getGLZoom()):r.distanceToPointAtRes(t,e,r.getGLRes())}_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())}jt(t){return"Y"===t?sr:"X"===t?ar:yr}}class vr extends t.renderer.CanvasRenderer{constructor(t){super(t),this.prepareWorker(),this.tilesLoading={},this.tileCache=new $t(1024*t.options.maxGPUMemory*1024,this.deleteTile.bind(this)),this.ie={},this.se=[]}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.se.length||super.needToRedraw())}drawOnInteracting(t,e,r){this.draw(e,r)}draw(t,e){const r=this.prepareCanvas();if(r&&!r.intersects(this.canvasExtent2D))return void this.completeRender();const{root:n,tiles:i}=this.layer.getTiles(),s=i.length;if(!i||!s)return void this.completeRender();this.ae();const{selectedTiles:a,leaves:o,requests:l}=this.oe(n,i);l.length&&this.loadTiles(l),this.le(a,o,e),this.ce(),l.length||this.completeRender()}oe(t,e){let r=[];this.he();let n=0;const i=this.fe(),s={};let a=!1,o=!1;for(let t=0;t<e.length;t++){const i=e[t],l=i.node;if(s[l.id])continue;s[l.id]=1;let c=!1;const h=this.ue(l.id);if(this.de(l.id)?(n++,c=o=!0,this.tilesLoading[l.id].current=!0):h?(this.getTileOpacity(h)<1&&(c=o=!0),a=!0,i.selected=!0,i.data=h):this.painter.has(l)||(c=o=!0,r.push(l)),!c)continue;if(this.ye(i))a=!0;else{this.me(i).length&&(a=!0)}}let l=[],c={};if(a&&({selectedTiles:l,leaves:c}=this.be(t)),r.length>1&&(r.sort(xr),i)){const t=i-n;r=t>0?r.slice(0,t):[]}return{loading:o,requests:r,selectedTiles:l,leaves:c}}be(t){const e=[],r={};let n;const i=[t],s=[];for(;i.length>0||s.length>0;){if(s.length>0){const t=s[s.length-1];if(t.pe===i.length){s.pop(),t===n&&(t.leave=!0,r[t.node.id]=1),e.push(t);continue}}const t=i.pop(),a=t.children;if(t.selected)if("add"===t.node.refine)r[t.node.id]=1,t.selectionDepth=s.length,e.push(t);else{if(t.selectionDepth=s.length,n=t,0===a.length){t.leave=!0,r[t.node.id]=1,e.push(t);continue}s.push(t),t.pe=i.length}for(let t=0;t<a.length;t++)i.push(a[t])}return{selectedTiles:e,leaves:r}}ye(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}me(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const r=t._e+1,n=[t.node];for(;n.length>0;){const i=n.pop().children;for(let s=0,a=i.length;s<a;s++){if((!i[s].content||!i[s].content.url)&&i[s].children&&i[s].children.length){n.push(i[s]);continue}const a=i[s].id;if(this.tileCache.has(a)){const r=this.layer.ge(i[s],t);r.selected=!0,r.data=this.tileCache.get(a),t.children.push(r),e.push(r)}else i[s]._e<=r&&n.push(i[s])}}return e}le(t,e,r){this.tileCache.markAll(!1);for(let e=0,r=t.length;e<r;e++){const r=t[e].data;r.current=!0,this.tileCache.add(t[e].node.id,r)}this.tileCache.shrink();const n={tiles:t,leaves:e};this.onDrawTileStart(n);const i=r&&r.renderTarget,s=r&&r.sceneFilter,a=this.painter.paint(t,e,s,i);this.layer.options.debug&&this.painter.paintRegion(t,{color:this.layer.options.debugOutline},s,i),this.onDrawTileEnd(n),a&&this.layer.fire("canvasisdirty",{renderCount:a})}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,r=t.length;e<r;e++){const r=t[e];this.tilesLoading[r.id]={current:!0,node:r},this.loadTile(r)}}loadTile(t){let e=t.content.url;if(L(e)){const r=M(e);return void this.we(e,r,t)}t&&-1===e.indexOf("http://")&&-1===e.indexOf("https://")&&(e=t.baseUrl+e);const r=this.layer.options.services[t.St];if(r.ajaxInMainThread){let n=r.urlParams;n&&(n=(e.indexOf("?")>0?"&":"?")+n);let i=pt.getArrayBuffer(e+(n||""),r.fetchOptions);const s=i.xhr;i=i.then((r=>{delete this.ie[e],r?this.we(e,r.data,t):this.onTileError(null,t)})).catch((r=>{delete this.ie[e],this.onTileError(r,t)})),this.ie[e]=s}else this.we(e,null,t)}we(t,e,n){let i=this.o;i||(i=r.Util.getSupportedFormats(this.gl.gl||this.gl),this.o=i),this.workerConn.loadTile(this.layer.getId(),{url:t,arraybuffer:e,rootIdx:n.St,upAxis:n.qt,transform:n.matrix,supportedFormats:i},((e,r)=>{if(e)return void this.onTileError(e,n);const{magic:i}=r;"b3dm"===i||"pnts"===i||"i3dm"===i||"cmpt"===i?this.se.push({data:r,tile:n}):this.onTilesetLoad(r,n,t)}))}ae(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let r=0;for(;this.se.length&&(r<e||!t.isInteracting());){const{data:t,tile:e}=this.se.shift(),{magic:n}=t;"b3dm"===n?this.painter.createB3DMMesh(t,e.id,e,((r,{mesh:n})=>{this.Ee(t,e,r,n)})):"pnts"===n?this.painter.createPntsMesh(t,e.id,e,((r,{mesh:n})=>{this.Ee(t,e,r,n)})):"i3dm"===n?this.painter.createI3DMMesh(t,e.id,e,((r,{mesh:n})=>{this.Ee(t,e,r,n)})):"cmpt"===n&&this.painter.createCMPTMesh(t,e.id,e,((r,{mesh:n})=>{this.Ee(t,e,r,n)})),r++}}Ee(t,e,r,n){if(r)this.onTileError(r,e);else{const r=this.Te(n);e.memorySize=r,this.onTileLoad(t,e)}}Te(t){let e=0;if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]&&(e+=this.Te(t[r]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.Ae(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,r){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,r))}onTileError(t,e){if(!this.layer)return;const r=e.content.url;console.warn("failed to load 3d tile: "+r),console.warn(t),delete this.tilesLoading[e.id],this.Ae(e),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}ue(t){return this.tileCache.get(t)}Ae(e){const r={loadTime:t.Util.now(),current:!0,node:e};this.tileCache.add(e.id,r)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;if(this.layer.options.services[t.node.St].ajaxInMainThread){const t=this.ie[e];t&&t.abort()}else this.workerConn.abortTileLoading(this.layer.getId(),e);delete this.ie[e]}he(){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};this.canvas.gl&&this.canvas.gl.wrap?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.ve(this.canvas,e)),this.regl=this.regl||l({gl:this.gl,attributes:e,extensions:["OES_element_index_uint","WEBGL_compressed_texture_s3tc"],optionalExtensions:t.options.optionalExtensions||[]}),this.painter=new Ar(this.regl,t)}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new Gt("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=g({},r),delete r.offset,r.projection=t.getSpatialReference().getProjection().code;const n=this.layer.getId();e.addLayer(n,r,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.ce(!0),this.tileCache.reset(),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}ce(t){this.xe||(this.xe=Date.now());const e=Date.now();if(t||!(e-this.xe<this.layer.options.retireInterval)){this.xe=e;for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||this.abortTileLoading(r)}}}fe(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}ve(t,e){const r=["webgl","experimental-webgl"];let n=null;for(let i=0;i<r.length;++i){try{n=t.getContext(r[i],e)}catch(t){}if(n)break}return n}de(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,r){return we(t,e,0,r)}}function xr(t,e){return t.Bt-e.Bt}function Sr(t,e,r){return t[0]=e[r],t[1]=e[r+3],t[2]=e[r+6],t}function Ur(t,e,r){return Math.sqrt(function(t,e,r){var n=Y(Or,r,t),i=Sr(Ir,e,0),s=Sr(Lr,e,1),a=Sr(Mr,e,2),o=X(i),l=X(s),c=X(a);Z(i,i),Z(s,s),Z(a,a);var h=Rr;h[0]=G(n,i),h[1]=G(n,s),h[2]=G(n,a);var f,u=0;h[0]<-o?u+=(f=h[0]+o)*f:h[0]>o&&(u+=(f=h[0]-o)*f);h[1]<-l?u+=(f=h[1]+l)*f:h[1]>l&&(u+=(f=h[1]-l)*f);h[2]<-c?u+=(f=h[2]+c)*f:h[2]>c&&(u+=(f=h[2]-c)*f);return u}(t,e,r))}const Or=[],Ir=[],Lr=[],Mr=[],Rr=[];const Nr=t.projection.EPSG3857,Br=new t.Extent(0,0,0,0),Pr=new t.Extent(0,0,0,0),kr=[],Cr=[],Dr=[],zr=[],Fr=new t.Point(0,0),Yr=new t.Coordinate(0,0),Hr=new t.Coordinate(0,0),Vr=[],Zr=new t.Coordinate(0,0),Gr=n.identity([]);class jr extends t.Layer{constructor(t,e){super(t,e),this.Se(),this.ie={},this.Ue=[]}Se(){let t=this.options.services.map((t=>t.url));this.Oe=t.map(((t,e)=>function(t,e){t=A(t);return{baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:n.identity([]),St:e,_e:0}}(t,e))),this.fire("rootready",{roots:this.Oe.slice(0)})}getExtent(e){if(!e&&0!==e){const e=new t.Extent;for(let t=0;t<this.Oe.length;t++)if(this.Oe[t].boundingVolume){const r=this.boundingVolumeToExtent(this.Oe[t]);e._combine(r)}return e}return this.Oe[e]&&this.Oe[e].boundingVolume?this.boundingVolumeToExtent(this.Oe[e]):null}boundingVolumeToExtent(e){const r=e.boundingVolume.Ie?Gr:e.matrix,n=this.getMap();if(e.boundingVolume.region){const r=e.boundingVolume.region;return new t.Extent(T(r[0]),T(r[1]),T(r[2]),T(r[3]))}if(e.boundingVolume.sphere){const s=e.boundingVolume.sphere,a=le([],i.transformMat4([],s,r)),o=s[3],l=n.locate(a,-o,o),c=n.locate(a,o,-o);return new t.Extent(l,c)}if(e.boundingVolume.box){const a=e.boundingVolume.box,o=i.transformMat4([],a,r),l=new t.Coordinate(le([],o)),c=a.slice(3);s.multiply(c,s.fromMat4([],e.matrix),c);const h=i.length(c.slice(0,3)),f=i.length(c.slice(3,6)),u=i.length(c.slice(6,9)),d=Math.max(h,f,u),y=n.locate(l,-d,d),m=n.locate(l,d,-d);return new t.Extent(y,m)}return null}getRootTiles(){return this.Oe}getTiles(){if(!this.getRenderer().ready)return this.Le(),{tiles:zr};const t=this.getMap(),e=t.cameraPosition;let r,n;if(t.getGLZoom)n=t.pointToDistance(e[2],0,t.getGLZoom()),Zr.set(e[0],e[1]),r=t.pointToCoord(Zr,t.getGLZoom());else{const i=t.getGLRes();n=t.pointAtResToDistance(e[2],0,i),Zr.set(e[0],e[1]),r=t.pointAtResToCoord(Zr,i)}this.Me=this.Me||[],i.set(this.Me,E(r.x),E(r.y),n),this.Re=re(this.Re||[],this.Me[0],this.Me[1],this.Me[2]),this.Ne=2*Math.tan(.5*E(t.getFov())),this.Be=Nr.project(r).toArray();const s=t.projViewMatrix,a={children:[],level:-1};let o=a;const l=[];for(let t=0;t<this.Oe.length;t++){let e=1/0;const r=[this.Oe[t]],n=this.Pe(t);for(;r.length>0;){const t=r.pop();for(t.id||this.ke(t);o.level>=t._e;)o=o.parent;const i=this.Ce(t,n,s);if(i<1){let r=o;for(;r&&!r.content;)r=r.parent;0===i&&r&&r.content&&this.De(l,r);if(!1===this.options.services[t.St].alwaysShow)continue;if(!(0===i&&t._e<=e))continue;t.content&&(e=t._e)}t.Bt<1/0&&this.ze(t);const a=this.ge(t,o);o.children.push(a);const c=t.children,h=c&&c.length,f=a.content;if(!h&&f&&this.De(l,a),h){f&&"add"===t.refine&&this.De(l,a),o=a;const e=c[0].parent;for(let n=0,i=c.length;n<i;n++){if(!e){c[n].parent=t,c[n].qt=t.qt,c[n].baseUrl=t.baseUrl;const e=c[n].content&&(c[n].content.url||c[n].content.uri);e&&(L(e)?c[n].baseUrl=t.baseUrl:-1===e.indexOf("http://")&&-1===e.indexOf("https://")?c[n].content.url=t.baseUrl+e:c[n].baseUrl=e.substring(0,e.lastIndexOf("/")+1))}r.push(c[n])}}}}return{root:a,tiles:l}}De(t,e){const{viewerRequestVolume:r}=e.node;r&&!function(t,e,r){if(r.region){const e=r.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(r.sphere)return qr(r,e);if(r.box)return 0===$r(r,e)}return!1}
|
|
18
|
+
let et=0;function rt(t){return null==t}function nt(t){return!rt(t)}function it(t){for(let e=1;e<arguments.length;e++){const r=arguments[e];for(const e in r)t[e]=r[e]}return t}function st(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 at(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function ot(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),r=e.length,n=new Uint8Array(r);for(let t=0;t<r;t++)n[t]=e.charCodeAt(t);return n.buffer}const lt=[],ct=[],ht=[],ft=[0,0,0],ut=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),dt=[1,1,1];function yt(t,e,r,n,i,s,a){const o=st(a);if((0===i||i===n*o.BYTES_PER_ELEMENT)&&s%o.BYTES_PER_ELEMENT==0){const i=new o(e,s,r*n);return t.set(i),t}const l=new Uint8Array(n*o.BYTES_PER_ELEMENT);for(let a=0;a<r;a++){let r=null;const c=new Uint8Array(e,i*a+s,n*o.BYTES_PER_ELEMENT);l.set(c),r=new o(l.buffer,0,n);for(let e=0;e<n;e++)t[a*n+e]=r[e]}return t}const mt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function bt(t,e,r){const n=new Uint8Array(t,e,r);return mt.decode(n)}const _t={get:function(t,e={}){e||(e={});const r=new AbortController,n={signal:r.signal,method:e.method||"GET",referrerPolicy:"origin"};"POST"===e.method&&(rt(e.body)||(n.body=JSON.stringify(e.body))),rt(e.headers)||(n.headers=e.headers),rt(e.credentials)||(n.credentials=e.credentials);const i=fetch(t,n).then((t=>{const r=this.t(t,e.responseType);return r.message?r:r.then((r=>"arraybuffer"===e.responseType?{data:r,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:r)).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 i.xhr=r,i},t:(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={})=>(e||(e={}),e.responseType="arraybuffer",_t.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?_t.jsonp(t):((e=e||{}).responseType="json",_t.get(t,e))}};_t.jsonp=function(t){const e="_maptalks_jsonp_"+et++;t.match(/\?/)?t+="&callback="+e:t+="?callback="+e;let r=document.createElement("script");return r.type="text/javascript",r.src=t,new Promise((t=>{window[e]=function(n){document.getElementsByTagName("head")[0].removeChild(r),r=null,delete window[e],t(n)},document.getElementsByTagName("head")[0].appendChild(r)}))};class pt{constructor(t,e,r){this.i=t,this.decoders=e,this.o=r,this.images={},this.l={}}requestImageFromBufferURI(t,e,r){if(this.buffers[t.id]){const n=this.buffers[t.id],i=this.h(e,n);return this.getImageByBuffer(i,r)}if(this.l[t.id])return this.l[t.id].then((()=>{const n=this.buffers[t.id],i=this.h(e,n);return this.getImageByBuffer(i,r)}));if(at(t.uri)){const n=this.buffers[t.id]=ot(t.uri),i=this.h(e,n);return this.getImageByBuffer(i,r)}return this.l[t.id]=_t.getArrayBuffer(t.uri,null).then((n=>{const i=this.buffers[t.id]=n.data,s=this.h(e,i);return this.getImageByBuffer(s,r)}))}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const r=this.decoders;if(r[e.mimeType])return r[e.mimeType](t,{supportedFormats:this.o});if("image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType)return console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null);{const r=new Blob([t],{type:e.mimeType}),n=URL.createObjectURL(r);return this.u(e.id,n)}}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;if(this.l[t.id])return this.l[t.id].then((()=>this.images[t.id]));return this.l[t.id]=this.u(t.id,e)}u(t,e){return new Promise(((r,n)=>{this.i(e,((i,s)=>{i?n(i):(URL.revokeObjectURL(e),this.images[t]=s,r(this.images[t]))}))}))}}const gt=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class wt{constructor(t,e,r){this.rootPath=t,this.gltf=e,this.m=!1,this.glbBuffer=r,this.buffers={},this.requests={},this.accessors={},this._()}p(t,e){const r=this.gltf,n=r.accessors[e];if(void 0===n.bufferView)return this.accessors[n.id]=this.g(t,e,null,0),Promise.resolve(this.accessors[n.id]);if(n&&this.accessors[n.id])return Promise.resolve(this.accessors[n.id]);const i=r.bufferViews[n.bufferView];return this.T(i).then((r=>{const{buffer:i,byteOffset:s}=r;return this.accessors[n.id]=this.g(t,e,i,s)}))}T(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(at(e.uri)){const t=this.buffers[e.id]=ot(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const r=e.uri.indexOf("blob:")>=0;t=e.uri.indexOf("://")>0||r?e.uri:this.rootPath+"/"+e.uri;return this.requests[e.id]=_t.getArrayBuffer(t,null).then((n=>{r&&URL.revokeObjectURL(t);return{buffer:this.buffers[e.id]=n.data,byteOffset:0}}))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}g(t,e,r,n=0){const i=this.gltf,s=i.accessors[e],a=void 0!==s.bufferView?i.bufferViews[s.bufferView]:{},o=(a.byteOffset||0)+n,l=this.A(s.type),c=st(s.componentType),h=a.byteStride||0;const f={array:undefined,name:t,accessorName:e,byteLength:s.count*l*c.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:l};if(s.min&&(f.min=s.min),s.max&&(f.max=s.max),r)if(this.m)f.byteStride=h,f.byteOffset=o+(s.byteOffset||0),!h||h===l*c.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(f.array=this.v(r,s.count,l,o+(s.byteOffset||0),c),f.array.buffer.byteLength===f.byteLength&&(f.byteOffset=0)):f.array=new Uint8Array(r,o,a.byteLength);else if(s.interleaved){f.byteStride=0,f.byteOffset=0;const t=new c(s.count*l);f.array=yt(t,r,s.count,l,h,o+(s.byteOffset||0),s.componentType)}else f.byteStride=0,f.array=this.v(r,s.count,l,o+(s.byteOffset||0),c),f.byteOffset=f.array.byteOffset;else{f.array=new c(s.count);const t=f.min||f.max;t&&(f.array[0]=t[0],f.array[1]=t[1],f.array[2]=t[2])}return f}_(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let r=0;r<t.length;r++)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0);else for(const e in t)for(const r in t)e!==r&&t[e].bufferView===t[r].bufferView&&(t[e].interleaved=t[r].interleaved=!0)}v(t,e,r,n,i){return n%i.BYTES_PER_ELEMENT!=0&&(t=t.slice(n,n+e*r*i.BYTES_PER_ELEMENT),n=0),new i(t,n,r*e)}A(t){const e=gt.indexOf(t);return gt[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,r=e.map((t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:r}=e;return this.T(e).then((n=>{const{buffer:i,byteOffset:s}=n,a=bt(i,s+(e.byteOffset||0),r);return t.content=a,t}))}if(t.uri){if(at(t.uri)){const e=ot(t.uri),r=bt(e,0,e.byteLength);return t.content=r,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return _t.get(e).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(r).then((()=>t))}}class Et extends pt{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=r,this.accessor=new wt(t,e,r)}iterate(t,e){const r=this.gltf[e];if(!r)return;let n=0;for(const e in r)t(e,r[e],n++)}createNode(t){const e={};if(nt(t.name)&&(e.name=t.name),nt(t.children)&&(e.children=t.children),nt(t.jointName)&&(e.jointName=t.jointName),nt(t.matrix)&&(e.matrix=t.matrix),nt(t.rotation)&&(e.rotation=t.rotation),nt(t.scale)&&(e.scale=t.scale),nt(t.translation)&&(e.translation=t.translation),nt(t.extras)&&(e.extras=t.extras),nt(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}(lt,e.translation||ft),n=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=r+r,o=n+n,l=i+i,c=r*a,h=n*a,f=n*o,u=i*a,d=i*o,y=i*l,m=s*a,b=s*o,_=s*l;return t[0]=1-f-y,t[1]=h+_,t[2]=u-b,t[3]=0,t[4]=h-_,t[5]=1-c-y,t[6]=d+m,t[7]=0,t[8]=u+b,t[9]=d-m,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(ct,e.rotation||ut),i=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}(ht,e.scale||dt);return B(i,n,i),B(t,r,i)}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}S(t){const e={};for(const r in t){const n=t[r];let i,s;n.instanceTechnique&&n.instanceTechnique.values?(i=n.instanceTechnique,s=i.values.diffuse):(i=n,s=i.values.tex||i.values.diffuseTex||i.values.diffuse);const a={"baseColorTexture":{index:s}};n.name&&(a.name=n.name),n.extensions&&(a.extensions=n.extensions),n.extras&&(a.extras=n.extras),e[r]=a}return e}U(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 r=this.gltf.bufferViews[e.bufferView],n=(r.byteOffset||0)+this.glbBuffer.byteOffset,i=r.byteLength,s=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,n,i);return this.getImageByBuffer(s,t)}return this.requestExternalImage(t)}O(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.U(r).then((t=>{const n=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extras:r.extras},sampler:n}}))}getBaseColorTexture(t){const e=this.gltf.materials[t];let r,n;if(e.instanceTechnique&&e.instanceTechnique.values?(r=e.instanceTechnique,n=r.values.diffuse):(r=e,n=r.values.tex||r.values.diffuseTex||r.values.diffuse),void 0===n||void 0===this.gltf.textures)return null;const i=this.gltf.textures[n];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}}class Tt extends pt{constructor(t,e,r,n,i,s){super(n,i,s),this.rootPath=t,this.gltf=e,this.glbBuffer=r,this.buffers={},this.requests={},this.accessor=new wt(t,e,r)}iterate(t,e){const r=this.gltf[e];if(r)for(let e=0;e<r.length;e++)t(e,r[e],e)}createNode(t){const e={};return it(e,t),!nt(t.weights)&&this.gltf.meshes&&nt(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}O(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.U(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}};it(n,e);const i=nt(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return i&&(n.sampler=i),t.format&&(n.format=t.format),n}))}U(t){if(!nt(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],r=this.gltf.buffers[e.buffer];if(r.uri)return this.requestImageFromBufferURI(r,e,t);if(this.glbBuffer)return this.I(e,t)}return null}I(t,e){const r=this.h(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(r,e)}h(t,e,r){r=r||0;const n=t.byteOffset+r,i=t.byteLength;return new Uint8Array(e,n,i)}L(t,e){const r=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)r[e]=String.fromCharCode(t[e]);r.join("");const n="data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(r)));return n}getAnimations(t){const e=[];return t.forEach((t=>{e.push(this.getSamplers(t.samplers))})),Promise.all(e).then((e=>{for(let r=0;r<e.length;r++)t[r].samplers=e[r];return t}))}getSamplers(t){const e=[];for(let r=0;r<t.length;r++)(nt(t[r].input)||nt(t[r].output))&&(e.push(this.accessor.p("input",t[r].input)),e.push(this.accessor.p("output",t[r].output)));return Promise.all(e).then((e=>{for(let r=0;r<e.length/2;r++)t[r].input=e[2*r],t[r].output=e[2*r+1],t[r].interpolation||(t[r].interpolation="LINEAR");return t}))}}const At="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null,vt=1313821514,xt=5130562;class St{static read(t,e=0,r=0){r||(r=t.byteLength);const n=new DataView(t,e,r),i=n.getUint32(4,!0);if(1===i)return St.readV1(n,e);if(2===i)return St.readV2(t,e);throw new Error("Unsupported glb version : "+i)}static readV1(t,e){const r=t.getUint32(8,!0),n=t.getUint32(12,!0);if(r!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const i=Ut(t.buffer,20+e,n);return{json:JSON.parse(i),glbBuffer:{byteOffset:20+e+n,buffer:t.buffer,byteLength:r}}}static readV2(t,e){let r,n,i;const s=new DataView(t,e+12);let a=0;for(;a<s.byteLength;){const o=s.getUint32(a,!0);a+=4;const l=s.getUint32(a,!0);if(a+=4,l===vt)r=Ut(t,e+12+a,o);else if(l===xt){i=e+12+a,n=o;break}a+=o}return{json:JSON.parse(r),glbBuffer:{byteOffset:i,buffer:t,byteLength:n}}}}function Ut(t,e,r){if(At){const n=new Uint8Array(t,e,r);return At.decode(n)}return function(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=Ot[i>>3&7];if(!(64&i)||!r||n+r>e)return null;for(i&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;i=i<<6|63&e}}r+=String.fromCharCode(i)}return r}(new Uint8Array(t,e,r))}const Ot=[1,1,1,1,2,2,3,0];const It=[0,0,0],Lt=[0,0,0,1],Mt=[1,1,1],Rt={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},Nt={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},Bt={M(t,e,r,n,i,s,a,o){const l=nt(t)?e.animations:[e.animations[0]],c={};for(let e=0;e<l.length;e++){const h=l[e],f=h.name||e;if(nt(t)&&f!==t)continue;const u=h.channelsMap[r];if(u)for(let t=0;t<u.length;t++){const e=u[t];"translation"===e.target.path?(this.R(i,h.samplers[e.sampler],n,1),c.translation=D(It,i)):"rotation"===e.target.path?(this.N(s,h.samplers[e.sampler],n,1),c.rotation=tt(Lt,s)):"scale"===e.target.path?(this.R(a,h.samplers[e.sampler],n,1),c.scale=D(Mt,a)):"weights"===e.target.path&&o&&(this.R(o,h.samplers[e.sampler],n,o.length),c.weights=o)}}return c},R(t,e,r,n){switch(e.interpolation){case"LINEAR":{const i=this.B(Nt,e,r,1*n);i&&(t=function(t,e,r,n){for(let i=0;i<t.length;i++)t[i]=e[i]+n*(r[i]-e[i]);return t}(t,i.PREVIOUS,i.NEXT,i.INTERPOLATION));break}case"STEP":{const i=this.B(Nt,e,r,1*n);i&&(t=function(t,e){for(let r=0;r<t.length;r++)t[r]=e[r];return t}(t,...i.PREVIOUS));break}case"CUBICSPLINE":{const i=this.B(Nt,e,r,3*n);i&&(t=this.P(t,i,e.input.array,3*n));break}}return t},N(t,e,r){switch(e.interpolation){case"LINEAR":{const n=this.B(Nt,e,r,1);n&&W(t,n.PREVIOUS,n.NEXT,n.INTERPOLATION);break}case"STEP":{const n=this.B(Nt,e,r,1);n&&(t=K(t,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.B(Nt,e,r,3);if(n){for(let t=0;t<n.PREVIOUS.length;t++)n.PREVIOUS[t]=Math.acos(n.PREVIOUS[t]),n.NEXT[t]=Math.acos(n.NEXT[t]);t=this.P(t,n,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},k(t,e){const r=t.length;let n,i,s,a=0,o=r-1,l=Math.floor((a+o)/2);for(;a<=r-1&&o>=0;){if(a===o)return null;if(t[l]<=e&&e<=t[l+1]){const r=t[l];return n=l,i=l+1,s=(e-r)/(t[l+1]-r),{preIndx:n,nextIndex:i,interpolation:s}}e<t[l]?(o=l,l=Math.floor((a+o)/2)):t[l+1]<e&&(a=l,l=Math.floor((a+o)/2))}return null},B(t,e,r,n){const i=e.input.array,s=e.output.array,a=e.output.itemSize;(r<i[0]||r>i[i.length-1])&&(r=Math.max(i[0],Math.min(i[i.length-1],r))),r===i[i.length-1]&&(r=i[0]);const o=this.k(i,r);if(!o||!o.nextIndex)return null;const{preIndx:l,nextIndex:c,interpolation:h}=o;t.PREINDEX=l,t.NEXTINDEX=c,t.INTERPOLATION=h;const f=a*n;return t.PREVIOUS=s.subarray(t.PREINDEX*f,(t.PREINDEX+1)*f),t.NEXT=s.subarray(t.NEXTINDEX*f,(t.NEXTINDEX+1)*f),t},P(t,e,r,n){const i=e.INTERPOLATION,s=r[e.PREINDEX],a=r[e.NEXTINDEX];for(let r=0;r<3;r++){const o=e.PREVIOUS[n+r],l=(a-s)*e.PREVIOUS[2*n+r],c=e.NEXT[3+r],h=(a-s)*e.NEXT[r],f=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*o+(Math.pow(i,3)-2*Math.pow(i,2)+i)*l+(2*-Math.pow(i,3)+3*Math.pow(i,2))*c+(Math.pow(i,3)-Math.pow(i,2))*h;t[r]=f}return t},getAnimationClip(t,e,r,n){const i=t.nodes[e]&&t.nodes[e].weights;z(It,...Rt.TRANSLATION),K(Lt,...Rt.ROTATION),z(Mt,...Rt.SCALE);return this.M(n,t,e,r,It,Lt,Mt,i)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach(((e,r)=>{let n=-1/0,i=1/0;const s=e.channels;for(let t=0;t<s.length;t++){const r=s[t],a=e.samplers[r.sampler].input.array;a[a.length-1]>n&&(n=a[a.length-1]),a[0]<i&&(i=a[0])}const a=e.name||r;t.timeSpan[a]={max:n,min:i}})),t.timeSpan},getTimeSpanByName(t,e){const r=this.getTimeSpan(t);return r?nt(e)?r[e]:r[Object.keys(r)[0]]:null}};let Pt=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(t){}t&&"undefined"!=typeof createImageBitmap&&(Pt=!0)}const kt="undefined"==typeof document?null:document.createElement("canvas");class Ct{constructor(t,e,r){if(this.options=r||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:r,glbBuffer:n}=St.read(e.buffer,e.byteOffset,e.byteLength);this.C(t,r,n)}else this.C(t,e);this.D=new wt(this.rootPath,this.gltf,this.glbBuffer),this.F()}F(){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.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}Y(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.D.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.H(t),r=this.V(),n=this.Z(),i=this.Y();return Promise.all([e,r,n,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 r=e[t];r.channelsMap={};for(let t=0;t<r.channels.length;t++){const e=r.channels[t];r.channelsMap[e.target.node]||(r.channelsMap[e.target.node]=[]),r.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:r}=this.gltf;for(let r=0;r<e.length;r++)e[r].uri&&e[r].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[r].uri});for(let e=0;e<r.length;e++)r[e].uri&&r[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:r[e].uri})}return t}static getAnimationClip(t,e,r,n){return Bt.getAnimationClip(t,e,r,n)}static getAnimationTimeSpan(t,e){return Bt.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return st(t)}static readInterleavedArray(t,e,r,n,i,s,a){return yt(t,e,r,n,i,s,a)}C(t,e,r){this.gltf=e,this.glbBuffer=r,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=Pt?Yt.bind(this):this.options.requestImage||Dt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new Tt(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="buffer_"+r}),"buffers"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors")):(this.adapter=new Et(t,e,r,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{}),this.adapter.iterate(((t,e,r)=>{e.id="accessor_"+r}),"accessors"),this.adapter.iterate(((t,e,r)=>{e.id="image_"+r}),"images"))}G(t,e){if(t.children&&t.children.length>0){if(!(r=t.children[0],"number"==typeof r&&isFinite(r)||function(t){return!rt(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}(t.children[0])))return t;const n=t.children.map((t=>{const r=e[t];return r.nodeIndex=t,this.G(r,e)}));t.children=n}var r;return t}H(t){return this.j(t).then((t=>{const e=this.scenes=[];let r;for(const e in t)t[e]=this.G(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate(((n,i,s)=>{const a={};i.name&&(a.name=i.name),i.nodes&&(a.nodes=i.nodes.map((e=>t[e]))),this.gltf.scene===n&&(r=s),e.push(a)}),"scenes");const n={asset:this.gltf.asset,scene:r,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins};if(this.gltf.extensions&&(n.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.S(this.gltf.materials);n.materials=t}return n}))}j(t){return this.q(t).then((()=>{const t=this.nodes={};return this.adapter.iterate(((e,r)=>{const n=this.adapter.createNode(r,this.meshes,this.skins);t[e]=n}),"nodes"),t}))}$(){this.skins=[];const t=[];return this.adapter.iterate(((e,r,n)=>{t.push(this.X(r).then((t=>{t.index=n,this.skins.push(t)})))}),"skins"),t}X(t){const e=t.inverseBindMatrices;return this.adapter.accessor.p("inverseBindMatrices",e).then((e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t)))}V(){const t=this.gltf.animations;return nt(t)?this.adapter.getAnimations(t):null}q(t){this.meshes={};let e=[];return this.adapter.iterate(((r,n,i)=>{e.push(this.K(n,t).then((t=>{t.index=i,this.meshes[r]=t})))}),"meshes"),e=e.concat(this.$()),Promise.all(e)}K(t,e){const r=t.primitives.map((t=>this.J(t,e))).filter((t=>!!t));return Promise.all(r).then((e=>{const r={};return it(r,t),r.primitives=e,r}))}Z(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const r in t)e.push(this.adapter.O(r));return Promise.all(e).then((e=>{if(this.transferables)for(let t=0;t<e.length;t++){const r=e[t].image.array;if(e[t]&&r){let t;t=r instanceof ImageBitmap?r:r.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const r={},n=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(r[n[t]]=e[t]);return r}return e}))}J(t,e){let r;const n=[],i=t.extensions;if(nt(t.targets))for(let e=0;e<t.targets.length;e++){const r=t.targets[e];for(const t in r){const i=this.adapter.accessor.p(`morphTargets_${t}_${e}`,r[t]);i&&n.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:a}=i.KHR_draco_mesh_compression,o=this.gltf.bufferViews[s],l=this.D.T(o).then((r=>{const{buffer:n,byteOffset:i}=r;let{byteOffset:s,byteLength:l}=o;s||(s=0);const c=new DataView(n,i+s,l),h={attributes:a,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(c,h).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));n.push(l),r=Promise.all(n)}else{const e=t.attributes;for(const t in e){const r=this.adapter.accessor.p(t,e[t]);r&&n.push(r)}if(nt(t.indices)){const e=this.adapter.accessor.p("indices",t.indices);e&&n.push(e)}r=Promise.all(n)}return r.then((e=>{if(i&&i.KHR_draco_mesh_compression){const r=t.targets?t.targets.length:0;e[r]=e[r].concat(e.slice(0,r)),e=e[r]}let r,n;const s=e.reduce(((t,e)=>{if("indices"===e.name)r=e;else if(e.name.indexOf("morphTargets_")>-1)n=n||{},n[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],r=[-1/0,-1/0,-1/0],{itemSize:n,array:i}=e,s=i.length/n;for(let e=0;e<s;e++)for(let s=0;s<n;s++){const a=e*n+s;i[a]<t[s]&&(t[s]=i[a]),i[a]>r[s]&&(r[s]=i[a])}if(e.quantization){const n=e.quantization,i=n.range/(1<<n.quantizationBits),s=n.minValues;V(t,t,i),F(t,t,s),V(r,r,i),F(r,r,s)}e.min=t,e.max=r}t[e.name]=e}return this.transferables&&e.array.buffer&&this.transferables.indexOf(e.array.buffer)<0&&this.transferables.push(e.array.buffer),t}),{}),a={attributes:s,material:t.material};return r&&(a.indices=r),n&&(a.morphTargets=n),a.mode=nt(t.mode)?t.mode:4,nt(t.extras)&&(a.extras=t.extras),a}))}}function Dt(t,e){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!kt)return void e(new Error("There is no canvas to draw image!"));kt.width=r.width,kt.height=r.height;const t=kt.getContext("2d");t.drawImage(r,0,0,r.width,r.height);const n=t.getImageData(0,0,r.width,r.height),i={width:r.width,height:r.height,data:new Uint8Array(n.data)};e(null,i)},r.onerror=function(t){e(t)},r.src=t}let zt,Ft;function Yt(t,e){zt||(zt=new OffscreenCanvas(2,2),Ft=zt.getContext("2d")),fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{let{width:r,height:n}=t;Ht(r)||(r=Vt(r)),Ht(n)||(n=Vt(n));const i=this.options.maxTextureSize;i&&(r=Math.min(i,r)),i&&(n=Math.min(i,n)),zt.width=r,zt.height=n,Ft.drawImage(t,0,0,r,n),t.close();const s=Ft.getImageData(0,0,r,n);e(null,{width:r,height:n,data:new Uint8Array(s.data)})})).catch((t=>{console.warn(t),e(t)}))}function Ht(t){return 0==(t&t-1)&&0!==t}function Vt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}const Zt="undefined"==typeof document?null:document.createElement("canvas");class Gt extends t.worker.Actor{constructor(t,e){super(t),this.mapId=e}initialize(t){t(null)}loadTile(t,e,r){let n=null;e&&e.arraybuffer&&(n=[e.arraybuffer]);const i={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(i,n,r)}abortTileLoading(t,e,r){const n={mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}};this.broadcast(n,null,r)}addLayer(t,e,r){const n={actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}};this.broadcast(n,null,r)}removeLayer(t,e){const r={mapId:this.mapId,layerId:t,command:"removeLayer"};this.broadcast(r,null,e)}requestImage({url:t},e){const r=new Image;r.onload=()=>{if(!this.isActive())return;if(!Zt)return void e(new Error("There is no canvas to draw image!"));const t=function(t){if(jt(t.width)&&jt(t.height))return t;let e=t.width,r=t.height;jt(e)||(e=qt(e));jt(r)||(r=qt(r));const n=document.createElement("canvas");n.width=e,n.height=r,n.getContext("2d").drawImage(t,0,0,e,r);const i=t.src,s=i.lastIndexOf("/")+1,a=i.substring(s);return console.warn(`Texture(${a})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${r})`),n}(r);Zt.width=t.width,Zt.height=t.height;const n=Zt.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),s={width:t.width,height:t.height,data:new Uint8Array(i.data)};e(null,s,[s.data.buffer])},r.onerror=function(t){e(t)},r.src=t}}function jt(t){return 0==(t&t-1)&&0!==t}function qt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}class $t{constructor(t,e){this.max=t,this.currentSize=0,this.onRemove=e,this.reset()}reset(){if(this.data){const t=this.data.values();for(const e of t)this.onRemove(e)}return this.data=new Map,this.currentSize=0,this}clear(){this.reset(),delete this.onRemove}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const r=this.data.get(t);r&&r.node&&r.node.memorySize&&(this.currentSize-=r.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){const t=this.data.keys();let e=t.next();for(;this.currentSize>this.max&&void 0!==e.value;){if(!this.data.get(e.value).current){const t=this.getAndRemove(e.value);t&&this.onRemove(t)}e=t.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const r=this.data.keys();for(let n of r)t[e++]=n;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 e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e),this}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const r of e){const e=r&&r.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t){const e=this.data.values();for(const r of e)r.current=t}}function Xt(t,e){if(t.scenes&&t.scenes.length)for(let r=0,n=t.scenes.length;r<n;r++){const n=t.scenes[r].nodes;for(let r=0,i=n.length;r<i;r++){const i=[];Kt(n[r],i,t,e)}}}function Kt(t,e,r,n){if(t.matrix&&e.push(t.matrix),t.children&&t.children.length)for(let i=0,s=t.children.length;i<s;i++)Kt(t.children[i],e,r,n);if(void 0!==t.mesh){const i=t.mesh,s=r.meshes[i];if(s){const t=e.slice(0),a=s.primitives;for(let e=0,s=a.length;e<s;e++){const s=a[e];s&&(s.matrices=t,n(s,i,e,r))}}}}function Jt(t,e,r){let{componentType:n,byteOffset:i,byteStride:s,itemSize:a}=e;const o=e.array.buffer,l=n?Ct.getTypedArrayCtor(n):e.array.constructor;if(i=void 0===i?e.array.byteOffset:i,s=s||0,!s||s===a*l.BYTES_PER_ELEMENT&&i%l.BYTES_PER_ELEMENT==0){const e=new l(o,i+r*a*l.BYTES_PER_ELEMENT,a);return t.set(e),t}s||(s=a*l.BYTES_PER_ELEMENT);const c=new Uint8Array(o,s*r+i,a*l.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(c),t}function Wt(t,e,r,n){t[4*e]=r[n],t[4*e+1]=r[n+4],t[4*e+2]=r[n+8],t[4*e+3]=r[n+12]}const Qt=new Array(3),te=new Array(3),ee=[40680631590769,40680631590769,40408299984661.445];function re(t,e,r,n){const i=ee,s=Math.cos(r);Qt[0]=s*Math.cos(e),Qt[1]=s*Math.sin(e),Qt[2]=Math.sin(r),ue(Qt,Qt),H(te,i,Qt);const a=Math.sqrt(G(Qt,te));var o,l,c;return l=te,c=a,(o=te)[0]=l[0]/c,o[1]=l[1]/c,o[2]=l[2]/c,V(Qt,Qt,n),F(t,te,Qt)}const ne=[1/6378137,1/6378137,1/6356752.314245179],ie=[1/40680631590769,1/40680631590769,1/40408299984661.445],se=new Array(3),ae=new Array(3),oe=new Array(3);function le(t,e){const r=ie,n=function(t,e,r,n,i){const s=e[0],a=e[1],o=e[2],l=r[0],c=r[1],h=r[2],f=s*s*l*l,u=a*a*c*c,d=o*o*h*h,y=f+u+d,m=Math.sqrt(1/y),b=V(ce,e,m);if(y<i)return isFinite(m)?b:void 0;const _=n[0],p=n[1],g=n[2],w=he;w[0]=b[0]*_*2,w[1]=b[1]*p*2,w[2]=b[2]*g*2;let E,T,A,v,x,S,U,O,I,L,M,R=(1-m)*fe(e)/(.5*fe(w)),N=0;do{R-=N,A=1/(1+R*_),v=1/(1+R*p),x=1/(1+R*g),S=A*A,U=v*v,O=x*x,I=S*A,L=U*v,M=O*x,E=f*S+u*U+d*O-1,T=f*I*_+u*L*p+d*M*g;N=E/(-2*T)}while(Math.abs(E)>1e-12);return t[0]=s*A,t[1]=a*v,t[2]=o*x,t}(se,e,ne,r,.1);let i=$(ae,n,r);i=ue(i,i);const s=q(oe,e,n),a=Math.atan2(i[1],i[0]),o=Math.asin(i[2]),l=v(G(s,e))*fe(s);return t[0]=T(a),t[1]=T(o),t[2]=l,t}const ce=new Array(3),he=new Array(3);function fe(t){return k(t)}function ue(t,e){const r=e[0],n=e[1],i=e[2];let s=r*r+n*n+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function de(t,e){return H(e,t,ie),Z(e,e)}var ye=Object.freeze({__proto__:null,radianToCartesian3:re,cartesian3ToDegree:le,normalizeCartesian:ue,geodeticSurfaceNormal:de});function me(t,e){let r="";for(let n=0;n<4;n++){const i=t.getUint8(e+n);r+=String.fromCharCode(i)}return r}const be="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function _e(t,e,r){const n=new Uint8Array(t,e,r);return be?JSON.parse(be.decode(n)):JSON.parse(S(n))}function pe(t,e,r){const n=new Uint8Array(t,e,r);return be?JSON.parse(be.decode(n)):JSON.parse(S(n))}function ge(t,e,r){return{offset:e,byteLength:r}}function we(t,e,r,n){const{byteOffset:i,componentType:s,type:a}=t,{ctor:o,type:l}=function(t){return Ae[t]}(s),c=function(t){if(!t)return 1;return Te[t]}(a);return{byteStride:0,byteOffset:i+r,itemSize:c,count:n*c,componentType:l,array:new o(e,r+i,n*c)}}function Ee(t,e,r,n){t.componentType||(t.componentType="UNSIGNED_SHORT");const i=we(t,e,r,n);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}const Te={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Ae={"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 ve(t){for(let e in Ae)if(t===Ae[e].ctor)return Ae[e].type;throw new Error("unrecognized ctor:"+t)}function xe(t,e,r,n){const i=t,s=e.length/3;for(let t=0;t<s;t++)i[3*t]=e[3*t]/65535*n[0]+r[0],i[3*t+1]=e[3*t+1]/65535*n[1]+r[1],i[3*t+2]=e[3*t+2]/65535*n[2]+r[2];return i}function Se(t,e,r){let n=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),a=t.getUint32(24,!0);const o=t.buffer;let l,c,h={},f={};n>0&&(h=_e(o,e,n),e+=n),i>0&&(l=function(t,e,r){return{offset:e,byteLength:r}}(0,e,i),e+=i),s>0&&(f=pe(o,e,s),e+=s);const u=ge(0,e,a);return c=o.slice(u.offset,u.offset+u.byteLength),r.push(c),{featureTable:h,featureTableBin:l,batchTable:f,batchTableBin:c}}var Ue={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Oe={},Ie={east:[],north:[],up:[],west:[],south:[],down:[]},Le=[],Me=[],Re=[];const Ne=[0,0,0];function Be(t,e,r,n){r=r||0,n=n||r;var i=Math.abs(t-e);return i<=n||i<=r*Math.max(Math.abs(t),Math.abs(e))}function Pe(t,e,r){return r[0]=t[0],r[1]=t[1],r[2]=t[2],r[3]=t[3],r[4]=t[4],r[5]=t[5],r[6]=t[6],r[7]=t[7],r[8]=t[8],r[9]=t[9],r[10]=t[10],r[11]=t[11],r[12]=e[0],r[13]=e[1],r[14]=e[2],r[15]=t[15],r}const ke=(Fe={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"}}[Ce="east"][De="north"],Oe[Ye=Ce+De]?ze=Oe[Ye]:(ze=function(t,e,r){if(o=Ne,l=(a=t)[0],c=a[1],h=a[2],f=o[0],u=o[1],d=o[2],Math.abs(l-f)<=1e-6*Math.max(1,Math.abs(l),Math.abs(f))&&Math.abs(c-u)<=1e-6*Math.max(1,Math.abs(c),Math.abs(u))&&Math.abs(h-d)<=1e-6*Math.max(1,Math.abs(h),Math.abs(d)))D(Le,Ue[Ce]),D(Me,Ue[De]),D(Re,Ue[Fe]);else if(Be(t[0],0,1e-14)&&Be(t[1],0,1e-14)){var n=v(t[2]);D(Le,Ue[Ce]),"east"!==Ce&&"west"!==Ce&&V(Le,Le,n),D(Me,Ue[De]),"east"!==De&&"west"!==De&&V(Me,Me,n),D(Re,Ue[Fe]),"east"!==Fe&&"west"!==Fe&&V(Re,Re,n)}else{de(t,Ie.up);var i=Ie.up,s=Ie.east;s[0]=-t[1],s[1]=t[0],s[2]=0,Z(Ie.east,s),j(Ie.north,i,s),V(Ie.down,Ie.up,-1),V(Ie.west,Ie.east,-1),V(Ie.south,Ie.north,-1),Le=Ie[Ce],Me=Ie[De],Re=Ie[Fe]}var a,o,l,c,h,f,u,d;return r[0]=Le[0],r[1]=Le[1],r[2]=Le[2],r[3]=0,r[4]=Me[0],r[5]=Me[1],r[6]=Me[2],r[7]=0,r[8]=Re[0],r[9]=Re[1],r[10]=Re[2],r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r},Oe[Ye]=ze),ze);var Ce,De,ze,Fe,Ye;const He=[],Ve=[],Ze=[],Ge=[],je=[],qe=[],$e=[],Xe={x:0,y:0},Ke={x:0,y:0},Je=Math.PI/180;const{getTextureMagFilter:We,getTextureMinFilter:Qe,getTextureWrap:tr,getMaterialType:er,getMaterialFormat:rr,getPrimitive:nr,getUniqueREGLBuffer:ir}=r.REGLHelper,sr=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],ar=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:or,logoutIBLResOnCanvas:lr,getIBLResOnCanvas:cr,getPBRUniforms:hr}=r.pbr.PBRUtils,fr={factor:0,units:0},ur={specularStrength:0,materialShininess:1},dr=[1,1,1],yr=n.identity([]),mr=t=>t.material instanceof r.PhongMaterial,br=t=>t.material instanceof r.pbr.StandardMaterial,_r=[!0,!0,!0,!0],pr=[],gr=new t.Coordinate(0,0),wr=[],Er=[],Tr={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT"};class Ar{constructor(e,n){this.W=n,this.tt=n.getRenderer().canvas,this.et=new t.SpatialReference,this.rt=e,this.nt=new r.Renderer(e),this.it={},this.st={},this.at={},this.ot={},this.lt={},this.ct={},this.ht={},this.ft=new r.Scene,this.ut=new r.Scene,this.dt=new r.Scene,this.yt=new r.Scene,this.bt=new r.ResourceLoader(e.texture(2)),this._t=this.gt.bind(this),this.wt=new r.PhongMaterial({"baseColorFactor":[1,1,1,1]}),this.Et(),this.Tt=new r.KHRTechniquesWebglManager(this.rt,this.At(),this.bt)}getI3DMMeshes(){return this.lt}getPNTSMeshes(){return this.ot}getB3DMMeshes(){return this.at}getMap(){return this.W.getMap()}paint(t,e,r,n){const i=this.getMap();if(!t.length||!i)return;const s=this.vt(),a=i.projViewMatrix,o=this.W.options.services,l=[];let c=[];for(let r=0,n=t.length;r<n;r++){let n=this.xt(t[r].data.node);if(!n){if(n=this.ct[t[r].data.node.id],!n)continue;n=O(n)}const i=t[r].node;let h=o[i.St].polygonOffset||fr;w(h)&&(h=h());const f=o[i.St].ambientLight;for(let o=0,u=n.length;o<u;o++)"b3dm"===n[o].properties.magic&&(n[o].getBoundingBox&&!d(a,n[o].getBoundingBox())||(n[o].properties.level=t[r].selectionDepth,n[o].properties.polygonOffset=h,Object.prototype.hasOwnProperty.call(n[o].uniforms,"ambientColor")||Object.defineProperty(n[o].uniforms,"ambientColor",{enumerable:!0,get:function(){return f||s.ambientColor}}),n[o].Ut=i,e[i.id]||l.push(n[o]),c.push(n[o])))}let h=0;const f=this.Tt.getExcludeFilter();h+=this.Ot(this.It,s,[r,mr,f],n,l,c),h+=this.Ot(this.Lt,s,[r,br,f],n,l,c),this.Tt.forEachShader(((t,e,i)=>{const s=this.vt(i);h+=this.Ot(t,s,[r,e],n,l,c)}));const u=[];for(const t in this.ot)u.push(this.ot[t]);this.ut.setMeshes(u);const y=this.Mt();return h+=this.nt.render(this.Rt,y,this.ut,n&&n.fbo),h}Ot(t,e,r,n,i,s){t.filter=r.filter((t=>!!t)),e.debug=!1,this.ft.setMeshes(i),e.stencilEnable=!1,e.debug=!1,e.cullFace="back",e.colorMask=_r;let a=0;this.ft.setMeshes(s),a+=this.nt.render(t,e,this.ft,n&&n.fbo),e.stencilEnable=!1;const o=[];for(const t in this.lt)o.push(...this.lt[t]);return this.dt.setMeshes(o),a+=this.nt.render(t,e,this.dt,n&&n.fbo),a}Nt(t,e){return e.Ut.Bt-t.Ut.Bt}paintRegion(t,e,r,n,i){const s=this.getMap();if(!t.length&&!e.length)return;const a=s.projViewMatrix,o=[];for(let r=0,n=(t=t.concat(e)).length;r<n;r++){const e=t[r].node,n=this.Pt(e);n&&(n.getBoundingBox&&!d(a,n.getBoundingBox())||o.push(n))}this.kt.filter=n,this.yt.setMeshes(o);const l=this.Ct(r);this.nt.render(this.kt,l,this.yt,i&&i.fbo)}deleteTile(t){const e=t.node.id;this.Dt(e)}Dt(t){const e=this.st[t];e&&(e.geometry.dispose(),e.dispose(),delete this.st[t]);let r=this.at[t]||this.ot[t]||this.lt[t]||this.ct[t]||this.it[t];this.ct[t]?this.zt(t):r&&(this.Ft(r),delete this.at[t],delete this.ot[t],delete this.lt[t],delete this.it[t])}zt(t){let e=this.ct[t];e=O(e);for(let t=0;t<e.length;t++){const{id:r}=e[t].properties;this.Dt(r)}delete this.ct[t]}Ft(t){if(Array.isArray(t))for(let e=0,r=t.length;e<r;e++)this.Ft(t[e]);else{const e=t.geometry.properties.url;if(e){const t=this.ht[e];t&&(t.refCount--,t.refCount<=0&&(t.geometry.dispose(),t.material.dispose(),delete this.ht[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.W;lr(t.getRenderer().canvas,t.getMap());for(const t in this.ct)this.zt(t);this.ct={};for(const t in this.at)this.Dt(t);this.at={};for(const t in this.ot)this.Dt(t);this.ot={};for(const t in this.lt)this.Dt(t);this.lt={};for(const t in this.it)this.Dt(t);this.it={};for(const t in this.st)this.Dt(t);this.st={},this.It&&(this.It.dispose(),delete this.It),this.Lt&&(this.Lt.dispose(),delete this.Lt),this.Rt&&(this.Rt.dispose(),delete this.Rt),this.kt&&(this.kt.dispose(),delete this.kt),this.Tt.dispose()}Pt(e){if(!e.boundingVolume||!e.boundingVolume.region)return null;if(this.st[e.id])return this.st[e.id];const i=e.boundingVolume.region;let s=new t.Coordinate(T(i[0]),T(i[1])),a=new t.Coordinate(T(i[2]),T(i[3]));s=this.Yt(s),a=this.Yt(a);const o=s.add(a).Ht(.5);s._sub(o),a._sub(o);const l=this.Vt(i[4],i[5]),c=l.x,h=l.y,f=[s.x,s.y,h,a.x,s.y,h,a.x,a.y,h,s.x,a.y,h,s.x,s.y,c,a.x,s.y,c,a.x,a.y,c,s.x,a.y,c],u=new r.Geometry({aPosition:f},[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],0,{primitive:"lines"});u.generateBuffers(this.rt);const d=new r.Mesh(u),y=n.identity([]);return d.setLocalTransform(n.translate(y,y,[o.x,o.y,0])),this.st[e.id]=d,d}xt(t){return this.at[t.id]}has(t){return this.xt(t)||this.ot[t.id]||this.lt[t.id]||this.ct[t.id]||this.it[t.id]}createPntsMesh(t,e,i,s){if(this.ot[e]){const t=this.ot[e];return console.warn(`pnts mesh with id(${e}) was already created.`),s(null,{id:e,mesh:t}),t}const{pnts:a,featureTable:o,rootIdx:l}=t,c=o.POINTS_LENGTH,h=new r.Geometry(a,null,c,{primitive:"points",positionAttribute:"POSITION"});h.generateBuffers(this.rt);const f={};a.POSITION?f.HAS_POSITION=1:a.POSITION_QUANTIZED&&(f.HAS_POSITION_QUANTIZED=1),a.RGB?f.HAS_RGB=1:a.RGBA?f.HAS_RGBA=1:a.RGB565&&(f.HAS_RGB565=1),(a.NORMAL||a.NORMAL_OCT16P)&&(f.HAS_NORMAL=1,a.NORMAL_OCT16P&&(f.HAS_NORMAL_OCT16P=1)),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:u,rtcCoord:d}=t,y=this.Zt(d),m=this.Gt(i,u,d);n.multiply(m,m,y);const b=this.W.options.services[l],_=new r.Mesh(h);return _.properties.magic="pnts",_.properties.id=e,_.properties.count=c,_.properties.batchTable=t.batchTable,_.properties.batchTableBin=t.batchTableBin,_.setDefines(f),Object.defineProperty(_.uniforms,"pointColor",{enumerable:!0,get:function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:b&&b.pointColor||[1,1,1,1]}}),Object.defineProperty(_.uniforms,"pointSize",{enumerable:!0,get:function(){return b&&b.pointSize||2}}),Object.defineProperty(_.uniforms,"pointOpacity",{enumerable:!0,get:function(){return b&&b.pointOpacity||1}}),_.setLocalTransform(m),this.ot[e]=_,s(null,{id:e,mesh:[_]}),[_]}createI3DMMesh(t,e,s,a){if(this.lt[e]){const t=this.lt[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.it[e]||a(null,{id:e,mesh:t}),t}const l=this.jt(s.qt),{i3dm:c,featureTable:h,gltf:f,batchTable:u,batchTableBin:d,count:y}=t,m=h.INSTANCES_LENGTH,{rtcCenter:b,rtcCoord:_}=t,p=this.Zt(_),g=this.Gt(s,b,_),{POSITION:w,NORMAL_UP:E,NORMAL_RIGHT:T,SCALE:A,SCALE_NON_UNIFORM:v,INSTANCE_ROTATION:x}=c,S={"instance_vectorA":new Float32Array(4*m),"instance_vectorB":new Float32Array(4*m),"instance_vectorC":new Float32Array(4*m)},O=new Float32Array(3),I=new Float32Array(3),L=[],M=new Float32Array(1),R=new Float32Array(3),N=[],B=[],P=[],k=[],C=new Float32Array(9);!function(t,e){let{componentType:r,byteOffset:n,byteStride:i,count:s,itemSize:a}=t;const o=t.array.buffer,l=r?Ct.getTypedArrayCtor(r):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,i=i||0,s=s||t.array.length/a,(!i||i===a*l.BYTES_PER_ELEMENT)&&n%l.BYTES_PER_ELEMENT==0){const t=new l(o,n,s*a);for(let r=0;r<s*a;r+=a)e(new l(t.buffer,n+r*l.BYTES_PER_ELEMENT,a),r/a);return}const c=new Uint8Array(a*l.BYTES_PER_ELEMENT);i||(i=a*l.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const r=new Uint8Array(o,i*t+n,a*l.BYTES_PER_ELEMENT);c.set(r),e(new l(c.buffer),t),r.set(c)}}(w,((t,e)=>{E?(Jt(I,T,e),Jt(O,E,e),i.cross(L,I,O),i.normalize(L,L),U(N,I,0),U(N,O,1),U(N,L,2),o.fromMat3(B,N)):x?(Jt(C,x,e),o.fromMat3(B,C)):o.identity(B),A?(Jt(M,A,e),i.set(P,M[0],M[0],M[0])):v?(Jt(R,v,e),i.set(P,...R)):i.set(P,1,1,1),n.fromRotationTranslationScale(k,B,t,P),Wt(S.instance_vectorA,e,k,0),Wt(S.instance_vectorB,e,k,1),Wt(S.instance_vectorC,e,k,2)}));const D={};for(const t in S)D[t]={buffer:this.rt.buffer({dimension:S[t].length/m,data:S[t]}),divisor:1};const z=this.W.options.services[s.St].shader||"phong";let F=0,Y=!0;const H=[];return Xt(f,((t,i,a,o)=>{let{geometry:c,material:h}=this.$t(t,i,a,o,s,!0,z);h&&!h.isReady()&&(Y=!1,F++);const f=new r.InstancedMesh(D,m,c,h);f.properties.magic="i3dm",f.properties.id=e,f.properties.count=y,f.properties.batchTable=u,f.properties.batchTableBin=d;const b=this.Xt(t,c,h,s.St),_=n.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.multiply(_,_,t.matrices[e]);n.multiply(_,l,_),f.setPositionMatrix(_),n.multiply(p,g,p),f.setLocalTransform(p),f.setDefines(b),f.properties.polygonOffset={offset:0,factor:0},H.push(f)})),Y?(this.lt[e]=H,a(null,{id:e,mesh:H})):(this.it[e]={meshes:H,count:F},H.Kt=a),H}createB3DMMesh(e,i,s,a){if(this.at[i]||this.it[i]){const t=this.at[i];return console.warn(`mesh with id(${i}) was already created.`),this.it[i]||a(null,{id:i,mesh:t}),t}let o;if(s.maxExtent){const e=new t.Extent(s.maxExtent).convertTo((t=>this._pointToPrj(t)));o=[e.xmin,e.ymin,e.xmax,e.ymax]}const l=this.jt(s.qt),c=e.gltf,{center:h,coord:f}=c.extensions.CESIUM_RTC,u=this.W.options.services[s.St].heightOffset||0;u&&(f[2]+=u);const d=this.Zt(f,s.St),y=this.W.options.services[s.St].shader||"phong",m=[];let b=0,_=!0;return Xt(c,((t,a,c,u)=>{let{geometry:p,material:g}=this.$t(t,a,c,u,s,!1,y);g&&!g.isReady()&&(_=!1,b++);const w=new r.Mesh(p,g);w.properties.magic="b3dm",w.properties.id=i,w.properties.batchTable=e.batchTable,w.properties.batchTableBin=e.batchTableBin,w.properties.count=e.featureTable.BATCH_LENGTH;const E=this.Xt(t,p,g,s.St);w.setDefines(E),o&&(E.USE_MAX_EXTENT=1,w.setUniform("maxPrjExtent",o));let T=n.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.multiply(T,T,t.matrices[e]);const A=this.Gt(s,h,f);n.multiply(T,l,T),n.multiply(T,d,T),n.multiply(T,A,T),w.setLocalTransform(T),m.push(w)})),_?(this.at[i]=m,a(null,{id:i,mesh:m})):(this.it[i]={meshes:m,count:b},m.Kt=a),m}Gt(e,r,s){const a=this.getMap(),o=this.W.options.services[e.St].heightOffset||0,l=new t.Coordinate(s),c=a.distanceToPointAtRes(100,0,a.getGLRes(),l).x/100;let h=e.matrix?n.copy([],e.matrix):n.identity([]);if(r){Pe(h,i.transformMat4(pr,r,h),h)}const f=function(t,e,r,n,i,s,a){e=D(He,e);const o=re(He,e[0]*Je,e[1]*Je,e[2]),l=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(Ve,r),c=n.ellipsoid;var h;h=0===X(l)?z(Ze,0,0,-6378137):le(Ze,l),Xe.x=h[0],Xe.y=h[1];const f=n.project(Xe,Ke);Ge[0]=f.x/i,Ge[1]=f.y/i,Ge[2]=(h[2]+a)*s;const u=ke(o,c,je),d=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],f=e[9],u=e[10],d=e[11],y=e[12],m=e[13],b=e[14],_=e[15],p=r*o-n*a,g=r*l-i*a,w=r*c-s*a,E=n*l-i*o,T=n*c-s*o,A=i*c-s*l,v=h*m-f*y,x=h*b-u*y,S=h*_-d*y,U=f*b-u*m,O=f*_-d*m,I=u*_-d*b,L=p*I-g*O+w*U+E*S-T*x+A*v;return L?(L=1/L,t[0]=(o*I-l*O+c*U)*L,t[1]=(i*O-n*I-s*U)*L,t[2]=(m*A-b*T+_*E)*L,t[3]=(u*T-f*A-d*E)*L,t[4]=(l*S-a*I-c*x)*L,t[5]=(r*I-i*S+s*x)*L,t[6]=(b*w-y*A-_*g)*L,t[7]=(h*A-u*w+d*g)*L,t[8]=(a*O-o*S+c*v)*L,t[9]=(n*S-r*O-s*v)*L,t[10]=(y*T-m*w+_*p)*L,t[11]=(f*w-h*T-d*p)*L,t[12]=(o*x-a*U-l*v)*L,t[13]=(r*U-n*x+i*v)*L,t[14]=(m*g-y*E-b*p)*L,t[15]=(h*E-f*g+u*p)*L,t):null}(qe,u),y=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}($e,r),m=function(t,e,r){var n=t[0],i=t[1],s=t[2],a=t[4],o=t[5],l=t[6],c=t[8],h=t[9],f=t[10],u=e[0],d=e[1],y=e[2],m=e[3],b=e[4],_=e[5],p=e[6],g=e[7],w=e[8],E=n*u+a*d+c*y,T=i*u+o*d+h*y,A=s*u+l*d+f*y,v=n*m+a*b+c*_,x=i*m+o*b+h*_,S=s*m+l*b+f*_,U=n*p+a*g+c*w,O=i*p+o*g+h*w,I=s*p+l*g+f*w;return r[0]=E,r[1]=T,r[2]=A,r[3]=0,r[4]=v,r[5]=x,r[6]=S,r[7]=0,r[8]=U,r[9]=O,r[10]=I,r[11]=0,r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r}(d,y,t);return Pe(t,Ge,m),t}(h,s,h,a.getProjection(),a.getGLRes(),c,o),u=function(t,e){return z(t,e[12],e[13],e[14]),t}(Er,f);let d=this.W.options.offset;if(w(d)){d=d(this.W.Jt(e.id).center)}return i.set(wr,d[0],d[1],0),i.sub(u,u,wr),Pe(f,u,f),f}createCMPTMesh(t,e,r,n){if(this.ct[e]){const t=this.ct[e];return console.warn(`mesh with id(${e}) was already created.`),n(null,{id:e,mesh:t}),t}const{content:i}=t,s=[];for(let t=0;t<i.length;t++){const{magic:n}=i[t],a=e+"."+t;"b3dm"===n?this.createB3DMMesh(i[t],a,r,((t,{mesh:e})=>{s.push(e)})):"i3dm"===n?this.createI3DMMesh(i[t],a,r,((t,{mesh:e})=>{s.push(e)})):"pnts"===n?this.createPntsMesh(i[t],a,r,((t,{mesh:e})=>{s.push(e)})):"cmpt"===n&&this.createCMPTMesh(i[t],a,r,((t,{mesh:e})=>{s.push(e)}))}return this.ct[e]=s,n(null,{id:e,mesh:s}),s}Xt(t,e,r,n){return("phong"===(this.W.options.services[n].shader||"phong")?this.It:this.Lt).getGeometryDefines(e)}$t(t,e,r,n,i,s,a){const o=n.url+"-"+e+"-"+r;if(this.ht[o])return this.ht[o].refCount++,this.ht[o];let l,c;const h=n.materials[t.material];if(n.extensions&&n.extensions.KHR_techniques_webgl&&h.extensions&&h.extensions.KHR_techniques_webgl){const e=this.Wt(t,n,s);l=e.material,c=e.geometry}else{c=this.Qt(t,s,Tr);const e=this.W.options.services[i.St].material;l=this.te(t.material,n,a,e||ur)}l&&!l.isReady()?l.ee=i.id:l||(l=this.wt);const f={refCount:1,geometry:c,material:l};return c.properties.url=o,this.ht[o]=f,f}Wt(t,e,r){const{geometry:n,material:i}=this.Tt.createMesh(t,e,r);return{geometry:n,material:i}}Qt(t,e,n){const i=t.attributes,s=n.COLOR_0;if(i[s]&&i[s]instanceof Float32Array){const t=new Uint8Array(i[s].length);for(let e=0;e<t.length;e++)t[e]=Math.round(255*i[s][e]);i[s]=t}const a={};for(const t in i){const e=ir(this.rt,i[t],{dimension:i[t].itemSize}),r=n[t]||t;a[r]={buffer:e},r===n.POSITION&&(a[r].array=i[t].array,a[r].min=i[t].min,a[r].max=i[t].max)}delete t.attributes;const o=new r.Geometry(a,t.indices.array?t.indices.array:t.indices,0,{positionAttribute:n.POSITION,normalAttribute:n.NORMAL,uv0Attribute:n.TEXCOORD_0,uv1Attribute:n.TEXCOORD_1,color0Attribute:n.COLOR_0,tangentAttribute:n.TANGENT,primitive:void 0===t.mode?"triangles":nr(t.mode)});return o.generateBuffers(this.rt,{excludeElementsInVAO:e}),o}Zt(t){const e=n.identity([]),r=this.getMap(),s=this.re();gr.x=t[0],gr.y=t[1];const a=r.distanceToPointAtRes(100,100,r.getGLRes(),gr);return i.set(s,a.x/100*1.01,a.y/100*1.01,a.y/100),n.scale(e,e,s),e}Et(){const t={x:0,y:0,width:()=>this.tt?this.tt.width:1,height:()=>this.tt?this.tt.height:1};this.kt=new r.MeshShader({vert:"attribute vec3 aPosition;\n\n\n\nuniform mat4 projViewModelMatrix;\n\n\n\nvoid main() {\n\n gl_Position = projViewModelMatrix * vec4(aPosition, 1.0);\n\n}\n\n",frag:"precision mediump float;\nuniform vec3 color;\nvoid main() {\n gl_FragColor = vec4(color, 1.0);\n}\n",uniforms:["color",{name:"projViewModelMatrix",type:"function",fn:(t,e)=>n.multiply([],e.projViewMatrix,e.modelMatrix)}],extraCommandProps:{viewport:t}});const e=[],i=[];this.Rt=new r.MeshShader({vert:"const 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\n\nvoid main() {\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_POSITION\n\n vec3 localPos = POSITION;\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\n\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n gl_PointSize = pointSize;\n\n}\n\n",frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n gl_FragColor = vColor;\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>n.multiply(i,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,r)=>s.fromMat4(e,r.modelMatrix)}],extraCommandProps:{viewport:t,blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,range:[0,1],func:"<"}}});const a=this.At();this.It=new r.PhongShader({extraCommandProps:a}),this.Lt=new r.pbr.StandardShader({extraCommandProps:a});const o=this.W;or(o.getRenderer().canvas,this.rt,o.getMap())}At(){return{viewport:{x:0,y:0,width:()=>this.tt?this.tt.width:1,height:()=>this.tt?this.tt.height:1},colorMask:(t,e)=>e.colorMask||_r,cull:{enable:!0,face:(t,e)=>e.cullFace},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:">=",ref:(t,e)=>e.meshProperties.level},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"keep"}},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}Ct(t){return{projViewMatrix:this.getMap().projViewMatrix,color:t&&t.color||[0,1,0]}}Mt(t){const e=this.getMap(),r=e.getLightManager(),n=(r&&r.getDirectionalLight()||{}).direction||[1,1,-1],s=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:s,lightDir:i.normalize(n,n)}}vt(){const t=this.getMap(),e=this.W.getRenderer().canvas,{iblTexes:r,dfgLUT:n}=cr(e),i=hr(t,r,n);return g(i,{lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[e.width,e.height],polygonFill:[1,1,1,1],polygonOpacity:1}),i}te(t,e,n,i){const s=e.materials[t];if(!s||!s.baseColorTexture&&!s.pbrMetallicRoughness)return null;const o=g({},i);if(s.baseColorTexture){const t=e.textures[s.baseColorTexture.index];let r;t&&!t.image.color&&(r=this.O(t)),o.baseColorFactor=t&&t.image.color||s.baseColorFactor||[1,1,1,1],r&&(o.baseColorTexture=r)}else{if(s.normalTexture){const t=this.O(e.textures[s.normalTexture.index]),r=s.normalTexture.scale||1;o.normalTexture=t,o.normalMapFactor=r}if(s.occlusionTexture){const t=this.O(e.textures[s.occlusionTexture.index]),r=s.occlusionTexture.strength||1;o.occlusionTexture=t,o.occlusionFactor=r}if(s.emissiveTexture){const t=this.O(e.textures[s.emissiveTexture.index]);o.emissiveTexture=t}s.emissiveFactor;const t=s.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(o.baseColorFactor=t.baseColorFactor),t.baseColorTexture){const r=e.textures[t.baseColorTexture.index];r.image.color?o.baseColorFactor=o.baseColorFactor?a.multiply(o.baseColorFactor,o.baseColorFactor,r.image.color):r.image.color:(o.baseColorTexture=this.O(r),o.baseColorTexture.getREGLTexture(this.rt))}if(p(t.metallicFactor)||(o.metallicFactor=t.metallicFactor),p(t.roughnessFactor)||(o.roughnessFactor=t.roughnessFactor),s.metallicRoughnessTexture){const t=this.O(e.textures[s.metallicRoughnessTexture.index]);o.metallicRoughnessTexture=t}}}let l=new r.pbr.StandardMaterial(o);return"phong"===n&&(l=r.PhongMaterial.convertFrom(l)),l.once("complete",this._t),l}O(t){const e={type:t.type?er(t.type):"uint8",format:t.format?rr(t.format):"rgba",flipY:!1},n=t.image;n.array?e.data=n.array:n.mipmap&&(e.mipmap=n.mipmap),e.width=n.width,e.height=n.height;const i=t.sampler||t.texture.sampler;return i&&(i.magFilter&&(e.mag=We(i.magFilter)),i.minFilter&&(e.min=Qe(i.minFilter)),i.wrapS&&(e.wrapS=tr(i.wrapS)),i.wrapT&&(e.wrapT=tr(i.wrapT))),new r.Texture2D(e,this.bt)}ne(t){const e=t.image,r=window.URL||window.webkitURL,n=new Blob([e.array],{type:e.mimeType});return r.createObjectURL(n)}gt({target:t}){const e=t.ee,r=this.it[e];if(r.count--,!r.count){const t=r.meshes;this.at[e]=t,delete this.it[e];const n=t.Kt;delete t.Kt,n(null,{mesh:r.meshes,id:e})}}re(){return dr}Yt(t){return this.W.Yt(t)}Vt(t,e){const r=this.getMap();return r.getGLZoom?r.distanceToPoint(t,e,r.getGLZoom()):r.distanceToPointAtRes(t,e,r.getGLRes())}_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())}jt(t){return"Y"===t?sr:"X"===t?ar:yr}}class vr extends t.renderer.CanvasRenderer{constructor(t){super(t),this.prepareWorker(),this.tilesLoading={},this.tileCache=new $t(1024*t.options.maxGPUMemory*1024,this.deleteTile.bind(this)),this.ie={},this.se=[]}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.se.length||super.needToRedraw())}drawOnInteracting(t,e,r){this.draw(e,r)}draw(t,e){const r=this.prepareCanvas();if(r&&!r.intersects(this.canvasExtent2D))return void this.completeRender();const{root:n,tiles:i}=this.layer.getTiles(),s=i.length;if(!i||!s)return void this.completeRender();this.ae();const{selectedTiles:a,leaves:o,requests:l}=this.oe(n,i);l.length&&this.loadTiles(l),this.le(a,o,e),this.ce(),l.length||this.completeRender()}oe(t,e){let r=[];this.he();let n=0;const i=this.fe(),s={};let a=!1,o=!1;for(let t=0;t<e.length;t++){const i=e[t],l=i.node;if(s[l.id])continue;s[l.id]=1;let c=!1;const h=this.ue(l.id);if(this.de(l.id)?(n++,c=o=!0,this.tilesLoading[l.id].current=!0):h?(this.getTileOpacity(h)<1&&(c=o=!0),a=!0,i.selected=!0,i.data=h):this.painter.has(l)||(c=o=!0,r.push(l)),!c)continue;if(this.ye(i))a=!0;else{this.me(i).length&&(a=!0)}}let l=[],c={};if(a&&({selectedTiles:l,leaves:c}=this.be(t)),r.length>1&&(r.sort(xr),i)){const t=i-n;r=t>0?r.slice(0,t):[]}return{loading:o,requests:r,selectedTiles:l,leaves:c}}be(t){const e=[],r={};let n;const i=[t],s=[];for(;i.length>0||s.length>0;){if(s.length>0){const t=s[s.length-1];if(t._e===i.length){s.pop(),t===n&&(t.leave=!0,r[t.node.id]=1),e.push(t);continue}}const t=i.pop(),a=t.children;if(t.selected)if("add"===t.node.refine)r[t.node.id]=1,t.selectionDepth=s.length,e.push(t);else{if(t.selectionDepth=s.length,n=t,0===a.length){t.leave=!0,r[t.node.id]=1,e.push(t);continue}s.push(t),t._e=i.length}for(let t=0;t<a.length;t++)i.push(a[t])}return{selectedTiles:e,leaves:r}}ye(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}me(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const r=t.pe+1,n=[t.node];for(;n.length>0;){const i=n.pop().children;for(let s=0,a=i.length;s<a;s++){if((!i[s].content||!i[s].content.url)&&i[s].children&&i[s].children.length){n.push(i[s]);continue}const a=i[s].id;if(this.tileCache.has(a)){const r=this.layer.ge(i[s],t);r.selected=!0,r.data=this.tileCache.get(a),t.children.push(r),e.push(r)}else i[s].pe<=r&&n.push(i[s])}}return e}le(t,e,r){this.tileCache.markAll(!1);for(let e=0,r=t.length;e<r;e++){const r=t[e].data;r.current=!0,this.tileCache.add(t[e].node.id,r)}this.tileCache.shrink();const n={tiles:t,leaves:e};this.onDrawTileStart(n);const i=r&&r.renderTarget,s=r&&r.sceneFilter,a=this.painter.paint(t,e,s,i);this.layer.options.debug&&this.painter.paintRegion(t,{color:this.layer.options.debugOutline},s,i),this.onDrawTileEnd(n),a&&this.layer.fire("canvasisdirty",{renderCount:a})}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,r=t.length;e<r;e++){const r=t[e];this.tilesLoading[r.id]={current:!0,node:r},this.loadTile(r)}}loadTile(t){let e=t.content.url;if(L(e)){const r=M(e);return void this.we(e,r,t)}t&&-1===e.indexOf("http://")&&-1===e.indexOf("https://")&&(e=t.baseUrl+e);const r=this.layer.options.services[t.St];if(r.ajaxInMainThread){let n=r.urlParams;n&&(n=(e.indexOf("?")>0?"&":"?")+n);let i=_t.getArrayBuffer(e+(n||""),r.fetchOptions);const s=i.xhr;i=i.then((r=>{delete this.ie[e],r?this.we(e,r.data,t):this.onTileError(null,t)})).catch((r=>{delete this.ie[e],this.onTileError(r,t)})),this.ie[e]=s}else this.we(e,null,t)}we(t,e,n){let i=this.o;i||(i=r.Util.getSupportedFormats(this.gl.gl||this.gl),this.o=i),this.workerConn.loadTile(this.layer.getId(),{url:t,arraybuffer:e,rootIdx:n.St,upAxis:n.qt,transform:n.matrix,supportedFormats:i},((e,r)=>{if(e)return void this.onTileError(e,n);const{magic:i}=r;"b3dm"===i||"pnts"===i||"i3dm"===i||"cmpt"===i?this.se.push({data:r,tile:n}):this.onTilesetLoad(r,n,t)}))}ae(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let r=0;for(;this.se.length&&(r<e||!t.isInteracting());){const{data:t,tile:e}=this.se.shift(),{magic:n}=t;"b3dm"===n?this.painter.createB3DMMesh(t,e.id,e,((r,{mesh:n})=>{this.Ee(t,e,r,n)})):"pnts"===n?this.painter.createPntsMesh(t,e.id,e,((r,{mesh:n})=>{this.Ee(t,e,r,n)})):"i3dm"===n?this.painter.createI3DMMesh(t,e.id,e,((r,{mesh:n})=>{this.Ee(t,e,r,n)})):"cmpt"===n&&this.painter.createCMPTMesh(t,e.id,e,((r,{mesh:n})=>{this.Ee(t,e,r,n)})),r++}}Ee(t,e,r,n){if(r)this.onTileError(r,e);else{const r=this.Te(n);e.memorySize=r,this.onTileLoad(t,e)}}Te(t){let e=0;if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]&&(e+=this.Te(t[r]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.Ae(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,r){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,r))}onTileError(t,e){if(!this.layer)return;const r=e.content.url;console.warn("failed to load 3d tile: "+r),console.warn(t),delete this.tilesLoading[e.id],this.Ae(e),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}ue(t){return this.tileCache.get(t)}Ae(e){const r={loadTime:t.Util.now(),current:!0,node:e};this.tileCache.add(e.id,r)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;if(this.layer.options.services[t.node.St].ajaxInMainThread){const t=this.ie[e];t&&t.abort()}else this.workerConn.abortTileLoading(this.layer.getId(),e);delete this.ie[e]}he(){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};this.canvas.gl&&this.canvas.gl.wrap?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.ve(this.canvas,e)),this.regl=this.regl||l({gl:this.gl,attributes:e,extensions:["OES_element_index_uint","WEBGL_compressed_texture_s3tc"],optionalExtensions:t.options.optionalExtensions||[]}),this.painter=new Ar(this.regl,t)}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new Gt("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=g({},r),delete r.offset,r.projection=t.getSpatialReference().getProjection().code;const n=this.layer.getId();e.addLayer(n,r,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.ce(!0),this.tileCache.reset(),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}ce(t){this.xe||(this.xe=Date.now());const e=Date.now();if(t||!(e-this.xe<this.layer.options.retireInterval)){this.xe=e;for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||this.abortTileLoading(r)}}}fe(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}ve(t,e){const r=["webgl","experimental-webgl"];let n=null;for(let i=0;i<r.length;++i){try{n=t.getContext(r[i],e)}catch(t){}if(n)break}return n}de(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,r){return we(t,e,0,r)}}function xr(t,e){return t.Bt-e.Bt}function Sr(t,e,r){return t[0]=e[r],t[1]=e[r+3],t[2]=e[r+6],t}function Ur(t,e,r){return Math.sqrt(function(t,e,r){var n=Y(Or,r,t),i=Sr(Ir,e,0),s=Sr(Lr,e,1),a=Sr(Mr,e,2),o=X(i),l=X(s),c=X(a);Z(i,i),Z(s,s),Z(a,a);var h=Rr;h[0]=G(n,i),h[1]=G(n,s),h[2]=G(n,a);var f,u=0;h[0]<-o?u+=(f=h[0]+o)*f:h[0]>o&&(u+=(f=h[0]-o)*f);h[1]<-l?u+=(f=h[1]+l)*f:h[1]>l&&(u+=(f=h[1]-l)*f);h[2]<-c?u+=(f=h[2]+c)*f:h[2]>c&&(u+=(f=h[2]-c)*f);return u}(t,e,r))}const Or=[],Ir=[],Lr=[],Mr=[],Rr=[];const Nr=t.projection.EPSG3857,Br=new t.Extent(0,0,0,0),Pr=new t.Extent(0,0,0,0),kr=[],Cr=[],Dr=[],zr=[],Fr=new t.Point(0,0),Yr=new t.Coordinate(0,0),Hr=new t.Coordinate(0,0),Vr=[],Zr=new t.Coordinate(0,0),Gr=n.identity([]);class jr extends t.Layer{constructor(t,e){super(t,e),this.Se(),this.ie={},this.Ue=[]}Se(){let t=this.options.services.map((t=>t.url));this.Oe=t.map(((t,e)=>function(t,e){t=A(t);return{baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:n.identity([]),St:e,pe:0}}(t,e))),this.fire("rootready",{roots:this.Oe.slice(0)})}getExtent(e){if(!e&&0!==e){const e=new t.Extent;for(let t=0;t<this.Oe.length;t++)if(this.Oe[t].boundingVolume){const r=this.boundingVolumeToExtent(this.Oe[t]);e._combine(r)}return e}return this.Oe[e]&&this.Oe[e].boundingVolume?this.boundingVolumeToExtent(this.Oe[e]):null}boundingVolumeToExtent(e){const r=e.boundingVolume.Ie?Gr:e.matrix,n=this.getMap();if(e.boundingVolume.region){const r=e.boundingVolume.region;return new t.Extent(T(r[0]),T(r[1]),T(r[2]),T(r[3]))}if(e.boundingVolume.sphere){const s=e.boundingVolume.sphere,a=le([],i.transformMat4([],s,r)),o=s[3],l=n.locate(a,-o,o),c=n.locate(a,o,-o);return new t.Extent(l,c)}if(e.boundingVolume.box){const a=e.boundingVolume.box,o=i.transformMat4([],a,r),l=new t.Coordinate(le([],o)),c=a.slice(3);s.multiply(c,s.fromMat4([],e.matrix),c);const h=i.length(c.slice(0,3)),f=i.length(c.slice(3,6)),u=i.length(c.slice(6,9)),d=Math.max(h,f,u),y=n.locate(l,-d,d),m=n.locate(l,d,-d);return new t.Extent(y,m)}return null}getRootTiles(){return this.Oe}getTiles(){if(!this.getRenderer().ready)return this.Le(),{tiles:zr};const t=this.getMap(),e=t.cameraPosition;let r,n;if(t.getGLZoom)n=t.pointToDistance(e[2],0,t.getGLZoom()),Zr.set(e[0],e[1]),r=t.pointToCoord(Zr,t.getGLZoom());else{const i=t.getGLRes();n=t.pointAtResToDistance(e[2],0,i),Zr.set(e[0],e[1]),r=t.pointAtResToCoord(Zr,i)}this.Me=this.Me||[],i.set(this.Me,E(r.x),E(r.y),n),this.Re=re(this.Re||[],this.Me[0],this.Me[1],this.Me[2]),this.Ne=2*Math.tan(.5*E(t.getFov())),this.Be=Nr.project(r).toArray();const s=t.projViewMatrix,a={children:[],level:-1};let o=a;const l=[];for(let t=0;t<this.Oe.length;t++){let e=1/0;const r=[this.Oe[t]],n=this.Pe(t);for(;r.length>0;){const t=r.pop();for(t.id||this.ke(t);o.level>=t.pe;)o=o.parent;const i=this.Ce(t,n,s);if(i<1){let r=o;for(;r&&!r.content;)r=r.parent;0===i&&r&&r.content&&this.De(l,r);if(!1===this.options.services[t.St].alwaysShow)continue;if(!(0===i&&t.pe<=e))continue;t.content&&(e=t.pe)}t.Bt<1/0&&this.ze(t);const a=this.ge(t,o);o.children.push(a);const c=t.children,h=c&&c.length,f=a.content;if(!h&&f&&this.De(l,a),h){f&&"add"===t.refine&&this.De(l,a),o=a;const e=c[0].parent;for(let n=0,i=c.length;n<i;n++){if(!e){c[n].parent=t,c[n].qt=t.qt,c[n].baseUrl=t.baseUrl;const e=c[n].content&&(c[n].content.url||c[n].content.uri);e&&(L(e)?c[n].baseUrl=t.baseUrl:-1===e.indexOf("http://")&&-1===e.indexOf("https://")?c[n].content.url=t.baseUrl+e:c[n].baseUrl=e.substring(0,e.lastIndexOf("/")+1))}r.push(c[n])}}}}return{root:a,tiles:l}}De(t,e){const{viewerRequestVolume:r}=e.node;r&&!function(t,e,r){if(r.region){const e=r.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(r.sphere)return qr(r,e);if(r.box)return 0===$r(r,e)}return!1}
|
|
19
19
|
/*!
|
|
20
|
-
* @maptalks/gl v0.67.
|
|
20
|
+
* @maptalks/gl v0.67.10
|
|
21
21
|
* LICENSE : UNLICENSED
|
|
22
22
|
* (c) 2016-2022 maptalks.com
|
|
23
|
-
*/(this.Me,this.Re,r)||t.push(e)}ge(t,e){return{id:t.id,node:t,children:[],level:t._e,parent:e,content:t.content&&t.content.url}}ke(e){e.id=t.Util.GUID(),e.matrix=e.transform||n.identity([]),e.Fe=this.Ye(e),e.parent&&(e.matrix=n.multiply(e.matrix,e.parent.matrix,e.matrix),e.St=e.parent.St,void 0===e._e&&(e._e=e.parent._e+1),e.maxExtent=e.parent.maxExtent),e.refine=e.refine&&e.refine.toLowerCase()||"replace",e.content&&!e.content.url&&e.content.uri&&(e.content.url=e.content.uri),this.He(e)}He(t){const e=t.boundingVolume;if(!e||e.Ie)return;const r=this.options.services[t.St].heightOffset||0,s=this.options.offset,a=w(s)||s[0]||s[1];if(!t.boundingVolume||!r&&n.exactEquals(t.matrix,Gr)&&!a)return;const{region:o,box:l,sphere:c}=e;if(o){const t=this.Ve([T(o[0]),T(o[1])]);o[0]=E(t.x),o[1]=E(t.y);const e=this.Ve([T(o[2]),T(o[3])]);o[2]=E(e.x),o[3]=E(e.y),o[4]+=r,o[5]+=r}else if(l||c){const e=l||c,n=i.transformMat4(kr,e,t.matrix),s=le(Cr,n),a=this.Ve([s[0],s[1]]);s[0]=a.x,s[1]=a.y,s[2]+=r,re(e,E(s[0]),E(s[1]),s[2])}e.Ie=!0}Ye(t){return void 0===t.geometricError||!t.boundingVolume}ze(t){let e=t.parent;for(;e&&e.Fe&&!(e.Bt<=t.Bt);)e.Bt=t.Bt,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const r=e.content.url;e.baseUrl=r.substring(0,r.lastIndexOf("/")+1);const n=this.getRenderer();n&&n.setToRedraw()}}onTilesetLoad(t,e,r){if(!t)return void console.warn("invalid tileset at : "+r);const i=(t.asset&&t.asset.gltfUpAxis||e&&e.qt||this.options.services[e.St].upAxis||"Y").toUpperCase();if(t.root.baseUrl=r.substring(0,r.lastIndexOf("/")+1),"ObliquePhotogrammetry"===t.asset.s3mType&&(t.root.baseUrl+="data/path/"),t.root.qt=i,e){const r=e.boundingVolume;g(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",r&&(e.boundingVolume=r);const i=t.root.transform;i&&(e.parent?e.matrix=n.multiply([],e.parent.matrix,i):e.matrix=i),this.He(e),e.Ze=e.content,delete e.content,t.root.content&&(e.content=t.root.content),e.Fe=this.Ye(e);const s=e.content&&(e.content.url||e.content.uri);s&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),s&&!L(s)&&-1===s.indexOf("http://")&&-1===s.indexOf("https://")&&(e.content.url=e.baseUrl+s)}this.Le(),this.fire("loadtileset",{tileset:t,index:e.St,url:r})}Ce(t,e,r){if(t.Bt=1/0,0===t._e||t.Fe)return 1;if(!this.Ge(t,e,r))return-1;if(0===t.geometricError)return 1;let n=this.options.services[t.St].maximumScreenSpaceError;null==n&&(n=8);let i=this.je(t);return 0===i&&t.parent&&(i=.5*(t.parent.qe||0)),i>=n?1:0}Yt(e,r){r||(r=new t.Point(0,0));const n=this.getMap();return n.getGLZoom?n.coordToPoint(e,n.getGLZoom(),r):n.coordToPointAtRes(e,n.getGLRes(),r)}Ge(e,r,i){const a=e.id;let o=this.Ue[a];const{boundingVolume:l}=e,c=l.sphere,f=l.region,u=l.box;if(!o){let r,i,l;if(f){r=Br.set(T(f[0]),T(f[1]),T(f[2]),T(f[3]));const t=r.getCenter(),e=this.$e(t);r=r.convertTo((t=>this.Yt(t,Fr)),Pr),l=f[4],i=f[5],o=this.Ue[a]=[[r.xmin,r.ymin,l*e[2]],[r.xmax,r.ymax,i*e[2]]],o.center=t}else if(c){const e=le(kr,c),r=new t.Coordinate(e),n=this.Yt(r,Fr).toArray(),i=this.$e(r);n.push(e[2]*i[2]),o=this.Ue[a]=[n,c[3]*i[2]],o.center=r}else if(u){const r=le(kr,u),i=new t.Coordinate(r),l=this.Yt(i,Fr).toArray(),c=this.$e(i);l.push(r[2]*c[2]);const h=u.slice(3);n.exactEquals(e.matrix,Gr)||s.multiply(h,s.fromMat4(Vr,e.matrix),h);for(let t=0;t<h.length;t++)h[t]*=c[t%3],u[3+t]=h[t];o=this.Ue[a]=[...l,...h],o.center=i}}if(r){if(f)Br.xmin=o[0][0],Br.ymin=o[0][1],Br.xmax=o[1][0],Br.ymax=o[1][1];else if(c){const t=o[2];Br.xmin=o[0][0]-t,Br.ymin=o[0][1]-t,Br.xmax=o[0][0]+t,Br.ymax=o[0][1]+t}else if(u){const t=o[1],e=o[2];Br.xmin=o[0][0]-t,Br.ymin=o[0][1]-e,Br.xmax=o[0][0]+t,Br.ymax=o[0][1]+e}if(!r.intersects(Br))return!1}return f?d(i,o):c?function(t,e,r){m(t);for(var n=e[0],i=-e[1],s=0;s<6;s++)if((!r||"0"!==r.charAt(s))&&p(h[s],n)<i)return!1;return!0}(i,o):!!u&&function(t,e,r){m(t);for(var n=0;n<6;n++)if(!(r&&"0"===r.charAt(n)||y(h[n],e)))return!1;return!0}(i,o)}$e(t){const e=this.getMap(),r=e.distanceToPointAtRes(100,100,e.getGLRes(),t);return i.set(Dr,r.x/100*1.01,r.y/100*1.01,r.y/100),Dr}Ve(e){Array.isArray(e)&&(e=new t.Coordinate(e));let r=this.options.offset;if(w(r)&&(r=r(Array.isArray(e)?new t.Coordinate(e):e)),r[0]||r[1]){const t=this.getMap(),n=t.getGLRes(),i=t.coordToPointAtRes(e,n);return i._sub(r),t.pointAtResToCoord(i,n)}return e}Pe(e){const r=this.options.services[e].maxExtent;if(!r)return null;const n=this.Oe[e];return n.maxExtent||(n.maxExtent=new t.Extent(r).convertTo((t=>this.Yt(t)))),n.maxExtent}je(t){const e=this.Ne,r=t.geometricError;if(0===r)return 0;const n=this.getMap();let i;if(t.boundingVolume.region){const e=this.Ue[t.id].center,r=(n.getGLZoom?n.distanceToPoint(100,0,n.getGLZoom(),e):n.distanceToPointAtRes(100,0,n.getGLRes(),e)).x/100;i=function(t,e,r,n){const i=t.boundingVolume.region;let s=t.Xe;s||(s=t.Xe=[Xr(i[0],i[1]),Xr(i[0],i[3]),Xr(i[2],i[1]),Xr(i[2],i[3]),Xr(i[0],i[1]),Xr(i[0],i[3]),Xr(i[2],i[1]),Xr(i[2],i[3])],t.Ke=[Math.min.apply(Math,s.map((t=>t[0]))),Math.min.apply(Math,s.map((t=>t[1])))],t.Je=[Math.max.apply(Math,s.map((t=>t[0]))),Math.max.apply(Math,s.map((t=>t[1])))]);if(r[0]>=i[0]&&r[0]<=i[2]&&r[1]>=i[1]&&r[1]<=i[3])return r[2]<=i[5]?0:r[2]-i[5];const a=(o=t.Ke,l=t.Je,c=e,h=Math.max(o[0]-c[0],0,c[0]-l[0]),f=Math.max(o[1]-c[1],0,c[1]-l[1]),Math.sqrt(h*h+f*f)/n);var o,l,c,h,f;let u=0;r[2]>i[5]&&(u=r[2]-i[5]);return Math.sqrt(a*a+u*u)}(t,this.Be,this.Me,r)}else t.boundingVolume.sphere?i=qr(t.boundingVolume,this.Re):t.boundingVolume.box&&(i=$r(t.boundingVolume,this.Re));const s=Math.max(Math.abs(i),1e-7),a=r*n.height/(s*e);return t.Bt=i,t.qe=a,a}Le(){const t=this.getRenderer();t&&t.setToRedraw()}Jt(t){return this.Ue[t]}}function qr(t,e){const r=t.sphere,n=i.dist(r,e),s=t.sphere[3];return n<s?0:n-s}function $r(t,e){const r=t.box;return Ur(i.set(kr,r[0],r[1],r[2]),s.set(Vr,r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11]),e)}function Xr(t,e){return Yr.x=T(t),Yr.y=T(e),Nr.project(Yr,Hr).toArray()}jr.mergeOptions({"maxGPUMemory":512,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":0,"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"debug":!1,"debugOutline":[0,1,0],"meshLimitPerFrame":1,"antialias":!1,"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"],"offset":[0,0]}),jr.registerRenderer("gl",vr);const Kr=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")},Jr=Kr(),Wr=Jr.gl_trans__coders=Jr.gl_trans__coders||{};Wr.inject=function(t){const e=t.toString(),r=e.indexOf("{")+1,n=e.substring(0,r),i=Jr.gl_trans__coders=Jr.gl_trans__coders||{};let s=`${n}\n const _____getGlobal = ${Kr.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(n.length),s},Wr.registerTranscoder=function(t,e){Wr[t]=e},Wr.getTranscoder=function(t){return Wr[t]};class Qr{constructor(t,e,r){this.i=t,this.We=e||Ct,this.o=r,this.Qe={"image/crn":Wr.crn&&Wr.crn(),"image/ktx2":Wr.ktx2&&Wr.ktx2(),"image/cttf":Wr.ktx2&&Wr.ktx2(),"draco":Wr.draco&&Wr.draco()}}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.tr(t,e,r,n,i)):pt.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.tr(t,i,r,n)}))}tr(t,e,r,n,i){const s=i&&i.maxTextureSize,a=this.er(e,r,n,t);if(a.error)return Promise.resolve(a);const o=t.substring(0,t.lastIndexOf("/")),l=new this.We(o,a.glb,{transferable:!0,requestImage:this.i,decoders:this.Qe,supportedFormats:this.o,maxTextureSize:s});return l.load().then((e=>{e.url=`${t}-${r}-${n}`;const i=l.transferables;for(let t=0;t<a.transferables.length;t++)i.indexOf(a.transferables[t])<0&&i.push(a.transferables[t]);return{magic:"b3dm",count:a.count,transferables:i,featureTable:a.featureTable,batchTable:a.batchTable,batchTableBin:a.batchTableBin,gltf:e}}))}er(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", url:"+n;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: "+n;return console.warn(t),{error:t}}let a,o=i.getUint32(12,!0),l=i.getUint32(16,!0),c=i.getUint32(20,!0),h=i.getUint32(24,!0),f=28+e;c>=570425344?(f-=8,a=o,c=l,h=0,o=0,l=0):h>=570425344&&(f-=4,a=c,c=o,h=l,o=0,l=0);const u=[t];let d,y,m;if(o>0?(d=pe(t,f,o),f+=o,a=d.BATCH_LENGTH):d={"BATCH_LENGTH":a},l>0&&(f+=l),c>0&&(y=_e(t,f,c),f+=c,h>0)){const e=ge(0,f,h);m=t.slice(e.offset,e.offset+e.byteLength),f+=h,u.push(m)}const b=d.BATCH_LENGTH,p={};if(d&&d.BATCH_ID){p.BATCH_ID=Ee(d.BATCH_ID,t,undefined.offset,b);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&u.indexOf(e)<0&&u.push(e)}return{count:a,transferables:u,featureTable:d,batchTable:y,batchTableBin:m,b3dm:p,glb:{buffer:t,byteOffset:f,byteLength:i.byteLength+i.byteOffset-f}}}rr(){return null}}class tn{constructor(t,e,r,n){this.i=t,this.We=e||Ct,this.o=r,this.Qe={"image/crn":Wr.crn&&Wr.crn(),"image/ktx2":Wr.ktx2&&Wr.ktx2(),"image/cttf":Wr.ktx2&&Wr.ktx2(),"draco":Wr.draco&&Wr.draco()},this.nr=n}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.tr(t,e,r,n,i)):pt.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.tr(t,i,r,n)}))}tr(t,e,r,n,i){return this.ir(t,e,r,n,i).then((({gltf:i,transferables:s})=>{const a=this.sr(e,r,n,t);if(a.error)return Promise.resolve(a);for(let t=0;t<s.length;t++)-1===a.transferables.indexOf(s[t])&&a.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:a.count,transferables:a.transferables,featureTable:a.featureTable,batchTable:a.batchTable,batchTableBin:a.batchTableBin,i3dm:a.i3dm,gltf:i})}))}ir(t,e,r,n,i){const s=i&&i.maxTextureSize,a={transferable:!0,requestImage:this.i,decoders:this.Qe,supportedFormats:this.o,maxTextureSize:s},o=new DataView(e,r,n),l=32+o.getUint32(12,!0)+o.getUint32(16,!0)+o.getUint32(20,!0)+o.getUint32(24,!0);if(0===o.getUint32(28,!0)){let n=S(new Uint8Array(e,l+r,o.byteLength-l));-1==n.indexOf("://")&&(n=t.substring(0,t.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?pt.getArrayBuffer(n,{}).then((t=>this.ar(n,{buffer:t.data,byteOffset:0},a))):pt.getJSON(n,{}).then((t=>this.ar(n,t,a)))}{const n={buffer:e,byteOffset:l+r,byteLength:o.byteLength-l};return this.ar(t,n,a)}}ar(t,e,r){const n=t.substring(0,t.lastIndexOf("/")),i=new this.We(n,e,r);return i.load({skipAttributeTransform:!0}).then((r=>{let n=0,s=0;return e.buffer&&(n=e.byteOffset||0,s=e.byteLength||0),r.url=`${t}-${n}-${s}`,{transferables:i.transferables,gltf:r}}))}sr(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;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: "+n;return console.warn(t),{error:t}}const a=[t],{featureTable:o,featureTableBin:l,batchTable:c,batchTableBin:h}=Se(i,32+e,a),f={},u=o.INSTANCES_LENGTH;if(o.POSITION){const{byteOffset:e}=o.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:new Float32Array(t,e+l.offset,3*u).slice()},a.push(f.POSITION.array.buffer)}else if(o.POSITION_QUANTIZED){const e=o.QUANTIZED_VOLUME_OFFSET,r=o.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=o.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:u,componentType:5126,array:this.lr(new Uint16Array(t,n+l.offset,3*u),e,r)},a.push(f.POSITION.array.buffer)}if(o.BATCH_ID){f.BATCH_ID=Ee(o.BATCH_ID,t,l.offset,u);const e=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;e&&a.indexOf(e)<0&&a.push(e)}if(o.NORMAL_UP){let{byteOffset:e}=o.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:new Float32Array(t,e+l.offset,3*u).slice()},a.push(f.NORMAL_UP.array.buffer),e=o.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:new Float32Array(t,e+l.offset,3*u).slice()},a.push(f.NORMAL_RIGHT.array.buffer)}else if(o.NORMAL_UP_OCT32P){let{byteOffset:e}=o.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:this.cr(new Uint16Array(t,e+l.offset,2*u))},a.push(f.NORMAL_UP.array.buffer),e=o.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:this.cr(new Uint16Array(t,e+l.offset,2*u))},a.push(f.NORMAL_RIGHT.array.buffer)}if(o.SCALE){const{byteOffset:e}=o.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:u,componentType:5126,array:new Float32Array(t,e+l.offset,u).slice()},a.push(f.SCALE.array.buffer)}else if(o.SCALE_NON_UNIFORM){const{byteOffset:e}=o.SCALE_NON_UNIFORM;f.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:new Float32Array(t,e+l.offset,3*u).slice()},a.push(f.SCALE_NON_UNIFORM.array.buffer)}return{count:u,batchTable:c,batchTableBin:h,featureTable:o,i3dm:f,transferables:a}}cr(t){const e=t.length/2,r=new Float32Array(3*e),n=[];for(let i=0;i<e;i++)en(n,t[2*i],t[2*i+1],65535),r[3*i]=n[0],r[3*i+1]=n[1],r[3*i+2]=n[2];return r}lr(t,e,r){return xe(new Float32Array(t.length),t,e,r)}rr(){return null}}function en(t,e,r,n){if(t[0]=rn(e,n),t[1]=rn(r,n),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]))*nn(e),t[1]=(1-Math.abs(e))*nn(t[1])}return Z(t,t)}function rn(t,e){return function(t,e,r){return t<e?e:t>r?r:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function nn(t){return t<0?-1:1}class sn{constructor(){}load(t,e,r=0,n=0){return e?(n||(n=e.byteLength),this.tr(t,e,r,n)):pt.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.tr(t,i,r,n)}))}tr(t,e,r,n){return this.hr(e,r,n,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}))}hr(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;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: "+n;return console.warn(t),{error:t}}const a=[t],{featureTable:o,featureTableBin:l,batchTable:c,batchTableBin:h}=Se(i,e+28,a),f=o.QUANTIZED_VOLUME_OFFSET,u=o.QUANTIZED_VOLUME_SCALE,d=o.POINTS_LENGTH;let y,m={};if(o.extensions&&o.extensions["3DTILES_draco_point_compression"]){m=o.extensions["3DTILES_draco_point_compression"],y=new DataView(t,m.byteOffset+l.offset,m.byteLength);const e={attributes:m.properties,useUniqueIDs:!1};return this.ur||(this.ur=Wr.draco()),this.ur(y,e).then((e=>{const r=e.attributes;!o.POSITION&&!o.POSITION_QUANTIZED||r.POSITION||r.POSITION_QUANTIZED||(r.POSITION=o.POSITION,r.POSITION_QUANTIZED=o.POSITION_QUANTIZED),!(o.RGB||o.RGBA||o.RGB565)||r.RGB||r.RGBA||r.RGB565||(r.RGB=o.RGB,r.RGBA=o.RGBA,r.RGB565=o.RGB565),!o.NORMAL&&!o.NORMAL_OCT16P||r.NORMAL||r.NORMAL_OCT16P||(r.NORMAL=o.NORMAL,r.NORMAL_OCT16P=o.NORMAL_OCT16P);const n=this.dr(t,e.attributes,l.offset,d,a,f,u);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;n.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:ve(t.constructor),array:t},a.push(t.buffer)}else if(o.BATCH_ID||Object.keys(c).length){o.BATCH_ID?n.BATCH_ID=Ee(o.BATCH_ID,t,l.offset,d):n.BATCH_ID=an(d);const e=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;e&&a.indexOf(e)<0&&a.push(e)}return{count:d,batchTable:c,batchTableBin:h,featureTable:o,pnts:n,transferables:a}}))}const b=this.dr(t,o,l.offset,d,a,f,u);if(o.BATCH_ID||Object.keys(c).length){o.BATCH_ID?b.BATCH_ID=Ee(o.BATCH_ID,t,l.offset,d):b.BATCH_ID=an(d);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&a.indexOf(e)<0&&a.push(e)}return Promise.resolve({count:d,batchTable:c,batchTableBin:h,featureTable:o,pnts:b,transferables:a})}dr(t,e,r,n,i,s,a){const o={};if(e.POSITION){let{byteOffset:s,array:a}=e.POSITION;s=s||0;const l=a?0:r;if(!a){const e=t.slice(s+l,s+l+3*n*4);a=new Float32Array(e)}o.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:a},i.push(a.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:l,array:c}=e.POSITION_QUANTIZED;l=l||0;const h=c?0:r;o.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this.lr(c||new Uint16Array(t,l+h,3*n),s,a)},i.push(o.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:a}=e.RGBA;s=s||0;const l=a?0:r;if(!a){const e=t.slice(s+l,s+l+4*n);a=new Uint8Array(e)}o.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:n,componentType:5121,array:a},i.push(a.buffer)}else if(e.RGB){let{byteOffset:s,array:a}=e.RGB;s=s||0;const l=a?0:r;if(!a){const e=t.slice(s+l,s+l+3*n);a=new Uint8Array(e)}o.RGB={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5121,array:a},i.push(a.buffer)}else if(e.RGB565){let{byteOffset:s,array:a}=e.RGB565;s=s||0;const l=a?0:r;if(!a){const e=t.slice(s+l,s+l+2*n);a=new Uint16Array(e)}o.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:n,componentType:5123,array:a},i.push(a.buffer)}if(e.NORMAL){let{byteOffset:s,array:a}=e.NORMAL;s=s||0;const l=a?0:r;if(!a){const e=t.slice(s+l,s+l+3*n*4);a=new Float32Array(e)}o.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:a},i.push(a.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:a}=e.NORMAL_OCT16P;s=s||0;const l=a?0:r;if(!a){const e=t.slice(s+l,s+l+2*n);a=new Uint8Array(e)}o.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:n,componentType:5121,array:a},i.push(a.buffer)}return o}lr(t,e,r){return xe(new Float32Array(t.length),t,e,r)}rr(){return null}}function an(t){const e=I(t),r=new e(t);for(let e=0;e<t;e++)r[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:ve(e),array:r}}class on{constructor(t,e){this.i=t,this.We=e||Ct}load(t,e,r=0,n=0,i){return e?this.tr(t,e,r,n,i):pt.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.tr(t,i,r,n)}))}tr(t,e,r,n,i){n||(n=e.byteLength);const s=this.yr(e,t,r,n),a=[];for(let r=0;r<s.length;r++){let n;if("b3dm"===s[r].magic)n=new Qr(this.i,this.We);else if("i3dm"===s[r].magic)n=new tn(this.i,this.We);else if("pnts"===s[r].magic)n=new sn;else{if("cmpt"!==s[r].magic){console.warn("Unsupported magic in CMPT tile:",s[r].magic);continue}n=new on(this.i,this.We)}a.push(n.load(t,e,s[r].offset,s[r].byteLength,i).then((t=>t)))}return Promise.all(a).then((t=>({magic:"cmpt",tiles:t})))}yr(t,e,r,n){const i=new DataView(t,r,n),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 a=[],o=i.getUint32(12,!0);let l=16;for(let e=0;e<o;e++){const e=me(i,l),n=i.getUint32(l+8,!0);a.push({magic:e,buffer:t,offset:l+r,byteLength:n}),l+=n}return a}}if(e.transcoders){const r=t.Map.VERSION;if(r.indexOf("1.0.0-beta")>=0||r.indexOf("1.0.0-alpha")>=0){const r=e.transcoders.inject(c);t.registerWorkerAdapter("@maptalks/3dtiles",r)}else t.registerWorkerAdapter("@maptalks/3dtiles",(function(){return e.transcoders.inject(c)}))}else t.registerWorkerAdapter("@maptalks/3dtiles",c);export{Qr as B3DMLoader,on as CMPTLoader,jr as Geo3DTilesLayer,R as Geo3DTilesUtil,ye as Geo3DTransform};"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.14.0");
|
|
23
|
+
*/(this.Me,this.Re,r)||t.push(e)}ge(t,e){return{id:t.id,node:t,children:[],level:t.pe,parent:e,content:t.content&&t.content.url}}ke(e){e.id=t.Util.GUID(),e.matrix=e.transform||n.identity([]),e.Fe=this.Ye(e),e.parent&&(e.matrix=n.multiply(e.matrix,e.parent.matrix,e.matrix),e.St=e.parent.St,void 0===e.pe&&(e.pe=e.parent.pe+1),e.maxExtent=e.parent.maxExtent),e.refine=e.refine&&e.refine.toLowerCase()||"replace",e.content&&!e.content.url&&e.content.uri&&(e.content.url=e.content.uri),this.He(e)}He(t){const e=t.boundingVolume;if(!e||e.Ie)return;const r=this.options.services[t.St].heightOffset||0,s=this.options.offset,a=w(s)||s[0]||s[1];if(!t.boundingVolume||!r&&n.exactEquals(t.matrix,Gr)&&!a)return;const{region:o,box:l,sphere:c}=e;if(o){const t=this.Ve([T(o[0]),T(o[1])]);o[0]=E(t.x),o[1]=E(t.y);const e=this.Ve([T(o[2]),T(o[3])]);o[2]=E(e.x),o[3]=E(e.y),o[4]+=r,o[5]+=r}else if(l||c){const e=l||c,n=i.transformMat4(kr,e,t.matrix),s=le(Cr,n),a=this.Ve([s[0],s[1]]);s[0]=a.x,s[1]=a.y,s[2]+=r,re(e,E(s[0]),E(s[1]),s[2])}e.Ie=!0}Ye(t){return void 0===t.geometricError||!t.boundingVolume}ze(t){let e=t.parent;for(;e&&e.Fe&&!(e.Bt<=t.Bt);)e.Bt=t.Bt,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const r=e.content.url;e.baseUrl=r.substring(0,r.lastIndexOf("/")+1);const n=this.getRenderer();n&&n.setToRedraw()}}onTilesetLoad(t,e,r){if(!t)return void console.warn("invalid tileset at : "+r);const i=(t.asset&&t.asset.gltfUpAxis||e&&e.qt||this.options.services[e.St].upAxis||"Y").toUpperCase();if(t.root.baseUrl=r.substring(0,r.lastIndexOf("/")+1),"ObliquePhotogrammetry"===t.asset.s3mType&&(t.root.baseUrl+="data/path/"),t.root.qt=i,e){const r=e.boundingVolume;g(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",r&&(e.boundingVolume=r);const i=t.root.transform;i&&(e.parent?e.matrix=n.multiply([],e.parent.matrix,i):e.matrix=i),this.He(e),e.Ze=e.content,delete e.content,t.root.content&&(e.content=t.root.content),e.Fe=this.Ye(e);const s=e.content&&(e.content.url||e.content.uri);s&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),s&&!L(s)&&-1===s.indexOf("http://")&&-1===s.indexOf("https://")&&(e.content.url=e.baseUrl+s)}this.Le(),this.fire("loadtileset",{tileset:t,index:e.St,url:r})}Ce(t,e,r){if(t.Bt=1/0,0===t.pe||t.Fe)return 1;if(!this.Ge(t,e,r))return-1;if(0===t.geometricError)return 1;let n=this.options.services[t.St].maximumScreenSpaceError;null==n&&(n=8);let i=this.je(t);return 0===i&&t.parent&&(i=.5*(t.parent.qe||0)),i>=n?1:0}Yt(e,r){r||(r=new t.Point(0,0));const n=this.getMap();return n.getGLZoom?n.coordToPoint(e,n.getGLZoom(),r):n.coordToPointAtRes(e,n.getGLRes(),r)}Ge(e,r,i){const a=e.id;let o=this.Ue[a];const{boundingVolume:l}=e,c=l.sphere,f=l.region,u=l.box;if(!o){let r,i,l;if(f){r=Br.set(T(f[0]),T(f[1]),T(f[2]),T(f[3]));const t=r.getCenter(),e=this.$e(t);r=r.convertTo((t=>this.Yt(t,Fr)),Pr),l=f[4],i=f[5],o=this.Ue[a]=[[r.xmin,r.ymin,l*e[2]],[r.xmax,r.ymax,i*e[2]]],o.center=t}else if(c){const e=le(kr,c),r=new t.Coordinate(e),n=this.Yt(r,Fr).toArray(),i=this.$e(r);n.push(e[2]*i[2]),o=this.Ue[a]=[n,c[3]*i[2]],o.center=r}else if(u){const r=le(kr,u),i=new t.Coordinate(r),l=this.Yt(i,Fr).toArray(),c=this.$e(i);l.push(r[2]*c[2]);const h=u.slice(3);n.exactEquals(e.matrix,Gr)||s.multiply(h,s.fromMat4(Vr,e.matrix),h);for(let t=0;t<h.length;t++)h[t]*=c[t%3],u[3+t]=h[t];o=this.Ue[a]=[...l,...h],o.center=i}}if(r){if(f)Br.xmin=o[0][0],Br.ymin=o[0][1],Br.xmax=o[1][0],Br.ymax=o[1][1];else if(c){const t=o[2];Br.xmin=o[0][0]-t,Br.ymin=o[0][1]-t,Br.xmax=o[0][0]+t,Br.ymax=o[0][1]+t}else if(u){const t=o[1],e=o[2];Br.xmin=o[0][0]-t,Br.ymin=o[0][1]-e,Br.xmax=o[0][0]+t,Br.ymax=o[0][1]+e}if(!r.intersects(Br))return!1}return f?d(i,o):c?function(t,e,r){m(t);for(var n=e[0],i=-e[1],s=0;s<6;s++)if((!r||"0"!==r.charAt(s))&&_(h[s],n)<i)return!1;return!0}(i,o):!!u&&function(t,e,r){m(t);for(var n=0;n<6;n++)if(!(r&&"0"===r.charAt(n)||y(h[n],e)))return!1;return!0}(i,o)}$e(t){const e=this.getMap(),r=e.distanceToPointAtRes(100,100,e.getGLRes(),t);return i.set(Dr,r.x/100*1.01,r.y/100*1.01,r.y/100),Dr}Ve(e){Array.isArray(e)&&(e=new t.Coordinate(e));let r=this.options.offset;if(w(r)&&(r=r(Array.isArray(e)?new t.Coordinate(e):e)),r[0]||r[1]){const t=this.getMap(),n=t.getGLRes(),i=t.coordToPointAtRes(e,n);return i._sub(r),t.pointAtResToCoord(i,n)}return e}Pe(e){const r=this.options.services[e].maxExtent;if(!r)return null;const n=this.Oe[e];return n.maxExtent||(n.maxExtent=new t.Extent(r).convertTo((t=>this.Yt(t)))),n.maxExtent}je(t){const e=this.Ne,r=t.geometricError;if(0===r)return 0;const n=this.getMap();let i;if(t.boundingVolume.region){const e=this.Ue[t.id].center,r=(n.getGLZoom?n.distanceToPoint(100,0,n.getGLZoom(),e):n.distanceToPointAtRes(100,0,n.getGLRes(),e)).x/100;i=function(t,e,r,n){const i=t.boundingVolume.region;let s=t.Xe;s||(s=t.Xe=[Xr(i[0],i[1]),Xr(i[0],i[3]),Xr(i[2],i[1]),Xr(i[2],i[3]),Xr(i[0],i[1]),Xr(i[0],i[3]),Xr(i[2],i[1]),Xr(i[2],i[3])],t.Ke=[Math.min.apply(Math,s.map((t=>t[0]))),Math.min.apply(Math,s.map((t=>t[1])))],t.Je=[Math.max.apply(Math,s.map((t=>t[0]))),Math.max.apply(Math,s.map((t=>t[1])))]);if(r[0]>=i[0]&&r[0]<=i[2]&&r[1]>=i[1]&&r[1]<=i[3])return r[2]<=i[5]?0:r[2]-i[5];const a=(o=t.Ke,l=t.Je,c=e,h=Math.max(o[0]-c[0],0,c[0]-l[0]),f=Math.max(o[1]-c[1],0,c[1]-l[1]),Math.sqrt(h*h+f*f)/n);var o,l,c,h,f;let u=0;r[2]>i[5]&&(u=r[2]-i[5]);return Math.sqrt(a*a+u*u)}(t,this.Be,this.Me,r)}else t.boundingVolume.sphere?i=qr(t.boundingVolume,this.Re):t.boundingVolume.box&&(i=$r(t.boundingVolume,this.Re));const s=Math.max(Math.abs(i),1e-7),a=r*n.height/(s*e);return t.Bt=i,t.qe=a,a}Le(){const t=this.getRenderer();t&&t.setToRedraw()}Jt(t){return this.Ue[t]}}function qr(t,e){const r=t.sphere,n=i.dist(r,e),s=t.sphere[3];return n<s?0:n-s}function $r(t,e){const r=t.box;return Ur(i.set(kr,r[0],r[1],r[2]),s.set(Vr,r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11]),e)}function Xr(t,e){return Yr.x=T(t),Yr.y=T(e),Nr.project(Yr,Hr).toArray()}jr.mergeOptions({"maxGPUMemory":512,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":0,"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"debug":!1,"debugOutline":[0,1,0],"meshLimitPerFrame":1,"antialias":!1,"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"],"offset":[0,0]}),jr.registerRenderer("gl",vr),jr.registerJSONType("Geo3DTilesLayer");const Kr=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")},Jr=Kr(),Wr=Jr.gl_trans__coders=Jr.gl_trans__coders||{};Wr.inject=function(t){const e=t.toString(),r=e.indexOf("{")+1,n=e.substring(0,r),i=Jr.gl_trans__coders=Jr.gl_trans__coders||{};let s=`${n}\n const _____getGlobal = ${Kr.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(n.length),s},Wr.registerTranscoder=function(t,e){Wr[t]=e},Wr.getTranscoder=function(t){return Wr[t]};class Qr{constructor(t,e,r){this.i=t,this.We=e||Ct,this.o=r,this.Qe={"image/crn":Wr.crn&&Wr.crn(),"image/ktx2":Wr.ktx2&&Wr.ktx2(),"image/cttf":Wr.ktx2&&Wr.ktx2(),"draco":Wr.draco&&Wr.draco()}}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.tr(t,e,r,n,i)):_t.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.tr(t,i,r,n)}))}tr(t,e,r,n,i){const s=i&&i.maxTextureSize,a=this.er(e,r,n,t);if(a.error)return Promise.resolve(a);const o=t.substring(0,t.lastIndexOf("/")),l=new this.We(o,a.glb,{transferable:!0,requestImage:this.i,decoders:this.Qe,supportedFormats:this.o,maxTextureSize:s});return l.load().then((e=>{e.url=`${t}-${r}-${n}`;const i=l.transferables;for(let t=0;t<a.transferables.length;t++)i.indexOf(a.transferables[t])<0&&i.push(a.transferables[t]);return{magic:"b3dm",count:a.count,transferables:i,featureTable:a.featureTable,batchTable:a.batchTable,batchTableBin:a.batchTableBin,gltf:e}}))}er(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", url:"+n;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: "+n;return console.warn(t),{error:t}}let a,o=i.getUint32(12,!0),l=i.getUint32(16,!0),c=i.getUint32(20,!0),h=i.getUint32(24,!0),f=28+e;c>=570425344?(f-=8,a=o,c=l,h=0,o=0,l=0):h>=570425344&&(f-=4,a=c,c=o,h=l,o=0,l=0);const u=[t];let d,y,m;if(o>0?(d=_e(t,f,o),f+=o,a=d.BATCH_LENGTH):d={"BATCH_LENGTH":a},l>0&&(f+=l),c>0&&(y=pe(t,f,c),f+=c,h>0)){const e=ge(0,f,h);m=t.slice(e.offset,e.offset+e.byteLength),f+=h,u.push(m)}const b=d.BATCH_LENGTH,_={};if(d&&d.BATCH_ID){_.BATCH_ID=Ee(d.BATCH_ID,t,undefined.offset,b);const e=_.BATCH_ID.array&&_.BATCH_ID.array.buffer;e&&u.indexOf(e)<0&&u.push(e)}return{count:a,transferables:u,featureTable:d,batchTable:y,batchTableBin:m,b3dm:_,glb:{buffer:t,byteOffset:f,byteLength:i.byteLength+i.byteOffset-f}}}rr(){return null}}class tn{constructor(t,e,r,n){this.i=t,this.We=e||Ct,this.o=r,this.Qe={"image/crn":Wr.crn&&Wr.crn(),"image/ktx2":Wr.ktx2&&Wr.ktx2(),"image/cttf":Wr.ktx2&&Wr.ktx2(),"draco":Wr.draco&&Wr.draco()},this.nr=n}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.tr(t,e,r,n,i)):_t.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.tr(t,i,r,n)}))}tr(t,e,r,n,i){return this.ir(t,e,r,n,i).then((({gltf:i,transferables:s})=>{const a=this.sr(e,r,n,t);if(a.error)return Promise.resolve(a);for(let t=0;t<s.length;t++)-1===a.transferables.indexOf(s[t])&&a.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:a.count,transferables:a.transferables,featureTable:a.featureTable,batchTable:a.batchTable,batchTableBin:a.batchTableBin,i3dm:a.i3dm,gltf:i})}))}ir(t,e,r,n,i){const s=i&&i.maxTextureSize,a={transferable:!0,requestImage:this.i,decoders:this.Qe,supportedFormats:this.o,maxTextureSize:s},o=new DataView(e,r,n),l=32+o.getUint32(12,!0)+o.getUint32(16,!0)+o.getUint32(20,!0)+o.getUint32(24,!0);if(0===o.getUint32(28,!0)){let n=S(new Uint8Array(e,l+r,o.byteLength-l));-1==n.indexOf("://")&&(n=t.substring(0,t.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?_t.getArrayBuffer(n,{}).then((t=>this.ar(n,{buffer:t.data,byteOffset:0},a))):_t.getJSON(n,{}).then((t=>this.ar(n,t,a)))}{const n={buffer:e,byteOffset:l+r,byteLength:o.byteLength-l};return this.ar(t,n,a)}}ar(t,e,r){const n=t.substring(0,t.lastIndexOf("/")),i=new this.We(n,e,r);return i.load({skipAttributeTransform:!0}).then((r=>{let n=0,s=0;return e.buffer&&(n=e.byteOffset||0,s=e.byteLength||0),r.url=`${t}-${n}-${s}`,{transferables:i.transferables,gltf:r}}))}sr(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;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: "+n;return console.warn(t),{error:t}}const a=[t],{featureTable:o,featureTableBin:l,batchTable:c,batchTableBin:h}=Se(i,32+e,a),f={},u=o.INSTANCES_LENGTH;if(o.POSITION){const{byteOffset:e}=o.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:new Float32Array(t,e+l.offset,3*u).slice()},a.push(f.POSITION.array.buffer)}else if(o.POSITION_QUANTIZED){const e=o.QUANTIZED_VOLUME_OFFSET,r=o.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=o.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:u,componentType:5126,array:this.lr(new Uint16Array(t,n+l.offset,3*u),e,r)},a.push(f.POSITION.array.buffer)}if(o.BATCH_ID){f.BATCH_ID=Ee(o.BATCH_ID,t,l.offset,u);const e=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;e&&a.indexOf(e)<0&&a.push(e)}if(o.NORMAL_UP){let{byteOffset:e}=o.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:new Float32Array(t,e+l.offset,3*u).slice()},a.push(f.NORMAL_UP.array.buffer),e=o.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:new Float32Array(t,e+l.offset,3*u).slice()},a.push(f.NORMAL_RIGHT.array.buffer)}else if(o.NORMAL_UP_OCT32P){let{byteOffset:e}=o.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:this.cr(new Uint16Array(t,e+l.offset,2*u))},a.push(f.NORMAL_UP.array.buffer),e=o.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:this.cr(new Uint16Array(t,e+l.offset,2*u))},a.push(f.NORMAL_RIGHT.array.buffer)}if(o.SCALE){const{byteOffset:e}=o.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:u,componentType:5126,array:new Float32Array(t,e+l.offset,u).slice()},a.push(f.SCALE.array.buffer)}else if(o.SCALE_NON_UNIFORM){const{byteOffset:e}=o.SCALE_NON_UNIFORM;f.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:u,componentType:5126,array:new Float32Array(t,e+l.offset,3*u).slice()},a.push(f.SCALE_NON_UNIFORM.array.buffer)}return{count:u,batchTable:c,batchTableBin:h,featureTable:o,i3dm:f,transferables:a}}cr(t){const e=t.length/2,r=new Float32Array(3*e),n=[];for(let i=0;i<e;i++)en(n,t[2*i],t[2*i+1],65535),r[3*i]=n[0],r[3*i+1]=n[1],r[3*i+2]=n[2];return r}lr(t,e,r){return xe(new Float32Array(t.length),t,e,r)}rr(){return null}}function en(t,e,r,n){if(t[0]=rn(e,n),t[1]=rn(r,n),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]))*nn(e),t[1]=(1-Math.abs(e))*nn(t[1])}return Z(t,t)}function rn(t,e){return function(t,e,r){return t<e?e:t>r?r:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function nn(t){return t<0?-1:1}class sn{constructor(){}load(t,e,r=0,n=0){return e?(n||(n=e.byteLength),this.tr(t,e,r,n)):_t.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.tr(t,i,r,n)}))}tr(t,e,r,n){return this.hr(e,r,n,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}))}hr(t,e,r,n){const i=new DataView(t,e,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+n;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: "+n;return console.warn(t),{error:t}}const a=[t],{featureTable:o,featureTableBin:l,batchTable:c,batchTableBin:h}=Se(i,e+28,a),f=o.QUANTIZED_VOLUME_OFFSET,u=o.QUANTIZED_VOLUME_SCALE,d=o.POINTS_LENGTH;let y,m={};if(o.extensions&&o.extensions["3DTILES_draco_point_compression"]){m=o.extensions["3DTILES_draco_point_compression"],y=new DataView(t,m.byteOffset+l.offset,m.byteLength);const e={attributes:m.properties,useUniqueIDs:!1};return this.ur||(this.ur=Wr.draco()),this.ur(y,e).then((e=>{const r=e.attributes;!o.POSITION&&!o.POSITION_QUANTIZED||r.POSITION||r.POSITION_QUANTIZED||(r.POSITION=o.POSITION,r.POSITION_QUANTIZED=o.POSITION_QUANTIZED),!(o.RGB||o.RGBA||o.RGB565)||r.RGB||r.RGBA||r.RGB565||(r.RGB=o.RGB,r.RGBA=o.RGBA,r.RGB565=o.RGB565),!o.NORMAL&&!o.NORMAL_OCT16P||r.NORMAL||r.NORMAL_OCT16P||(r.NORMAL=o.NORMAL,r.NORMAL_OCT16P=o.NORMAL_OCT16P);const n=this.dr(t,e.attributes,l.offset,d,a,f,u);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;n.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:ve(t.constructor),array:t},a.push(t.buffer)}else if(o.BATCH_ID||Object.keys(c).length){o.BATCH_ID?n.BATCH_ID=Ee(o.BATCH_ID,t,l.offset,d):n.BATCH_ID=an(d);const e=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;e&&a.indexOf(e)<0&&a.push(e)}return{count:d,batchTable:c,batchTableBin:h,featureTable:o,pnts:n,transferables:a}}))}const b=this.dr(t,o,l.offset,d,a,f,u);if(o.BATCH_ID||Object.keys(c).length){o.BATCH_ID?b.BATCH_ID=Ee(o.BATCH_ID,t,l.offset,d):b.BATCH_ID=an(d);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&a.indexOf(e)<0&&a.push(e)}return Promise.resolve({count:d,batchTable:c,batchTableBin:h,featureTable:o,pnts:b,transferables:a})}dr(t,e,r,n,i,s,a){const o={};if(e.POSITION){let{byteOffset:s,array:a}=e.POSITION;s=s||0;const l=a?0:r;if(!a){const e=t.slice(s+l,s+l+3*n*4);a=new Float32Array(e)}o.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:a},i.push(a.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:l,array:c}=e.POSITION_QUANTIZED;l=l||0;const h=c?0:r;o.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this.lr(c||new Uint16Array(t,l+h,3*n),s,a)},i.push(o.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:a}=e.RGBA;s=s||0;const l=a?0:r;if(!a){const e=t.slice(s+l,s+l+4*n);a=new Uint8Array(e)}o.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:n,componentType:5121,array:a},i.push(a.buffer)}else if(e.RGB){let{byteOffset:s,array:a}=e.RGB;s=s||0;const l=a?0:r;if(!a){const e=t.slice(s+l,s+l+3*n);a=new Uint8Array(e)}o.RGB={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5121,array:a},i.push(a.buffer)}else if(e.RGB565){let{byteOffset:s,array:a}=e.RGB565;s=s||0;const l=a?0:r;if(!a){const e=t.slice(s+l,s+l+2*n);a=new Uint16Array(e)}o.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:n,componentType:5123,array:a},i.push(a.buffer)}if(e.NORMAL){let{byteOffset:s,array:a}=e.NORMAL;s=s||0;const l=a?0:r;if(!a){const e=t.slice(s+l,s+l+3*n*4);a=new Float32Array(e)}o.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:a},i.push(a.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:a}=e.NORMAL_OCT16P;s=s||0;const l=a?0:r;if(!a){const e=t.slice(s+l,s+l+2*n);a=new Uint8Array(e)}o.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:n,componentType:5121,array:a},i.push(a.buffer)}return o}lr(t,e,r){return xe(new Float32Array(t.length),t,e,r)}rr(){return null}}function an(t){const e=I(t),r=new e(t);for(let e=0;e<t;e++)r[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:ve(e),array:r}}class on{constructor(t,e){this.i=t,this.We=e||Ct}load(t,e,r=0,n=0,i){return e?this.tr(t,e,r,n,i):_t.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.tr(t,i,r,n)}))}tr(t,e,r,n,i){n||(n=e.byteLength);const s=this.yr(e,t,r,n),a=[];for(let r=0;r<s.length;r++){let n;if("b3dm"===s[r].magic)n=new Qr(this.i,this.We);else if("i3dm"===s[r].magic)n=new tn(this.i,this.We);else if("pnts"===s[r].magic)n=new sn;else{if("cmpt"!==s[r].magic){console.warn("Unsupported magic in CMPT tile:",s[r].magic);continue}n=new on(this.i,this.We)}a.push(n.load(t,e,s[r].offset,s[r].byteLength,i).then((t=>t)))}return Promise.all(a).then((t=>({magic:"cmpt",tiles:t})))}yr(t,e,r,n){const i=new DataView(t,r,n),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 a=[],o=i.getUint32(12,!0);let l=16;for(let e=0;e<o;e++){const e=me(i,l),n=i.getUint32(l+8,!0);a.push({magic:e,buffer:t,offset:l+r,byteLength:n}),l+=n}return a}}if(e.transcoders){const r=t.Map.VERSION;if(r.indexOf("1.0.0-beta")>=0||r.indexOf("1.0.0-alpha")>=0){const r=e.transcoders.inject(c);t.registerWorkerAdapter("@maptalks/3dtiles",r)}else t.registerWorkerAdapter("@maptalks/3dtiles",(function(){return e.transcoders.inject(c)}))}else t.registerWorkerAdapter("@maptalks/3dtiles",c);export{Qr as B3DMLoader,on as CMPTLoader,jr as Geo3DTilesLayer,R as Geo3DTilesUtil,ye as Geo3DTransform};"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.14.1");
|