@maptalks/3dtiles 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @maptalks/3dtiles v0.
|
|
2
|
+
* @maptalks/3dtiles v0.23.0
|
|
3
3
|
* LICENSE : UNLICENSED
|
|
4
|
-
* (c) 2016-
|
|
4
|
+
* (c) 2016-2023 maptalks.org
|
|
5
5
|
*/
|
|
6
|
-
import*as t from"maptalks";import*as e from"@maptalks/gl";import{reshader as r,mat4 as n,HighlightUtil as i,vec3 as s,mat3 as o,vec4 as a,quat as c,createREGL as l}from"@maptalks/gl";const f='function(t){var e=1e-6,r="undefined"!=typeof Float32Array?Float32Array:Array;function n(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}function i(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function s(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 o(t,e,r){var n=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],f=e[6],u=e[7],l=e[8],E=e[9],_=e[10],A=e[11],h=e[12],T=e[13],R=e[14],y=e[15],I=r[0],N=r[1],U=r[2],d=r[3];return t[0]=I*n+N*a+U*l+d*h,t[1]=I*i+N*c+U*E+d*T,t[2]=I*s+N*f+U*_+d*R,t[3]=I*o+N*u+U*A+d*y,I=r[4],N=r[5],U=r[6],d=r[7],t[4]=I*n+N*a+U*l+d*h,t[5]=I*i+N*c+U*E+d*T,t[6]=I*s+N*f+U*_+d*R,t[7]=I*o+N*u+U*A+d*y,I=r[8],N=r[9],U=r[10],d=r[11],t[8]=I*n+N*a+U*l+d*h,t[9]=I*i+N*c+U*E+d*T,t[10]=I*s+N*f+U*_+d*R,t[11]=I*o+N*u+U*A+d*y,I=r[12],N=r[13],U=r[14],d=r[15],t[12]=I*n+N*a+U*l+d*h,t[13]=I*i+N*c+U*E+d*T,t[14]=I*s+N*f+U*_+d*R,t[15]=I*o+N*u+U*A+d*y,t}function a(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function c(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function f(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,c=i+i,f=r*o,u=n*o,l=n*a,E=i*o,_=i*a,A=i*c,h=s*o,T=s*a,R=s*c;return t[0]=1-l-A,t[1]=u+R,t[2]=E-T,t[3]=0,t[4]=u-R,t[5]=1-f-A,t[6]=_+h,t[7]=0,t[8]=E+T,t[9]=_-h,t[10]=1-f-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function u(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function l(){var t=new r(3);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function E(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function _(t,e,n){var i=new r(3);return i[0]=t,i[1]=e,i[2]=n,i}function A(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function h(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function T(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function R(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 I(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function N(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 U(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 d(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function S(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[0],a=r[1],c=r[2];return t[0]=i*c-s*a,t[1]=s*o-n*c,t[2]=n*a-i*o,t}function m(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 O=R,F=y,M=E;function C(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}function b(){var t=new r(4);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function p(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function w(t,r,n,i){var s=r[0],o=r[1],a=r[2],c=r[3],f=n[0],u=n[1],l=n[2],E=n[3],_=void 0,A=void 0,h=void 0,T=void 0,R=void 0;return(A=s*f+o*u+a*l+c*E)<0&&(A=-A,f=-f,u=-u,l=-l,E=-E),1-A>e?(_=Math.acos(A),h=Math.sin(_),T=Math.sin((1-i)*_)/h,R=Math.sin(i*_)/h):(T=1-i,R=i),t[0]=T*s+R*f,t[1]=T*o+R*u,t[2]=T*a+R*l,t[3]=T*c+R*E,t}l(),function(){var t,e=(t=new r(4),r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var D,B=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};l(),_(1,0,0),_(0,1,0),b(),b(),D=new r(9),r!=Float32Array&&(D[1]=0,D[2]=0,D[3]=0,D[5]=0,D[6]=0,D[7]=0),D[0]=1,D[4]=1,D[8]=1;\n/*!\n * @maptalks/gltf-loader v0.27.2\n * LICENSE : UNLICENSED\n * (c) 2016-2022 maptalks.org\n */\nlet L=0;function P(t){return null==t}function g(t){return!P(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 v(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 X(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function H(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 x=[],V=[],k=[],Z=[0,0,0],Y=p([]),K=[1,1,1];function z(t,e,r,n,i,s,o){const a=v(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}0===i&&(i=n*a.BYTES_PER_ELEMENT);const c=new Uint8Array(n*a.BYTES_PER_ELEMENT);for(let o=0;o<r;o++){let r=null;const f=new Uint8Array(e,i*o+s,n*a.BYTES_PER_ELEMENT);c.set(f),r=new a(c.buffer,0,n);for(let e=0;e<n;e++)t[o*n+e]=r[e]}return t}const W="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function j(t,e,r){const n=new Uint8Array(t,e,r);return W.decode(n)}const q={get:function(t,e={}){e||(e={});const r=new AbortController,n=r.signal,i=G({},e);i.signal=n,i.method||(i.method="GET");const s=fetch(t,i).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 s.xhr=r,s},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",q.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?q.jsonp(t):((e=e||{}).responseType="json",q.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+L++;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 ${constructor(t,e,r){this.i=t,this.decoders=e,this.o=r,this.images={},this.u={}}requestImageFromBufferURI(t,e,r){if(this.buffers[t.id]){const n=this.buffers[t.id],i=this.l(e,n);return this.getImageByBuffer(i,r)}if(this.u[t.id])return this.u[t.id].then((()=>{const n=this.buffers[t.id],i=this.l(e,n);return this.getImageByBuffer(i,r)}));if(X(t.uri)){const n=this.buffers[t.id]=H(t.uri),i=this.l(e,n);return this.getImageByBuffer(i,r)}return this.u[t.id]=q.getArrayBuffer(t.uri,null).then((n=>{const i=this.buffers[t.id]=n.data,s=this.l(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._(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;return this.u[t.id]?this.u[t.id].then((()=>this.images[t.id])):this.u[t.id]=this._(t.id,e)}_(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 J=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class Q{constructor(t,e,r){this.rootPath=t,this.gltf=e,this.A=!1,this.glbBuffer=r,this.buffers={},this.requests={},this.accessors={},this.h()}T(t,e){const r=this.gltf,n=r.accessors[e];if(void 0===n.bufferView)return this.accessors[n.id]=this.I(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.N(i).then((r=>{const{buffer:i,byteOffset:s}=r;return this.accessors[n.id]=this.I(t,e,i,s)}))}N(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(X(e.uri)){const t=this.buffers[e.id]=H(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const r=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||r?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=q.getArrayBuffer(t,null).then((n=>(r&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=n.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}I(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,c=this.U(s.type),f=v(s.componentType),u=o.byteStride||0,l={array:void 0,name:t,accessorName:e,byteLength:s.count*c*f.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:c};if(s.min&&(l.min=s.min),s.max&&(l.max=s.max),r)if(this.A)l.byteStride=u,l.byteOffset=a+(s.byteOffset||0),!u||u===c*f.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(l.array=this.S(r,s.count,c,a+(s.byteOffset||0),f),l.array.buffer.byteLength===l.byteLength&&(l.byteOffset=0)):l.array=new Uint8Array(r,a,o.byteLength);else if(s.interleaved){l.byteStride=0,l.byteOffset=0;const t=new f(s.count*c);l.array=z(t,r,s.count,c,u,a+(s.byteOffset||0),s.componentType)}else l.byteStride=0,l.array=this.S(r,s.count,c,a+(s.byteOffset||0),f),l.byteOffset=l.array.byteOffset;else{l.array=new f(s.count);const t=l.min||l.max;t&&(l.array[0]=t[0],l.array[1]=t[1],l.array[2]=t[2])}return l}h(){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)}S(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)}U(t){const e=J.indexOf(t);return J[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.N(e).then((n=>{const{buffer:i,byteOffset:s}=n,o=j(i,s+(e.byteOffset||0),r);return t.content=o,t}))}if(t.uri){if(X(t.uri)){const e=H(t.uri),r=j(e,0,e.byteLength);return t.content=r,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return q.get(e).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(r).then((()=>t))}}class tt extends ${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 Q(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(g(t.name)&&(e.name=t.name),g(t.children)&&(e.children=t.children),g(t.jointName)&&(e.jointName=t.jointName),g(t.matrix)&&(e.matrix=t.matrix),g(t.rotation)&&(e.rotation=t.rotation),g(t.scale)&&(e.scale=t.scale),g(t.translation)&&(e.translation=t.translation),g(t.extras)&&(e.extras=t.extras),g(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=a(x,e.translation||Z),n=f(V,e.rotation||Y),i=c(k,e.scale||K);return o(i,n,i),o(t,r,i)}return s(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}m(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}O(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)}F(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.O(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 et extends ${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 Q(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 G(e,t),!g(t.weights)&&this.gltf.meshes&&g(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}F(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.O(r).then((t=>{if(!t)return null;const n={image:{array:t.data,mipmap:t.mipmap,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};G(n,e);const i=g(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return i&&(n.sampler=i),t.format&&(n.format=t.format),n}))}O(t){if(!g(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.M(e,t)}return null}M(t,e){const r=this.l(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(r,e)}l(t,e,r){r=r||0;const n=t.byteOffset+r,i=t.byteLength;return new Uint8Array(e,n,i)}C(t,e){const r=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)r[e]=String.fromCharCode(t[e]);return r.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(r)))}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++)(g(t[r].input)||g(t[r].output))&&(e.push(this.accessor.T("input",t[r].input)),e.push(this.accessor.T("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 rt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class nt{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 nt.readV1(n,e);if(2===i)return nt.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=it(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 c=s.getUint32(o,!0);if(o+=4,1313821514===c)r=it(t,e+12+o,a);else if(5130562===c){i=e+12+o,n=a;break}o+=a}return{json:JSON.parse(r),glbBuffer:{byteOffset:i,buffer:t,byteLength:n}}}}function it(t,e,r){if(rt){const n=new Uint8Array(t,e,r);return rt.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=st[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 st=[1,1,1,1,2,2,3,0],ot=[0,0,0],at=[0,0,0,1],ct=[1,1,1],ft={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},ut={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},lt={p(t,e,r,n,i,s,o,a){const c=g(t)?e.animations:[e.animations[0]],f={};for(let e=0;e<c.length;e++){const u=c[e],l=u.name||e;if(g(t)&&l!==t)continue;const E=u.channelsMap[r];if(E)for(let t=0;t<E.length;t++){const e=E[t];"translation"===e.target.path?(this.D(i,u.samplers[e.sampler],n,1),f.translation=A(ot,i)):"rotation"===e.target.path?(this.B(s,u.samplers[e.sampler],n,1),f.rotation=B(at,s)):"scale"===e.target.path?(this.D(o,u.samplers[e.sampler],n,1),f.scale=A(ct,o)):"weights"===e.target.path&&a&&(this.D(a,u.samplers[e.sampler],n,a.length),f.weights=a)}}return f},D(t,e,r,n){switch(e.interpolation){case"LINEAR":{const i=this.L(ut,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.L(ut,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.L(ut,e,r,3*n);i&&(t=this.P(t,i,e.input.array,3*n));break}}return t},B(t,e,r){switch(e.interpolation){case"LINEAR":{const n=this.L(ut,e,r,1);n&&w(t,n.PREVIOUS,n.NEXT,n.INTERPOLATION);break}case"STEP":{const n=this.L(ut,e,r,1);n&&(t=C(t,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.L(ut,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},G(t,e){const r=t.length;let n,i,s,o=0,a=r-1,c=Math.floor((o+a)/2);for(;o<=r-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const r=t[c];return n=c,i=c+1,s=(e-r)/(t[c+1]-r),{preIndx:n,nextIndex:i,interpolation:s}}e<t[c]?(a=c,c=Math.floor((o+a)/2)):t[c+1]<e&&(o=c,c=Math.floor((o+a)/2))}return null},L(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.G(i,r);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:f,interpolation:u}=a;t.PREINDEX=c,t.NEXTINDEX=f,t.INTERPOLATION=u;const l=o*n;return t.PREVIOUS=s.subarray(t.PREINDEX*l,(t.PREINDEX+1)*l),t.NEXT=s.subarray(t.NEXTINDEX*l,(t.NEXTINDEX+1)*l),t},P(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],c=(o-s)*e.PREVIOUS[2*n+r],f=e.NEXT[3+r],u=(o-s)*e.NEXT[r],l=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*a+(Math.pow(i,3)-2*Math.pow(i,2)+i)*c+(2*-Math.pow(i,3)+3*Math.pow(i,2))*f+(Math.pow(i,3)-Math.pow(i,2))*u;t[r]=l}return t},getAnimationClip(t,e,r,n){const i=t.nodes[e]&&t.nodes[e].weights;return h(ot,...ft.TRANSLATION),C(at,...ft.ROTATION),h(ct,...ft.SCALE),this.p(n,t,e,r,ot,at,ct,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?g(e)?r[e]:r[Object.keys(r)[0]]:null}};let Et=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Re){}t&&"undefined"!=typeof createImageBitmap&&(Et=!0)}const _t="undefined"==typeof document?null:document.createElement("canvas");class At{constructor(t,e,r){if(this.options=r||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:r,glbBuffer:n}=nt.read(e.buffer,e.byteOffset,e.byteLength);this.v(t,r,n)}else this.v(t,e);this.X=new Q(this.rootPath,this.gltf,this.glbBuffer),this.H()}H(){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")}}V(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.X.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.k(t),r=this.Z(),n=this.Y(),i=this.V();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 lt.getAnimationClip(t,e,r,n)}static getAnimationTimeSpan(t,e){return lt.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return v(t)}static readInterleavedArray(t,e,r,n,i,s,o){return z(t,e,r,n,i,s,o)}v(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=Et?yt.bind(this):this.options.requestImage||ht,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new et(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 tt(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"))}K(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(r=t.children[0])&&isFinite(r)||function(t){return!P(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.K(r,e)}));t.children=n}var r;return t}k(t){return this.W(t).then((t=>{const e=this.scenes=[];let r;for(const e in t)t[e]=this.K(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.m(this.gltf.materials);n.materials=t}return n}))}W(t){return this.j(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}))}q(){this.skins=[];const t=[];return this.adapter.iterate(((e,r,n)=>{t.push(this.$(r).then((t=>{t.index=n,this.skins.push(t)})))}),"skins"),t}$(t){const e=t.inverseBindMatrices;return this.adapter.accessor.T("inverseBindMatrices",e).then((e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t)))}Z(){const t=this.gltf.animations;return g(t)?this.adapter.getAnimations(t):null}j(t){this.meshes={};let e=[];return this.adapter.iterate(((r,n,i)=>{e.push(this.J(n,t).then((t=>{t.index=i,this.meshes[r]=t})))}),"meshes"),e=e.concat(this.q()),Promise.all(e)}J(t,e){const r=t.primitives.map((t=>this.tt(t,e))).filter((t=>!!t));return Promise.all(r).then((e=>{const r={};return G(r,t),r.primitives=e,r}))}Y(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const r in t)e.push(this.adapter.F(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}))}tt(t,e){let r;const n=[],i=t.extensions;if(g(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.T(`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],c=this.X.N(a).then((r=>{const{buffer:n,byteOffset:i}=r;let{byteOffset:s,byteLength:c}=a;s||(s=0);const f=new DataView(n,i+s,c),u={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(f,u).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));n.push(c),r=Promise.all(n)}else{const e=t.attributes;for(const t in e){const r=this.adapter.accessor.T(t,e[t]);r&&n.push(r)}if(g(t.indices)){const e=this.adapter.accessor.T("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;I(t,t,i),T(t,t,s),I(r,r,i),T(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=g(t.mode)?t.mode:4,g(t.extras)&&(s.extras=t.extras),s}))}}function ht(t,e){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!_t)return void e(new Error("There is no canvas to draw image!"));_t.width=r.width,_t.height=r.height;const t=_t.getContext("2d",{willReadFrequently:!0});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 Tt,Rt;function yt(t,e){Tt||(Tt=new OffscreenCanvas(2,2),Rt=Tt.getContext("2d",{willReadFrequently:!0})),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;It(r)||(r=Nt(r)),It(n)||(n=Nt(n));const i=this.options.maxTextureSize;i&&(r=Math.min(i,r),n=Math.min(i,n)),Tt.width=r,Tt.height=n,Rt.drawImage(t,0,0,r,n),t.close();const s=Rt.getImageData(0,0,r,n);e(null,{width:r,height:n,data:new Uint8Array(s.data)})})).catch((t=>{console.warn(t),e(t)}))}function It(t){return 0==(t&t-1)&&0!==t}function Nt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Ut(t){return"object"==typeof t&&!!t}function dt(t){return t*Math.PI/180}function St(t){return t/Math.PI*180}function mt(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const Ot=[1,1,1,1,2,2,3,0];function Ft(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}const Mt=new Array(3),Ct=new Array(3),bt=[40680631590769,40680631590769,40408299984661.445];const pt=[1/6378137,1/6378137,1/6356752.314245179],wt=[1/40680631590769,1/40680631590769,1/40408299984661.445],Dt=new Array(3),Bt=new Array(3),Lt=new Array(3);function Pt(t,e){const r=wt,n=function(t,e,r,n,i){const s=e[0],o=e[1],a=e[2],c=r[0],f=r[1],u=r[2],l=s*s*c*c,E=o*o*f*f,_=a*a*u*u,A=l+E+_,h=Math.sqrt(1/A),T=I(gt,e,h);if(A<i)return isFinite(h)?T:void 0;const R=n[0],y=n[1],N=n[2],U=Gt;U[0]=T[0]*R*2,U[1]=T[1]*y*2,U[2]=T[2]*N*2;let d,S,m,O,F,M,C,b,p,w,D,B=(1-h)*vt(e)/(.5*vt(U)),L=0;do{B-=L,m=1/(1+B*R),O=1/(1+B*y),F=1/(1+B*N),M=m*m,C=O*O,b=F*F,p=M*m,w=C*O,D=b*F,d=l*M+E*C+_*b-1,S=l*p*R+E*w*y+_*D*N;L=d/(-2*S)}while(Math.abs(d)>1e-12);return t[0]=s*m,t[1]=o*O,t[2]=a*F,t}(Dt,e,pt,r,.1);let i=F(Bt,n,r);i=Xt(i,i);const s=O(Lt,e,n),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=mt(d(s,e))*vt(s);return t[0]=St(o),t[1]=St(a),t[2]=c,t}const gt=new Array(3),Gt=new Array(3);function vt(t){return E(t)}function Xt(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 Ht(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 xt(t,e){let r="";for(let n=0;n<4;n++){const i=t.getUint8(e+n);r+=String.fromCharCode(i)}return r}const Vt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function kt(t,e,r){const n=new Uint8Array(t,e,r);return Vt?JSON.parse(Vt.decode(n)):JSON.parse(Ft(n))}function Zt(t,e,r){const n=new Uint8Array(t,e,r);return Vt?JSON.parse(Vt.decode(n)):JSON.parse(Ft(n))}function Yt(t,e,r){return{offset:e,byteLength:r}}function Kt(t,e,r,n){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=function(t){return jt[t]}(s||"UNSIGNED_SHORT"),f=function(t){if(!t)return 1;return Wt[t]}(o);return{byteStride:0,byteOffset:i+r,itemSize:f,count:n*f,componentType:c,array:new a(e,r+i,n*f)}}function zt(t,e,r,n){const i=Kt(t,e,r,n);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}const Wt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const jt={"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 qt(t){for(let e in jt)if(t===jt[e].ctor)return jt[e].type;throw new Error("unrecognized ctor:"+t)}function $t(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 Jt(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 c,f,u={},l={};n>0&&(u=kt(a,e,n),e+=n),i>0&&(c=function(t,e,r){return{offset:e,byteLength:r}}(0,e,i),e+=i),s>0&&(l=Zt(a,e,s),e+=s);const E=Yt(0,e,o);return f=a.slice(E.offset,E.offset+E.byteLength),r.push(f),{featureTable:u,featureTableBin:c,batchTable:l,batchTableBin:f}}var Qt={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},te={},ee={east:[],north:[],up:[],west:[],south:[],down:[]},re=[],ne=[],ie=[];const se=[0,0,0];const oe=(ue={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"}}[ae="east"][ce="north"],te[le=ae+ce]?fe=te[le]:(fe=function(t,r,n){if(function(t,r){var n=t[0],i=t[1],s=t[2],o=r[0],a=r[1],c=r[2];return Math.abs(n-o)<=e*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=e*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(s-c)<=e*Math.max(1,Math.abs(s),Math.abs(c))}(t,se))A(re,Qt[ae]),A(ne,Qt[ce]),A(ie,Qt[ue]);else if(Ht(t[0],0,1e-14)&&Ht(t[1],0,1e-14)){var i=mt(t[2]);A(re,Qt[ae]),"east"!==ae&&"west"!==ae&&I(re,re,i),A(ne,Qt[ce]),"east"!==ce&&"west"!==ce&&I(ne,ne,i),A(ie,Qt[ue]),"east"!==ue&&"west"!==ue&&I(ie,ie,i)}else{!function(t,e){y(e,t,wt),U(e,e)}(t,ee.up);var s=ee.up,o=ee.east;o[0]=-t[1],o[1]=t[0],o[2]=0,U(ee.east,o),S(ee.north,s,o),I(ee.down,ee.up,-1),I(ee.west,ee.east,-1),I(ee.south,ee.north,-1),re=ee[ae],ne=ee[ce],ie=ee[ue]}return n[0]=re[0],n[1]=re[1],n[2]=re[2],n[3]=0,n[4]=ne[0],n[5]=ne[1],n[6]=ne[2],n[7]=0,n[8]=ie[0],n[9]=ie[1],n[10]=ie[2],n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n},te[le]=fe),fe);var ae,ce,fe,ue,le;const Ee={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function _e(t){for(let e in Ee)if(t===Ee[e])return+e;throw new Error("unrecognized ctor:"+t)}function Ae(t){return 1===t?"FLOAT":"VEC"+t}\n/*!\n * @maptalks/gl v0.80.0\n * LICENSE : UNLICENSED\n * (c) 2016-2022 maptalks.com\n */const he=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")},Te=he(),Re=Te.gl_trans__coders=Te.gl_trans__coders||{};Re.inject=function(t){const e=t.toString(),r=e.indexOf("{")+1,n=e.substring(0,r),i=Te.gl_trans__coders=Te.gl_trans__coders||{};let s=`${n}\\n const _____getGlobal = ${he.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},Re.registerTranscoder=function(t,e){Re[t]=e},Re.getTranscoder=function(t){return Re[t]};let ye=null;function Ie(){return ye||(ye={"image/crn":Re.crn&&Re.crn(),"image/ktx2":Re.ktx2&&Re.ktx2(),"image/cttf":Re.ktx2&&Re.ktx2(),"draco":Re.draco&&Re.draco()}),ye}class Ne{constructor(t,e,r){this.i=t,this.et=e||At,this.o=r,this.rt=Ie()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.nt(t,e,r,n,i)):q.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.nt(t,i,r,n)}))}nt(t,e,r,n,i){const s=i&&i.maxTextureSize,o=this.it(e,r,n,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.et(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.rt,supportedFormats:this.o,maxTextureSize:s});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${r}-${n}`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}it(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),c=i.getUint32(16,!0),f=i.getUint32(20,!0),u=i.getUint32(24,!0),l=28+e;f>=570425344?(l-=8,o=a,f=c,u=0,a=0,c=0):u>=570425344&&(l-=4,o=f,f=a,u=c,a=0,c=0);const E=[t];let _,A,h;if(a>0?(_=kt(t,l,a),l+=a,o=_.BATCH_LENGTH):_={"BATCH_LENGTH":o},c>0&&(l+=c),f>0&&(A=Zt(t,l,f),l+=f,u>0)){const e=Yt(0,l,u);h=t.slice(e.offset,e.offset+e.byteLength),l+=u,E.push(h)}const T=_.BATCH_LENGTH,R={};if(_&&_.BATCH_ID){R.BATCH_ID=zt(_.BATCH_ID,t,undefined.offset,T);const e=R.BATCH_ID.array&&R.BATCH_ID.array.buffer;e&&E.indexOf(e)<0&&E.push(e)}return{count:o,transferables:E,featureTable:_,batchTable:A,batchTableBin:h,b3dm:R,glb:{buffer:t,byteOffset:l,byteLength:i.byteLength+i.byteOffset-l}}}st(){return null}}class Ue{constructor(t,e,r,n){this.i=t,this.et=e||At,this.o=r,this.rt=Ie(),this.ot=n}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.nt(t,e,r,n,i)):q.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.nt(t,i,r,n)}))}nt(t,e,r,n,i){return this.ct(t,e,r,n,i).then((({gltf:i,transferables:s})=>{const o=this.ft(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})}))}ct(t,e,r,n,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.rt,supportedFormats:this.o,maxTextureSize:s},a=new DataView(e,r,n),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let n=Ft(new Uint8Array(e,c+r,a.byteLength-c));-1==n.indexOf("://")&&(n=t.substring(0,t.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?q.getArrayBuffer(n,{}).then((t=>this.ut(n,{buffer:t.data,byteOffset:0},o))):q.getJSON(n,{}).then((t=>this.ut(n,t,o)))}{const n={buffer:e,byteOffset:c+r,byteLength:a.byteLength-c};return this.ut(t,n,o)}}ut(t,e,r){const n=t.substring(0,t.lastIndexOf("/")),i=new this.et(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}}))}ft(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:c,batchTable:f,batchTableBin:u}=Jt(i,32+e,o),l={},E=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;l.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,3*E).slice()},o.push(l.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,r=a.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=a.POSITION_QUANTIZED;l.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:E,componentType:5126,array:this.lt(new Uint16Array(t,n+c.offset,3*E),e,r)},o.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=zt(a.BATCH_ID,t,c.offset,E);const e=l.BATCH_ID.array&&l.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,3*E).slice()},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,3*E).slice()},o.push(l.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:this.Et(new Uint16Array(t,e+c.offset,2*E))},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:this.Et(new Uint16Array(t,e+c.offset,2*E))},o.push(l.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;l.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,E).slice()},o.push(l.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;l.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:E,componentType:5126,array:new Float32Array(t,e+c.offset,3*E).slice()},o.push(l.SCALE_NON_UNIFORM.array.buffer)}return{count:E,batchTable:f,batchTableBin:u,featureTable:a,i3dm:l,transferables:o}}Et(t){const e=t.length/2,r=new Float32Array(3*e),n=[];for(let i=0;i<e;i++)de(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}lt(t,e,r){return $t(new Float32Array(t.length),t,e,r)}st(){return null}}function de(t,e,r,n){if(t[0]=Se(e,n),t[1]=Se(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]))*me(e),t[1]=(1-Math.abs(e))*me(t[1])}return U(t,t)}function Se(t,e){return e=function(t,e){if(null!=t)return t;return e}(e,255),function(t,e,r){return t<e?e:t>r?r:t}(t,0,e)/e*2-1}function me(t){return t<0?-1:1}class Oe{constructor(){}load(t,e,r=0,n=0){return e?(n||(n=e.byteLength),this.nt(t,e,r,n)):q.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.nt(t,i,r,n)}))}nt(t,e,r,n){return this._t(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}))}_t(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:c,batchTable:f,batchTableBin:u}=Jt(i,e+28,o),l=a.QUANTIZED_VOLUME_OFFSET,E=a.QUANTIZED_VOLUME_SCALE,_=a.POINTS_LENGTH;let A,h={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){h=a.extensions["3DTILES_draco_point_compression"],A=new DataView(t,h.byteOffset+c.offset,h.byteLength);const e={attributes:h.properties,useUniqueIDs:!1};return this.At||(this.At=Ie().draco),this.At(A,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,c.offset,_,o,l,E);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:qt(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(f).length){a.BATCH_ID?n.BATCH_ID=zt(a.BATCH_ID,t,c.offset,_):n.BATCH_ID=Fe(_);const e=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:_,batchTable:f,batchTableBin:u,featureTable:a,pnts:n,transferables:o}}))}const T=this.ht(t,a,c.offset,_,o,l,E);if(a.BATCH_ID||Object.keys(f).length){a.BATCH_ID?T.BATCH_ID=zt(a.BATCH_ID,t,c.offset,_):T.BATCH_ID=Fe(_);const e=T.BATCH_ID.array&&T.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:_,batchTable:f,batchTableBin:u,featureTable:a,pnts:T,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 c=o?0:r;if(!o){const e=t.slice(s+c,s+c+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:c,array:f}=e.POSITION_QUANTIZED;c=c||0;const u=f?0:r;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this.lt(f||new Uint16Array(t,c+u,3*n),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+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 c=o?0:r;if(!o){const e=t.slice(s+c,s+c+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 c=o?0:r;if(!o){const e=t.slice(s+c,s+c+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 c=o?0:r;if(!o){const e=t.slice(s+c,s+c+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 c=o?0:r;if(!o){const e=t.slice(s+c,s+c+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}lt(t,e,r){return $t(new Float32Array(t.length),t,e,r)}st(){return null}}function Fe(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:qt(e),array:n}}class Me{constructor(t,e,r,n){this.o=r,this.i=t,this.et=e||At,this.ot=n}load(t,e,r=0,n=0,i){return e?this.nt(t,e,r,n,i):q.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.nt(t,i,r,n)}))}nt(t,e,r,n,i){n||(n=e.byteLength);const s=this.Tt(e,t,r,n),o=[];for(let r=0;r<s.length;r++){let n;if("b3dm"===s[r].magic)n=new Ne(this.i,this.et,this.o);else if("i3dm"===s[r].magic)n=new Ue(this.i,this.et,this.o,this.ot);else if("pnts"===s[r].magic)n=new Oe;else{if("cmpt"!==s[r].magic){console.warn("Unsupported magic in CMPT tile:",s[r].magic);continue}n=new Me(this.i,this.et,this.o,this.ot)}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})))}Tt(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 c=16;for(let e=0;e<a;e++){const e=xt(i,c),n=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+r,byteLength:n}),c+=n}return o}}function Ce(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=[];Pe(n[r],i,t,e)}}}const be=[],pe=[],we=[],De=[0,0,0],Be=p([]),Le=[1,1,1];function Pe(t,e,r,n){const i=e.slice(0);if(t.matrix)i.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=a(be,t.translation||De),r=f(pe,t.rotation||Be),n=c(we,t.scale||Le);o(n,r,n);const s=o([],e,n);i.push(s)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)Pe(t.children[e],i,r,n);if(void 0!==t.mesh){const e=t.mesh,s=r.meshes[e];if(s){const t=i.slice(0),o=s.primitives;for(let i=0,s=o.length;i<s;i++){const s=o[i];s&&(s.matrices=t,n(s,e,i,r))}}}}function ge(t,e){let{componentType:r,byteOffset:n,byteStride:i,count:s,itemSize:o}=t;const a=t.array.buffer,c=r?At.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*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*o);for(let r=0;r<s*o;r+=o){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o)}return}const f=new Uint8Array(o*c.BYTES_PER_ELEMENT);i||(i=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const r=new Uint8Array(a,i*t+n,o*c.BYTES_PER_ELEMENT);f.set(r);e(new c(f.buffer),t),r.set(f)}}const Ge=[],ve=[];function Xe(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,s=t.position.z,o=function(t,e,r,n){const i=bt,s=Math.cos(r);Mt[0]=s*Math.cos(e),Mt[1]=s*Math.sin(e),Mt[2]=Math.sin(r),Xt(Mt,Mt),y(Ct,i,Mt);const o=Math.sqrt(d(Mt,Ct));var a,c,f;return c=Ct,f=o,(a=Ct)[0]=c[0]/f,a[1]=c[1]/f,a[2]=c[2]/f,I(Mt,Mt,n),T(t,Ct,Mt)}([],dt(r),dt(n),s),a=oe(o,null,[]);e.root.transform=i([],a);const c=[];for(let r=0,n=t.tiles.length;r<n;r++)if(t.tiles[r].boundingbox){const n=t.tiles[r].boundingbox;h(Ge,n.min.x,n.min.y,n.min.z),h(ve,n.max.x,n.max.y,n.max.z);const i={center:[0,0,0],radius:0};He(Ge,ve,i),e.root.children.push({boundingVolume:{sphere:[...i.center,i.radius]},content:{uri:t.tiles[r].url},geometricError:70,refine:"REPLACE"}),c.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"}),c.push(i)}const f=function(t,e){if(0===t.length)return e;const r=t.length;if(1===r)return function(t,e){return A(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=R(Ve,s,n),c=nr(a);if(i>=c+o)return t.clone(r),r;if(o>=c+i)return e.clone(r),r;const f=.5*(i+c+o),u=I(ke,a,(-i+f)/c);return T(u,u,n),A(r.center,u),r.radius=f,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=h(e.center,0,0,0),e.radius=0,e;const r=A(qe,t[0]),n=A(Ze,r),i=A(Ye,r),s=A(Ke,r),o=A(ze,r),a=A(We,r),c=A(je,r),f=t.length;for(let e=1;e<f;e++){A(r,t[e]);const f=r[0],u=r[1],l=r[2];f<n[0]&&A(n,r),f>o[0]&&A(o,r),u<i[1]&&A(i,r),u>a[1]&&A(a,r),l<s[2]&&A(s,r),l>c[2]&&A(c,r)}const u=rr(R($e,o,n)),l=rr(R($e,a,i)),E=rr(R($e,c,s));let _=n,T=o,y=u;l>y&&(y=l,_=i,T=a);E>y&&(y=E,_=s,T=c);const I=Je;I[0]=.5*(_[0]+T[0]),I[1]=.5*(_[1]+T[1]),I[2]=.5*(_[2]+T[2]);let N=rr(R($e,T,I)),U=Math.sqrt(N);const d=Qe;d[0]=n[0],d[1]=i[1],d[2]=s[2];const S=tr;S[0]=o[0],S[1]=a[1],S[2]=c[2];const m=xe(d,S,er);let O=0;for(let e=0;e<f;e++){A(r,t[e]);const n=nr(R($e,r,m));n>O&&(O=n);const i=rr(R($e,r,I));if(i>N){const t=Math.sqrt(i);U=.5*(U+t),N=U*U;const e=t-U;I[0]=(U*I[0]+e*r[0])/t,I[1]=(U*I[1]+e*r[1])/t,I[2]=(U*I[2]+e*r[2])/t}}U<O?(A(e.center,I),e.radius=U):(A(e.center,m),e.radius=O);return e}(n,e)).center;let s=e.radius;for(let e=0;e<r;e++){const r=t[e];s=Math.max(s,N(i,r.center)+r.radius)}return e.radius=s,e}(c,{center:[0,0,0],radius:0});return e.root.boundingVolume.sphere=[...f.center,f.radius],e}function He(t,e,r){var n=xe(t,e,r.center);return r.radius=N(n,e),r}function xe(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 Ve=[],ke=[];const Ze=[],Ye=[],Ke=[],ze=[],We=[],je=[],qe=[],$e=[],Je=[],Qe=[],tr=[],er=[];function rr(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function nr(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 ir(t){let e=t.length;for(;--e>=0;)t[e]=0}const sr=256,or=286,ar=30,cr=15,fr=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]),ur=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]),lr=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Er=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_r=new Array(576);ir(_r);const Ar=new Array(60);ir(Ar);const hr=new Array(512);ir(hr);const Tr=new Array(256);ir(Tr);const Rr=new Array(29);ir(Rr);const yr=new Array(ar);function Ir(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,Ur,dr;function Sr(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}ir(yr);const mr=t=>t<256?hr[t]:hr[256+(t>>>7)],Or=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},Fr=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,Or(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)},Mr=(t,e,r)=>{Fr(t,r[2*e],r[2*e+1])},Cr=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},br=(t,e,r)=>{const n=new Array(16);let i,s,o=0;for(i=1;i<=cr;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]=Cr(n[e]++,e))}},pr=t=>{let e;for(e=0;e<or;e++)t.dyn_ltree[2*e]=0;for(e=0;e<ar;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},wr=t=>{t.bi_valid>8?Or(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},Dr=(t,e,r,n)=>{const i=2*e,s=2*r;return t[i]<t[s]||t[i]===t[s]&&n[e]<=n[r]},Br=(t,e,r)=>{const n=t.heap[r];let i=r<<1;for(;i<=t.heap_len&&(i<t.heap_len&&Dr(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!Dr(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n},Lr=(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?Mr(t,i,e):(s=Tr[i],Mr(t,s+sr+1,e),o=fr[s],0!==o&&(i-=Rr[s],Fr(t,i,o)),n--,s=mr(n),Mr(t,s,r),o=ur[s],0!==o&&(n-=yr[s],Fr(t,n,o)))}while(a<t.last_lit);Mr(t,256,e)},Pr=(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,c,f=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<s;o++)0!==r[2*o]?(t.heap[++t.heap_len]=f=o,t.depth[o]=0):r[2*o+1]=0;for(;t.heap_len<2;)c=t.heap[++t.heap_len]=f<2?++f:0,r[2*c]=1,t.depth[c]=0,t.opt_len--,i&&(t.static_len-=n[2*c+1]);for(e.max_code=f,o=t.heap_len>>1;o>=1;o--)Br(t,r,o);c=s;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],Br(t,r,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,r[2*c]=r[2*o]+r[2*a],t.depth[c]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,r[2*o+1]=r[2*a+1]=c,t.heap[1]=c++,Br(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,c=e.stat_desc.max_length;let f,u,l,E,_,A,h=0;for(E=0;E<=cr;E++)t.bl_count[E]=0;for(r[2*t.heap[t.heap_max]+1]=0,f=t.heap_max+1;f<573;f++)u=t.heap[f],E=r[2*r[2*u+1]+1]+1,E>c&&(E=c,h++),r[2*u+1]=E,u>n||(t.bl_count[E]++,_=0,u>=a&&(_=o[u-a]),A=r[2*u],t.opt_len+=A*(E+_),s&&(t.static_len+=A*(i[2*u+1]+_)));if(0!==h){do{for(E=c-1;0===t.bl_count[E];)E--;t.bl_count[E]--,t.bl_count[E+1]+=2,t.bl_count[c]--,h-=2}while(h>0);for(E=c;0!==E;E--)for(u=t.bl_count[E];0!==u;)l=t.heap[--f],l>n||(r[2*l+1]!==E&&(t.opt_len+=(E-r[2*l+1])*r[2*l],r[2*l+1]=E),u--)}})(t,e),br(r,f,t.bl_count)},gr=(t,e,r)=>{let n,i,s=-1,o=e[1],a=0,c=7,f=4;for(0===o&&(c=138,f=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=o,o=e[2*(n+1)+1],++a<c&&i===o||(a<f?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?(c=138,f=3):i===o?(c=6,f=3):(c=7,f=4))},Gr=(t,e,r)=>{let n,i,s=-1,o=e[1],a=0,c=7,f=4;for(0===o&&(c=138,f=3),n=0;n<=r;n++)if(i=o,o=e[2*(n+1)+1],!(++a<c&&i===o)){if(a<f)do{Mr(t,i,t.bl_tree)}while(0!=--a);else 0!==i?(i!==s&&(Mr(t,i,t.bl_tree),a--),Mr(t,16,t.bl_tree),Fr(t,a-3,2)):a<=10?(Mr(t,17,t.bl_tree),Fr(t,a-3,3)):(Mr(t,18,t.bl_tree),Fr(t,a-11,7));a=0,s=i,0===o?(c=138,f=3):i===o?(c=6,f=3):(c=7,f=4)}};let vr=!1;const Xr=(t,e,r,n)=>{Fr(t,0+(n?1:0),3),((t,e,r,n)=>{wr(t),n&&(Or(t,r),Or(t,~r)),t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r})(t,e,r,!0)};var Hr=t=>{vr||((()=>{let t,e,r,n,i;const s=new Array(16);for(r=0,n=0;n<28;n++)for(Rr[n]=r,t=0;t<1<<fr[n];t++)Tr[r++]=n;for(Tr[r-1]=n,i=0,n=0;n<16;n++)for(yr[n]=i,t=0;t<1<<ur[n];t++)hr[i++]=n;for(i>>=7;n<ar;n++)for(yr[n]=i<<7,t=0;t<1<<ur[n]-7;t++)hr[256+i++]=n;for(e=0;e<=cr;e++)s[e]=0;for(t=0;t<=143;)_r[2*t+1]=8,t++,s[8]++;for(;t<=255;)_r[2*t+1]=9,t++,s[9]++;for(;t<=279;)_r[2*t+1]=7,t++,s[7]++;for(;t<=287;)_r[2*t+1]=8,t++,s[8]++;for(br(_r,287,s),t=0;t<ar;t++)Ar[2*t+1]=5,Ar[2*t]=Cr(t,5);Nr=new Ir(_r,fr,257,or,cr),Ur=new Ir(Ar,ur,0,ar,cr),dr=new Ir(new Array(0),lr,0,19,7)})(),vr=!0),t.l_desc=new Sr(t.dyn_ltree,Nr),t.d_desc=new Sr(t.dyn_dtree,Ur),t.bl_desc=new Sr(t.bl_tree,dr),t.bi_buf=0,t.bi_valid=0,pr(t)},xr=(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<sr;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),Pr(t,t.l_desc),Pr(t,t.d_desc),o=(t=>{let e;for(gr(t,t.dyn_ltree,t.l_desc.max_code),gr(t,t.dyn_dtree,t.d_desc.max_code),Pr(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*Er[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?Xr(t,e,r,n):4===t.strategy||s===i?(Fr(t,2+(n?1:0),3),Lr(t,_r,Ar)):(Fr(t,4+(n?1:0),3),((t,e,r,n)=>{let i;for(Fr(t,e-257,5),Fr(t,r-1,5),Fr(t,n-4,4),i=0;i<n;i++)Fr(t,t.bl_tree[2*Er[i]+1],3);Gr(t,t.dyn_ltree,e-1),Gr(t,t.dyn_dtree,r-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),Lr(t,t.dyn_ltree,t.dyn_dtree)),pr(t),n&&wr(t)},Vr={Rt:Hr,yt:Xr,It:xr,Nt:(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*(Tr[r]+sr+1)]++,t.dyn_dtree[2*mr(e)]++),t.last_lit===t.lit_bufsize-1),Ut:t=>{Fr(t,2,3),Mr(t,256,_r),(t=>{16===t.bi_valid?(Or(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 kr=(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 Zr=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 Yr=(t,e,r,n)=>{const i=Zr,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"},zr={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{Rt:Wr,yt:jr,It:qr,Nt:$r,Ut:Jr}=Vr,{Z_NO_FLUSH:Qr,Z_PARTIAL_FLUSH:tn,Z_FULL_FLUSH:en,Z_FINISH:rn,Z_BLOCK:nn,Z_OK:sn,Z_STREAM_END:on,Z_STREAM_ERROR:an,Z_DATA_ERROR:cn,Z_BUF_ERROR:fn,Z_DEFAULT_COMPRESSION:un,Z_FILTERED:ln,Z_HUFFMAN_ONLY:En,Z_RLE:_n,Z_FIXED:An,Z_DEFAULT_STRATEGY:hn,Z_UNKNOWN:Tn,Z_DEFLATED:Rn}=zr,yn=258,In=262,Nn=103,Un=113,dn=666,Sn=(t,e)=>(t.msg=Kr[e],e),mn=t=>(t<<1)-(t>4?9:0),On=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let Fn=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask;const Mn=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))},Cn=(t,e)=>{qr(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Mn(t.strm)},bn=(t,e)=>{t.pending_buf[t.pending++]=e},pn=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},wn=(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=kr(t.adler,e,i,r):2===t.state.wrap&&(t.adler=Yr(t.adler,e,i,r)),t.next_in+=i,t.total_in+=i,i)},Dn=(t,e)=>{let r,n,i=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match;const c=t.strstart>t.w_size-In?t.strstart-(t.w_size-In):0,f=t.window,u=t.w_mask,l=t.prev,E=t.strstart+yn;let _=f[s+o-1],A=f[s+o];t.prev_length>=t.good_match&&(i>>=2),a>t.lookahead&&(a=t.lookahead);do{if(r=e,f[r+o]===A&&f[r+o-1]===_&&f[r]===f[s]&&f[++r]===f[s+1]){s+=2,r++;do{}while(f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&f[++s]===f[++r]&&s<E);if(n=yn-(E-s),s=E-yn,n>o){if(t.match_start=e,o=n,n>=a)break;_=f[s+o-1],A=f[s+o]}}}while((e=l[e&u])>c&&0!=--i);return o<=t.lookahead?o:t.lookahead},Bn=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-In)){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=wn(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=Fn(t,t.ins_h,t.window[o+1]);t.insert&&(t.ins_h=Fn(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<In&&0!==t.strm.avail_in)},Ln=(t,e)=>{let r,n;for(;;){if(t.lookahead<In){if(Bn(t),t.lookahead<In&&e===Qr)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=Fn(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-In&&(t.match_length=Dn(t,r)),t.match_length>=3)if(n=$r(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=Fn(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=Fn(t,t.ins_h,t.window[t.strstart+1]);else n=$r(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(Cn(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===rn?(Cn(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Cn(t,!1),0===t.strm.avail_out)?1:2},Pn=(t,e)=>{let r,n,i;for(;;){if(t.lookahead<In){if(Bn(t),t.lookahead<In&&e===Qr)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=Fn(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-In&&(t.match_length=Dn(t,r),t.match_length<=5&&(t.strategy===ln||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=$r(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=Fn(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&&(Cn(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=$r(t,0,t.window[t.strstart-1]),n&&Cn(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=$r(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===rn?(Cn(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Cn(t,!1),0===t.strm.avail_out)?1:2};function gn(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 Gn=[new gn(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(Bn(t),0===t.lookahead&&e===Qr)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,Cn(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-In&&(Cn(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===rn?(Cn(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(Cn(t,!1),t.strm.avail_out),1)})),new gn(4,4,8,4,Ln),new gn(4,5,16,8,Ln),new gn(4,6,32,32,Ln),new gn(4,4,16,16,Pn),new gn(8,16,32,32,Pn),new gn(8,16,128,128,Pn),new gn(8,32,128,256,Pn),new gn(32,128,258,1024,Pn),new gn(32,258,258,4096,Pn)];function vn(){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=Rn,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),On(this.dyn_ltree),On(this.dyn_dtree),On(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),On(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),On(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 Xn=t=>{if(!t||!t.state)return Sn(t,an);t.total_in=t.total_out=0,t.data_type=Tn;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:Un,t.adler=2===e.wrap?0:1,e.last_flush=Qr,Wr(e),sn},Hn=t=>{const e=Xn(t);var r;return e===sn&&((r=t.state).window_size=2*r.w_size,On(r.head),r.max_lazy_match=Gn[r.level].max_lazy,r.good_match=Gn[r.level].good_length,r.nice_match=Gn[r.level].nice_length,r.max_chain_length=Gn[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},xn=(t,e,r,n,i,s)=>{if(!t)return an;let o=1;if(e===un&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),i<1||i>9||r!==Rn||n<8||n>15||e<0||e>9||s<0||s>An)return Sn(t,an);8===n&&(n=9);const a=new vn;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,Hn(t)};var Vn=(t,e)=>{let r=e.length;if(!t||!t.state)return an;const n=t.state,i=n.wrap;if(2===i||1===i&&42!==n.status||n.lookahead)return an;if(1===i&&(t.adler=kr(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===i&&(On(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,Bn(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=Fn(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,Bn(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,sn},kn={deflateInit:(t,e)=>xn(t,e,Rn,15,8,hn),deflateInit2:xn,deflateReset:Hn,deflateResetKeep:Xn,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?an:(t.state.gzhead=e,sn):an,deflate:(t,e)=>{let r,n;if(!t||!t.state||e>nn||e<0)return t?Sn(t,an):an;const i=t.state;if(!t.output||!t.input&&0!==t.avail_in||i.status===dn&&e!==rn)return Sn(t,0===t.avail_out?fn:an);i.strm=t;const s=i.last_flush;if(i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,bn(i,31),bn(i,139),bn(i,8),i.gzhead?(bn(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)),bn(i,255&i.gzhead.time),bn(i,i.gzhead.time>>8&255),bn(i,i.gzhead.time>>16&255),bn(i,i.gzhead.time>>24&255),bn(i,9===i.level?2:i.strategy>=En||i.level<2?4:0),bn(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(bn(i,255&i.gzhead.extra.length),bn(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=Yr(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(bn(i,0),bn(i,0),bn(i,0),bn(i,0),bn(i,0),bn(i,9===i.level?2:i.strategy>=En||i.level<2?4:0),bn(i,3),i.status=Un);else{let e=Rn+(i.w_bits-8<<4)<<8,r=-1;r=i.strategy>=En||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=Un,pn(i,e),0!==i.strstart&&(pn(i,t.adler>>>16),pn(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=Yr(t.adler,i.pending_buf,i.pending-r,r)),Mn(t),r=i.pending,i.pending!==i.pending_buf_size));)bn(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>r&&(t.adler=Yr(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=Yr(t.adler,i.pending_buf,i.pending-r,r)),Mn(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,bn(i,n)}while(0!==n);i.gzhead.hcrc&&i.pending>r&&(t.adler=Yr(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=Yr(t.adler,i.pending_buf,i.pending-r,r)),Mn(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,bn(i,n)}while(0!==n);i.gzhead.hcrc&&i.pending>r&&(t.adler=Yr(t.adler,i.pending_buf,i.pending-r,r)),0===n&&(i.status=Nn)}else i.status=Nn;if(i.status===Nn&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&Mn(t),i.pending+2<=i.pending_buf_size&&(bn(i,255&t.adler),bn(i,t.adler>>8&255),t.adler=0,i.status=Un)):i.status=Un),0!==i.pending){if(Mn(t),0===t.avail_out)return i.last_flush=-1,sn}else if(0===t.avail_in&&mn(e)<=mn(s)&&e!==rn)return Sn(t,fn);if(i.status===dn&&0!==t.avail_in)return Sn(t,fn);if(0!==t.avail_in||0!==i.lookahead||e!==Qr&&i.status!==dn){let r=i.strategy===En?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(Bn(t),0===t.lookahead)){if(e===Qr)return 1;break}if(t.match_length=0,r=$r(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(Cn(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===rn?(Cn(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Cn(t,!1),0===t.strm.avail_out)?1:2})(i,e):i.strategy===_n?((t,e)=>{let r,n,i,s;const o=t.window;for(;;){if(t.lookahead<=yn){if(Bn(t),t.lookahead<=yn&&e===Qr)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+yn;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=yn-(s-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=$r(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=$r(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(Cn(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===rn?(Cn(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Cn(t,!1),0===t.strm.avail_out)?1:2})(i,e):Gn[i.level].func(i,e);if(3!==r&&4!==r||(i.status=dn),1===r||3===r)return 0===t.avail_out&&(i.last_flush=-1),sn;if(2===r&&(e===tn?Jr(i):e!==nn&&(jr(i,0,0,!1),e===en&&(On(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),Mn(t),0===t.avail_out))return i.last_flush=-1,sn}return e!==rn?sn:i.wrap<=0?on:(2===i.wrap?(bn(i,255&t.adler),bn(i,t.adler>>8&255),bn(i,t.adler>>16&255),bn(i,t.adler>>24&255),bn(i,255&t.total_in),bn(i,t.total_in>>8&255),bn(i,t.total_in>>16&255),bn(i,t.total_in>>24&255)):(pn(i,t.adler>>>16),pn(i,65535&t.adler)),Mn(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?sn:on)},deflateEnd:t=>{if(!t||!t.state)return an;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==Nn&&e!==Un&&e!==dn?Sn(t,an):(t.state=null,e===Un?Sn(t,cn):sn)},deflateSetDictionary:Vn,deflateInfo:"pako deflate (from Nodeca project)"};const Zn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Yn=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)Zn(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 zn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){zn=!1}const Wn=new Uint8Array(256);for(let t=0;t<256;t++)Wn[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Wn[254]=Wn[254]=1;var jn=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},qn=(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=Wn[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&&zn)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)},$n=(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+Wn[t[r]]>e?r:e};var Jn=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 Qn=Object.prototype.toString,{Z_NO_FLUSH:ti,Z_SYNC_FLUSH:ei,Z_FULL_FLUSH:ri,Z_FINISH:ni,Z_OK:ii,Z_STREAM_END:si,Z_DEFAULT_COMPRESSION:oi,Z_DEFAULT_STRATEGY:ai,Z_DEFLATED:ci}=zr;function fi(t){this.options=Yn({level:oi,method:ci,chunkSize:16384,windowBits:15,memLevel:8,strategy:ai},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 Jn,this.strm.avail_out=0;let r=kn.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==ii)throw new Error(Kr[r]);if(e.header&&kn.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?jn(e.dictionary):"[object ArrayBuffer]"===Qn.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,r=kn.deflateSetDictionary(this.strm,t),r!==ii)throw new Error(Kr[r]);this.dt=!0}}function ui(t,e){const r=new fi(e);if(r.push(t,!0),r.err)throw r.msg||Kr[r.err];return r.result}fi.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?ni:ti,"string"==typeof t?r.input=jn(t):"[object ArrayBuffer]"===Qn.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===ei||s===ri)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(i=kn.deflate(r,s),i===si)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),i=kn.deflateEnd(this.strm),this.onEnd(i),this.ended=!0,i===ii;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},fi.prototype.onData=function(t){this.chunks.push(t)},fi.prototype.onEnd=function(t){t===ii&&(this.result=Kn(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var li={Deflate:fi,deflate:ui,deflateRaw:function(t,e){return(e=e||{}).raw=!0,ui(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,ui(t,e)},constants:zr};var Ei=function(t,e){let r,n,i,s,o,a,c,f,u,l,E,_,A,h,T,R,y,I,N,U,d,S,m,O;const F=t.state;r=t.next_in,m=t.input,n=r+(t.avail_in-5),i=t.next_out,O=t.output,s=i-(e-t.avail_out),o=i+(t.avail_out-257),a=F.dmax,c=F.wsize,f=F.whave,u=F.wnext,l=F.window,E=F.hold,_=F.bits,A=F.lencode,h=F.distcode,T=(1<<F.lenbits)-1,R=(1<<F.distbits)-1;t:do{_<15&&(E+=m[r++]<<_,_+=8,E+=m[r++]<<_,_+=8),y=A[E&T];e:for(;;){if(I=y>>>24,E>>>=I,_-=I,I=y>>>16&255,0===I)O[i++]=65535&y;else{if(!(16&I)){if(0==(64&I)){y=A[(65535&y)+(E&(1<<I)-1)];continue e}if(32&I){F.mode=12;break t}t.msg="invalid literal/length code",F.mode=30;break t}N=65535&y,I&=15,I&&(_<I&&(E+=m[r++]<<_,_+=8),N+=E&(1<<I)-1,E>>>=I,_-=I),_<15&&(E+=m[r++]<<_,_+=8,E+=m[r++]<<_,_+=8),y=h[E&R];r:for(;;){if(I=y>>>24,E>>>=I,_-=I,I=y>>>16&255,!(16&I)){if(0==(64&I)){y=h[(65535&y)+(E&(1<<I)-1)];continue r}t.msg="invalid distance code",F.mode=30;break t}if(U=65535&y,I&=15,_<I&&(E+=m[r++]<<_,_+=8,_<I&&(E+=m[r++]<<_,_+=8)),U+=E&(1<<I)-1,U>a){t.msg="invalid distance too far back",F.mode=30;break t}if(E>>>=I,_-=I,I=i-s,U>I){if(I=U-I,I>f&&F.sane){t.msg="invalid distance too far back",F.mode=30;break t}if(d=0,S=l,0===u){if(d+=c-I,I<N){N-=I;do{O[i++]=l[d++]}while(--I);d=i-U,S=O}}else if(u<I){if(d+=c+u-I,I-=u,I<N){N-=I;do{O[i++]=l[d++]}while(--I);if(d=0,u<N){I=u,N-=I;do{O[i++]=l[d++]}while(--I);d=i-U,S=O}}}else if(d+=u-I,I<N){N-=I;do{O[i++]=l[d++]}while(--I);d=i-U,S=O}for(;N>2;)O[i++]=S[d++],O[i++]=S[d++],O[i++]=S[d++],N-=3;N&&(O[i++]=S[d++],N>1&&(O[i++]=S[d++]))}else{d=i-U;do{O[i++]=O[d++],O[i++]=O[d++],O[i++]=O[d++],N-=3}while(N>2);N&&(O[i++]=O[d++],N>1&&(O[i++]=O[d++]))}break}}break}}while(r<n&&i<o);N=_>>3,r-=N,_-=N<<3,E&=(1<<_)-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),F.hold=E,F.bits=_};const _i=15,Ai=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]),hi=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]),Ti=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]),Ri=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 yi=(t,e,r,n,i,s,o,a)=>{const c=a.bits;let f,u,l,E,_,A,h=0,T=0,R=0,y=0,I=0,N=0,U=0,d=0,S=0,m=0,O=null,F=0;const M=new Uint16Array(16),C=new Uint16Array(16);let b,p,w,D=null,B=0;for(h=0;h<=_i;h++)M[h]=0;for(T=0;T<n;T++)M[e[r+T]]++;for(I=c,y=_i;y>=1&&0===M[y];y--);if(I>y&&(I=y),0===y)return i[s++]=20971520,i[s++]=20971520,a.bits=1,0;for(R=1;R<y&&0===M[R];R++);for(I<R&&(I=R),d=1,h=1;h<=_i;h++)if(d<<=1,d-=M[h],d<0)return-1;if(d>0&&(0===t||1!==y))return-1;for(C[1]=0,h=1;h<_i;h++)C[h+1]=C[h]+M[h];for(T=0;T<n;T++)0!==e[r+T]&&(o[C[e[r+T]]++]=T);if(0===t?(O=D=o,A=19):1===t?(O=Ai,F-=257,D=hi,B-=257,A=256):(O=Ti,D=Ri,A=-1),m=0,T=0,h=R,_=s,N=I,U=0,l=-1,S=1<<I,E=S-1,1===t&&S>852||2===t&&S>592)return 1;for(;;){b=h-U,o[T]<A?(p=0,w=o[T]):o[T]>A?(p=D[B+o[T]],w=O[F+o[T]]):(p=96,w=0),f=1<<h-U,u=1<<N,R=u;do{u-=f,i[_+(m>>U)+u]=b<<24|p<<16|w|0}while(0!==u);for(f=1<<h-1;m&f;)f>>=1;if(0!==f?(m&=f-1,m+=f):m=0,T++,0==--M[h]){if(h===y)break;h=e[r+o[T]]}if(h>I&&(m&E)!==l){for(0===U&&(U=I),_+=R,N=h-U,d=1<<N;N+U<y&&(d-=M[N+U],!(d<=0));)N++,d<<=1;if(S+=1<<N,1===t&&S>852||2===t&&S>592)return 1;l=m&E,i[l]=I<<24|N<<16|_-s|0}}return 0!==m&&(i[_+m]=h-U<<24|64<<16|0),a.bits=I,0};const{Z_FINISH:Ii,Z_BLOCK:Ni,Z_TREES:Ui,Z_OK:di,Z_STREAM_END:Si,Z_NEED_DICT:mi,Z_STREAM_ERROR:Oi,Z_DATA_ERROR:Fi,Z_MEM_ERROR:Mi,Z_BUF_ERROR:Ci,Z_DEFLATED:bi}=zr,pi=12,wi=30,Di=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Bi(){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 Li=t=>{if(!t||!t.state)return Oi;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,di},Pi=t=>{if(!t||!t.state)return Oi;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Li(t)},gi=(t,e)=>{let r;if(!t||!t.state)return Oi;const n=t.state;return e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?Oi:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,Pi(t))},Gi=(t,e)=>{if(!t)return Oi;const r=new Bi;t.state=r,r.window=null;const n=gi(t,e);return n!==di&&(t.state=null),n};let vi,Xi,Hi=!0;const xi=t=>{if(Hi){vi=new Int32Array(512),Xi=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(yi(1,t.lens,0,288,vi,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;yi(2,t.lens,0,32,Xi,0,t.work,{bits:5}),Hi=!1}t.lencode=vi,t.lenbits=9,t.distcode=Xi,t.distbits=5},Vi=(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 ki=(t,e)=>{let r,n,i,s,o,a,c,f,u,l,E,_,A,h,T,R,y,I,N,U,d,S,m=0;const O=new Uint8Array(4);let F,M;const C=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 Oi;r=t.state,r.mode===pi&&(r.mode=13),o=t.next_out,i=t.output,c=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,f=r.hold,u=r.bits,l=a,E=c,S=di;t:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(2&r.wrap&&35615===f){r.check=0,O[0]=255&f,O[1]=f>>>8&255,r.check=Yr(r.check,O,2,0),f=0,u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&f)<<8)+(f>>8))%31){t.msg="incorrect header check",r.mode=wi;break}if((15&f)!==bi){t.msg="unknown compression method",r.mode=wi;break}if(f>>>=4,u-=4,d=8+(15&f),0===r.wbits)r.wbits=d;else if(d>r.wbits){t.msg="invalid window size",r.mode=wi;break}r.dmax=1<<r.wbits,t.adler=r.check=1,r.mode=512&f?10:pi,f=0,u=0;break;case 2:for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(r.flags=f,(255&r.flags)!==bi){t.msg="unknown compression method",r.mode=wi;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=wi;break}r.head&&(r.head.text=f>>8&1),512&r.flags&&(O[0]=255&f,O[1]=f>>>8&255,r.check=Yr(r.check,O,2,0)),f=0,u=0,r.mode=3;case 3:for(;u<32;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.head&&(r.head.time=f),512&r.flags&&(O[0]=255&f,O[1]=f>>>8&255,O[2]=f>>>16&255,O[3]=f>>>24&255,r.check=Yr(r.check,O,4,0)),f=0,u=0,r.mode=4;case 4:for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.head&&(r.head.xflags=255&f,r.head.os=f>>8),512&r.flags&&(O[0]=255&f,O[1]=f>>>8&255,r.check=Yr(r.check,O,2,0)),f=0,u=0,r.mode=5;case 5:if(1024&r.flags){for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.length=f,r.head&&(r.head.extra_len=f),512&r.flags&&(O[0]=255&f,O[1]=f>>>8&255,r.check=Yr(r.check,O,2,0)),f=0,u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(_=r.length,_>a&&(_=a),_&&(r.head&&(d=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+_),d)),512&r.flags&&(r.check=Yr(r.check,n,_,s)),a-=_,s+=_,r.length-=_),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===a)break t;_=0;do{d=n[s+_++],r.head&&d&&r.length<65536&&(r.head.name+=String.fromCharCode(d))}while(d&&_<a);if(512&r.flags&&(r.check=Yr(r.check,n,_,s)),a-=_,s+=_,d)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;_=0;do{d=n[s+_++],r.head&&d&&r.length<65536&&(r.head.comment+=String.fromCharCode(d))}while(d&&_<a);if(512&r.flags&&(r.check=Yr(r.check,n,_,s)),a-=_,s+=_,d)break t}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;u<16;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(f!==(65535&r.check)){t.msg="header crc mismatch",r.mode=wi;break}f=0,u=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=pi;break;case 10:for(;u<32;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}t.adler=r.check=Di(f),f=0,u=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=o,t.avail_out=c,t.next_in=s,t.avail_in=a,r.hold=f,r.bits=u,mi;t.adler=r.check=1,r.mode=pi;case pi:if(e===Ni||e===Ui)break t;case 13:if(r.last){f>>>=7&u,u-=7&u,r.mode=27;break}for(;u<3;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}switch(r.last=1&f,f>>>=1,u-=1,3&f){case 0:r.mode=14;break;case 1:if(xi(r),r.mode=20,e===Ui){f>>>=2,u-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=wi}f>>>=2,u-=2;break;case 14:for(f>>>=7&u,u-=7&u;u<32;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if((65535&f)!=(f>>>16^65535)){t.msg="invalid stored block lengths",r.mode=wi;break}if(r.length=65535&f,f=0,u=0,r.mode=15,e===Ui)break t;case 15:r.mode=16;case 16:if(_=r.length,_){if(_>a&&(_=a),_>c&&(_=c),0===_)break t;i.set(n.subarray(s,s+_),o),a-=_,s+=_,c-=_,o+=_,r.length-=_;break}r.mode=pi;break;case 17:for(;u<14;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(r.nlen=257+(31&f),f>>>=5,u-=5,r.ndist=1+(31&f),f>>>=5,u-=5,r.ncode=4+(15&f),f>>>=4,u-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=wi;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;u<3;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.lens[C[r.have++]]=7&f,f>>>=3,u-=3}for(;r.have<19;)r.lens[C[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,F={bits:r.lenbits},S=yi(0,r.lens,0,19,r.lencode,0,r.work,F),r.lenbits=F.bits,S){t.msg="invalid code lengths set",r.mode=wi;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;m=r.lencode[f&(1<<r.lenbits)-1],T=m>>>24,R=m>>>16&255,y=65535&m,!(T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(y<16)f>>>=T,u-=T,r.lens[r.have++]=y;else{if(16===y){for(M=T+2;u<M;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(f>>>=T,u-=T,0===r.have){t.msg="invalid bit length repeat",r.mode=wi;break}d=r.lens[r.have-1],_=3+(3&f),f>>>=2,u-=2}else if(17===y){for(M=T+3;u<M;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}f>>>=T,u-=T,d=0,_=3+(7&f),f>>>=3,u-=3}else{for(M=T+7;u<M;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}f>>>=T,u-=T,d=0,_=11+(127&f),f>>>=7,u-=7}if(r.have+_>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=wi;break}for(;_--;)r.lens[r.have++]=d}}if(r.mode===wi)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=wi;break}if(r.lenbits=9,F={bits:r.lenbits},S=yi(1,r.lens,0,r.nlen,r.lencode,0,r.work,F),r.lenbits=F.bits,S){t.msg="invalid literal/lengths set",r.mode=wi;break}if(r.distbits=6,r.distcode=r.distdyn,F={bits:r.distbits},S=yi(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,F),r.distbits=F.bits,S){t.msg="invalid distances set",r.mode=wi;break}if(r.mode=20,e===Ui)break t;case 20:r.mode=21;case 21:if(a>=6&&c>=258){t.next_out=o,t.avail_out=c,t.next_in=s,t.avail_in=a,r.hold=f,r.bits=u,Ei(t,E),o=t.next_out,i=t.output,c=t.avail_out,s=t.next_in,n=t.input,a=t.avail_in,f=r.hold,u=r.bits,r.mode===pi&&(r.back=-1);break}for(r.back=0;m=r.lencode[f&(1<<r.lenbits)-1],T=m>>>24,R=m>>>16&255,y=65535&m,!(T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(R&&0==(240&R)){for(I=T,N=R,U=y;m=r.lencode[U+((f&(1<<I+N)-1)>>I)],T=m>>>24,R=m>>>16&255,y=65535&m,!(I+T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}f>>>=I,u-=I,r.back+=I}if(f>>>=T,u-=T,r.back+=T,r.length=y,0===R){r.mode=26;break}if(32&R){r.back=-1,r.mode=pi;break}if(64&R){t.msg="invalid literal/length code",r.mode=wi;break}r.extra=15&R,r.mode=22;case 22:if(r.extra){for(M=r.extra;u<M;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.length+=f&(1<<r.extra)-1,f>>>=r.extra,u-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;m=r.distcode[f&(1<<r.distbits)-1],T=m>>>24,R=m>>>16&255,y=65535&m,!(T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(0==(240&R)){for(I=T,N=R,U=y;m=r.distcode[U+((f&(1<<I+N)-1)>>I)],T=m>>>24,R=m>>>16&255,y=65535&m,!(I+T<=u);){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}f>>>=I,u-=I,r.back+=I}if(f>>>=T,u-=T,r.back+=T,64&R){t.msg="invalid distance code",r.mode=wi;break}r.offset=y,r.extra=15&R,r.mode=24;case 24:if(r.extra){for(M=r.extra;u<M;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}r.offset+=f&(1<<r.extra)-1,f>>>=r.extra,u-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=wi;break}r.mode=25;case 25:if(0===c)break t;if(_=E-c,r.offset>_){if(_=r.offset-_,_>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=wi;break}_>r.wnext?(_-=r.wnext,A=r.wsize-_):A=r.wnext-_,_>r.length&&(_=r.length),h=r.window}else h=i,A=o-r.offset,_=r.length;_>c&&(_=c),c-=_,r.length-=_;do{i[o++]=h[A++]}while(--_);0===r.length&&(r.mode=21);break;case 26:if(0===c)break t;i[o++]=r.length,c--,r.mode=21;break;case 27:if(r.wrap){for(;u<32;){if(0===a)break t;a--,f|=n[s++]<<u,u+=8}if(E-=c,t.total_out+=E,r.total+=E,E&&(t.adler=r.check=r.flags?Yr(r.check,i,E,o-E):kr(r.check,i,E,o-E)),E=c,(r.flags?f:Di(f))!==r.check){t.msg="incorrect data check",r.mode=wi;break}f=0,u=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;u<32;){if(0===a)break t;a--,f+=n[s++]<<u,u+=8}if(f!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=wi;break}f=0,u=0}r.mode=29;case 29:S=Si;break t;case wi:S=Fi;break t;case 31:return Mi;default:return Oi}return t.next_out=o,t.avail_out=c,t.next_in=s,t.avail_in=a,r.hold=f,r.bits=u,(r.wsize||E!==t.avail_out&&r.mode<wi&&(r.mode<27||e!==Ii))&&Vi(t,t.output,t.next_out,E-t.avail_out),l-=t.avail_in,E-=t.avail_out,t.total_in+=l,t.total_out+=E,r.total+=E,r.wrap&&E&&(t.adler=r.check=r.flags?Yr(r.check,i,E,t.next_out-E):kr(r.check,i,E,t.next_out-E)),t.data_type=r.bits+(r.last?64:0)+(r.mode===pi?128:0)+(20===r.mode||15===r.mode?256:0),(0===l&&0===E||e===Ii)&&S===di&&(S=Ci),S},Zi={inflateReset:Pi,inflateReset2:gi,inflateResetKeep:Li,inflateInit:t=>Gi(t,15),inflateInit2:Gi,inflate:ki,inflateEnd:t=>{if(!t||!t.state)return Oi;let e=t.state;return e.window&&(e.window=null),t.state=null,di},inflateGetHeader:(t,e)=>{if(!t||!t.state)return Oi;const r=t.state;return 0==(2&r.wrap)?Oi:(r.head=e,e.done=!1,di)},inflateSetDictionary:(t,e)=>{const r=e.length;let n,i,s;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?Oi:11===n.mode&&(i=1,i=kr(i,e,r,0),i!==n.check)?Fi:(s=Vi(t,e,r,r),s?(n.mode=31,Mi):(n.havedict=1,di))):Oi},inflateInfo:"pako inflate (from Nodeca project)"};var Yi=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:zi,Z_FINISH:Wi,Z_OK:ji,Z_STREAM_END:qi,Z_NEED_DICT:$i,Z_STREAM_ERROR:Ji,Z_DATA_ERROR:Qi,Z_MEM_ERROR:ts}=zr;function es(t){this.options=Yn({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 Jn,this.strm.avail_out=0;let r=Zi.inflateInit2(this.strm,e.windowBits);if(r!==ji)throw new Error(Kr[r]);if(this.header=new Yi,Zi.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=jn(e.dictionary):"[object ArrayBuffer]"===Ki.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=Zi.inflateSetDictionary(this.strm,e.dictionary),r!==ji)))throw new Error(Kr[r])}function rs(t,e){const r=new es(e);if(r.push(t),r.err)throw r.msg||Kr[r.err];return r.result}es.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?Wi:zi,"[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=Zi.inflate(r,o),s===$i&&i&&(s=Zi.inflateSetDictionary(r,i),s===ji?s=Zi.inflate(r,o):s===Qi&&(s=$i));r.avail_in>0&&s===qi&&r.state.wrap>0&&0!==t[r.next_in];)Zi.inflateReset(r),s=Zi.inflate(r,o);switch(s){case Ji:case Qi:case $i:case ts:return this.onEnd(s),this.ended=!0,!1}if(a=r.avail_out,r.next_out&&(0===r.avail_out||s===qi))if("string"===this.options.to){let t=$n(r.output,r.next_out),e=r.next_out-t,i=qn(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!==ji||0!==a){if(s===qi)return s=Zi.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},es.prototype.onData=function(t){this.chunks.push(t)},es.prototype.onEnd=function(t){t===ji&&("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 ns={Inflate:es,inflate:rs,inflateRaw:function(t,e){return(e=e||{}).raw=!0,rs(t,e)},ungzip:rs,constants:zr};const{Deflate:is,deflate:ss,deflateRaw:os,gzip:as}=li,{Inflate:cs,inflate:fs,inflateRaw:us,ungzip:ls}=ns;var Es={Deflate:is,deflate:ss,deflateRaw:os,gzip:as,Inflate:cs,inflate:fs,inflateRaw:us,ungzip:ls,constants:zr},_s=5,As=11,hs=13,Ts=14;function Rs(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}var ys=new Uint8Array(16),Is=new Uint8Array(16);function Ns(t,e,r,n){var i=0;0!=(6&n)&&(i=8),function(t,e,r,n){for(var i=Rs(e[r+0],e[r+1],ys,0),s=Rs(e[r+2],e[r+3],ys,4),o=0;o<3;o++){var a=ys[o],c=ys[4+o];n&&i<=s?(ys[8+o]=(a+c)/2,ys[12+o]=0):(ys[8+o]=(2*a+c)/3,ys[12+o]=(a+2*c)/3)}for(ys[11]=255,ys[15]=n&&i<=s?0:255,o=0;o<4;++o){var f=e[r+4+o];Is[4*o+0]=3&f,Is[4*o+1]=f>>2&3,Is[4*o+2]=f>>4&3,Is[4*o+3]=f>>6&3}for(o=0;o<16;++o)for(var u=4*Is[o],l=0;l<4;++l)t[4*o+l]=ys[u+l]}(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];if(ys[0]=n,ys[1]=i,n<=i){for(var s=1;s<5;++s)ys[1+s]=((5-s)*n+s*i)/5;ys[6]=0,ys[7]=255}else for(s=1;s<7;++s)ys[1+s]=((7-s)*n+s*i)/7;r+=2;var o=0;for(s=0;s<2;++s){for(var a=0,c=0;c<3;++c)a|=e[r++]<<8*c;for(c=0;c<8;++c){var f=a>>3*c&7;Is[o++]=f}}for(s=0;s<16;++s)t[4*s+3]=ys[Is[s]]}(t,e,r)}var Us=new Uint16Array(4);\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 */\nvar ds=new Uint8Array(64);function Ss(t){}function ms(){}Ss.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=t,s=0,o=0,a=0,c=0,f=0,u=0,l=0,E=0,_=0,A=e/4,h=r/4,T=0;T<h;T++)for(var R=0;R<A;R++)a=4*((h-T)*A+R),Us[0]=n[a],Us[1]=n[a+1],c=31&Us[0],f=2016&Us[0],u=63488&Us[0],l=31&Us[1],E=2016&Us[1],_=63488&Us[1],Us[2]=5*c+3*l>>3|5*f+3*E>>3&2016|5*u+3*_>>3&63488,Us[3]=5*l+3*c>>3|5*E+3*f>>3&2016|5*_+3*u>>3&63488,s=n[a+2],i[o=4*T*e+4*R]=Us[3&s],i[o+1]=Us[s>>2&3],i[o+2]=Us[s>>4&3],i[o+3]=Us[s>>6&3],i[o+=e]=Us[s>>8&3],i[o+1]=Us[s>>10&3],i[o+2]=Us[s>>12&3],i[o+3]=Us[s>>14],s=n[a+3],i[o+=e]=Us[3&s],i[o+1]=Us[s>>2&3],i[o+2]=Us[s>>4&3],i[o+3]=Us[s>>6&3],i[o+=e]=Us[s>>8&3],i[o+1]=Us[s>>10&3],i[o+2]=Us[s>>12&3],i[o+3]=Us[s>>14]}(t,e,r,n):function(t,e,r,n,i,s){for(var o=0!=(1&i)?8:16,a=0,c=0;c<r;c+=4)for(var f=0;f<e;f+=4){Ns(ds,n,a,i);for(var u=0,l=0;l<4;++l)for(var E=0;E<4;++E){var _=f+E,A=c+l;if(_<e&&A<r){var h=4*(e*(r-A)+_);if(s===hs||s===Ts)t[h+2]=ds[u++],t[h+1]=ds[u++],t[h+0]=ds[u++],t[h+3]=ds[u++];else for(var T=0;T<4;++T)t[h++]=ds[u++]}else u+=4}a+=o}}(t,e,r,n,s,i)}},ms.s3tc=!0,ms.pvrtc=!1,ms.etc1=!1;let Os=1,Fs=2;const Ms=10,Cs=11,bs=1,ps=2,ws=16,Ds=32;function Bs(t,e,r){r=t.byteLength;return t=t.subarray(0,0+r),new TextDecoder("utf-8").decode(t)}function Ls(t,e,r){let n=e.getUint32(r,!0);return r+=Uint32Array.BYTES_PER_ELEMENT,{string:Bs(new Uint8Array(t,r,n)),bytesOffset:r+=n}}function Ps(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=Ls(t,e,r);s.push(n.string),r=n.bytesOffset}return n.push(i),r}function gs(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=Ls(t,e,r),c=a.string;r=a.bytesOffset;let f=c.indexOf("Geometry");if(-1!==f){let t=c.substring(f);c=c.replace(t,"")}i.childTile=c,i.geodes=[];let u=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<u;n++)r=Ps(t,e,r,i.geodes);return n.push(i),r}function Gs(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,c=new Uint8Array(t,r,a);r+=a;let f=n.vertexAttributes,u=n.attrLocation;return u.aPosition=f.length,f.push({index:u.aPosition,typedArray:c,componentsPerAttribute:s,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function vs(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,c=new Uint8Array(t,r,a);r+=a;let f=n.vertexAttributes,u=n.attrLocation;return u.aNormal=f.length,f.push({index:u.aNormal,typedArray:c,componentsPerAttribute:s,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function Xs(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,c=n.attrLocation;return c.aColor=a.length,a.push({index:c.aColor,typedArray:s,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),n.vertexColor=s,r}function Hs(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,c=n.attrLocation;return c.aSecondColor=a.length,a.push({index:c.aSecondColor,typedArray:o,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),r}function xs(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,c=new Uint8Array(t,r,a);r+=a;let f="aTexCoord"+s,u=n.vertexAttributes,l=n.attrLocation;l[f]=u.length,u.push({index:l[f],typedArray:c,componentsPerAttribute:o,componentDatatype:5126,offsetInBytes:0,strideInBytes:o*Float32Array.BYTES_PER_ELEMENT,normalize:!1})}return r}function Vs(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 c=i*a*Float32Array.BYTES_PER_ELEMENT;if(17===a){let e=new Uint8Array(t,r,c);n.instanceCount=i,n.instanceMode=a,n.instanceBuffer=e,n.instanceIndex=1;let f,u=a*i*4,l=e.slice(0,u);n.vertexColorInstance=l,17===a?(f=17*Float32Array.BYTES_PER_ELEMENT,o.uv2=s.length,s.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:f,instanceDivisor:1}),o.uv3=s.length,s.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv4=s.length,s.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,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:f,instanceDivisor:1}),o.uv6=s.length,s.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1})):29===a&&(f=29*Float32Array.BYTES_PER_ELEMENT,o.uv1=s.length,s.push({index:o.uv1,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:f,instanceDivisor:1,byteLength:c}),o.uv2=s.length,s.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv3=s.length,s.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv4=s.length,s.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv5=s.length,s.push({index:o.uv5,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv6=s.length,s.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:20*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,instanceDivisor:1}),o.uv7=s.length,s.push({index:o.uv7,componentsPerAttribute:3,componentDatatype:5126,normalize:!1,offsetInBytes:24*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,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:f,instanceDivisor:1}),o.uv9=s.length,s.push({index:o.uv9,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:28*Float32Array.BYTES_PER_ELEMENT,strideInBytes:f,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+=c}return r}function ks(t,e,r,n){return r=Vs(t,e,r=xs(t,e,r=Hs(t,e,r=Xs(t,e,r=vs(t,e,r=Gs(t,e,r,n),n),n),n),n),n)}function Zs(t,e,r,n){let i=e.getUint32(r,!0);return n.compressOptions=i,r+=Uint32Array.BYTES_PER_ELEMENT,r=(i&bs)===bs?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 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.vertCompressConstant=a,n.minVerticesValue=c;let f=i*s*Int16Array.BYTES_PER_ELEMENT,u=new Uint8Array(t,r,f);r+=f;let l=n.vertexAttributes,E=n.attrLocation;return E.aPosition=l.length,l.push({index:E.aPosition,typedArray:u,componentsPerAttribute:s,componentDatatype:5122,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}(t,e,r,n):Gs(t,e,r,n),r=(i&ps)===ps?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 c=n.vertexAttributes,f=n.attrLocation;return f.aNormal=c.length,c.push({index:f.aNormal,typedArray:a,componentsPerAttribute:2,componentDatatype:5122,offsetInBytes:0,strideInBytes:s,normalize:!1}),r}(t,e,r,n):vs(t,e,r,n),r=Hs(t,e,r=Xs(t,e,r,n),n),r=(i&ws)===ws?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 c=e.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT,n.texCoordCompressConstant.push(c);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.minTexCoordValue.push(f);let u=o*a*Int16Array.BYTES_PER_ELEMENT,l=new Uint8Array(t,r,u),E=(r+=u)%4;0!==E&&(r+=4-E);let _="aTexCoord"+s,A=n.vertexAttributes,h=n.attrLocation;if(h[_]=A.length,A.push({index:h[_],typedArray:l,componentsPerAttribute:a,componentDatatype:5122,offsetInBytes:0,strideInBytes:a*Int16Array.BYTES_PER_ELEMENT,normalize:!1}),i){u=o*Float32Array.BYTES_PER_ELEMENT;let e=new Uint8Array(t,r,u);r+=u,n.texCoordZMatrix=!0,_="aTexCoordZ"+s,h[_]=A.length,A.push({index:h[_],typedArray:e,componentsPerAttribute:1,componentDatatype:5126,offsetInBytes:0,strideInBytes:Float32Array.BYTES_PER_ELEMENT,normalize:!1})}}return r}(t,e,r,n):xs(t,e,r,n),(i&Ds)===Ds&&(n.textureCoordIsW=!0),r=Vs(t,e,r,n)}function Ys(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 c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<c;n++){let n=Ls(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 Ks={red:0,green:0,blue:0,alpha:0};function zs(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})}ms.parseBuffer=function(t){let e=0,r={version:void 0,groupNode:void 0,geoPackage:{},matrials:void 0,texturePackage:{}},n=new DataView(t);r.version=n.getFloat32(e,!0),e+=Float32Array.BYTES_PER_ELEMENT,r.version>=2&&(n.getUint32(e,!0),e+=Uint32Array.BYTES_PER_ELEMENT),n.getUint32(e,!0),e+=Uint32Array.BYTES_PER_ELEMENT;let i=function(t,e){let r=new Uint8Array(t,e);return Es.inflate(r).buffer}(t,e);n=new DataView(i),e=0;let s=n.getUint32(e,!0);return e+=Uint32Array.BYTES_PER_ELEMENT,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=gs(t,e,r,s);i.pageLods=s;let a=r%4;return 0!==a&&(r+=4-a),n.groupNode=i,r}(i,n,e,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=Ls(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 c={vertexAttributes:[],attrLocation:{},instanceCount:0,instanceMode:0,instanceIndex:-1};a===Os?r=ks(t,e,r,c):a===Fs&&(r=Zs(t,e,r,c));let f,u=[];r=Ys(t,e,r,u),2===u.length&&13===u[1].primitiveType&&u[1].indicesCount>=3&&(f=S3MEdgeProcessor.createEdgeDataByIndices(c,u[1])),n[s]={vertexPackage:c,arrIndexPackage:u,edgeGeometry:f}}return r+=e.getUint32(r,!0),r+Uint32Array.BYTES_PER_ELEMENT}(i,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=Ls(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 c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let f=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let u=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let l=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let E=new Uint8Array(t,r,u);r+=u;let _=l===Ms||l===Cs?33776:33779;if(22===f&&(_=36196),!ms.s3tc&&(33776===_||33779===_)){let t=new Uint8Array(a*c*4);Ss.decode(t,a,c,E,l),E=t,f=0,_=l===Ms||l===Ms?273:4369}n[s]={id:s,width:a,height:c,compressType:f,nFormat:l,internalFormat:_,arrayBufferView:E}}return r}(i,n,e,r.texturePackage),e=function(t,e,r,n){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=Bs(new Uint8Array(t,r,i));return r+=i,n.materials=JSON.parse(s),r}(i,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=Ls(t,e,r),o=n.string;r=n.bytesOffset;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let c={};if(i[o].pickInfo=c,-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})}c[i]=o}zs(i[o].vertexPackage,t,void 0)}else{let t=i[o].vertexPackage.instanceCount,n=i[o].vertexPackage.instanceBuffer,f=i[o].vertexPackage.instanceMode,u=new Float32Array(t),l=[];for(let t=0;t<a;t++){let t=e.getUint32(r,!0);l.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 E=17===f?16:28;E*=Float32Array.BYTES_PER_ELEMENT;for(let e=0;e<t;e++){u[e]=e;let t=e*f*Float32Array.BYTES_PER_ELEMENT+E;Cesium.Color.unpack(n,t,Ks);let r=2===s?l[e]:Ks.red+256*Ks.green+65536*Ks.blue;void 0===c[r]&&(c[r]={vertexColorCount:1,instanceIds:[],vertexColorOffset:e}),c[r].instanceIds.push(e)}zs(i[o].vertexPackage,u,1)}}}}(i,n,e,s,r.geoPackage,r.version),r};class Ws{constructor(t,e,{width:r,height:n,colorDepth:i,format:s}){if(this.format=s,this.offset=e,this.depth=i,this.stride=\n/*!\n * decode-bmp\n * https://github.com/LinusU/decode-bmp\n * MIT License\n */\nfunction(t){const e=t%4;return e?t+4-e:t}(r*this.depth/8),this.size=this.stride*n,this.data=t.subarray(this.offset,this.offset+this.size),this.size!==this.data.byteLength)throw new Error("Truncated bitmap data")}get(t,e,r){const n=this.format.indexOf(r);if(1===this.depth){return(this.data[e*this.stride+(t/8|0)]&1<<7-t%8*1)>>7-t%8*1}if(2===this.depth){return(this.data[e*this.stride+(t/4|0)]&3<<6-t%4*2)>>>6-t%4*2}if(4===this.depth){return(this.data[e*this.stride+(t/2|0)]&15<<4-t%2*4)>>>4-t%2*4}return this.data[e*this.stride+t*(this.depth/8)+n]}}function js(t,e,r,n,{width:i=0,height:s=0,icon:o=!1}={}){const a=new DataView(e,r,n);let c,f,u,l,E;o?(c=a.getUint32(0,!0),f=a.getUint32(4,!0)/1|0,u=a.getUint32(8,!0)/2|0,l=a.getUint16(14,!0),E=a.getUint32(32,!0)):(!function(t){if(19778!==t)throw new Error(`Invalid magic byte 0x${t.toString(16)}`)}(a.getUint16(0,!0)),c=14+a.getUint32(14,!0),f=a.getUint32(18,!0),u=a.getUint32(22,!0),l=a.getUint16(28,!0),E=a.getUint32(46,!0)),0===E&&l<=8&&(E=1<<l);const _=0===f?i:f,A=0===u?s:u,h=new Uint8Array(a.buffer,a.byteOffset+c,a.byteLength-c),T=t.byteLength===_*A*4,R=E?function(t,e,r,{width:n,height:i,colorDepth:s,colorCount:o,icon:a}){if(8!==s&&4!==s&&2!==s&&1!==s)throw new Error(`A color depth of ${s} is not supported`);const c=new Ws(r,0,{width:o,height:1,colorDepth:32,format:"BGRA"}),f=new Ws(r,c.offset+c.size,{width:n,height:i,colorDepth:s,format:"C"}),u=a?new Ws(r,f.offset+f.size,{width:n,height:i,colorDepth:1,format:"A"}):null,l=t;let E=0;for(let t=0;t<i;t++)for(let r=0;r<n;r++){const n=f.get(r,i-t-1,"C");l[E++]=c.get(n,0,"R"),l[E++]=c.get(n,0,"G"),l[E++]=c.get(n,0,"B"),e&&(l[E++]=u&&u.get(r,i-t-1,"A")?0:255)}return l}(t,T,h,{width:_,height:A,colorDepth:l,colorCount:E,icon:o}):function(t,e,r,{width:n,height:i,colorDepth:s,icon:o}){if(32!==s&&24!==s)throw new Error(`A color depth of ${s} is not supported`);const a=new Ws(r,0,{width:n,height:i,colorDepth:s,format:"BGRA"}),c=24===s&&o?new Ws(r,a.offset+a.size,{width:n,height:i,colorDepth:1,format:"A"}):null,f=t;let u=0;for(let t=0;t<i;t++)for(let r=0;r<n;r++)f[u++]=a.get(r,i-t-1,"R"),f[u++]=a.get(r,i-t-1,"G"),f[u++]=a.get(r,i-t-1,"B"),e&&(f[u++]=32===s?a.get(r,i-t-1,"A"):c&&c.get(r,i-t-1,"A")?0:255);return f}(t,T,h,{width:_,height:A,colorDepth:l,icon:o});return R}var qs=Object.freeze({DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:33995,TEXTURE12:33996,TEXTURE13:33997,TEXTURE14:33998,TEXTURE15:33999,TEXTURE16:34e3,TEXTURE17:34001,TEXTURE18:34002,TEXTURE19:34003,TEXTURE20:34004,TEXTURE21:34005,TEXTURE22:34006,TEXTURE23:34007,TEXTURE24:34008,TEXTURE25:34009,TEXTURE26:34010,TEXTURE27:34011,TEXTURE28:34012,TEXTURE29:34013,TEXTURE30:34014,TEXTURE31:34015,ACTIVE_TEXTURE:34016,REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,INT_VEC2:35667,INT_VEC3:35668,INT_VEC4:35669,BOOL:35670,BOOL_VEC2:35671,BOOL_VEC3:35672,BOOL_VEC4:35673,FLOAT_MAT2:35674,FLOAT_MAT3:35675,FLOAT_MAT4:35676,SAMPLER_2D:35678,SAMPLER_CUBE:35680,VERTEX_ATTRIB_ARRAY_ENABLED:34338,VERTEX_ATTRIB_ARRAY_SIZE:34339,VERTEX_ATTRIB_ARRAY_STRIDE:34340,VERTEX_ATTRIB_ARRAY_TYPE:34341,VERTEX_ATTRIB_ARRAY_NORMALIZED:34922,VERTEX_ATTRIB_ARRAY_POINTER:34373,VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:34975,IMPLEMENTATION_COLOR_READ_TYPE:35738,IMPLEMENTATION_COLOR_READ_FORMAT:35739,COMPILE_STATUS:35713,LOW_FLOAT:36336,MEDIUM_FLOAT:36337,HIGH_FLOAT:36338,LOW_INT:36339,MEDIUM_INT:36340,HIGH_INT:36341,FRAMEBUFFER:36160,RENDERBUFFER:36161,RGBA4:32854,RGB5_A1:32855,RGB565:36194,DEPTH_COMPONENT16:33189,STENCIL_INDEX:6401,STENCIL_INDEX8:36168,DEPTH_STENCIL:34041,RENDERBUFFER_WIDTH:36162,RENDERBUFFER_HEIGHT:36163,RENDERBUFFER_INTERNAL_FORMAT:36164,RENDERBUFFER_RED_SIZE:36176,RENDERBUFFER_GREEN_SIZE:36177,RENDERBUFFER_BLUE_SIZE:36178,RENDERBUFFER_ALPHA_SIZE:36179,RENDERBUFFER_DEPTH_SIZE:36180,RENDERBUFFER_STENCIL_SIZE:36181,FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:36048,FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:36049,FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:36050,FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:36051,COLOR_ATTACHMENT0:36064,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306,NONE:0,FRAMEBUFFER_COMPLETE:36053,FRAMEBUFFER_INCOMPLETE_ATTACHMENT:36054,FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:36055,FRAMEBUFFER_INCOMPLETE_DIMENSIONS:36057,FRAMEBUFFER_UNSUPPORTED:36061,FRAMEBUFFER_BINDING:36006,RENDERBUFFER_BINDING:36007,MAX_RENDERBUFFER_SIZE:34024,INVALID_FRAMEBUFFER_OPERATION:1286,UNPACK_FLIP_Y_WEBGL:37440,UNPACK_PREMULTIPLY_ALPHA_WEBGL:37441,CONTEXT_LOST_WEBGL:37442,UNPACK_COLORSPACE_CONVERSION_WEBGL:37443,BROWSER_DEFAULT_WEBGL:37444,COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:35840,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:35841,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:35842,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:35843,COMPRESSED_RGBA_ASTC_4x4_WEBGL:37808,COMPRESSED_RGB_ETC1_WEBGL:36196,COMPRESSED_RGBA_BPTC_UNORM:36492,HALF_FLOAT_OES:36193,DOUBLE:5130,READ_BUFFER:3074,UNPACK_ROW_LENGTH:3314,UNPACK_SKIP_ROWS:3315,UNPACK_SKIP_PIXELS:3316,PACK_ROW_LENGTH:3330,PACK_SKIP_ROWS:3331,PACK_SKIP_PIXELS:3332,COLOR:6144,DEPTH:6145,STENCIL:6146,RED:6403,RGB8:32849,RGBA8:32856,RGB10_A2:32857,TEXTURE_BINDING_3D:32874,UNPACK_SKIP_IMAGES:32877,UNPACK_IMAGE_HEIGHT:32878,TEXTURE_3D:32879,TEXTURE_WRAP_R:32882,MAX_3D_TEXTURE_SIZE:32883,UNSIGNED_INT_2_10_10_10_REV:33640,MAX_ELEMENTS_VERTICES:33e3,MAX_ELEMENTS_INDICES:33001,TEXTURE_MIN_LOD:33082,TEXTURE_MAX_LOD:33083,TEXTURE_BASE_LEVEL:33084,TEXTURE_MAX_LEVEL:33085,MIN:32775,MAX:32776,DEPTH_COMPONENT24:33190,MAX_TEXTURE_LOD_BIAS:34045,TEXTURE_COMPARE_MODE:34892,TEXTURE_COMPARE_FUNC:34893,CURRENT_QUERY:34917,QUERY_RESULT:34918,QUERY_RESULT_AVAILABLE:34919,STREAM_READ:35041,STREAM_COPY:35042,STATIC_READ:35045,STATIC_COPY:35046,DYNAMIC_READ:35049,DYNAMIC_COPY:35050,MAX_DRAW_BUFFERS:34852,DRAW_BUFFER0:34853,DRAW_BUFFER1:34854,DRAW_BUFFER2:34855,DRAW_BUFFER3:34856,DRAW_BUFFER4:34857,DRAW_BUFFER5:34858,DRAW_BUFFER6:34859,DRAW_BUFFER7:34860,DRAW_BUFFER8:34861,DRAW_BUFFER9:34862,DRAW_BUFFER10:34863,DRAW_BUFFER11:34864,DRAW_BUFFER12:34865,DRAW_BUFFER13:34866,DRAW_BUFFER14:34867,DRAW_BUFFER15:34868,MAX_FRAGMENT_UNIFORM_COMPONENTS:35657,MAX_VERTEX_UNIFORM_COMPONENTS:35658,SAMPLER_3D:35679,SAMPLER_2D_SHADOW:35682,FRAGMENT_SHADER_DERIVATIVE_HINT:35723,PIXEL_PACK_BUFFER:35051,PIXEL_UNPACK_BUFFER:35052,PIXEL_PACK_BUFFER_BINDING:35053,PIXEL_UNPACK_BUFFER_BINDING:35055,FLOAT_MAT2x3:35685,FLOAT_MAT2x4:35686,FLOAT_MAT3x2:35687,FLOAT_MAT3x4:35688,FLOAT_MAT4x2:35689,FLOAT_MAT4x3:35690,SRGB:35904,SRGB8:35905,SRGB8_ALPHA8:35907,COMPARE_REF_TO_TEXTURE:34894,RGBA32F:34836,RGB32F:34837,RGBA16F:34842,RGB16F:34843,VERTEX_ATTRIB_ARRAY_INTEGER:35069,MAX_ARRAY_TEXTURE_LAYERS:35071,MIN_PROGRAM_TEXEL_OFFSET:35076,MAX_PROGRAM_TEXEL_OFFSET:35077,MAX_VARYING_COMPONENTS:35659,TEXTURE_2D_ARRAY:35866,TEXTURE_BINDING_2D_ARRAY:35869,R11F_G11F_B10F:35898,UNSIGNED_INT_10F_11F_11F_REV:35899,RGB9_E5:35901,UNSIGNED_INT_5_9_9_9_REV:35902,TRANSFORM_FEEDBACK_BUFFER_MODE:35967,MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:35968,TRANSFORM_FEEDBACK_VARYINGS:35971,TRANSFORM_FEEDBACK_BUFFER_START:35972,TRANSFORM_FEEDBACK_BUFFER_SIZE:35973,TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:35976,RASTERIZER_DISCARD:35977,MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:35978,MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:35979,INTERLEAVED_ATTRIBS:35980,SEPARATE_ATTRIBS:35981,TRANSFORM_FEEDBACK_BUFFER:35982,TRANSFORM_FEEDBACK_BUFFER_BINDING:35983,RGBA32UI:36208,RGB32UI:36209,RGBA16UI:36214,RGB16UI:36215,RGBA8UI:36220,RGB8UI:36221,RGBA32I:36226,RGB32I:36227,RGBA16I:36232,RGB16I:36233,RGBA8I:36238,RGB8I:36239,RED_INTEGER:36244,RGB_INTEGER:36248,RGBA_INTEGER:36249,SAMPLER_2D_ARRAY:36289,SAMPLER_2D_ARRAY_SHADOW:36292,SAMPLER_CUBE_SHADOW:36293,UNSIGNED_INT_VEC2:36294,UNSIGNED_INT_VEC3:36295,UNSIGNED_INT_VEC4:36296,INT_SAMPLER_2D:36298,INT_SAMPLER_3D:36299,INT_SAMPLER_CUBE:36300,INT_SAMPLER_2D_ARRAY:36303,UNSIGNED_INT_SAMPLER_2D:36306,UNSIGNED_INT_SAMPLER_3D:36307,UNSIGNED_INT_SAMPLER_CUBE:36308,UNSIGNED_INT_SAMPLER_2D_ARRAY:36311,DEPTH_COMPONENT32F:36012,DEPTH32F_STENCIL8:36013,FLOAT_32_UNSIGNED_INT_24_8_REV:36269,FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:33296,FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:33297,FRAMEBUFFER_ATTACHMENT_RED_SIZE:33298,FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:33299,FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:33300,FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:33301,FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:33302,FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:33303,FRAMEBUFFER_DEFAULT:33304,UNSIGNED_INT_24_8:34042,DEPTH24_STENCIL8:35056,UNSIGNED_NORMALIZED:35863,DRAW_FRAMEBUFFER_BINDING:36006,READ_FRAMEBUFFER:36008,DRAW_FRAMEBUFFER:36009,READ_FRAMEBUFFER_BINDING:36010,RENDERBUFFER_SAMPLES:36011,FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:36052,MAX_COLOR_ATTACHMENTS:36063,COLOR_ATTACHMENT1:36065,COLOR_ATTACHMENT2:36066,COLOR_ATTACHMENT3:36067,COLOR_ATTACHMENT4:36068,COLOR_ATTACHMENT5:36069,COLOR_ATTACHMENT6:36070,COLOR_ATTACHMENT7:36071,COLOR_ATTACHMENT8:36072,COLOR_ATTACHMENT9:36073,COLOR_ATTACHMENT10:36074,COLOR_ATTACHMENT11:36075,COLOR_ATTACHMENT12:36076,COLOR_ATTACHMENT13:36077,COLOR_ATTACHMENT14:36078,COLOR_ATTACHMENT15:36079,FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:36182,MAX_SAMPLES:36183,HALF_FLOAT:5131,RG:33319,RG_INTEGER:33320,R8:33321,RG8:33323,R16F:33325,R32F:33326,RG16F:33327,RG32F:33328,R8I:33329,R8UI:33330,R16I:33331,R16UI:33332,R32I:33333,R32UI:33334,RG8I:33335,RG8UI:33336,RG16I:33337,RG16UI:33338,RG32I:33339,RG32UI:33340,VERTEX_ARRAY_BINDING:34229,R8_SNORM:36756,RG8_SNORM:36757,RGB8_SNORM:36758,RGBA8_SNORM:36759,SIGNED_NORMALIZED:36764,COPY_READ_BUFFER:36662,COPY_WRITE_BUFFER:36663,COPY_READ_BUFFER_BINDING:36662,COPY_WRITE_BUFFER_BINDING:36663,UNIFORM_BUFFER:35345,UNIFORM_BUFFER_BINDING:35368,UNIFORM_BUFFER_START:35369,UNIFORM_BUFFER_SIZE:35370,MAX_VERTEX_UNIFORM_BLOCKS:35371,MAX_FRAGMENT_UNIFORM_BLOCKS:35373,MAX_COMBINED_UNIFORM_BLOCKS:35374,MAX_UNIFORM_BUFFER_BINDINGS:35375,MAX_UNIFORM_BLOCK_SIZE:35376,MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS:35377,MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS:35379,UNIFORM_BUFFER_OFFSET_ALIGNMENT:35380,ACTIVE_UNIFORM_BLOCKS:35382,UNIFORM_TYPE:35383,UNIFORM_SIZE:35384,UNIFORM_BLOCK_INDEX:35386,UNIFORM_OFFSET:35387,UNIFORM_ARRAY_STRIDE:35388,UNIFORM_MATRIX_STRIDE:35389,UNIFORM_IS_ROW_MAJOR:35390,UNIFORM_BLOCK_BINDING:35391,UNIFORM_BLOCK_DATA_SIZE:35392,UNIFORM_BLOCK_ACTIVE_UNIFORMS:35394,UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:35395,UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:35396,UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:35398,INVALID_INDEX:4294967295,MAX_VERTEX_OUTPUT_COMPONENTS:37154,MAX_FRAGMENT_INPUT_COMPONENTS:37157,MAX_SERVER_WAIT_TIMEOUT:37137,OBJECT_TYPE:37138,SYNC_CONDITION:37139,SYNC_STATUS:37140,SYNC_FLAGS:37141,SYNC_FENCE:37142,SYNC_GPU_COMMANDS_COMPLETE:37143,UNSIGNALED:37144,SIGNALED:37145,ALREADY_SIGNALED:37146,TIMEOUT_EXPIRED:37147,CONDITION_SATISFIED:37148,WAIT_FAILED:37149,SYNC_FLUSH_COMMANDS_BIT:1,VERTEX_ATTRIB_ARRAY_DIVISOR:35070,ANY_SAMPLES_PASSED:35887,ANY_SAMPLES_PASSED_CONSERVATIVE:36202,SAMPLER_BINDING:35097,RGB10_A2UI:36975,INT_2_10_10_10_REV:36255,TRANSFORM_FEEDBACK:36386,TRANSFORM_FEEDBACK_PAUSED:36387,TRANSFORM_FEEDBACK_ACTIVE:36388,TRANSFORM_FEEDBACK_BINDING:36389,COMPRESSED_R11_EAC:37488,COMPRESSED_SIGNED_R11_EAC:37489,COMPRESSED_RG11_EAC:37490,COMPRESSED_SIGNED_RG11_EAC:37491,COMPRESSED_RGB8_ETC2:37492,COMPRESSED_SRGB8_ETC2:37493,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:37494,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:37495,COMPRESSED_RGBA8_ETC2_EAC:37496,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:37497,TEXTURE_IMMUTABLE_FORMAT:37167,MAX_ELEMENT_INDEX:36203,TEXTURE_IMMUTABLE_LEVELS:33503,MAX_TEXTURE_MAX_ANISOTROPY_EXT:34047}),$s={UNSIGNED_BYTE:qs.UNSIGNED_BYTE,UNSIGNED_SHORT:qs.UNSIGNED_SHORT,UNSIGNED_INT:qs.UNSIGNED_INT,FLOAT:qs.FLOAT,HALF_FLOAT:qs.HALF_FLOAT_OES,UNSIGNED_INT_24_8:qs.UNSIGNED_INT_24_8,UNSIGNED_SHORT_4_4_4_4:qs.UNSIGNED_SHORT_4_4_4_4,UNSIGNED_SHORT_5_5_5_1:qs.UNSIGNED_SHORT_5_5_5_1,UNSIGNED_SHORT_5_6_5:qs.UNSIGNED_SHORT_5_6_5,toWebGLConstant:function(t,e){switch(t){case $s.UNSIGNED_BYTE:return qs.UNSIGNED_BYTE;case $s.UNSIGNED_SHORT:return qs.UNSIGNED_SHORT;case $s.UNSIGNED_INT:return qs.UNSIGNED_INT;case $s.FLOAT:return qs.FLOAT;case $s.HALF_FLOAT:return e.webgl2?qs.HALF_FLOAT:qs.HALF_FLOAT_OES;case $s.UNSIGNED_INT_24_8:return qs.UNSIGNED_INT_24_8;case $s.UNSIGNED_SHORT_4_4_4_4:return qs.UNSIGNED_SHORT_4_4_4_4;case $s.UNSIGNED_SHORT_5_5_5_1:return qs.UNSIGNED_SHORT_5_5_5_1;case $s.UNSIGNED_SHORT_5_6_5:return $s.UNSIGNED_SHORT_5_6_5}},isPacked:function(t){return t===$s.UNSIGNED_INT_24_8||t===$s.UNSIGNED_SHORT_4_4_4_4||t===$s.UNSIGNED_SHORT_5_5_5_1||t===$s.UNSIGNED_SHORT_5_6_5},sizeInBytes:function(t){switch(t){case $s.UNSIGNED_BYTE:return 1;case $s.UNSIGNED_SHORT:case $s.UNSIGNED_SHORT_4_4_4_4:case $s.UNSIGNED_SHORT_5_5_5_1:case $s.UNSIGNED_SHORT_5_6_5:case $s.HALF_FLOAT:return 2;case $s.UNSIGNED_INT:case $s.FLOAT:case $s.UNSIGNED_INT_24_8:return 4}},validate:function(t){return t===$s.UNSIGNED_BYTE||t===$s.UNSIGNED_SHORT||t===$s.UNSIGNED_INT||t===$s.FLOAT||t===$s.HALF_FLOAT||t===$s.UNSIGNED_INT_24_8||t===$s.UNSIGNED_SHORT_4_4_4_4||t===$s.UNSIGNED_SHORT_5_5_5_1||t===$s.UNSIGNED_SHORT_5_6_5}},Js=Object.freeze($s),Qs={DEPTH_COMPONENT:qs.DEPTH_COMPONENT,DEPTH_STENCIL:qs.DEPTH_STENCIL,ALPHA:qs.ALPHA,RGB:qs.RGB,RGBA:qs.RGBA,LUMINANCE:qs.LUMINANCE,LUMINANCE_ALPHA:qs.LUMINANCE_ALPHA,RGB_DXT1:qs.COMPRESSED_RGB_S3TC_DXT1_EXT,RGBA_DXT1:qs.COMPRESSED_RGBA_S3TC_DXT1_EXT,RGBA_DXT3:qs.COMPRESSED_RGBA_S3TC_DXT3_EXT,RGBA_DXT5:qs.COMPRESSED_RGBA_S3TC_DXT5_EXT,RGB_PVRTC_4BPPV1:qs.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,RGB_PVRTC_2BPPV1:qs.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,RGBA_PVRTC_4BPPV1:qs.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,RGBA_PVRTC_2BPPV1:qs.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,RGBA_ASTC:qs.COMPRESSED_RGBA_ASTC_4x4_WEBGL,RGB_ETC1:qs.COMPRESSED_RGB_ETC1_WEBGL,RGB8_ETC2:qs.COMPRESSED_RGB8_ETC2,RGBA8_ETC2_EAC:qs.COMPRESSED_RGBA8_ETC2_EAC,RGBA_BC7:qs.COMPRESSED_RGBA_BPTC_UNORM,componentsLength:function(t){switch(t){case Qs.RGB:return 3;case Qs.RGBA:return 4;case Qs.LUMINANCE_ALPHA:return 2;case Qs.ALPHA:case Qs.LUMINANCE:default:return 1}},validate:function(t){return t===Qs.DEPTH_COMPONENT||t===Qs.DEPTH_STENCIL||t===Qs.ALPHA||t===Qs.RGB||t===Qs.RGBA||t===Qs.LUMINANCE||t===Qs.LUMINANCE_ALPHA||t===Qs.RGB_DXT1||t===Qs.RGBA_DXT1||t===Qs.RGBA_DXT3||t===Qs.RGBA_DXT5||t===Qs.RGB_PVRTC_4BPPV1||t===Qs.RGB_PVRTC_2BPPV1||t===Qs.RGBA_PVRTC_4BPPV1||t===Qs.RGBA_PVRTC_2BPPV1||t===Qs.RGBA_ASTC||t===Qs.RGB_ETC1||t===Qs.RGB8_ETC2||t===Qs.RGBA8_ETC2_EAC||t===Qs.RGBA_BC7},isColorFormat:function(t){return t===Qs.ALPHA||t===Qs.RGB||t===Qs.RGBA||t===Qs.LUMINANCE||t===Qs.LUMINANCE_ALPHA},isDepthFormat:function(t){return t===Qs.DEPTH_COMPONENT||t===Qs.DEPTH_STENCIL},isCompressedFormat:function(t){return t===Qs.RGB_DXT1||t===Qs.RGBA_DXT1||t===Qs.RGBA_DXT3||t===Qs.RGBA_DXT5||t===Qs.RGB_PVRTC_4BPPV1||t===Qs.RGB_PVRTC_2BPPV1||t===Qs.RGBA_PVRTC_4BPPV1||t===Qs.RGBA_PVRTC_2BPPV1||t===Qs.RGBA_ASTC||t===Qs.RGB_ETC1||t===Qs.RGB8_ETC2||t===Qs.RGBA8_ETC2_EAC||t===Qs.RGBA_BC7},isDXTFormat:function(t){return t===Qs.RGB_DXT1||t===Qs.RGBA_DXT1||t===Qs.RGBA_DXT3||t===Qs.RGBA_DXT5},isPVRTCFormat:function(t){return t===Qs.RGB_PVRTC_4BPPV1||t===Qs.RGB_PVRTC_2BPPV1||t===Qs.RGBA_PVRTC_4BPPV1||t===Qs.RGBA_PVRTC_2BPPV1},isASTCFormat:function(t){return t===Qs.RGBA_ASTC},isETC1Format:function(t){return t===Qs.RGB_ETC1},isETC2Format:function(t){return t===Qs.RGB8_ETC2||t===Qs.RGBA8_ETC2_EAC},isBC7Format:function(t){return t===Qs.RGBA_BC7},compressedTextureSizeInBytes:function(t,e,r){switch(t){case Qs.RGB_DXT1:case Qs.RGBA_DXT1:case Qs.RGB_ETC1:case Qs.RGB8_ETC2:return Math.floor((e+3)/4)*Math.floor((r+3)/4)*8;case Qs.RGBA_DXT3:case Qs.RGBA_DXT5:case Qs.RGBA_ASTC:case Qs.RGBA8_ETC2_EAC:return Math.floor((e+3)/4)*Math.floor((r+3)/4)*16;case Qs.RGB_PVRTC_4BPPV1:case Qs.RGBA_PVRTC_4BPPV1:return Math.floor((Math.max(e,8)*Math.max(r,8)*4+7)/8);case Qs.RGB_PVRTC_2BPPV1:case Qs.RGBA_PVRTC_2BPPV1:return Math.floor((Math.max(e,16)*Math.max(r,8)*2+7)/8);case Qs.RGBA_BC7:return Math.ceil(e/4)*Math.ceil(r/4)*16;default:return 0}},textureSizeInBytes:function(t,e,r,n){var i=Qs.componentsLength(t);return Js.isPacked(e)&&(i=1),i*Js.sizeInBytes(e)*r*n},alignmentInBytes:function(t,e,r){var n=Qs.textureSizeInBytes(t,e,r,1)%4;return 0===n?4:2===n?2:1},createTypedArray:function(t,e,r,n){var i=Js.sizeInBytes(e);return new(i===Uint8Array.BYTES_PER_ELEMENT?Uint8Array:i===Uint16Array.BYTES_PER_ELEMENT?Uint16Array:i===Float32Array.BYTES_PER_ELEMENT&&e===Js.FLOAT?Float32Array:Uint32Array)(Qs.componentsLength(t)*r*n)},flipY:function(t,e,r,n,i){if(1===i)return t;for(var s=Qs.createTypedArray(e,r,n,i),o=Qs.componentsLength(e),a=n*o,c=0;c<i;++c)for(var f=c*n*o,u=(i-c-1)*n*o,l=0;l<a;++l)s[u+l]=t[f+l];return s},toInternalFormat:function(t,e,r){if(!r.webgl2)return t;if(t===Qs.DEPTH_STENCIL)return qs.DEPTH24_STENCIL8;if(t===Qs.DEPTH_COMPONENT){if(e===Js.UNSIGNED_SHORT)return qs.DEPTH_COMPONENT16;if(e===Js.UNSIGNED_INT)return qs.DEPTH_COMPONENT24}if(e===Js.FLOAT)switch(t){case Qs.RGBA:return qs.RGBA32F;case Qs.RGB:return qs.RGB32F;case Qs.RG:return qs.RG32F;case Qs.R:return qs.R32F}if(e===Js.HALF_FLOAT)switch(t){case Qs.RGBA:return qs.RGBA16F;case Qs.RGB:return qs.RGB16F;case Qs.RG:return qs.RG16F;case Qs.R:return qs.R16F}return t}},to=Object.freeze(Qs);function eo(t,e,r,n,i,s){const o=function(t,e,r,n){let i=t.length,s=r,o=n,a=0;for(;s>0&&o>0;){if(a+=to.compressedTextureSizeInBytes(e,s,o),s>>=1,o>>=1,0===s&&0===o)break;s=Math.max(s,1),o=Math.max(o,1)}return a===i}(t,r,i,s);if(!o)return null;const a=6410===r||4369===r;let c=0,f=i,u=s;const l=[];do{let n=to.compressedTextureSizeInBytes(r,f,u),i=new Uint8Array(t.buffer,e+c,n);l.push(i),f=Math.max(f>>1,1),u=Math.max(u>>1,1),c+=n}while(c<t.byteLength&&o);return{flipY:a,mipmap:l}}function ro(t,e){for(var r,n,i,s=t.bytesOffset,o=ms.parseBuffer(t.buffer,s),a=o.geoPackage,c=o.groupNode.pageLods,f=[],u=[],l=[],E=[],_=[],A=[],h=[],T=c[0].geodes[0].matrix,R={},y=0;y<o.materials.material.length;y++)R[o.materials.material[y].material.id]=o.materials.material[y].material;var I=Number.MAX_VALUE,N=Number.MAX_VALUE,U=Number.MAX_VALUE,d=Number.MIN_VALUE,S=Number.MIN_VALUE,m=Number.MIN_VALUE;for(var O in a){var F=a[O].vertexPackage;r=F.verticesCount;var M=F.vertexAttributes[0].typedArray.buffer,C=F.vertexAttributes[0].typedArray.byteOffset,b=F.vertexAttributes[0].componentsPerAttribute;i=new Float32Array(M,F.vertexAttributes[0].offsetInBytes+C,r*b);for(let t=0;t<r;t++){var p=i[t*b],w=i[t*b+1],D=i[t*b+2];I=Math.min(I,p),N=Math.min(N,w),U=Math.min(U,D),d=Math.max(d,p),S=Math.max(S,w),m=Math.max(m,D)}f.push(i),Co("aTexCoord0",F,M,r,l),Co("batchId",F,M,r,_),F.vertexColor?E.push(F.vertexColor):E.push(void 0);var B=a[O].arrIndexPackage[0].indicesTypedArray,L=B.byteLength/a[O].arrIndexPackage[0].indicesCount;n=new(4===L?Uint32Array:2===L?Uint16Array:Uint8Array)(B.buffer,(a[O].arrIndexPackage[0].bytesOffset||0)+B.byteOffset,a[O].arrIndexPackage[0].indicesCount),u.push(n),n.length,h.push(r);var P=a[O].arrIndexPackage[0].materialCode;A.push(R[P])}var g=[I,N,U],G=[d,S,m];const v=function(t,e,r,n,i,s,o,a,c,f,u,l,E,_,A){let h=0;for(const t in a)a[t].width*a[t].height*4>h&&(h=a[t].width*a[t].height*4);(!io||h>io)&&(no=new Uint8ClampedArray(h+122),io=h);const T=[],R={magFilter:9729,minFilter:9729,wrapS:10497,wrapT:10497},y={},I={},N=[],U=[],d=[];for(let c=0;c<r.length;c++){const h=e[c],S=t[c],m=r[c],O=i&&i[c]&&i[c],F=n&&n[c]&&n[c],M=s&&s[c]&&s[c],C=o&&o[c]&&o[c],b={POSITION:{array:m,componentType:5126,count:S,byteOffset:m.byteOffset,byteStride:0,byteLength:m.byteLength,type:Ae(m.length/S),itemSize:m.length/S,name:"POSITION",min:f,max:u}};N.indexOf(m.buffer)<0&&N.push(m.buffer),O&&bo(b,"TEXCOORD_0",O,S,N),F&&bo(b,"NORMAL",F,S,N),M&&bo(b,"COLOR_0",M,S,N),C&&bo(b,"_BATCHID",C,S,N);const p={attributes:b,material:c,indices:{array:h.slice(),itemSize:1,byteLength:h.byteLength,byteOffset:0,byteStride:0,name:h,count:h.length,componentType:5123},mode:4};N.push(p.indices.array.buffer);const w={primitives:[p],index:c};I[c]=w;const D={mesh:c,nodeIndex:c,matrix:A};y[c]=D,U.push({nodes:[D]});const B=E[c],L={uFillForeColor:[1,1,1,1]};let P=B.ambient;L.ambientColor=[P.r,P.g,P.b,P.a];let g=B.diffuse;L.uDiffuseColor=[g.r,g.g,g.b,g.a];let G=B.specular;L.specularColor=[G.r,G.g,G.b,G.a],L.shininess=B.shininess,L.bTransparentSorting=B.transparentsorting;let v=B.textureunitstates;if(v.length){L.uTexMatrix=v[0].textureunitstate.texmodmatrix;const t=a[v[0].textureunitstate.id];if(L.uTexture0Width=t.width,v[1]){const t=a[v[1].textureunitstate.id];L.uTexture1Width=t.width}}d.push({pbrMetallicRoughness:{baseColorFactor:[.8,.8,.8,1],metallicFactor:0,roughnessFactor:.5},extensions:{KHR_techniques_webgl:{technique:0,values:L}}}),T.push(ao(c,E,l,a,_).then((t=>{if(!t)return null;const{array:e,mipmap:r,width:n,height:i,format:s,flipY:o}=t;if(e&&N.indexOf(e.buffer)<0&&N.push(e.buffer),r)for(let t=0;t<r.length;t++)e&&N.indexOf(r[t].buffer)<0&&N.push(r[t].buffer);let a=R;return r&&(a={magFilter:R.magFilter,minFilter:9987,wrapS:R.wrapS,wrapT:R.wrapT}),{materialIndex:c,image:{mipmap:r,array:e,flipY:!!o,width:n,height:i,mimeType:"image/bmp"},sampler:a,format:s,source:c}})))}return Promise.all(T).then((t=>{t=t.filter((t=>!!t));for(let e=0;e<t.length;e++){const{materialIndex:r}=t[e];let n="uTexture";d[r].extensions.KHR_techniques_webgl.values.uTexture&&(n="uTexture2"),d[r].extensions.KHR_techniques_webgl.values[n]={"index":e,"texCoord":r},delete t[e].materialIndex}return{transferables:N,gltf:{"asset":{"generator":"S3M","version":"2.0"},"scene":0,"scenes":U,"nodes":y,"meshes":I,"materials":d,"skins":[],"animations":null,"textures":t,"transferables":[{},{},{},{},{}]}}}))}(h,u,f,null,l,E,_,o.texturePackage,0,g,G,[],A,e,T);return v.then((({gltf:t,transferables:e})=>({gltf:t,featureTable:{"BATCH_LENGTH":0},transferables:e,pageLods:c})))}ms.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],c=t[2]*n+t[6]*i+t[10]*s+t[14];return r.x=o,r.y=a,r.z=c,r};let no,io=0;let so=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(Sn){}t&&"undefined"!=typeof createImageBitmap&&(so=!0)}const oo={};function ao(t,e,r,n,i){const s=no;return new Promise((function(r){!function(t){if(e[t].textureunitstates[0]){var o=e[t].textureunitstates[0].textureunitstate.id,a=n[o],c=a.arrayBufferView,f=a.nFormat,u=a.internalFormat;if(function(t){return t===Ao||t===ho||t===To||t===Ro||t===yo||t===Io||t===No||t===Uo||t===So||t===mo||t===Oo||t===Fo||t===Mo}(u)&&a.width===a.height){const t=eo(c,c.byteOffset,u,0,a.width,a.height);if(t){const{mipmap:e,flipY:n}=t;return void r({format:u,mipmap:e,flipY:n,width:a.width,height:a.height})}}let l;l=f>As||f===_s?122+a.width*a.height*4:61+a.width*a.height,Ss.decode(s.subarray(122),a.width,a.height,c,f),function(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}(s.buffer,a.width,a.height);let{width:E,height:_}=a;co(E)||(E=fo(E)),co(_)||(_=fo(_));const A=i;let h;A&&(E=Math.min(A,E),_=Math.min(A,_));let T=6408;const R=a.width*a.height*4;!so||E===a.width&&_===a.height?(h=new Uint8Array(3*R/4),T=6407):(oo[R]||(oo[R]=new Uint8Array(R)),h=oo[R]),h=js(h,s.buffer,0,l),!so||E===a.width&&_===a.height||(h=function(t,e,r,n,i){uo||(uo=new OffscreenCanvas(2,2),lo=uo.getContext("2d"),Eo=new OffscreenCanvas(2,2),_o=Eo.getContext("2d",{willReadFrequently:!0}));const s=new ImageData(new Uint8ClampedArray(t.buffer),e,r);return uo.width=e,uo.height=r,lo.putImageData(s,0,0),Eo.width=n,Eo.height=i,_o.drawImage(uo,0,0,n,i),_o.getImageData(0,0,n,i).data}(h,a.width,a.height,E,_)),h.buffer===(oo[R]&&oo[R].buffer)&&(h=new Uint8Array(h)),r({array:h,width:E,height:_,format:T})}else r(null)}(t)}))}function co(t){return 0==(t&t-1)&&0!==t}function fo(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}let uo,lo,Eo,_o;const Ao=33776,ho=33777,To=33778,Ro=33779,yo=35840,Io=35841,No=35842,Uo=35843,So=37808,mo=36196,Oo=37492,Fo=37496,Mo=36492;function Co(t,e,r,n,i){var s,o=e.attrLocation[t];if(o){const t=e.vertexAttributes[o];if(t.typedArray.buffer!==r)i.push(t.typedArray);else{var a=t.componentsPerAttribute;var c=new(s=t.componentDatatype,Ee[s])(r,t.offsetInBytes+t.typedArray.byteOffset,n*a);i.push(c)}}else i.push(void 0)}function bo(t,e,r,n,i){t[e]={array:r,componentType:_e(r.constructor),count:n,byteOffset:r.byteOffset,byteStride:0,byteLength:r.byteLength,type:Ae(r.length/n),itemSize:r.length/n,name:e},i.indexOf(r.buffer)<0&&i.push(r.buffer)}var po=Po("DXT1"),wo=Po("DXT3"),Do=Po("DXT5"),Bo=Po("DX10"),Lo=function(t){var e,r,n=new Int32Array(t,0,31);if(542327876!==n[0])throw new Error("Invalid magic number in DDS header");if(4&!n[20])throw new Error("Unsupported format, must contain a FourCC code");var i=n[21];switch(i){case po:e=8,r="dxt1";break;case wo:e=16,r="dxt3";break;case Do:e=16,r="dxt5";break;case 116:r="rgba32f";break;case Bo:var s=new Uint32Array(t.slice(128,148));r=s[0];var o=s[1];if(s[2],s[3],s[4],3!==o||2!==r)throw new Error("Unsupported DX10 texture format "+r);r="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(a=i,String.fromCharCode(255&a,a>>8&255,a>>16&255,a>>24&255)))}var a;var c=n[2],f=1;131072&c&&(f=Math.max(1,n[7]));var u=!1;512&n[28]&&(u=!0);var l,E=n[4],_=n[3],A=n[1]+4,h=E,T=_,R=[];i===Bo&&(A+=20);if(u)for(var y=0;y<6;y++){if("rgba32f"!==r)throw new Error("Only RGBA32f cubemaps are supported");E=h,_=T;for(var I=Math.log(E)/Math.log(2)+1,N=0;N<I;N++)l=E*_*16,R.push({offset:A,length:l,shape:[E,_]}),N<f&&(A+=l),E=Math.floor(E/2),_=Math.floor(_/2)}else for(N=0;N<f;N++)l=Math.max(4,E)/4*Math.max(4,_)/4*e,R.push({offset:A,length:l,shape:[E,_]}),A+=l,E=Math.floor(E/2),_=Math.floor(_/2);return{shape:[h,T],images:R,format:r,flags:c,cubemap:u}};function Po(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}const go=Math.PI/180,Go=6378137*Math.PI/180,vo=85.0511287798;function Xo(t,e,r){if("EPSG:3857"===r)return function(t,e){const r=vo,n=e[0],i=Math.max(Math.min(r,e[1]),-r);let s;s=0===i?0:Math.log(Math.tan((90+i)*go/2))/go;return t[0]=n*Go,t[1]=s*Go,t}(t,e);if("EPSG:4326"===r||"EPSG:4490"===r||"identity"===r)return Ho(t,e);if("baidu"===r)return Ho(t,e);throw new Error("unsupported projection:"+r)}function Ho(t,e){return t[0]=e[0],t[1]=e[1],t}const xo=s([]),Vo=Ie().draco,ko=Ie().ktx2,Zo={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},Yo={"position":{name:"POSITION",accessor:{"componentType":5126,"type":"VEC3"}},"normal":{name:"NORMAL",accessor:{"componentType":5126,"type":"VEC3"}},"uv0":{name:"TEXCOORD_0",accessor:{"componentType":5126,"type":"VEC2"}},"color":{name:"COLOR_0",accessor:{"componentType":5121,"type":"VEC4"}},"uv-region":{name:"uvRegion",accessor:{"componentType":5123,"type":"VEC4"}},"feature-index":{name:"_BATCHID",accessor:{"componentType":5125,"type":"SCALAR"}},"faceRange":{name:"faceRange",accessor:{"componentType":5125,"type":"VEC2"}}};function Ko(t,e,r,n){const i=[],o=[],a=[];for(let e=0;e<t.meshes.length;e++){const{geometry:r,material:n}=t.meshes[e];let s=q.getArrayBuffer(r.url);s.xhr.url=r.url,a.push(s.xhr);const c=s.then((t=>({buffer:t})));i.push(c);const f=[];if(ta(n,f),f.length){const t=f.map((t=>{const e=q.getArrayBuffer(t.url);return e.xhr.url=t.url,a.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));i.push(...t)}o[e]=f.length}const c=Promise.all(i).then((i=>{for(let t=0;t<i.length;t++)if(!i[t]||!i[t].buffer)return Promise.resolve(null);const a=[];let c=0;for(let t=0;t<o.length;t++){const e=o[t];a.push({geoBuffer:{data:i[c].buffer.data},textureBuffers:i.slice(c+1,e+c+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),c+=1+e}const f=function(t,e,r,n,i){const o={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},a=[];for(let c=0;c<t.meshes.length;c++){let f,{geometry:u,material:l}=t.meshes[c];const E=e[c].geoBuffer.data;if(!E)continue;f=oa(E)?Wo(o,c,u,E,t.transform,t.center,i):qo(o,c,u,E,t.transform,t.center,i),a.push(f),o.nodes[c]={mesh:c,nodeIndex:c,matrix:s([])},o.scenes[0].nodes[c]=o.nodes[c],l||(l=Zo);const _=Jo(c,o,l,e[c].textureBuffers,r,n);a.push(_)}return Promise.all(a).then((()=>({gltf:o,featureTable:{BATCH_LENGTH:0},transferables:o.transferables})))}(t,a,e,n,r);return f}));return c.xhr=a,c}const zo={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Wo(t,e,r,n,i,s,o){const a=r.info.compressedAttributes.attributes.reduce(((t,e,r)=>{const n=Yo[e];if(!n)return t;return t[n.name||e]=r,t}),{});return Vo(n,{attributes:a,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((r=>$o(r,t,e,i,s,o)))}var jo={position:function(t,e,r){const n=3*t.vertexCount,i=new Float32Array(e,r,n);return t.position={array:i,componentType:5126,itemSize:3,count:n/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},r+=4*n},normal:function(t,e,r){var n=3*t.vertexCount;const i=new Float32Array(e,r,n);return t.normal={array:i,componentType:5126,itemSize:3,count:n/3,type:"VEC3"},r+=4*n},uv0:function(t,e,r){var n=2*t.vertexCount;const i=new Float32Array(e,r,n);return t.uv0={array:i,componentType:5126,itemSize:2,count:n/2,type:"VEC2"},r+=4*n},color:function(t,e,r){var n=4*t.vertexCount;const i=new Uint8Array(e,r,n);return t.color={array:i,componentType:5121,itemSize:4,count:n/4,type:"VEC4"},r+=n},featureId:function(t,e,r){return r+=8*t.featureCount},id:function(t,e,r){return r+=8*t.featureCount},faceRange:function(t,e,r){var n=2*t.featureCount;const i=new Uint32Array(e,r,n);return t.faceRange={array:i,componentType:5125,itemSize:2,count:n/2,type:"VEC2"},r+=4*n},uvRegion:function(t,e,r){var n=4*t.vertexCount;const i=new Uint16Array(e,r,n);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:n/4,type:"VEC4"},r+=2*n},region:function(t,e,r){var n=4*t.vertexCount;const i=new Uint16Array(e,r,n);return t["uv-region"]={array:i,componentType:5123,itemSize:4,count:n/4,type:"VEC4"},r+=2*n}};function qo(t,e,r,n,i,s,o){const a={vertexCount:0},c=new DataView(n);try{var f=0;a.vertexCount=c.getUint32(f,1),f+=4,a.featureCount=c.getUint32(f,1),f+=4;const t=r.info.ordering?null:r.info;if(t){const e=[];for(const r in t)"offset"!==r&&""!==r&&e.push(r);for(var u=0;u<e.length;u++)jo[e[u]]?f=jo[e[u]](a,n,f):console.error("Unknown decoder for",e[u])}else{const t=r.info;let e=t.ordering,i=t.featureAttributeOrder;const s=null;s&&s.geometryData&&s.geometryData[0]&&s.geometryData[0].params;for(var l=0;l<e.length;l++){var E=jo[e[l]];E||console.log(e[l]),f=E(a,n,f)}for(var _=0;_<i.length;_++){var A=jo[i[_]];A||console.log(i[_]),f=A(a,n,f)}}}catch(t){}a.scale_x=1,a.scale_y=1;const h={};for(const t in a){const e=Yo[t]&&Yo[t].name;e&&(h[e]=a[t])}if(a.faceRange){const t=a.faceRange.array,e=t.length/2,r=(T=e)<=255?Uint8Array:T<=65535?Uint16Array:Uint32Array,n=new r(h.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const r=e/2,i=t[e],s=t[e+1];for(let t=i;t<=s;t++)n[3*t]=r,n[3*t+1]=r,n[3*t+2]=r}h._BATCHID={componentType:_e(r),array:n,itemSize:1,count:n.length,type:"SCALAR"}}var T;return $o({attributes:h},t,e,i,s,o)}function $o(t,e,r,n,i,s){const o={attributes:t.attributes,material:r,indices:t.indices,mode:4};!function(t){const e=t.array,r=t.meta&&t.meta["i3s-scale_x"],n=t.meta&&t.meta["i3s-scale_y"];if(r&&n&&(1!==r||1!==n))for(let t=0;t<e.length;t+=3)e[t]*=r.value,e[t+1]*=n.value}(t.attributes.POSITION);const a=function(t,e,r,n){const i=r;let s,o=[0,0,0,1],a=[0,0];const c=Xo([],r,n);c[2]=r[2];const f=e&&u(xo,e);return ge(t,(t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],f||(o=m(o,o,e)),i&&T(o,o,i),Xo(a,o,n),s=o[2],t[0]=a[0]-c[0],t[1]=a[1]-c[1],t[2]=s-c[2],t))),c}(t.attributes.POSITION,n,i,s);e.meshes[r]={primitives:[o],index:r},e.extensions.MAPTALKS_RTC={projCenter:a},e.extensions.CESIUM_RTC={rtcCoord:i};for(const r in t.attributes)sa(e.transferables,t.attributes[r].array.buffer);return t.indices&&sa(e.transferables,t.indices.array.buffer),o}function Jo(t,e,r,n,i,s){const o=n.map((t=>function(t,e,r,n,i){if("dds"===e){const e=Lo(t),n=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),i="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:n,width:e.shape[0],height:e.shape[1],mimeType:r},sampler:zo,format:i})}if("png"===e||"jpg"===e)return function(t,e){ea||(ea=new OffscreenCanvas(2,2),ra=ea.getContext("2d",{willReadFrequently:!0}));const r=new Blob([new Uint8Array(t)]);return createImageBitmap(r).then((t=>{let{width:r,height:n}=t;na(r)||(r=ia(r)),na(n)||(n=ia(n));const i=e;i&&(r=Math.min(i,r),n=Math.min(i,n)),ea.width=r,ea.height=n,ra.drawImage(t,0,0,r,n),t.close();const s=ra.getImageData(0,0,r,n);return{width:r,height:n,array:new Uint8Array(s.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,i).then((t=>{t.mimeType=r;return{image:t,sampler:zo,format:6408}}));if("ktx2"===e)return ko(t,n).then((t=>(t.mimeType=r,{image:t,sampler:zo,format:t.format})))}(t.data,t.format,t.mimeType,i,s).then((t=>{if(t.image)if(t.image.array)sa(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let r=0;r<t.image.mipmap.length;r++)sa(e.transferables,t.image.mipmap[r].buffer);return t}))));return Promise.all(o).then((n=>{Qo(t,e,r,n)}))}function Qo(t,e,r,n){const i=JSON.parse(JSON.stringify(r)),s=e.textures;n.ptr||(n.ptr=0);for(const t in r)r[t]&&r[t].url?(s.push(n[n.ptr++]),i[t]={index:s.length-1},void 0!==r[t].factor&&(i[t].scale=r[t].factor)):Ut(r[t])&&(i[t]=Qo(-1,e,r[t],n));return t>=0&&(e.materials[t]=i),i}function ta(t,e){for(const r in t)t[r]&&t[r].url?e.push({url:t[r].url,mimeType:t[r].mimeType,format:t[r].format}):Ut(t[r])&&ta(t[r],e)}let ea,ra;function na(t){return 0==(t&t-1)&&0!==t}function ia(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function sa(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function oa(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}const aa=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],ca=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],fa="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let ua,la,Ea=!1;if("undefined"!=typeof OffscreenCanvas){try{la=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(Sn){}la&&"undefined"!=typeof createImageBitmap&&(Ea=!0)}const _a=s([]),Aa=[0,0,0],ha=[],Ta=[],Ra=[],ya=[];class Ia{constructor(t,e,r,n){this.id=t,this.options=e,this.St=this.requestImage.bind(this),this.Ot=r,this.Ft={},n(null,{},[])}Mt(t){this.Ct||(this.o=t,this.bt=new Oe,this.Ct=new Ne(this.St,At,t),this.wt=new Ue(this.St,At,t))}requestImage(t,e){Ea?fetch(t).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{ua.width=t.width,ua.height=t.height,la.drawImage(t,0,0);const r=la.getImageData(0,0,ua.width,ua.height);e(null,{width:t.width,height:t.height,data:new Uint8Array(r.data)})})):this.Ot("requestImage",{url:t},null,e)}loadTile(t,e){this.Mt(t.supportedFormats);const r=t.url,n=t.arraybuffer;if(function(t){return t.indexOf("i3s:")>=0}(r)){const n=t.i3sInfo,i=this.options.services[t.rootIdx].maxTextureSize||1024,s=Ko(n,t.supportedFormats,this.options.projection,i);return s.then((t=>{if(delete this.Ft[r],!t)return void e({status:404,url:r,i3sInfo:n});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:n});t.gltf.url=r;const{transferables:i}=t;t.magic="b3dm",e(null,t,i)})),void(this.Ft[r]=s.xhr)}if(n){delete this.Ft[r];const i=new DataView(n),s=xt(i,0);if("{"===s[0]||" "===s[0]||"<"===s[0]){const i=function(t,e,r){if(fa){const n=new Uint8Array(t,e,r);return fa.decode(n)}return Ft(new Uint8Array(t,e,r))}(n,0,n.byteLength),s=JSON.parse(i);this.Dt(t.rootIdx,s,n,r,e)}else{const o=i.getFloat32(0,!0);1===o||2===o?this.Bt(n,r,t,e):this.Lt(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=q.getArrayBuffer(r+(i||""),n.fetchOptions);const o=s.xhr;s=s.then((n=>{delete this.Ft[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this.Ft[r],e(t)})),this.Ft[r]=o}}Lt(t,e,r,n,i){const s=this.options.services[r.rootIdx];if("b3dm"===n){this.Ct.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{if(t.error)return void i(t);const{content:e,transferables:n}=this.Pt(t,r);i(null,e,n)})).catch((t=>{i(t)}))}else if("pnts"===n){const n=r.transform;this.bt.load(e,t).then((t=>{const{content:e,transferables:s}=this.gt(t,n,r.rootIdx);i(null,e,s)}))}else if("i3dm"===n){const n=r.transform;this.wt.load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{const{content:e,transferables:s}=this.gt(t,n,r.rootIdx);i(null,e,s)}))}else if("cmpt"===n){new Me(this.St,At,this.o,s.maxTextureSize||1024).load(e,t,0,0,{maxTextureSize:s.maxTextureSize||1024}).then((t=>{const{content:e,transferables:n}=this.Gt(t,r);i(null,e,n)})).catch((t=>{i(t)}))}}Bt(t,e,r,n){ro({buffer:t,bytesOffset:0},this.options.services[r.rootIdx].maxTextureSize||1024).then((t=>{t.gltf.url=e;const{content:i,transferables:s}=this.Pt(t,r);if(i.magic="b3dm",t.pageLods){const e=this.vt(t.pageLods);e.length&&(i.children=e)}n(null,i,s)}))}vt(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}Dt(t,e,r,n,i){return e.dataType&&e.position?void i(null,Xe(e)):(e.capabilities,void i(null,e))}Gt(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.Pt(r[t],e);Sa(i,o),n.content.push(s)}else if("i3dm"===s||"pnts"===s){const{transform:s,rootIdx:o}=e,{content:a,transferables:c}=this.gt(r[t],s,o);Sa(i,c),n.content.push(a)}else if("cmpt"===s){const{content:s,transferables:o}=this.Gt(r[t],e);Sa(i,o),n.content.push(s)}}return{content:n,transferables:i}}Pt(t,e){const{gltf:r,transferables:n,featureTable:i}=t,s=function(t){if(!t||!t.meshes)return!1;const e="visited";let r=1;const n=[];for(const i in t.meshes){const s=t.meshes[i],{primitives:o}=s;if(o)for(let t=0;t<o.length;t++){const i=o[t].attributes&&o[t].attributes.POSITION;if(!i||!i.array)continue;i.array.buffer[e]||(i.array.buffer[e]=r++);const s=r-1+"-"+(i.byteOffset||0);if(n.indexOf(s)>=0)return!0;n.push(s)}}return!1}(r);return this.Xt(t.gltf),t.gltf.asset||(t.gltf.asset={}),s?(t.gltf.asset.sharePosition=!0,this.Ht(r,i,e.upAxis,e.transform)):this.xt(r,i,e.upAxis,e.transform),delete t.transferables,{content:t,transferables:n}}gt(t,e,r){const{featureTable:i}=t,s=t.pnts||t.i3dm;let o=i&&i.RTC_CENTER||[0,0,0];if(i.EAST_NORTH_UP&&!s.NORMAL_UP&&!s.NORMAL_UP_OCT32P){const e=new Float32Array(3*s.POSITION.array.length),r=[],i=[],a=[];ge(s.POSITION,((t,s)=>{T(a,t,o),oe(a,null,r),n(i,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*s,9*(s+1)),i)})),s.INSTANCE_ROTATION={byteStride:0,byteOffset:0,itemSize:9,componentType:5126,array:e},t.transferables.push(e.buffer)}const a={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Ua(s.POSITION.array,3,o,_a,a);const c=da(a),f=A([],c),u=[1/0,1/0,1/0],l=[-1/0,-1/0,-1/0];ge(s.POSITION,(t=>{t[0]=t[0]+o[0]-f[0],t[1]=t[1]+o[1]-f[1],t[2]=t[2]+o[2]-f[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]>l[0]&&(l[0]=t[0]),t[1]>l[1]&&(l[1]=t[1]),t[2]>l[2]&&(l[2]=t[2])})),s.POSITION.min=u,s.POSITION.max=l,e&&m(c,c,e);const E=this.Vt(c);t.rtcCenter=f,t.rtcCoord=E,t.rootIdx=r;const _=t.transferables;return delete t.transferables,{content:t,transferables:_}}Xt(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.Ft[t.url];if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t].abort();else r&&r.abort&&r.abort();delete this.Ft[t.url],e(null)}kt(t,e,r,n){let i=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center,a=aa;"X"===(r=r&&r.toUpperCase())?a=ca:"Z"===r&&(a=_a),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),i&&(t.extensions.CESIUM_RTC.center=i),t.extensions.MAPTALKS_RTC={};const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Ce(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=s(ha);t.matrices&&ma(e,t.matrices);const r=t.attributes.POSITION.array,f=t.attributes.POSITION.itemSize;o(e,a,e),n&&o(e,n,e),Ua(r,f,i||Aa,e,c)}));const f=da(c);return{rtcCenter:i,modelCenter:f,upAxisTransform:a}}Ht(t,e,r,n){const{modelCenter:i,upAxisTransform:a,rtcCenter:c}=this.kt(t,e,r),f=A([],i);n&&m(i,i,n),t.extensions.CESIUM_RTC.rtcCoord=this.Vt(i),c||(Ce(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=s(ha);t.matrices&&ma(r,t.matrices),o(r,a,r);const n=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],f=e[7],u=e[8],l=e[9],E=e[10],_=e[11],A=e[12],h=e[13],T=e[14],R=e[15],y=r*a-n*o,I=r*c-i*o,N=r*f-s*o,U=n*c-i*a,d=n*f-s*a,S=i*f-s*c,m=u*h-l*A,O=u*T-E*A,F=u*R-_*A,M=l*T-E*h,C=l*R-_*h,b=E*R-_*T,p=y*b-I*C+N*M+U*F-d*O+S*m;return p?(p=1/p,t[0]=(a*b-c*C+f*M)*p,t[1]=(i*C-n*b-s*M)*p,t[2]=(h*S-T*d+R*U)*p,t[3]=(E*d-l*S-_*U)*p,t[4]=(c*F-o*b-f*O)*p,t[5]=(r*b-i*F+s*O)*p,t[6]=(T*N-A*S-R*I)*p,t[7]=(u*S-E*N+_*I)*p,t[8]=(o*C-a*F+f*m)*p,t[9]=(n*F-r*C-s*m)*p,t[10]=(A*d-h*N+R*y)*p,t[11]=(l*N-u*d-_*y)*p,t[12]=(a*O-o*M-c*m)*p,t[13]=(r*M-n*O+i*m)*p,t[14]=(h*I-A*U-T*y)*p,t[15]=(u*U-l*I+E*y)*p,t):null}(Ta,r),i=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];ge(e,(t=>{m(t,t,r),t[0]=t[0]-f[0],t[1]=t[1]-f[1],t[2]=t[2]-f[2],m(t,t,n),t[0]<i[0]&&(i[0]=t[0]),t[1]<i[1]&&(i[1]=t[1]),t[2]<i[2]&&(i[2]=t[2]),t[0]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])})),e.min=i,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=f)}xt(t,e,r,n){const{modelCenter:i,rtcCenter:s}=this.kt(t,e,r,n),o=this.Zt(i);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.CESIUM_RTC.rtcCoord=this.Vt(i),Ce(t,(e=>{e.attributes&&e.attributes.POSITION&&(e.attributes.NORMAL&&this.Yt(e.attributes.NORMAL,e.matrices,r),e.attributes.TANGENT&&this.Yt(e.attributes.TANGENT,e.matrices,r),this.Kt(e.attributes.POSITION,e.matrices,s,t.extensions.MAPTALKS_RTC,r,n))}));for(const e in t.nodes){t.nodes[e].matrix=_a}}Zt(t){0===M(t)?h(Ra,0,0,-6378137):Pt(Ra,t);const e=this.options.projection;Xo(ya,Ra,e);const r=Ra[2],n=[];return n[0]=ya[0],n[1]=ya[1],n[2]=r,n}Yt(t,e,r){let s;s="Y"===r?aa:"X"===r?ca:_a;const o=i([],s);if(ma(o,e),u(o,_a))return;const a=n([],o),c=[];ge(t,(t=>(function(t,e,r){var n=e[0],i=e[1],s=e[2];t[0]=n*r[0]+i*r[3]+s*r[6],t[1]=n*r[1]+i*r[4]+s*r[7],t[2]=n*r[2]+i*r[5]+s*r[8]}(c,t,a),U(c,c),A(t,c),c)))}Kt(t,e,r,n,i,o){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return;const a=s([]);ma(a,e);const c=this.options.projection;i=i&&i.toUpperCase();const f=r;let l=null;"Y"===i?l=aa:"X"===i&&(l=ca);let E=[0,0,0,1],_=[0,0,0],A=[0,0];const R=n.projCenter,y=o&&u(_a,o),I=t.min=t.min||[],N=t.max=t.max||[];return h(I,1/0,1/0,1/0),h(N,-1/0,-1/0,-1/0),ge(t,(t=>(E[0]=t[0],E[1]=t[1],E[2]=t[2],E=m(E,E,a),l&&(E=m(E,E,l)),f&&T(E,E,f),o&&!y&&(E=m(E,E,o)),0===M(E)?h(_,0,0,-6378137):Pt(_,E),Xo(A,_,c),t[0]=A[0]-R[0],t[1]=A[1]-R[1],t[2]=_[2]-R[2],t[0]<I[0]&&(I[0]=t[0]),t[1]<I[1]&&(I[1]=t[1]),t[2]<I[2]&&(I[2]=t[2]),t[0]>N[0]&&(N[0]=t[0]),t[1]>N[1]&&(N[1]=t[1]),t[2]>N[2]&&(N[2]=t[2]),t))),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:R}}Vt(t){return 0===M(t)?h([],0,0,-6378137):Pt([],t)}onRemove(){}}const Na=[];function Ua(t,e,r,n,i){for(let s=0,o=t.length;s<o;s+=e){const{xmin:o,ymin:a,xmax:c,ymax:f,hmin:u,hmax:l}=i;h(Na,t[s],t[s+1],t[s+2]),m(Na,Na,n);const E=T(Na,r,Na);E[0]<o&&(i.xmin=E[0]),E[0]>c&&(i.xmax=E[0]),E[1]<a&&(i.ymin=E[1]),E[1]>f&&(i.ymax=E[1]),e>2&&(E[2]<u&&(i.hmin=E[2]),E[2]>l&&(i.hmax=E[2]))}}function da(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 Sa(t,e){for(let r=0;r<e.length;r++)t.indexOf(e[r])<0&&t.push(e[r])}function ma(t,e){const r=t;for(let t=e.length-1;t>=0;t--)o(r,e[t],r);return r}let Oa=0;class Fa{constructor(t){this.workerId=t,this.workers={},this.zt={}}addLayer({actorId:t,mapId:e,layerId:r,params:n},i){if(this.Wt(e,r))return;const s=this.jt(e,r),o=n.options,a=this.send.bind(this,t);this.workers[s]=new Ia(r,o,a,i)}removeLayer({mapId:t,layerId:e},r){const n=this.Wt(t,e),i=this.jt(t,e);delete this.workers[i],n&&n.onRemove(r)}loadTile({mapId:t,layerId:e,params:r},n){const i=this.Wt(t,e);i&&i.loadTile(r,n)}abortTileLoading({mapId:t,layerId:e,params:r},n){const i=this.Wt(t,e);i&&i.abortTileLoading(r,n)}receive(t){const e=t.callback,r=this.zt[e];delete this.zt[e],r&&t.error?r(new Error(t.error)):r&&r(null,t.data)}send(t,e,r,n,i){const s=i?`${t}-${Oa++}`:null;i&&(this.zt[s]=i),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:r,callback:String(s)},n||[])}jt(t,e){return`${t}-${e}`}Wt(t,e){const r=this.jt(t,e);return this.workers[r]}}t.initialize=function(){},t.onmessage=function(t,e){const r=t.data;this.dispatcher||(this.dispatcher=new Fa(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)=>{t instanceof Error&&(t={message:t.message}),e(t,r,n)}))},Object.defineProperty(t,"qt",{value:!0})}';for(
|
|
6
|
+
import*as t from"maptalks";import*as e from"@maptalks/gl";import{reshader as r,mat4 as n,HighlightUtil as i,vec3 as s,mat3 as o,vec4 as a,quat as A,createREGL as c}from"@maptalks/gl";const l='function(t){var e=1e-6,r="undefined"!=typeof Float32Array?Float32Array:Array;function n(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}function A(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function i(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 o(t,e,r){var n=e[0],A=e[1],i=e[2],o=e[3],s=e[4],a=e[5],B=e[6],E=e[7],c=e[8],C=e[9],f=e[10],l=e[11],u=e[12],_=e[13],I=e[14],D=e[15],h=r[0],R=r[1],T=r[2],F=r[3];return t[0]=h*n+R*s+T*c+F*u,t[1]=h*A+R*a+T*C+F*_,t[2]=h*i+R*B+T*f+F*I,t[3]=h*o+R*E+T*l+F*D,h=r[4],R=r[5],T=r[6],F=r[7],t[4]=h*n+R*s+T*c+F*u,t[5]=h*A+R*a+T*C+F*_,t[6]=h*i+R*B+T*f+F*I,t[7]=h*o+R*E+T*l+F*D,h=r[8],R=r[9],T=r[10],F=r[11],t[8]=h*n+R*s+T*c+F*u,t[9]=h*A+R*a+T*C+F*_,t[10]=h*i+R*B+T*f+F*I,t[11]=h*o+R*E+T*l+F*D,h=r[12],R=r[13],T=r[14],F=r[15],t[12]=h*n+R*s+T*c+F*u,t[13]=h*A+R*a+T*C+F*_,t[14]=h*i+R*B+T*f+F*I,t[15]=h*o+R*E+T*l+F*D,t}function s(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function a(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function B(t,e){var r=e[0],n=e[1],A=e[2],i=e[3],o=r+r,s=n+n,a=A+A,B=r*o,E=n*o,c=n*s,C=A*o,f=A*s,l=A*a,u=i*o,_=i*s,I=i*a;return t[0]=1-c-l,t[1]=E+I,t[2]=C-_,t[3]=0,t[4]=E-I,t[5]=1-B-l,t[6]=f+u,t[7]=0,t[8]=C+_,t[9]=f-u,t[10]=1-B-c,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function E(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function c(){var t=new r(3);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function C(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function f(t,e,n){var A=new r(3);return A[0]=t,A[1]=e,A[2]=n,A}function l(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function u(t,e,r,n){return t[0]=e,t[1]=r,t[2]=n,t}function _(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function I(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function D(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,t[1]=e[1]*r,t[2]=e[2]*r,t}function R(t,e){var r=e[0]-t[0],n=e[1]-t[1],A=e[2]-t[2];return Math.sqrt(r*r+n*n+A*A)}function T(t,e){var r=e[0],n=e[1],A=e[2],i=r*r+n*n+A*A;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i),t}function F(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function P(t,e,r){var n=e[0],A=e[1],i=e[2],o=r[0],s=r[1],a=r[2];return t[0]=A*a-i*s,t[1]=i*o-n*a,t[2]=n*s-A*o,t}function O(t,e,r){var n=e[0],A=e[1],i=e[2],o=r[3]*n+r[7]*A+r[11]*i+r[15];return o=o||1,t[0]=(r[0]*n+r[4]*A+r[8]*i+r[12])/o,t[1]=(r[1]*n+r[5]*A+r[9]*i+r[13])/o,t[2]=(r[2]*n+r[6]*A+r[10]*i+r[14])/o,t}var L=I,y=D,M=C;function N(t,e,r,n,A){return t[0]=e,t[1]=r,t[2]=n,t[3]=A,t}function S(){var t=new r(4);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function U(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function d(t,r,n,A){var i=r[0],o=r[1],s=r[2],a=r[3],B=n[0],E=n[1],c=n[2],C=n[3],f=void 0,l=void 0,u=void 0,_=void 0,I=void 0;return(l=i*B+o*E+s*c+a*C)<0&&(l=-l,B=-B,E=-E,c=-c,C=-C),1-l>e?(f=Math.acos(l),u=Math.sin(f),_=Math.sin((1-A)*f)/u,I=Math.sin(A*f)/u):(_=1-A,I=A),t[0]=_*i+I*B,t[1]=_*o+I*E,t[2]=_*s+I*c,t[3]=_*a+I*C,t}c(),function(){var t,e=(t=new r(4),r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var G,m=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};c(),f(1,0,0),f(0,1,0),S(),S(),G=new r(9),r!=Float32Array&&(G[1]=0,G[2]=0,G[3]=0,G[5]=0,G[6]=0,G[7]=0),G[0]=1,G[4]=1,G[8]=1;\n/*!\n * @maptalks/gltf-loader v0.27.2\n * LICENSE : UNLICENSED\n * (c) 2016-2022 maptalks.org\n */\nlet b=0;function p(t){return null==t}function w(t){return!p(t)}function H(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 K(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 g(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function V(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 J=[],v=[],X=[],Z=[0,0,0],k=U([]),x=[1,1,1];function W(t,e,r,n,A,i,o){const s=K(o);if((0===A||A===n*s.BYTES_PER_ELEMENT)&&i%s.BYTES_PER_ELEMENT==0){const A=new s(e,i,r*n);return t.set(A),t}0===A&&(A=n*s.BYTES_PER_ELEMENT);const a=new Uint8Array(n*s.BYTES_PER_ELEMENT);for(let o=0;o<r;o++){let r=null;const B=new Uint8Array(e,A*o+i,n*s.BYTES_PER_ELEMENT);a.set(B),r=new s(a.buffer,0,n);for(let e=0;e<n;e++)t[o*n+e]=r[e]}return t}const Q="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function j(t,e,r){const n=new Uint8Array(t,e,r);return Q.decode(n)}const Y={get:function(t,e={}){e||(e={});const r=new AbortController,n=r.signal,A=H({},e);A.signal=n,A.method||(A.method="GET");const i=fetch(t,A).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",Y.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?Y.jsonp(t):((e=e||{}).responseType="json",Y.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+b++;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 z{constructor(t,e,r){this.A=t,this.decoders=e,this.i=r,this.images={},this.o={}}requestImageFromBufferURI(t,e,r){if(this.buffers[t.id]){const n=this.buffers[t.id],A=this.B(e,n);return this.getImageByBuffer(A,r)}if(this.o[t.id])return this.o[t.id].then((()=>{const n=this.buffers[t.id],A=this.B(e,n);return this.getImageByBuffer(A,r)}));if(g(t.uri)){const n=this.buffers[t.id]=V(t.uri),A=this.B(e,n);return this.getImageByBuffer(A,r)}return this.o[t.id]=Y.getArrayBuffer(t.uri,null).then((n=>{const A=this.buffers[t.id]=n.data,i=this.B(e,A);return this.getImageByBuffer(i,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.i});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.C(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;return this.o[t.id]?this.o[t.id].then((()=>this.images[t.id])):this.o[t.id]=this.C(t.id,e)}C(t,e){return new Promise(((r,n)=>{this.A(e,((A,i)=>{A?n(A):(URL.revokeObjectURL(e),this.images[t]=i,r(this.images[t]))}))}))}}const q=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class ${constructor(t,e,r){this.rootPath=t,this.gltf=e,this.l=!1,this.glbBuffer=r,this.buffers={},this.requests={},this.accessors={},this.u()}_(t,e){const r=this.gltf,n=r.accessors[e];if(void 0===n.bufferView)return this.accessors[n.id]=this.I(t,e,null,0),Promise.resolve(this.accessors[n.id]);if(n&&this.accessors[n.id])return Promise.resolve(this.accessors[n.id]);const A=r.bufferViews[n.bufferView];return this.D(A).then((r=>{const{buffer:A,byteOffset:i}=r;return this.accessors[n.id]=this.I(t,e,A,i)}))}D(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(g(e.uri)){const t=this.buffers[e.id]=V(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const r=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||r?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=Y.getArrayBuffer(t,null).then((n=>(r&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=n.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}I(t,e,r,n=0){const A=this.gltf,i=A.accessors[e],o=void 0!==i.bufferView?A.bufferViews[i.bufferView]:{},s=(o.byteOffset||0)+n,a=this.h(i.type),B=K(i.componentType),E=o.byteStride||0,c={array:void 0,name:t,accessorName:e,byteLength:i.count*a*B.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:a};if(i.min&&(c.min=i.min),i.max&&(c.max=i.max),r)if(this.l)c.byteStride=E,c.byteOffset=s+(i.byteOffset||0),!E||E===a*B.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(c.array=this.T(r,i.count,a,s+(i.byteOffset||0),B),c.array.buffer.byteLength===c.byteLength&&(c.byteOffset=0)):c.array=new Uint8Array(r,s,o.byteLength);else if(i.interleaved){c.byteStride=0,c.byteOffset=0;const t=new B(i.count*a);c.array=W(t,r,i.count,a,E,s+(i.byteOffset||0),i.componentType)}else c.byteStride=0,c.array=this.T(r,i.count,a,s+(i.byteOffset||0),B),c.byteOffset=c.array.byteOffset;else{c.array=new B(i.count);const t=c.min||c.max;t&&(c.array[0]=t[0],c.array[1]=t[1],c.array[2]=t[2])}return c}u(){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,A){return n%A.BYTES_PER_ELEMENT!=0&&(t=t.slice(n,n+e*r*A.BYTES_PER_ELEMENT),n=0),new A(t,n,r*e)}h(t){const e=q.indexOf(t);return q[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.D(e).then((n=>{const{buffer:A,byteOffset:i}=n,o=j(A,i+(e.byteOffset||0),r);return t.content=o,t}))}if(t.uri){if(g(t.uri)){const e=V(t.uri),r=j(e,0,e.byteLength);return t.content=r,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return Y.get(e).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(r).then((()=>t))}}class tt extends z{constructor(t,e,r,n,A,i){super(n,A,i),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=r,this.accessor=new $(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(w(t.name)&&(e.name=t.name),w(t.children)&&(e.children=t.children),w(t.jointName)&&(e.jointName=t.jointName),w(t.matrix)&&(e.matrix=t.matrix),w(t.rotation)&&(e.rotation=t.rotation),w(t.scale)&&(e.scale=t.scale),w(t.translation)&&(e.translation=t.translation),w(t.extras)&&(e.extras=t.extras),w(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=s(J,e.translation||Z),n=B(v,e.rotation||k),A=a(X,e.scale||x);return o(A,n,A),o(t,r,A)}return i(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}F(t){const e={};for(const r in t){const n=t[r];let A,i;n.instanceTechnique&&n.instanceTechnique.values?(A=n.instanceTechnique,i=A.values.diffuse):(A=n,i=A.values.tex||A.values.diffuseTex||A.values.diffuse);const o={baseColorTexture:{index:i}};n.name&&(o.name=n.name),n.extensions&&(o.extensions=n.extensions),n.extras&&(o.extras=n.extras),e[r]=o}return e}P(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,A=r.byteLength,i=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,n,A);return this.getImageByBuffer(i,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.P(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 A=this.gltf.textures[n];if(!A)return null;const i=this.gltf.samplers[A.sampler];return{format:A.format||6408,internalFormat:A.internalFormat||6408,type:A.type||5121,sampler:i,source:this.gltf.images[A.source]}}getMaterial(){return null}getAnimations(){return null}}class et extends z{constructor(t,e,r,n,A,i){super(n,A,i),this.rootPath=t,this.gltf=e,this.glbBuffer=r,this.buffers={},this.requests={},this.accessor=new $(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 H(e,t),!w(t.weights)&&this.gltf.meshes&&w(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.P(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}};H(n,e);const A=w(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return A&&(n.sampler=A),t.format&&(n.format=t.format),n}))}P(t){if(!w(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.L(e,t)}return null}L(t,e){const r=this.B(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(r,e)}B(t,e,r){r=r||0;const n=t.byteOffset+r,A=t.byteLength;return new Uint8Array(e,n,A)}M(t,e){const r=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)r[e]=String.fromCharCode(t[e]);return r.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(r)))}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++)(w(t[r].input)||w(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 rt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class nt{static read(t,e=0,r=0){r||(r=t.byteLength);const n=new DataView(t,e,r),A=n.getUint32(4,!0);if(1===A)return nt.readV1(n,e);if(2===A)return nt.readV2(t,e);throw new Error("Unsupported glb version : "+A)}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 A=At(t.buffer,20+e,n);return{json:JSON.parse(A),glbBuffer:{byteOffset:20+e+n,buffer:t.buffer,byteLength:r}}}static readV2(t,e){let r,n,A;const i=new DataView(t,e+12);let o=0;for(;o<i.byteLength;){const s=i.getUint32(o,!0);o+=4;const a=i.getUint32(o,!0);if(o+=4,1313821514===a)r=At(t,e+12+o,s);else if(5130562===a){A=e+12+o,n=s;break}o+=s}return{json:JSON.parse(r),glbBuffer:{byteOffset:A,buffer:t,byteLength:n}}}}function At(t,e,r){if(rt){const n=new Uint8Array(t,e,r);return rt.decode(n)}return function(t){const e=t.length;let r="";for(let n=0;n<e;){let A=t[n++];if(128&A){let r=it[A>>3&7];if(!(64&A)||!r||n+r>e)return null;for(A&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;A=A<<6|63&e}}r+=String.fromCharCode(A)}return r}(new Uint8Array(t,e,r))}const it=[1,1,1,1,2,2,3,0],ot=[0,0,0],st=[0,0,0,1],at=[1,1,1],Bt={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},Et={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},ct={N(t,e,r,n,A,i,o,s){const a=w(t)?e.animations:[e.animations[0]],B={};for(let e=0;e<a.length;e++){const E=a[e],c=E.name||e;if(w(t)&&c!==t)continue;const C=E.channelsMap[r];if(C)for(let t=0;t<C.length;t++){const e=C[t];"translation"===e.target.path?(this.S(A,E.samplers[e.sampler],n,1),B.translation=l(ot,A)):"rotation"===e.target.path?(this.U(i,E.samplers[e.sampler],n,1),B.rotation=m(st,i)):"scale"===e.target.path?(this.S(o,E.samplers[e.sampler],n,1),B.scale=l(at,o)):"weights"===e.target.path&&s&&(this.S(s,E.samplers[e.sampler],n,s.length),B.weights=s)}}return B},S(t,e,r,n){switch(e.interpolation){case"LINEAR":{const A=this.G(Et,e,r,1*n);A&&(t=function(t,e,r,n){for(let A=0;A<t.length;A++)t[A]=e[A]+n*(r[A]-e[A]);return t}(t,A.PREVIOUS,A.NEXT,A.INTERPOLATION));break}case"STEP":{const A=this.G(Et,e,r,1*n);A&&(t=function(t,e){for(let r=0;r<t.length;r++)t[r]=e[r];return t}(t,...A.PREVIOUS));break}case"CUBICSPLINE":{const A=this.G(Et,e,r,3*n);A&&(t=this.m(t,A,e.input.array,3*n));break}}return t},U(t,e,r){switch(e.interpolation){case"LINEAR":{const n=this.G(Et,e,r,1);n&&d(t,n.PREVIOUS,n.NEXT,n.INTERPOLATION);break}case"STEP":{const n=this.G(Et,e,r,1);n&&(t=N(t,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.G(Et,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},p(t,e){const r=t.length;let n,A,i,o=0,s=r-1,a=Math.floor((o+s)/2);for(;o<=r-1&&s>=0;){if(o===s)return null;if(t[a]<=e&&e<=t[a+1]){const r=t[a];return n=a,A=a+1,i=(e-r)/(t[a+1]-r),{preIndx:n,nextIndex:A,interpolation:i}}e<t[a]?(s=a,a=Math.floor((o+s)/2)):t[a+1]<e&&(o=a,a=Math.floor((o+s)/2))}return null},G(t,e,r,n){const A=e.input.array,i=e.output.array,o=e.output.itemSize;(r<A[0]||r>A[A.length-1])&&(r=Math.max(A[0],Math.min(A[A.length-1],r))),r===A[A.length-1]&&(r=A[0]);const s=this.p(A,r);if(!s||!s.nextIndex)return null;const{preIndx:a,nextIndex:B,interpolation:E}=s;t.PREINDEX=a,t.NEXTINDEX=B,t.INTERPOLATION=E;const c=o*n;return t.PREVIOUS=i.subarray(t.PREINDEX*c,(t.PREINDEX+1)*c),t.NEXT=i.subarray(t.NEXTINDEX*c,(t.NEXTINDEX+1)*c),t},m(t,e,r,n){const A=e.INTERPOLATION,i=r[e.PREINDEX],o=r[e.NEXTINDEX];for(let r=0;r<3;r++){const s=e.PREVIOUS[n+r],a=(o-i)*e.PREVIOUS[2*n+r],B=e.NEXT[3+r],E=(o-i)*e.NEXT[r],c=(2*Math.pow(A,3)-3*Math.pow(A,2)+1)*s+(Math.pow(A,3)-2*Math.pow(A,2)+A)*a+(2*-Math.pow(A,3)+3*Math.pow(A,2))*B+(Math.pow(A,3)-Math.pow(A,2))*E;t[r]=c}return t},getAnimationClip(t,e,r,n){const A=t.nodes[e]&&t.nodes[e].weights;return u(ot,...Bt.TRANSLATION),N(st,...Bt.ROTATION),u(at,...Bt.SCALE),this.N(n,t,e,r,ot,st,at,A)},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,A=1/0;const i=e.channels;for(let t=0;t<i.length;t++){const r=i[t],o=e.samplers[r.sampler].input.array;o[o.length-1]>n&&(n=o[o.length-1]),o[0]<A&&(A=o[0])}const o=e.name||r;t.timeSpan[o]={max:n,min:A}})),t.timeSpan},getTimeSpanByName(t,e){const r=this.getTimeSpan(t);return r?w(e)?r[e]:r[Object.keys(r)[0]]:null}};let Ct=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(De){}t&&"undefined"!=typeof createImageBitmap&&(Ct=!0)}const ft="undefined"==typeof document?null:document.createElement("canvas");class lt{constructor(t,e,r){if(this.options=r||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:r,glbBuffer:n}=nt.read(e.buffer,e.byteOffset,e.byteLength);this.H(t,r,n)}else this.H(t,e);this.K=new $(this.rootPath,this.gltf,this.glbBuffer),this.V()}V(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}J(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.K.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.X(),n=this.Z(),A=this.J();return Promise.all([e,r,n,A]).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 ct.getAnimationClip(t,e,r,n)}static getAnimationTimeSpan(t,e){return ct.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return K(t)}static readInterleavedArray(t,e,r,n,A,i,o){return W(t,e,r,n,A,i,o)}H(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=Ct?Dt.bind(this):this.options.requestImage||ut,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new et(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 tt(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"))}k(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(r=t.children[0])&&isFinite(r)||function(t){return!p(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.k(r,e)}));t.children=n}var r;return t}v(t){return this.W(t).then((t=>{const e=this.scenes=[];let r;for(const e in t)t[e]=this.k(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate(((n,A,i)=>{const o={};A.name&&(o.name=A.name),A.nodes&&(o.nodes=A.nodes.map((e=>t[e]))),this.gltf.scene===n&&(r=i),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.F(this.gltf.materials);n.materials=t}return n}))}W(t){return this.j(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}))}Y(){this.skins=[];const t=[];return this.adapter.iterate(((e,r,n)=>{t.push(this.q(r).then((t=>{t.index=n,this.skins.push(t)})))}),"skins"),t}q(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)))}X(){const t=this.gltf.animations;return w(t)?this.adapter.getAnimations(t):null}j(t){this.meshes={};let e=[];return this.adapter.iterate(((r,n,A)=>{e.push(this.$(n,t).then((t=>{t.index=A,this.meshes[r]=t})))}),"meshes"),e=e.concat(this.Y()),Promise.all(e)}$(t,e){const r=t.primitives.map((t=>this.tt(t,e))).filter((t=>!!t));return Promise.all(r).then((e=>{const r={};return H(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}))}tt(t,e){let r;const n=[],A=t.extensions;if(w(t.targets))for(let e=0;e<t.targets.length;e++){const r=t.targets[e];for(const t in r){const A=this.adapter.accessor._(`morphTargets_${t}_${e}`,r[t]);A&&n.push(A)}}if(A&&A.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const t=this.options.decoders.draco,{bufferView:i,attributes:o}=A.KHR_draco_mesh_compression,s=this.gltf.bufferViews[i],a=this.K.D(s).then((r=>{const{buffer:n,byteOffset:A}=r;let{byteOffset:i,byteLength:a}=s;i||(i=0);const B=new DataView(n,A+i,a),E={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(B,E).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));n.push(a),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(w(t.indices)){const e=this.adapter.accessor._("indices",t.indices);e&&n.push(e)}r=Promise.all(n)}return r.then((e=>{if(A&&A.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 i={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:A}=e,i=A.length/n;for(let e=0;e<i;e++)for(let i=0;i<n;i++){const o=e*n+i;A[o]<t[i]&&(t[i]=A[o]),A[o]>r[i]&&(r[i]=A[o])}if(e.quantization){const n=e.quantization,A=n.range/(1<<n.quantizationBits),i=n.minValues;h(t,t,A),_(t,t,i),h(r,r,A),_(r,r,i)}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&&(i.indices=r),n&&(i.morphTargets=n),i.mode=w(t.mode)?t.mode:4,w(t.extras)&&(i.extras=t.extras),i}))}}function ut(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",{willReadFrequently:!0});t.drawImage(r,0,0,r.width,r.height);const n=t.getImageData(0,0,r.width,r.height),A={width:r.width,height:r.height,data:new Uint8Array(n.data)};e(null,A)},r.onerror=function(t){e(t)},r.src=t}let _t,It;function Dt(t,e){_t||(_t=new OffscreenCanvas(2,2),It=_t.getContext("2d",{willReadFrequently:!0})),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=Rt(r)),ht(n)||(n=Rt(n));const A=this.options.maxTextureSize;A&&(r=Math.min(A,r),n=Math.min(A,n)),_t.width=r,_t.height=n,It.drawImage(t,0,0,r,n),t.close();const i=It.getImageData(0,0,r,n);e(null,{width:r,height:n,data:new Uint8Array(i.data)})})).catch((t=>{console.warn(t),e(t)}))}function ht(t){return 0==(t&t-1)&&0!==t}function Rt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Tt(t){return"object"==typeof t&&!!t}function Ft(t){return t*Math.PI/180}function Pt(t){return t/Math.PI*180}function Ot(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const Lt=[1,1,1,1,2,2,3,0];function yt(t){const e=t.length;let r="";for(let n=0;n<e;){let A=t[n++];if(128&A){let r=Lt[A>>3&7];if(!(64&A)||!r||n+r>e)return null;for(A&=63>>r;r>0;r-=1){const e=t[n++];if(128!=(192&e))return null;A=A<<6|63&e}}r+=String.fromCharCode(A)}return r}const Mt=new Array(3),Nt=new Array(3),St=[40680631590769,40680631590769,40408299984661.445];const Ut=[1/6378137,1/6378137,1/6356752.314245179],dt=[1/40680631590769,1/40680631590769,1/40408299984661.445],Gt=new Array(3),mt=new Array(3),bt=new Array(3);function pt(t,e){const r=dt,n=function(t,e,r,n,A){const i=e[0],o=e[1],s=e[2],a=r[0],B=r[1],E=r[2],c=i*i*a*a,C=o*o*B*B,f=s*s*E*E,l=c+C+f,u=Math.sqrt(1/l),_=h(wt,e,u);if(l<A)return isFinite(u)?_:void 0;const I=n[0],D=n[1],R=n[2],T=Ht;T[0]=_[0]*I*2,T[1]=_[1]*D*2,T[2]=_[2]*R*2;let F,P,O,L,y,M,N,S,U,d,G,m=(1-u)*Kt(e)/(.5*Kt(T)),b=0;do{m-=b,O=1/(1+m*I),L=1/(1+m*D),y=1/(1+m*R),M=O*O,N=L*L,S=y*y,U=M*O,d=N*L,G=S*y,F=c*M+C*N+f*S-1,P=c*U*I+C*d*D+f*G*R;b=F/(-2*P)}while(Math.abs(F)>1e-12);return t[0]=i*O,t[1]=o*L,t[2]=s*y,t}(Gt,e,Ut,r,.1);let A=y(mt,n,r);A=gt(A,A);const i=L(bt,e,n),o=Math.atan2(A[1],A[0]),s=Math.asin(A[2]),a=Ot(F(i,e))*Kt(i);return t[0]=Pt(o),t[1]=Pt(s),t[2]=a,t}const wt=new Array(3),Ht=new Array(3);function Kt(t){return C(t)}function gt(t,e){const r=e[0],n=e[1],A=e[2];let i=r*r+n*n+A*A;return i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i),t}function Vt(t,e,r,n){r=r||0,n=n||r;var A=Math.abs(t-e);return A<=n||A<=r*Math.max(Math.abs(t),Math.abs(e))}function Jt(t,e){let r="";for(let n=0;n<4;n++){const A=t.getUint8(e+n);r+=String.fromCharCode(A)}return r}const vt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Xt(t,e,r){const n=new Uint8Array(t,e,r);return vt?JSON.parse(vt.decode(n)):JSON.parse(yt(n))}function Zt(t,e,r){const n=new Uint8Array(t,e,r);return vt?JSON.parse(vt.decode(n)):JSON.parse(yt(n))}function kt(t,e,r){return{offset:e,byteLength:r}}function xt(t,e,r,n){const{byteOffset:A,componentType:i,type:o}=t,{ctor:s,type:a}=function(t){return jt[t]}(i||"UNSIGNED_SHORT"),B=function(t){if(!t)return 1;return Qt[t]}(o);return{byteStride:0,byteOffset:A+r,itemSize:B,count:n*B,componentType:a,array:new s(e,r+A,n*B)}}function Wt(t,e,r,n){const A=xt(t,e,r,n);return A.array.buffer.byteLength!==e.byteLength&&(A.array=A.array.slice()),A}const Qt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const jt={"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 Yt(t){for(let e in jt)if(t===jt[e].ctor)return jt[e].type;throw new Error("unrecognized ctor:"+t)}function zt(t,e,r,n){const A=t,i=e.length/3;for(let t=0;t<i;t++)A[3*t]=e[3*t]/65535*n[0]+r[0],A[3*t+1]=e[3*t+1]/65535*n[1]+r[1],A[3*t+2]=e[3*t+2]/65535*n[2]+r[2];return A}function qt(t,e,r){let n=t.getUint32(12,!0),A=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0);const s=t.buffer;let a,B,E={},c={};n>0&&(E=Xt(s,e,n),e+=n),A>0&&(a=function(t,e,r){return{offset:e,byteLength:r}}(0,e,A),e+=A),i>0&&(c=Zt(s,e,i),e+=i);const C=kt(0,e,o);return B=s.slice(C.offset,C.offset+C.byteLength),r.push(B),{featureTable:E,featureTableBin:a,batchTable:c,batchTableBin:B}}var $t={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},te={},ee={east:[],north:[],up:[],west:[],south:[],down:[]},re=[],ne=[],Ae=[];const ie=[0,0,0];const oe=(Ee={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}}[se="east"][ae="north"],te[ce=se+ae]?Be=te[ce]:(Be=function(t,r,n){if(function(t,r){var n=t[0],A=t[1],i=t[2],o=r[0],s=r[1],a=r[2];return Math.abs(n-o)<=e*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(A-s)<=e*Math.max(1,Math.abs(A),Math.abs(s))&&Math.abs(i-a)<=e*Math.max(1,Math.abs(i),Math.abs(a))}(t,ie))l(re,$t[se]),l(ne,$t[ae]),l(Ae,$t[Ee]);else if(Vt(t[0],0,1e-14)&&Vt(t[1],0,1e-14)){var A=Ot(t[2]);l(re,$t[se]),"east"!==se&&"west"!==se&&h(re,re,A),l(ne,$t[ae]),"east"!==ae&&"west"!==ae&&h(ne,ne,A),l(Ae,$t[Ee]),"east"!==Ee&&"west"!==Ee&&h(Ae,Ae,A)}else{!function(t,e){D(e,t,dt),T(e,e)}(t,ee.up);var i=ee.up,o=ee.east;o[0]=-t[1],o[1]=t[0],o[2]=0,T(ee.east,o),P(ee.north,i,o),h(ee.down,ee.up,-1),h(ee.west,ee.east,-1),h(ee.south,ee.north,-1),re=ee[se],ne=ee[ae],Ae=ee[Ee]}return n[0]=re[0],n[1]=re[1],n[2]=re[2],n[3]=0,n[4]=ne[0],n[5]=ne[1],n[6]=ne[2],n[7]=0,n[8]=Ae[0],n[9]=Ae[1],n[10]=Ae[2],n[11]=0,n[12]=t[0],n[13]=t[1],n[14]=t[2],n[15]=1,n},te[ce]=Be),Be);var se,ae,Be,Ee,ce;const Ce={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function fe(t){return Ce[t]}function le(t){for(let e in Ce)if(t===Ce[e])return+e;throw new Error("unrecognized ctor:"+t)}function ue(t){return 1===t?"FLOAT":"VEC"+t}\n/*!\n * @maptalks/gl v0.81.0\n * LICENSE : UNLICENSED\n * (c) 2016-2023 maptalks.com\n */const _e=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")},Ie=_e(),De=Ie.gl_trans__coders=Ie.gl_trans__coders||{};De.inject=function(t){const e=t.toString(),r=e.indexOf("{")+1,n=e.substring(0,r),A=Ie.gl_trans__coders=Ie.gl_trans__coders||{};let i=`${n}\\n const _____getGlobal = ${_e.toString()};\\n const g___lobals = _____getGlobal()\\n const tran_____scoders = g___lobals[\'gl_trans__coders\'] = g___lobals[\'gl_trans__coders\'] || {};`;for(const t in A)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+=\'tran_____scoders["\'+t+\'"] =\'+A[t].toString()+"\\n;");return i+="\\n"+e.substring(n.length),i},De.registerTranscoder=function(t,e){De[t]=e},De.getTranscoder=function(t){return De[t]};let he=null;function Re(){return he||(he={"image/crn":De.crn&&De.crn(),"image/ktx2":De.ktx2&&De.ktx2(),"image/cttf":De.ktx2&&De.ktx2(),"draco":De.draco&&De.draco()}),he}class Te{constructor(t,e,r){this.A=t,this.et=e||lt,this.i=r,this.rt=Re()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,r=0,n=0,A){return e?(n||(n=e.byteLength),this.nt(t,e,r,n,A)):Y.getArrayBuffer(t,{}).then((e=>{const A=e.data;return n||(n=A.byteLength),this.nt(t,A,r,n)}))}nt(t,e,r,n,A){const i=A&&A.maxTextureSize,o=this.At(e,r,n,t);if(o.error)return Promise.resolve(o);const s=t.substring(0,t.lastIndexOf("/")),a=new this.et(s,o.glb,{transferable:!0,requestImage:this.A,decoders:this.rt,supportedFormats:this.i,maxTextureSize:i});return a.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${r}-${n}`;const A=a.transferables;for(let t=0;t<o.transferables.length;t++)A.indexOf(o.transferables[t])<0&&A.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:A,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}At(t,e,r,n){const A=new DataView(t,e,r),i=A.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+n;return console.warn(t),{error:t}}if(A.getUint32(8,!0)!==A.byteLength){const t="Length in b3dm header is inconsistent with b3dm\'s byte length, url: "+n;return console.warn(t),{error:t}}let o,s=A.getUint32(12,!0),a=A.getUint32(16,!0),B=A.getUint32(20,!0),E=A.getUint32(24,!0),c=28+e;B>=570425344?(c-=8,o=s,B=a,E=0,s=0,a=0):E>=570425344&&(c-=4,o=B,B=s,E=a,s=0,a=0);const C=[t];let f,l,u;if(s>0?(f=Xt(t,c,s),c+=s,o=f.BATCH_LENGTH):f={"BATCH_LENGTH":o},a>0&&(c+=a),B>0&&(l=Zt(t,c,B),c+=B,E>0)){const e=kt(0,c,E);u=t.slice(e.offset,e.offset+e.byteLength),c+=E,C.push(u)}const _=f.BATCH_LENGTH,I={};if(f&&f.BATCH_ID){I.BATCH_ID=Wt(f.BATCH_ID,t,undefined.offset,_);const e=I.BATCH_ID.array&&I.BATCH_ID.array.buffer;e&&C.indexOf(e)<0&&C.push(e)}return{count:o,transferables:C,featureTable:f,batchTable:l,batchTableBin:u,b3dm:I,glb:{buffer:t,byteOffset:c,byteLength:A.byteLength+A.byteOffset-c}}}it(){return null}}class Fe{constructor(t,e,r,n){this.A=t,this.et=e||lt,this.i=r,this.rt=Re(),this.ot=n}load(t,e,r=0,n=0,A){return e?(n||(n=e.byteLength),this.nt(t,e,r,n,A)):Y.getArrayBuffer(t,{}).then((e=>{const A=e.data;return n||(n=A.byteLength),this.nt(t,A,r,n)}))}nt(t,e,r,n,A){return this.st(t,e,r,n,A).then((({gltf:A,transferables:i})=>{const o=this.Bt(e,r,n,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete A.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:A})}))}st(t,e,r,n,A){const i=A&&A.maxTextureSize,o={transferable:!0,requestImage:this.A,decoders:this.rt,supportedFormats:this.i,maxTextureSize:i},s=new DataView(e,r,n),a=32+s.getUint32(12,!0)+s.getUint32(16,!0)+s.getUint32(20,!0)+s.getUint32(24,!0);if(0===s.getUint32(28,!0)){let n=yt(new Uint8Array(e,a+r,s.byteLength-a));-1==n.indexOf("://")&&(n=t.substring(0,t.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?Y.getArrayBuffer(n,{}).then((t=>this.Et(n,{buffer:t.data,byteOffset:0},o))):Y.getJSON(n,{}).then((t=>this.Et(n,t,o)))}{const n={buffer:e,byteOffset:a+r,byteLength:s.byteLength-a};return this.Et(t,n,o)}}Et(t,e,r){const n=t.substring(0,t.lastIndexOf("/")),A=new this.et(n,e,r);return A.load({skipAttributeTransform:!0}).then((r=>{let n=0,i=0;return e.buffer&&(n=e.byteOffset||0,i=e.byteLength||0),r.url=`${t}-${n}-${i}`,{transferables:A.transferables,gltf:r}}))}Bt(t,e,r,n){const A=new DataView(t,e,r),i=A.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+n;return console.warn(t),{error:t}}if(A.getUint32(8,!0)!==A.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:s,featureTableBin:a,batchTable:B,batchTableBin:E}=qt(A,32+e,o),c={},C=s.INSTANCES_LENGTH;if(s.POSITION){const{byteOffset:e}=s.POSITION;c.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:C,componentType:5126,array:new Float32Array(t,e+a.offset,3*C).slice()},o.push(c.POSITION.array.buffer)}else if(s.POSITION_QUANTIZED){const e=s.QUANTIZED_VOLUME_OFFSET,r=s.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=s.POSITION_QUANTIZED;c.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:C,componentType:5126,array:this.ct(new Uint16Array(t,n+a.offset,3*C),e,r)},o.push(c.POSITION.array.buffer)}if(s.BATCH_ID){c.BATCH_ID=Wt(s.BATCH_ID,t,a.offset,C);const e=c.BATCH_ID.array&&c.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(s.NORMAL_UP){let{byteOffset:e}=s.NORMAL_UP;c.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:C,componentType:5126,array:new Float32Array(t,e+a.offset,3*C).slice()},o.push(c.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT.byteOffset,c.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:C,componentType:5126,array:new Float32Array(t,e+a.offset,3*C).slice()},o.push(c.NORMAL_RIGHT.array.buffer)}else if(s.NORMAL_UP_OCT32P){let{byteOffset:e}=s.NORMAL_UP_OCT32P;c.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:C,componentType:5126,array:this.Ct(new Uint16Array(t,e+a.offset,2*C))},o.push(c.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT_OCT32P.byteOffset,c.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:C,componentType:5126,array:this.Ct(new Uint16Array(t,e+a.offset,2*C))},o.push(c.NORMAL_RIGHT.array.buffer)}if(s.SCALE){const{byteOffset:e}=s.SCALE;c.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:C,componentType:5126,array:new Float32Array(t,e+a.offset,C).slice()},o.push(c.SCALE.array.buffer)}else if(s.SCALE_NON_UNIFORM){const{byteOffset:e}=s.SCALE_NON_UNIFORM;c.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:C,componentType:5126,array:new Float32Array(t,e+a.offset,3*C).slice()},o.push(c.SCALE_NON_UNIFORM.array.buffer)}return{count:C,batchTable:B,batchTableBin:E,featureTable:s,i3dm:c,transferables:o}}Ct(t){const e=t.length/2,r=new Float32Array(3*e),n=[];for(let A=0;A<e;A++)Pe(n,t[2*A],t[2*A+1],65535),r[3*A]=n[0],r[3*A+1]=n[1],r[3*A+2]=n[2];return r}ct(t,e,r){return zt(new Float32Array(t.length),t,e,r)}it(){return null}}function Pe(t,e,r,n){if(t[0]=Oe(e,n),t[1]=Oe(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]))*Le(e),t[1]=(1-Math.abs(e))*Le(t[1])}return T(t,t)}function Oe(t,e){return e=function(t,e){if(null!=t)return t;return e}(e,255),function(t,e,r){return t<e?e:t>r?r:t}(t,0,e)/e*2-1}function Le(t){return t<0?-1:1}class ye{constructor(){}load(t,e,r=0,n=0){return e?(n||(n=e.byteLength),this.nt(t,e,r,n)):Y.getArrayBuffer(t,{}).then((e=>{const A=e.data;return n||(n=A.byteLength),this.nt(t,A,r,n)}))}nt(t,e,r,n){return this.ft(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}))}ft(t,e,r,n){const A=new DataView(t,e,r),i=A.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+n;return console.warn(t),{error:t}}if(A.getUint32(8,!0)!==A.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+n;return console.warn(t),{error:t}}const o=[t],{featureTable:s,featureTableBin:a,batchTable:B,batchTableBin:E}=qt(A,e+28,o),c=s.QUANTIZED_VOLUME_OFFSET,C=s.QUANTIZED_VOLUME_SCALE,f=s.POINTS_LENGTH;let l,u={};if(s.extensions&&s.extensions["3DTILES_draco_point_compression"]){u=s.extensions["3DTILES_draco_point_compression"],l=new DataView(t,u.byteOffset+a.offset,u.byteLength);const e={attributes:u.properties,useUniqueIDs:!1};return this.lt||(this.lt=Re().draco),this.lt(l,e).then((e=>{const r=e.attributes;!s.POSITION&&!s.POSITION_QUANTIZED||r.POSITION||r.POSITION_QUANTIZED||(r.POSITION=s.POSITION,r.POSITION_QUANTIZED=s.POSITION_QUANTIZED),!(s.RGB||s.RGBA||s.RGB565)||r.RGB||r.RGBA||r.RGB565||(r.RGB=s.RGB,r.RGBA=s.RGBA,r.RGB565=s.RGB565),!s.NORMAL&&!s.NORMAL_OCT16P||r.NORMAL||r.NORMAL_OCT16P||(r.NORMAL=s.NORMAL,r.NORMAL_OCT16P=s.NORMAL_OCT16P);const n=this.ut(t,e.attributes,a.offset,f,o,c,C);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:Yt(t.constructor),array:t},o.push(t.buffer)}else if(s.BATCH_ID||Object.keys(B).length){s.BATCH_ID?n.BATCH_ID=Wt(s.BATCH_ID,t,a.offset,f):n.BATCH_ID=Me(f);const e=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:f,batchTable:B,batchTableBin:E,featureTable:s,pnts:n,transferables:o}}))}const _=this.ut(t,s,a.offset,f,o,c,C);if(s.BATCH_ID||Object.keys(B).length){s.BATCH_ID?_.BATCH_ID=Wt(s.BATCH_ID,t,a.offset,f):_.BATCH_ID=Me(f);const e=_.BATCH_ID.array&&_.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:f,batchTable:B,batchTableBin:E,featureTable:s,pnts:_,transferables:o})}ut(t,e,r,n,A,i,o){const s={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const a=o?0:r;if(!o){const e=t.slice(i+a,i+a+3*n*4);o=new Float32Array(e)}s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},A.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:a,array:B}=e.POSITION_QUANTIZED;a=a||0;const E=B?0:r;s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this.ct(B||new Uint16Array(t,a+E,3*n),i,o)},A.push(s.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const a=o?0:r;if(!o){const e=t.slice(i+a,i+a+4*n);o=new Uint8Array(e)}s.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:n,componentType:5121,array:o},A.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const a=o?0:r;if(!o){const e=t.slice(i+a,i+a+3*n);o=new Uint8Array(e)}s.RGB={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5121,array:o},A.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const a=o?0:r;if(!o){const e=t.slice(i+a,i+a+2*n);o=new Uint16Array(e)}s.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:n,componentType:5123,array:o},A.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const a=o?0:r;if(!o){const e=t.slice(i+a,i+a+3*n*4);o=new Float32Array(e)}s.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:o},A.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const a=o?0:r;if(!o){const e=t.slice(i+a,i+a+2*n);o=new Uint8Array(e)}s.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:n,componentType:5121,array:o},A.push(o.buffer)}return s}ct(t,e,r){return zt(new Float32Array(t.length),t,e,r)}it(){return null}}function Me(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:Yt(e),array:n}}class Ne{constructor(t,e,r,n){this.i=r,this.A=t,this.et=e||lt,this.ot=n}load(t,e,r=0,n=0,A){return e?this.nt(t,e,r,n,A):Y.getArrayBuffer(t,{}).then((e=>{const A=e.data;return this.nt(t,A,r,n)}))}nt(t,e,r,n,A){n||(n=e.byteLength);const i=this._t(e,t,r,n),o=[];for(let r=0;r<i.length;r++){let n;if("b3dm"===i[r].magic)n=new Te(this.A,this.et,this.i);else if("i3dm"===i[r].magic)n=new Fe(this.A,this.et,this.i,this.ot);else if("pnts"===i[r].magic)n=new ye;else{if("cmpt"!==i[r].magic){console.warn("Unsupported magic in CMPT tile:",i[r].magic);continue}n=new Ne(this.A,this.et,this.i,this.ot)}o.push(n.load(t,e,i[r].offset,i[r].byteLength,A).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}_t(t,e,r,n){const A=new DataView(t,r,n),i=A.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===A.byteLength)return[];const o=[],s=A.getUint32(12,!0);let a=16;for(let e=0;e<s;e++){const e=Jt(A,a),n=A.getUint32(a+8,!0);o.push({magic:e,buffer:t,offset:a+r,byteLength:n}),a+=n}return o}}function Se(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,A=n.length;r<A;r++){const A=[];we(n[r],A,t,e)}}}const Ue=[],de=[],Ge=[],me=[0,0,0],be=U([]),pe=[1,1,1];function we(t,e,r,n){const A=e.slice(0);if(t.matrix)A.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=s(Ue,t.translation||me),r=B(de,t.rotation||be),n=a(Ge,t.scale||pe);o(n,r,n);const i=o([],e,n);A.push(i)}if(t.children&&t.children.length)for(let e=0,i=t.children.length;e<i;e++)we(t.children[e],A,r,n);if(void 0!==t.mesh){const e=t.mesh,i=r.meshes[e];if(i){const t=A.slice(0),o=i.primitives;for(let A=0,i=o.length;A<i;A++){const i=o[A];i&&(i.matrices=t,n(i,e,A,r))}}}}function He(t,e){let{componentType:r,byteOffset:n,byteStride:A,count:i,itemSize:o}=t;const s=t.array.buffer,a=r?lt.getTypedArrayCtor(r):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,A=A||0,i=i||t.array.length/o,(!A||A===o*a.BYTES_PER_ELEMENT)&&n%a.BYTES_PER_ELEMENT==0){const t=new a(s,n,i*o);for(let r=0;r<i*o;r+=o){e(new a(t.buffer,n+r*a.BYTES_PER_ELEMENT,o),r/o)}return}const B=new Uint8Array(o*a.BYTES_PER_ELEMENT);A||(A=o*a.BYTES_PER_ELEMENT);for(let t=0;t<i;t++){const r=new Uint8Array(s,A*t+n,o*a.BYTES_PER_ELEMENT);B.set(r);e(new a(B.buffer),t),r.set(B)}}const Ke=[],ge=[];function Ve(t){"3.0"===t.version&&(t=function(t){const e=JSON.parse(JSON.stringify(t)),r=e.rootTiles;for(let t=0;t<r.length;t++){const{boundingbox:e}=r[t],{center:n,xExtent:A,yExtent:i,zExtent:o}=e,s={x:2*n.x-A.x,y:2*n.y-i.y,z:2*n.z-o.z},a={x:A.x,y:i.y,z:o.z};e.min=s,e.max=a}return e.tiles=r,e}(t));const e={asset:{version:"1.0",gltfUpAxis:"Z",s3mType:t.dataType},extensions:t.extensions,geometricError:0,root:{boundingVolume:{},content:{uri:""},transform:[],geometricError:0,refine:"REPLACE",children:[]}},r=t.position.x,n=t.position.y,i=t.position.z,o=function(t,e,r,n){const A=St,i=Math.cos(r);Mt[0]=i*Math.cos(e),Mt[1]=i*Math.sin(e),Mt[2]=Math.sin(r),gt(Mt,Mt),D(Nt,A,Mt);const o=Math.sqrt(F(Mt,Nt));var s,a,B;return a=Nt,B=o,(s=Nt)[0]=a[0]/B,s[1]=a[1]/B,s[2]=a[2]/B,h(Mt,Mt,n),_(t,Nt,Mt)}([],Ft(r),Ft(n),i),s=oe(o,null,[]);e.root.transform=A([],s);const a=[];for(let r=0,n=t.tiles.length;r<n;r++)if(t.tiles[r].boundingbox){const n=t.tiles[r].boundingbox;u(Ke,n.min.x,n.min.y,n.min.z),u(ge,n.max.x,n.max.y,n.max.z);const A={center:[0,0,0],radius:0};Je(Ke,ge,A),e.root.children.push({boundingVolume:{sphere:[...A.center,A.radius]},content:{uri:t.tiles[r].url},geometricError:70,refine:"REPLACE"}),a.push(A)}else if(t.tiles[r].boundingsphere){const{boundingsphere:n}=t.tiles[r],A={center:[n.center.x,n.center.y,n.center.z],radius:n.radius};e.root.children.push({boundingVolume:{sphere:[...A.center,A.radius]},content:{uri:t.tiles[r].url},geometricError:70,refine:"REPLACE"}),a.push(A)}const B=function(t,e){if(0===t.length)return e;const r=t.length;if(1===r)return function(t,e){return l(e.center,t.center),e.radius=t.radius,e}(t[0],e);if(2===r)return function(t,e,r){const n=t.center,A=t.radius,i=e.center,o=e.radius,s=I(Xe,i,n),a=Ar(s);if(A>=a+o)return t.clone(r),r;if(o>=a+A)return e.clone(r),r;const B=.5*(A+a+o),E=h(Ze,s,(-A+B)/a);return _(E,E,n),l(r.center,E),r.radius=B,r}(t[0],t[1],e);const n=[];for(let e=0;e<r;e++)n.push(t[e].center);const A=(e=function(t,e){if(0===t.length)return e.center=u(e.center,0,0,0),e.radius=0,e;const r=l(ze,t[0]),n=l(ke,r),A=l(xe,r),i=l(We,r),o=l(Qe,r),s=l(je,r),a=l(Ye,r),B=t.length;for(let e=1;e<B;e++){l(r,t[e]);const B=r[0],E=r[1],c=r[2];B<n[0]&&l(n,r),B>o[0]&&l(o,r),E<A[1]&&l(A,r),E>s[1]&&l(s,r),c<i[2]&&l(i,r),c>a[2]&&l(a,r)}const E=nr(I(qe,o,n)),c=nr(I(qe,s,A)),C=nr(I(qe,a,i));let f=n,_=o,D=E;c>D&&(D=c,f=A,_=s);C>D&&(D=C,f=i,_=a);const h=$e;h[0]=.5*(f[0]+_[0]),h[1]=.5*(f[1]+_[1]),h[2]=.5*(f[2]+_[2]);let R=nr(I(qe,_,h)),T=Math.sqrt(R);const F=tr;F[0]=n[0],F[1]=A[1],F[2]=i[2];const P=er;P[0]=o[0],P[1]=s[1],P[2]=a[2];const O=ve(F,P,rr);let L=0;for(let e=0;e<B;e++){l(r,t[e]);const n=Ar(I(qe,r,O));n>L&&(L=n);const A=nr(I(qe,r,h));if(A>R){const t=Math.sqrt(A);T=.5*(T+t),R=T*T;const e=t-T;h[0]=(T*h[0]+e*r[0])/t,h[1]=(T*h[1]+e*r[1])/t,h[2]=(T*h[2]+e*r[2])/t}}T<L?(l(e.center,h),e.radius=T):(l(e.center,O),e.radius=L);return e}(n,e)).center;let i=e.radius;for(let e=0;e<r;e++){const r=t[e];i=Math.max(i,R(A,r.center)+r.radius)}return e.radius=i,e}(a,{center:[0,0,0],radius:0});return e.root.boundingVolume.sphere=[...B.center,B.radius],e}function Je(t,e,r){var n=ve(t,e,r.center);return r.radius=R(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 Xe=[],Ze=[];const ke=[],xe=[],We=[],Qe=[],je=[],Ye=[],ze=[],qe=[],$e=[],tr=[],er=[],rr=[];function nr(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function Ar(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 ir(t){let e=t.length;for(;--e>=0;)t[e]=0}const or=256,sr=286,ar=30,Br=15,Er=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]),cr=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]),Cr=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),fr=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lr=new Array(576);ir(lr);const ur=new Array(60);ir(ur);const _r=new Array(512);ir(_r);const Ir=new Array(256);ir(Ir);const Dr=new Array(29);ir(Dr);const hr=new Array(ar);function Rr(t,e,r,n,A){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=A,this.has_stree=t&&t.length}let Tr,Fr,Pr;function Or(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}ir(hr);const Lr=t=>t<256?_r[t]:_r[256+(t>>>7)],yr=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},Mr=(t,e,r)=>{t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,yr(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)},Nr=(t,e,r)=>{Mr(t,r[2*e],r[2*e+1])},Sr=(t,e)=>{let r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1},Ur=(t,e,r)=>{const n=new Array(16);let A,i,o=0;for(A=1;A<=Br;A++)n[A]=o=o+r[A-1]<<1;for(i=0;i<=e;i++){let e=t[2*i+1];0!==e&&(t[2*i]=Sr(n[e]++,e))}},dr=t=>{let e;for(e=0;e<sr;e++)t.dyn_ltree[2*e]=0;for(e=0;e<ar;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},Gr=t=>{t.bi_valid>8?yr(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},mr=(t,e,r,n)=>{const A=2*e,i=2*r;return t[A]<t[i]||t[A]===t[i]&&n[e]<=n[r]},br=(t,e,r)=>{const n=t.heap[r];let A=r<<1;for(;A<=t.heap_len&&(A<t.heap_len&&mr(e,t.heap[A+1],t.heap[A],t.depth)&&A++,!mr(e,n,t.heap[A],t.depth));)t.heap[r]=t.heap[A],r=A,A<<=1;t.heap[r]=n},pr=(t,e,r)=>{let n,A,i,o,s=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*s]<<8|t.pending_buf[t.d_buf+2*s+1],A=t.pending_buf[t.l_buf+s],s++,0===n?Nr(t,A,e):(i=Ir[A],Nr(t,i+or+1,e),o=Er[i],0!==o&&(A-=Dr[i],Mr(t,A,o)),n--,i=Lr(n),Nr(t,i,r),o=cr[i],0!==o&&(n-=hr[i],Mr(t,n,o)))}while(s<t.last_lit);Nr(t,256,e)},wr=(t,e)=>{const r=e.dyn_tree,n=e.stat_desc.static_tree,A=e.stat_desc.has_stree,i=e.stat_desc.elems;let o,s,a,B=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<i;o++)0!==r[2*o]?(t.heap[++t.heap_len]=B=o,t.depth[o]=0):r[2*o+1]=0;for(;t.heap_len<2;)a=t.heap[++t.heap_len]=B<2?++B:0,r[2*a]=1,t.depth[a]=0,t.opt_len--,A&&(t.static_len-=n[2*a+1]);for(e.max_code=B,o=t.heap_len>>1;o>=1;o--)br(t,r,o);a=i;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],br(t,r,1),s=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=s,r[2*a]=r[2*o]+r[2*s],t.depth[a]=(t.depth[o]>=t.depth[s]?t.depth[o]:t.depth[s])+1,r[2*o+1]=r[2*s+1]=a,t.heap[1]=a++,br(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,A=e.stat_desc.static_tree,i=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,s=e.stat_desc.extra_base,a=e.stat_desc.max_length;let B,E,c,C,f,l,u=0;for(C=0;C<=Br;C++)t.bl_count[C]=0;for(r[2*t.heap[t.heap_max]+1]=0,B=t.heap_max+1;B<573;B++)E=t.heap[B],C=r[2*r[2*E+1]+1]+1,C>a&&(C=a,u++),r[2*E+1]=C,E>n||(t.bl_count[C]++,f=0,E>=s&&(f=o[E-s]),l=r[2*E],t.opt_len+=l*(C+f),i&&(t.static_len+=l*(A[2*E+1]+f)));if(0!==u){do{for(C=a-1;0===t.bl_count[C];)C--;t.bl_count[C]--,t.bl_count[C+1]+=2,t.bl_count[a]--,u-=2}while(u>0);for(C=a;0!==C;C--)for(E=t.bl_count[C];0!==E;)c=t.heap[--B],c>n||(r[2*c+1]!==C&&(t.opt_len+=(C-r[2*c+1])*r[2*c],r[2*c+1]=C),E--)}})(t,e),Ur(r,B,t.bl_count)},Hr=(t,e,r)=>{let n,A,i=-1,o=e[1],s=0,a=7,B=4;for(0===o&&(a=138,B=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)A=o,o=e[2*(n+1)+1],++s<a&&A===o||(s<B?t.bl_tree[2*A]+=s:0!==A?(A!==i&&t.bl_tree[2*A]++,t.bl_tree[32]++):s<=10?t.bl_tree[34]++:t.bl_tree[36]++,s=0,i=A,0===o?(a=138,B=3):A===o?(a=6,B=3):(a=7,B=4))},Kr=(t,e,r)=>{let n,A,i=-1,o=e[1],s=0,a=7,B=4;for(0===o&&(a=138,B=3),n=0;n<=r;n++)if(A=o,o=e[2*(n+1)+1],!(++s<a&&A===o)){if(s<B)do{Nr(t,A,t.bl_tree)}while(0!=--s);else 0!==A?(A!==i&&(Nr(t,A,t.bl_tree),s--),Nr(t,16,t.bl_tree),Mr(t,s-3,2)):s<=10?(Nr(t,17,t.bl_tree),Mr(t,s-3,3)):(Nr(t,18,t.bl_tree),Mr(t,s-11,7));s=0,i=A,0===o?(a=138,B=3):A===o?(a=6,B=3):(a=7,B=4)}};let gr=!1;const Vr=(t,e,r,n)=>{Mr(t,0+(n?1:0),3),((t,e,r,n)=>{Gr(t),n&&(yr(t,r),yr(t,~r)),t.pending_buf.set(t.window.subarray(e,e+r),t.pending),t.pending+=r})(t,e,r,!0)};var Jr=t=>{gr||((()=>{let t,e,r,n,A;const i=new Array(16);for(r=0,n=0;n<28;n++)for(Dr[n]=r,t=0;t<1<<Er[n];t++)Ir[r++]=n;for(Ir[r-1]=n,A=0,n=0;n<16;n++)for(hr[n]=A,t=0;t<1<<cr[n];t++)_r[A++]=n;for(A>>=7;n<ar;n++)for(hr[n]=A<<7,t=0;t<1<<cr[n]-7;t++)_r[256+A++]=n;for(e=0;e<=Br;e++)i[e]=0;for(t=0;t<=143;)lr[2*t+1]=8,t++,i[8]++;for(;t<=255;)lr[2*t+1]=9,t++,i[9]++;for(;t<=279;)lr[2*t+1]=7,t++,i[7]++;for(;t<=287;)lr[2*t+1]=8,t++,i[8]++;for(Ur(lr,287,i),t=0;t<ar;t++)ur[2*t+1]=5,ur[2*t]=Sr(t,5);Tr=new Rr(lr,Er,257,sr,Br),Fr=new Rr(ur,cr,0,ar,Br),Pr=new Rr(new Array(0),Cr,0,19,7)})(),gr=!0),t.l_desc=new Or(t.dyn_ltree,Tr),t.d_desc=new Or(t.dyn_dtree,Fr),t.bl_desc=new Or(t.bl_tree,Pr),t.bi_buf=0,t.bi_valid=0,dr(t)},vr=(t,e,r,n)=>{let A,i,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<or;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(Hr(t,t.dyn_ltree,t.l_desc.max_code),Hr(t,t.dyn_dtree,t.d_desc.max_code),wr(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*fr[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),A=t.opt_len+3+7>>>3,i=t.static_len+3+7>>>3,i<=A&&(A=i)):A=i=r+5,r+4<=A&&-1!==e?Vr(t,e,r,n):4===t.strategy||i===A?(Mr(t,2+(n?1:0),3),pr(t,lr,ur)):(Mr(t,4+(n?1:0),3),((t,e,r,n)=>{let A;for(Mr(t,e-257,5),Mr(t,r-1,5),Mr(t,n-4,4),A=0;A<n;A++)Mr(t,t.bl_tree[2*fr[A]+1],3);Kr(t,t.dyn_ltree,e-1),Kr(t,t.dyn_dtree,r-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),pr(t,t.dyn_ltree,t.dyn_dtree)),dr(t),n&&Gr(t)},Xr={It:Jr,Dt:Vr,ht:vr,Rt:(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*(Ir[r]+or+1)]++,t.dyn_dtree[2*Lr(e)]++),t.last_lit===t.lit_bufsize-1),Tt:t=>{Mr(t,2,3),Nr(t,256,lr),(t=>{16===t.bi_valid?(yr(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 Zr=(t,e,r,n)=>{let A=65535&t|0,i=t>>>16&65535|0,o=0;for(;0!==r;){o=r>2e3?2e3:r,r-=o;do{A=A+e[n++]|0,i=i+A|0}while(--o);A%=65521,i%=65521}return A|i<<16|0};const kr=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 xr=(t,e,r,n)=>{const A=kr,i=n+r;t^=-1;for(let r=n;r<i;r++)t=t>>>8^A[255&(t^e[r])];return-1^t},Wr={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"},Qr={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{It:jr,Dt:Yr,ht:zr,Rt:qr,Tt:$r}=Xr,{Z_NO_FLUSH:tn,Z_PARTIAL_FLUSH:en,Z_FULL_FLUSH:rn,Z_FINISH:nn,Z_BLOCK:An,Z_OK:on,Z_STREAM_END:sn,Z_STREAM_ERROR:an,Z_DATA_ERROR:Bn,Z_BUF_ERROR:En,Z_DEFAULT_COMPRESSION:cn,Z_FILTERED:Cn,Z_HUFFMAN_ONLY:fn,Z_RLE:ln,Z_FIXED:un,Z_DEFAULT_STRATEGY:_n,Z_UNKNOWN:In,Z_DEFLATED:Dn}=Qr,hn=258,Rn=262,Tn=103,Fn=113,Pn=666,On=(t,e)=>(t.msg=Wr[e],e),Ln=t=>(t<<1)-(t>4?9:0),yn=t=>{let e=t.length;for(;--e>=0;)t[e]=0};let Mn=(t,e,r)=>(e<<t.hash_shift^r)&t.hash_mask;const Nn=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))},Sn=(t,e)=>{zr(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,Nn(t.strm)},Un=(t,e)=>{t.pending_buf[t.pending++]=e},dn=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Gn=(t,e,r,n)=>{let A=t.avail_in;return A>n&&(A=n),0===A?0:(t.avail_in-=A,e.set(t.input.subarray(t.next_in,t.next_in+A),r),1===t.state.wrap?t.adler=Zr(t.adler,e,A,r):2===t.state.wrap&&(t.adler=xr(t.adler,e,A,r)),t.next_in+=A,t.total_in+=A,A)},mn=(t,e)=>{let r,n,A=t.max_chain_length,i=t.strstart,o=t.prev_length,s=t.nice_match;const a=t.strstart>t.w_size-Rn?t.strstart-(t.w_size-Rn):0,B=t.window,E=t.w_mask,c=t.prev,C=t.strstart+hn;let f=B[i+o-1],l=B[i+o];t.prev_length>=t.good_match&&(A>>=2),s>t.lookahead&&(s=t.lookahead);do{if(r=e,B[r+o]===l&&B[r+o-1]===f&&B[r]===B[i]&&B[++r]===B[i+1]){i+=2,r++;do{}while(B[++i]===B[++r]&&B[++i]===B[++r]&&B[++i]===B[++r]&&B[++i]===B[++r]&&B[++i]===B[++r]&&B[++i]===B[++r]&&B[++i]===B[++r]&&B[++i]===B[++r]&&i<C);if(n=hn-(C-i),i=C-hn,n>o){if(t.match_start=e,o=n,n>=s)break;f=B[i+o-1],l=B[i+o]}}}while((e=c[e&E])>a&&0!=--A);return o<=t.lookahead?o:t.lookahead},bn=t=>{const e=t.w_size;let r,n,A,i,o;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-Rn)){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{A=t.head[--r],t.head[r]=A>=e?A-e:0}while(--n);n=e,r=n;do{A=t.prev[--r],t.prev[r]=A>=e?A-e:0}while(--n);i+=e}if(0===t.strm.avail_in)break;if(n=Gn(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=n,t.lookahead+t.insert>=3)for(o=t.strstart-t.insert,t.ins_h=t.window[o],t.ins_h=Mn(t,t.ins_h,t.window[o+1]);t.insert&&(t.ins_h=Mn(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<Rn&&0!==t.strm.avail_in)},pn=(t,e)=>{let r,n;for(;;){if(t.lookahead<Rn){if(bn(t),t.lookahead<Rn&&e===tn)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=Mn(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-Rn&&(t.match_length=mn(t,r)),t.match_length>=3)if(n=qr(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=Mn(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=Mn(t,t.ins_h,t.window[t.strstart+1]);else n=qr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(Sn(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===nn?(Sn(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Sn(t,!1),0===t.strm.avail_out)?1:2},wn=(t,e)=>{let r,n,A;for(;;){if(t.lookahead<Rn){if(bn(t),t.lookahead<Rn&&e===tn)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=Mn(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-Rn&&(t.match_length=mn(t,r),t.match_length<=5&&(t.strategy===Cn||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){A=t.strstart+t.lookahead-3,n=qr(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=A&&(t.ins_h=Mn(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&&(Sn(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(n=qr(t,0,t.window[t.strstart-1]),n&&Sn(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=qr(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===nn?(Sn(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Sn(t,!1),0===t.strm.avail_out)?1:2};function Hn(t,e,r,n,A){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=A}const Kn=[new Hn(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(bn(t),0===t.lookahead&&e===tn)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,Sn(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-Rn&&(Sn(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===nn?(Sn(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(Sn(t,!1),t.strm.avail_out),1)})),new Hn(4,4,8,4,pn),new Hn(4,5,16,8,pn),new Hn(4,6,32,32,pn),new Hn(4,4,16,16,wn),new Hn(8,16,32,32,wn),new Hn(8,16,128,128,wn),new Hn(8,32,128,256,wn),new Hn(32,128,258,1024,wn),new Hn(32,258,258,4096,wn)];function gn(){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=Dn,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),yn(this.dyn_ltree),yn(this.dyn_dtree),yn(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),yn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),yn(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 Vn=t=>{if(!t||!t.state)return On(t,an);t.total_in=t.total_out=0,t.data_type=In;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:Fn,t.adler=2===e.wrap?0:1,e.last_flush=tn,jr(e),on},Jn=t=>{const e=Vn(t);var r;return e===on&&((r=t.state).window_size=2*r.w_size,yn(r.head),r.max_lazy_match=Kn[r.level].max_lazy,r.good_match=Kn[r.level].good_length,r.nice_match=Kn[r.level].nice_length,r.max_chain_length=Kn[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,A,i)=>{if(!t)return an;let o=1;if(e===cn&&(e=6),n<0?(o=0,n=-n):n>15&&(o=2,n-=16),A<1||A>9||r!==Dn||n<8||n>15||e<0||e>9||i<0||i>un)return On(t,an);8===n&&(n=9);const s=new gn;return t.state=s,s.strm=t,s.wrap=o,s.gzhead=null,s.w_bits=n,s.w_size=1<<s.w_bits,s.w_mask=s.w_size-1,s.hash_bits=A+7,s.hash_size=1<<s.hash_bits,s.hash_mask=s.hash_size-1,s.hash_shift=~~((s.hash_bits+3-1)/3),s.window=new Uint8Array(2*s.w_size),s.head=new Uint16Array(s.hash_size),s.prev=new Uint16Array(s.w_size),s.lit_bufsize=1<<A+6,s.pending_buf_size=4*s.lit_bufsize,s.pending_buf=new Uint8Array(s.pending_buf_size),s.d_buf=1*s.lit_bufsize,s.l_buf=3*s.lit_bufsize,s.level=e,s.strategy=i,s.method=r,Jn(t)};var Xn=(t,e)=>{let r=e.length;if(!t||!t.state)return an;const n=t.state,A=n.wrap;if(2===A||1===A&&42!==n.status||n.lookahead)return an;if(1===A&&(t.adler=Zr(t.adler,e,r,0)),n.wrap=0,r>=n.w_size){0===A&&(yn(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 i=t.avail_in,o=t.next_in,s=t.input;for(t.avail_in=r,t.next_in=0,t.input=e,bn(n);n.lookahead>=3;){let t=n.strstart,e=n.lookahead-2;do{n.ins_h=Mn(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,bn(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=s,t.avail_in=i,n.wrap=A,on},Zn={deflateInit:(t,e)=>vn(t,e,Dn,15,8,_n),deflateInit2:vn,deflateReset:Jn,deflateResetKeep:Vn,deflateSetHeader:(t,e)=>t&&t.state?2!==t.state.wrap?an:(t.state.gzhead=e,on):an,deflate:(t,e)=>{let r,n;if(!t||!t.state||e>An||e<0)return t?On(t,an):an;const A=t.state;if(!t.output||!t.input&&0!==t.avail_in||A.status===Pn&&e!==nn)return On(t,0===t.avail_out?En:an);A.strm=t;const i=A.last_flush;if(A.last_flush=e,42===A.status)if(2===A.wrap)t.adler=0,Un(A,31),Un(A,139),Un(A,8),A.gzhead?(Un(A,(A.gzhead.text?1:0)+(A.gzhead.hcrc?2:0)+(A.gzhead.extra?4:0)+(A.gzhead.name?8:0)+(A.gzhead.comment?16:0)),Un(A,255&A.gzhead.time),Un(A,A.gzhead.time>>8&255),Un(A,A.gzhead.time>>16&255),Un(A,A.gzhead.time>>24&255),Un(A,9===A.level?2:A.strategy>=fn||A.level<2?4:0),Un(A,255&A.gzhead.os),A.gzhead.extra&&A.gzhead.extra.length&&(Un(A,255&A.gzhead.extra.length),Un(A,A.gzhead.extra.length>>8&255)),A.gzhead.hcrc&&(t.adler=xr(t.adler,A.pending_buf,A.pending,0)),A.gzindex=0,A.status=69):(Un(A,0),Un(A,0),Un(A,0),Un(A,0),Un(A,0),Un(A,9===A.level?2:A.strategy>=fn||A.level<2?4:0),Un(A,3),A.status=Fn);else{let e=Dn+(A.w_bits-8<<4)<<8,r=-1;r=A.strategy>=fn||A.level<2?0:A.level<6?1:6===A.level?2:3,e|=r<<6,0!==A.strstart&&(e|=32),e+=31-e%31,A.status=Fn,dn(A,e),0!==A.strstart&&(dn(A,t.adler>>>16),dn(A,65535&t.adler)),t.adler=1}if(69===A.status)if(A.gzhead.extra){for(r=A.pending;A.gzindex<(65535&A.gzhead.extra.length)&&(A.pending!==A.pending_buf_size||(A.gzhead.hcrc&&A.pending>r&&(t.adler=xr(t.adler,A.pending_buf,A.pending-r,r)),Nn(t),r=A.pending,A.pending!==A.pending_buf_size));)Un(A,255&A.gzhead.extra[A.gzindex]),A.gzindex++;A.gzhead.hcrc&&A.pending>r&&(t.adler=xr(t.adler,A.pending_buf,A.pending-r,r)),A.gzindex===A.gzhead.extra.length&&(A.gzindex=0,A.status=73)}else A.status=73;if(73===A.status)if(A.gzhead.name){r=A.pending;do{if(A.pending===A.pending_buf_size&&(A.gzhead.hcrc&&A.pending>r&&(t.adler=xr(t.adler,A.pending_buf,A.pending-r,r)),Nn(t),r=A.pending,A.pending===A.pending_buf_size)){n=1;break}n=A.gzindex<A.gzhead.name.length?255&A.gzhead.name.charCodeAt(A.gzindex++):0,Un(A,n)}while(0!==n);A.gzhead.hcrc&&A.pending>r&&(t.adler=xr(t.adler,A.pending_buf,A.pending-r,r)),0===n&&(A.gzindex=0,A.status=91)}else A.status=91;if(91===A.status)if(A.gzhead.comment){r=A.pending;do{if(A.pending===A.pending_buf_size&&(A.gzhead.hcrc&&A.pending>r&&(t.adler=xr(t.adler,A.pending_buf,A.pending-r,r)),Nn(t),r=A.pending,A.pending===A.pending_buf_size)){n=1;break}n=A.gzindex<A.gzhead.comment.length?255&A.gzhead.comment.charCodeAt(A.gzindex++):0,Un(A,n)}while(0!==n);A.gzhead.hcrc&&A.pending>r&&(t.adler=xr(t.adler,A.pending_buf,A.pending-r,r)),0===n&&(A.status=Tn)}else A.status=Tn;if(A.status===Tn&&(A.gzhead.hcrc?(A.pending+2>A.pending_buf_size&&Nn(t),A.pending+2<=A.pending_buf_size&&(Un(A,255&t.adler),Un(A,t.adler>>8&255),t.adler=0,A.status=Fn)):A.status=Fn),0!==A.pending){if(Nn(t),0===t.avail_out)return A.last_flush=-1,on}else if(0===t.avail_in&&Ln(e)<=Ln(i)&&e!==nn)return On(t,En);if(A.status===Pn&&0!==t.avail_in)return On(t,En);if(0!==t.avail_in||0!==A.lookahead||e!==tn&&A.status!==Pn){let r=A.strategy===fn?((t,e)=>{let r;for(;;){if(0===t.lookahead&&(bn(t),0===t.lookahead)){if(e===tn)return 1;break}if(t.match_length=0,r=qr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(Sn(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===nn?(Sn(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Sn(t,!1),0===t.strm.avail_out)?1:2})(A,e):A.strategy===ln?((t,e)=>{let r,n,A,i;const o=t.window;for(;;){if(t.lookahead<=hn){if(bn(t),t.lookahead<=hn&&e===tn)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(A=t.strstart-1,n=o[A],n===o[++A]&&n===o[++A]&&n===o[++A])){i=t.strstart+hn;do{}while(n===o[++A]&&n===o[++A]&&n===o[++A]&&n===o[++A]&&n===o[++A]&&n===o[++A]&&n===o[++A]&&n===o[++A]&&A<i);t.match_length=hn-(i-A),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=qr(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=qr(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(Sn(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===nn?(Sn(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(Sn(t,!1),0===t.strm.avail_out)?1:2})(A,e):Kn[A.level].func(A,e);if(3!==r&&4!==r||(A.status=Pn),1===r||3===r)return 0===t.avail_out&&(A.last_flush=-1),on;if(2===r&&(e===en?$r(A):e!==An&&(Yr(A,0,0,!1),e===rn&&(yn(A.head),0===A.lookahead&&(A.strstart=0,A.block_start=0,A.insert=0))),Nn(t),0===t.avail_out))return A.last_flush=-1,on}return e!==nn?on:A.wrap<=0?sn:(2===A.wrap?(Un(A,255&t.adler),Un(A,t.adler>>8&255),Un(A,t.adler>>16&255),Un(A,t.adler>>24&255),Un(A,255&t.total_in),Un(A,t.total_in>>8&255),Un(A,t.total_in>>16&255),Un(A,t.total_in>>24&255)):(dn(A,t.adler>>>16),dn(A,65535&t.adler)),Nn(t),A.wrap>0&&(A.wrap=-A.wrap),0!==A.pending?on:sn)},deflateEnd:t=>{if(!t||!t.state)return an;const e=t.state.status;return 42!==e&&69!==e&&73!==e&&91!==e&&e!==Tn&&e!==Fn&&e!==Pn?On(t,an):(t.state=null,e===Fn?On(t,Bn):on)},deflateSetDictionary:Xn,deflateInfo:"pako deflate (from Nodeca project)"};const kn=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var xn=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)kn(r,e)&&(t[e]=r[e])}}return t},Wn=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,A=t.length;e<A;e++){let A=t[e];r.set(A,n),n+=A.length}return r};let Qn=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Qn=!1}const jn=new Uint8Array(256);for(let t=0;t<256;t++)jn[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;jn[254]=jn[254]=1;var Yn=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,r,n,A,i,o=t.length,s=0;for(A=0;A<o;A++)r=t.charCodeAt(A),55296==(64512&r)&&A+1<o&&(n=t.charCodeAt(A+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),A++)),s+=r<128?1:r<2048?2:r<65536?3:4;for(e=new Uint8Array(s),i=0,A=0;i<s;A++)r=t.charCodeAt(A),55296==(64512&r)&&A+1<o&&(n=t.charCodeAt(A+1),56320==(64512&n)&&(r=65536+(r-55296<<10)+(n-56320),A++)),r<128?e[i++]=r:r<2048?(e[i++]=192|r>>>6,e[i++]=128|63&r):r<65536?(e[i++]=224|r>>>12,e[i++]=128|r>>>6&63,e[i++]=128|63&r):(e[i++]=240|r>>>18,e[i++]=128|r>>>12&63,e[i++]=128|r>>>6&63,e[i++]=128|63&r);return e},zn=(t,e)=>{const r=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let n,A;const i=new Array(2*r);for(A=0,n=0;n<r;){let e=t[n++];if(e<128){i[A++]=e;continue}let o=jn[e];if(o>4)i[A++]=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?i[A++]=65533:e<65536?i[A++]=e:(e-=65536,i[A++]=55296|e>>10&1023,i[A++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Qn)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})(i,A)},qn=(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+jn[t[r]]>e?r:e};var $n=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 tA=Object.prototype.toString,{Z_NO_FLUSH:eA,Z_SYNC_FLUSH:rA,Z_FULL_FLUSH:nA,Z_FINISH:AA,Z_OK:iA,Z_STREAM_END:oA,Z_DEFAULT_COMPRESSION:sA,Z_DEFAULT_STRATEGY:aA,Z_DEFLATED:BA}=Qr;function EA(t){this.options=xn({level:sA,method:BA,chunkSize:16384,windowBits:15,memLevel:8,strategy:aA},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 $n,this.strm.avail_out=0;let r=Zn.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(r!==iA)throw new Error(Wr[r]);if(e.header&&Zn.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Yn(e.dictionary):"[object ArrayBuffer]"===tA.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,r=Zn.deflateSetDictionary(this.strm,t),r!==iA)throw new Error(Wr[r]);this.Ft=!0}}function cA(t,e){const r=new EA(e);if(r.push(t,!0),r.err)throw r.msg||Wr[r.err];return r.result}EA.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize;let A,i;if(this.ended)return!1;for(i=e===~~e?e:!0===e?AA:eA,"string"==typeof t?r.input=Yn(t):"[object ArrayBuffer]"===tA.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),(i===rA||i===nA)&&r.avail_out<=6)this.onData(r.output.subarray(0,r.next_out)),r.avail_out=0;else{if(A=Zn.deflate(r,i),A===oA)return r.next_out>0&&this.onData(r.output.subarray(0,r.next_out)),A=Zn.deflateEnd(this.strm),this.onEnd(A),this.ended=!0,A===iA;if(0!==r.avail_out){if(i>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},EA.prototype.onData=function(t){this.chunks.push(t)},EA.prototype.onEnd=function(t){t===iA&&(this.result=Wn(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var CA={Deflate:EA,deflate:cA,deflateRaw:function(t,e){return(e=e||{}).raw=!0,cA(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,cA(t,e)},constants:Qr};var fA=function(t,e){let r,n,A,i,o,s,a,B,E,c,C,f,l,u,_,I,D,h,R,T,F,P,O,L;const y=t.state;r=t.next_in,O=t.input,n=r+(t.avail_in-5),A=t.next_out,L=t.output,i=A-(e-t.avail_out),o=A+(t.avail_out-257),s=y.dmax,a=y.wsize,B=y.whave,E=y.wnext,c=y.window,C=y.hold,f=y.bits,l=y.lencode,u=y.distcode,_=(1<<y.lenbits)-1,I=(1<<y.distbits)-1;t:do{f<15&&(C+=O[r++]<<f,f+=8,C+=O[r++]<<f,f+=8),D=l[C&_];e:for(;;){if(h=D>>>24,C>>>=h,f-=h,h=D>>>16&255,0===h)L[A++]=65535&D;else{if(!(16&h)){if(0==(64&h)){D=l[(65535&D)+(C&(1<<h)-1)];continue e}if(32&h){y.mode=12;break t}t.msg="invalid literal/length code",y.mode=30;break t}R=65535&D,h&=15,h&&(f<h&&(C+=O[r++]<<f,f+=8),R+=C&(1<<h)-1,C>>>=h,f-=h),f<15&&(C+=O[r++]<<f,f+=8,C+=O[r++]<<f,f+=8),D=u[C&I];r:for(;;){if(h=D>>>24,C>>>=h,f-=h,h=D>>>16&255,!(16&h)){if(0==(64&h)){D=u[(65535&D)+(C&(1<<h)-1)];continue r}t.msg="invalid distance code",y.mode=30;break t}if(T=65535&D,h&=15,f<h&&(C+=O[r++]<<f,f+=8,f<h&&(C+=O[r++]<<f,f+=8)),T+=C&(1<<h)-1,T>s){t.msg="invalid distance too far back",y.mode=30;break t}if(C>>>=h,f-=h,h=A-i,T>h){if(h=T-h,h>B&&y.sane){t.msg="invalid distance too far back",y.mode=30;break t}if(F=0,P=c,0===E){if(F+=a-h,h<R){R-=h;do{L[A++]=c[F++]}while(--h);F=A-T,P=L}}else if(E<h){if(F+=a+E-h,h-=E,h<R){R-=h;do{L[A++]=c[F++]}while(--h);if(F=0,E<R){h=E,R-=h;do{L[A++]=c[F++]}while(--h);F=A-T,P=L}}}else if(F+=E-h,h<R){R-=h;do{L[A++]=c[F++]}while(--h);F=A-T,P=L}for(;R>2;)L[A++]=P[F++],L[A++]=P[F++],L[A++]=P[F++],R-=3;R&&(L[A++]=P[F++],R>1&&(L[A++]=P[F++]))}else{F=A-T;do{L[A++]=L[F++],L[A++]=L[F++],L[A++]=L[F++],R-=3}while(R>2);R&&(L[A++]=L[F++],R>1&&(L[A++]=L[F++]))}break}}break}}while(r<n&&A<o);R=f>>3,r-=R,f-=R<<3,C&=(1<<f)-1,t.next_in=r,t.next_out=A,t.avail_in=r<n?n-r+5:5-(r-n),t.avail_out=A<o?o-A+257:257-(A-o),y.hold=C,y.bits=f};const lA=15,uA=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]),_A=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]),IA=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]),DA=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 hA=(t,e,r,n,A,i,o,s)=>{const a=s.bits;let B,E,c,C,f,l,u=0,_=0,I=0,D=0,h=0,R=0,T=0,F=0,P=0,O=0,L=null,y=0;const M=new Uint16Array(16),N=new Uint16Array(16);let S,U,d,G=null,m=0;for(u=0;u<=lA;u++)M[u]=0;for(_=0;_<n;_++)M[e[r+_]]++;for(h=a,D=lA;D>=1&&0===M[D];D--);if(h>D&&(h=D),0===D)return A[i++]=20971520,A[i++]=20971520,s.bits=1,0;for(I=1;I<D&&0===M[I];I++);for(h<I&&(h=I),F=1,u=1;u<=lA;u++)if(F<<=1,F-=M[u],F<0)return-1;if(F>0&&(0===t||1!==D))return-1;for(N[1]=0,u=1;u<lA;u++)N[u+1]=N[u]+M[u];for(_=0;_<n;_++)0!==e[r+_]&&(o[N[e[r+_]]++]=_);if(0===t?(L=G=o,l=19):1===t?(L=uA,y-=257,G=_A,m-=257,l=256):(L=IA,G=DA,l=-1),O=0,_=0,u=I,f=i,R=h,T=0,c=-1,P=1<<h,C=P-1,1===t&&P>852||2===t&&P>592)return 1;for(;;){S=u-T,o[_]<l?(U=0,d=o[_]):o[_]>l?(U=G[m+o[_]],d=L[y+o[_]]):(U=96,d=0),B=1<<u-T,E=1<<R,I=E;do{E-=B,A[f+(O>>T)+E]=S<<24|U<<16|d|0}while(0!==E);for(B=1<<u-1;O&B;)B>>=1;if(0!==B?(O&=B-1,O+=B):O=0,_++,0==--M[u]){if(u===D)break;u=e[r+o[_]]}if(u>h&&(O&C)!==c){for(0===T&&(T=h),f+=I,R=u-T,F=1<<R;R+T<D&&(F-=M[R+T],!(F<=0));)R++,F<<=1;if(P+=1<<R,1===t&&P>852||2===t&&P>592)return 1;c=O&C,A[c]=h<<24|R<<16|f-i|0}}return 0!==O&&(A[f+O]=u-T<<24|64<<16|0),s.bits=h,0};const{Z_FINISH:RA,Z_BLOCK:TA,Z_TREES:FA,Z_OK:PA,Z_STREAM_END:OA,Z_NEED_DICT:LA,Z_STREAM_ERROR:yA,Z_DATA_ERROR:MA,Z_MEM_ERROR:NA,Z_BUF_ERROR:SA,Z_DEFLATED:UA}=Qr,dA=12,GA=30,mA=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function bA(){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 pA=t=>{if(!t||!t.state)return yA;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,PA},wA=t=>{if(!t||!t.state)return yA;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,pA(t)},HA=(t,e)=>{let r;if(!t||!t.state)return yA;const n=t.state;return e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?yA:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,wA(t))},KA=(t,e)=>{if(!t)return yA;const r=new bA;t.state=r,r.window=null;const n=HA(t,e);return n!==PA&&(t.state=null),n};let gA,VA,JA=!0;const vA=t=>{if(JA){gA=new Int32Array(512),VA=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(hA(1,t.lens,0,288,gA,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;hA(2,t.lens,0,32,VA,0,t.work,{bits:5}),JA=!1}t.lencode=gA,t.lenbits=9,t.distcode=VA,t.distbits=5},XA=(t,e,r,n)=>{let A;const i=t.state;return null===i.window&&(i.wsize=1<<i.wbits,i.wnext=0,i.whave=0,i.window=new Uint8Array(i.wsize)),n>=i.wsize?(i.window.set(e.subarray(r-i.wsize,r),0),i.wnext=0,i.whave=i.wsize):(A=i.wsize-i.wnext,A>n&&(A=n),i.window.set(e.subarray(r-n,r-n+A),i.wnext),(n-=A)?(i.window.set(e.subarray(r-n,r),0),i.wnext=n,i.whave=i.wsize):(i.wnext+=A,i.wnext===i.wsize&&(i.wnext=0),i.whave<i.wsize&&(i.whave+=A))),0};var ZA=(t,e)=>{let r,n,A,i,o,s,a,B,E,c,C,f,l,u,_,I,D,h,R,T,F,P,O=0;const L=new Uint8Array(4);let y,M;const N=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 yA;r=t.state,r.mode===dA&&(r.mode=13),o=t.next_out,A=t.output,a=t.avail_out,i=t.next_in,n=t.input,s=t.avail_in,B=r.hold,E=r.bits,c=s,C=a,P=PA;t:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;E<16;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(2&r.wrap&&35615===B){r.check=0,L[0]=255&B,L[1]=B>>>8&255,r.check=xr(r.check,L,2,0),B=0,E=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&B)<<8)+(B>>8))%31){t.msg="incorrect header check",r.mode=GA;break}if((15&B)!==UA){t.msg="unknown compression method",r.mode=GA;break}if(B>>>=4,E-=4,F=8+(15&B),0===r.wbits)r.wbits=F;else if(F>r.wbits){t.msg="invalid window size",r.mode=GA;break}r.dmax=1<<r.wbits,t.adler=r.check=1,r.mode=512&B?10:dA,B=0,E=0;break;case 2:for(;E<16;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(r.flags=B,(255&r.flags)!==UA){t.msg="unknown compression method",r.mode=GA;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=GA;break}r.head&&(r.head.text=B>>8&1),512&r.flags&&(L[0]=255&B,L[1]=B>>>8&255,r.check=xr(r.check,L,2,0)),B=0,E=0,r.mode=3;case 3:for(;E<32;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}r.head&&(r.head.time=B),512&r.flags&&(L[0]=255&B,L[1]=B>>>8&255,L[2]=B>>>16&255,L[3]=B>>>24&255,r.check=xr(r.check,L,4,0)),B=0,E=0,r.mode=4;case 4:for(;E<16;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}r.head&&(r.head.xflags=255&B,r.head.os=B>>8),512&r.flags&&(L[0]=255&B,L[1]=B>>>8&255,r.check=xr(r.check,L,2,0)),B=0,E=0,r.mode=5;case 5:if(1024&r.flags){for(;E<16;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}r.length=B,r.head&&(r.head.extra_len=B),512&r.flags&&(L[0]=255&B,L[1]=B>>>8&255,r.check=xr(r.check,L,2,0)),B=0,E=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(f=r.length,f>s&&(f=s),f&&(r.head&&(F=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Uint8Array(r.head.extra_len)),r.head.extra.set(n.subarray(i,i+f),F)),512&r.flags&&(r.check=xr(r.check,n,f,i)),s-=f,i+=f,r.length-=f),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===s)break t;f=0;do{F=n[i+f++],r.head&&F&&r.length<65536&&(r.head.name+=String.fromCharCode(F))}while(F&&f<s);if(512&r.flags&&(r.check=xr(r.check,n,f,i)),s-=f,i+=f,F)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===s)break t;f=0;do{F=n[i+f++],r.head&&F&&r.length<65536&&(r.head.comment+=String.fromCharCode(F))}while(F&&f<s);if(512&r.flags&&(r.check=xr(r.check,n,f,i)),s-=f,i+=f,F)break t}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;E<16;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(B!==(65535&r.check)){t.msg="header crc mismatch",r.mode=GA;break}B=0,E=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=dA;break;case 10:for(;E<32;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}t.adler=r.check=mA(B),B=0,E=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=o,t.avail_out=a,t.next_in=i,t.avail_in=s,r.hold=B,r.bits=E,LA;t.adler=r.check=1,r.mode=dA;case dA:if(e===TA||e===FA)break t;case 13:if(r.last){B>>>=7&E,E-=7&E,r.mode=27;break}for(;E<3;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}switch(r.last=1&B,B>>>=1,E-=1,3&B){case 0:r.mode=14;break;case 1:if(vA(r),r.mode=20,e===FA){B>>>=2,E-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=GA}B>>>=2,E-=2;break;case 14:for(B>>>=7&E,E-=7&E;E<32;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if((65535&B)!=(B>>>16^65535)){t.msg="invalid stored block lengths",r.mode=GA;break}if(r.length=65535&B,B=0,E=0,r.mode=15,e===FA)break t;case 15:r.mode=16;case 16:if(f=r.length,f){if(f>s&&(f=s),f>a&&(f=a),0===f)break t;A.set(n.subarray(i,i+f),o),s-=f,i+=f,a-=f,o+=f,r.length-=f;break}r.mode=dA;break;case 17:for(;E<14;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(r.nlen=257+(31&B),B>>>=5,E-=5,r.ndist=1+(31&B),B>>>=5,E-=5,r.ncode=4+(15&B),B>>>=4,E-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=GA;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;E<3;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}r.lens[N[r.have++]]=7&B,B>>>=3,E-=3}for(;r.have<19;)r.lens[N[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,y={bits:r.lenbits},P=hA(0,r.lens,0,19,r.lencode,0,r.work,y),r.lenbits=y.bits,P){t.msg="invalid code lengths set",r.mode=GA;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;O=r.lencode[B&(1<<r.lenbits)-1],_=O>>>24,I=O>>>16&255,D=65535&O,!(_<=E);){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(D<16)B>>>=_,E-=_,r.lens[r.have++]=D;else{if(16===D){for(M=_+2;E<M;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(B>>>=_,E-=_,0===r.have){t.msg="invalid bit length repeat",r.mode=GA;break}F=r.lens[r.have-1],f=3+(3&B),B>>>=2,E-=2}else if(17===D){for(M=_+3;E<M;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}B>>>=_,E-=_,F=0,f=3+(7&B),B>>>=3,E-=3}else{for(M=_+7;E<M;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}B>>>=_,E-=_,F=0,f=11+(127&B),B>>>=7,E-=7}if(r.have+f>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=GA;break}for(;f--;)r.lens[r.have++]=F}}if(r.mode===GA)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=GA;break}if(r.lenbits=9,y={bits:r.lenbits},P=hA(1,r.lens,0,r.nlen,r.lencode,0,r.work,y),r.lenbits=y.bits,P){t.msg="invalid literal/lengths set",r.mode=GA;break}if(r.distbits=6,r.distcode=r.distdyn,y={bits:r.distbits},P=hA(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,y),r.distbits=y.bits,P){t.msg="invalid distances set",r.mode=GA;break}if(r.mode=20,e===FA)break t;case 20:r.mode=21;case 21:if(s>=6&&a>=258){t.next_out=o,t.avail_out=a,t.next_in=i,t.avail_in=s,r.hold=B,r.bits=E,fA(t,C),o=t.next_out,A=t.output,a=t.avail_out,i=t.next_in,n=t.input,s=t.avail_in,B=r.hold,E=r.bits,r.mode===dA&&(r.back=-1);break}for(r.back=0;O=r.lencode[B&(1<<r.lenbits)-1],_=O>>>24,I=O>>>16&255,D=65535&O,!(_<=E);){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(I&&0==(240&I)){for(h=_,R=I,T=D;O=r.lencode[T+((B&(1<<h+R)-1)>>h)],_=O>>>24,I=O>>>16&255,D=65535&O,!(h+_<=E);){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}B>>>=h,E-=h,r.back+=h}if(B>>>=_,E-=_,r.back+=_,r.length=D,0===I){r.mode=26;break}if(32&I){r.back=-1,r.mode=dA;break}if(64&I){t.msg="invalid literal/length code",r.mode=GA;break}r.extra=15&I,r.mode=22;case 22:if(r.extra){for(M=r.extra;E<M;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}r.length+=B&(1<<r.extra)-1,B>>>=r.extra,E-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;O=r.distcode[B&(1<<r.distbits)-1],_=O>>>24,I=O>>>16&255,D=65535&O,!(_<=E);){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(0==(240&I)){for(h=_,R=I,T=D;O=r.distcode[T+((B&(1<<h+R)-1)>>h)],_=O>>>24,I=O>>>16&255,D=65535&O,!(h+_<=E);){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}B>>>=h,E-=h,r.back+=h}if(B>>>=_,E-=_,r.back+=_,64&I){t.msg="invalid distance code",r.mode=GA;break}r.offset=D,r.extra=15&I,r.mode=24;case 24:if(r.extra){for(M=r.extra;E<M;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}r.offset+=B&(1<<r.extra)-1,B>>>=r.extra,E-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=GA;break}r.mode=25;case 25:if(0===a)break t;if(f=C-a,r.offset>f){if(f=r.offset-f,f>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=GA;break}f>r.wnext?(f-=r.wnext,l=r.wsize-f):l=r.wnext-f,f>r.length&&(f=r.length),u=r.window}else u=A,l=o-r.offset,f=r.length;f>a&&(f=a),a-=f,r.length-=f;do{A[o++]=u[l++]}while(--f);0===r.length&&(r.mode=21);break;case 26:if(0===a)break t;A[o++]=r.length,a--,r.mode=21;break;case 27:if(r.wrap){for(;E<32;){if(0===s)break t;s--,B|=n[i++]<<E,E+=8}if(C-=a,t.total_out+=C,r.total+=C,C&&(t.adler=r.check=r.flags?xr(r.check,A,C,o-C):Zr(r.check,A,C,o-C)),C=a,(r.flags?B:mA(B))!==r.check){t.msg="incorrect data check",r.mode=GA;break}B=0,E=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;E<32;){if(0===s)break t;s--,B+=n[i++]<<E,E+=8}if(B!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=GA;break}B=0,E=0}r.mode=29;case 29:P=OA;break t;case GA:P=MA;break t;case 31:return NA;default:return yA}return t.next_out=o,t.avail_out=a,t.next_in=i,t.avail_in=s,r.hold=B,r.bits=E,(r.wsize||C!==t.avail_out&&r.mode<GA&&(r.mode<27||e!==RA))&&XA(t,t.output,t.next_out,C-t.avail_out),c-=t.avail_in,C-=t.avail_out,t.total_in+=c,t.total_out+=C,r.total+=C,r.wrap&&C&&(t.adler=r.check=r.flags?xr(r.check,A,C,t.next_out-C):Zr(r.check,A,C,t.next_out-C)),t.data_type=r.bits+(r.last?64:0)+(r.mode===dA?128:0)+(20===r.mode||15===r.mode?256:0),(0===c&&0===C||e===RA)&&P===PA&&(P=SA),P},kA={inflateReset:wA,inflateReset2:HA,inflateResetKeep:pA,inflateInit:t=>KA(t,15),inflateInit2:KA,inflate:ZA,inflateEnd:t=>{if(!t||!t.state)return yA;let e=t.state;return e.window&&(e.window=null),t.state=null,PA},inflateGetHeader:(t,e)=>{if(!t||!t.state)return yA;const r=t.state;return 0==(2&r.wrap)?yA:(r.head=e,e.done=!1,PA)},inflateSetDictionary:(t,e)=>{const r=e.length;let n,A,i;return t&&t.state?(n=t.state,0!==n.wrap&&11!==n.mode?yA:11===n.mode&&(A=1,A=Zr(A,e,r,0),A!==n.check)?MA:(i=XA(t,e,r,r),i?(n.mode=31,NA):(n.havedict=1,PA))):yA},inflateInfo:"pako inflate (from Nodeca project)"};var xA=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 WA=Object.prototype.toString,{Z_NO_FLUSH:QA,Z_FINISH:jA,Z_OK:YA,Z_STREAM_END:zA,Z_NEED_DICT:qA,Z_STREAM_ERROR:$A,Z_DATA_ERROR:ti,Z_MEM_ERROR:ei}=Qr;function ri(t){this.options=xn({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 $n,this.strm.avail_out=0;let r=kA.inflateInit2(this.strm,e.windowBits);if(r!==YA)throw new Error(Wr[r]);if(this.header=new xA,kA.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Yn(e.dictionary):"[object ArrayBuffer]"===WA.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(r=kA.inflateSetDictionary(this.strm,e.dictionary),r!==YA)))throw new Error(Wr[r])}function ni(t,e){const r=new ri(e);if(r.push(t),r.err)throw r.msg||Wr[r.err];return r.result}ri.prototype.push=function(t,e){const r=this.strm,n=this.options.chunkSize,A=this.options.dictionary;let i,o,s;if(this.ended)return!1;for(o=e===~~e?e:!0===e?jA:QA,"[object ArrayBuffer]"===WA.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),i=kA.inflate(r,o),i===qA&&A&&(i=kA.inflateSetDictionary(r,A),i===YA?i=kA.inflate(r,o):i===ti&&(i=qA));r.avail_in>0&&i===zA&&r.state.wrap>0&&0!==t[r.next_in];)kA.inflateReset(r),i=kA.inflate(r,o);switch(i){case $A:case ti:case qA:case ei:return this.onEnd(i),this.ended=!0,!1}if(s=r.avail_out,r.next_out&&(0===r.avail_out||i===zA))if("string"===this.options.to){let t=qn(r.output,r.next_out),e=r.next_out-t,A=zn(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(A)}else this.onData(r.output.length===r.next_out?r.output:r.output.subarray(0,r.next_out));if(i!==YA||0!==s){if(i===zA)return i=kA.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===r.avail_in)break}}return!0},ri.prototype.onData=function(t){this.chunks.push(t)},ri.prototype.onEnd=function(t){t===YA&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Wn(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var Ai={Inflate:ri,inflate:ni,inflateRaw:function(t,e){return(e=e||{}).raw=!0,ni(t,e)},ungzip:ni,constants:Qr};const{Deflate:ii,deflate:oi,deflateRaw:si,gzip:ai}=CA,{Inflate:Bi,inflate:Ei,inflateRaw:ci,ungzip:Ci}=Ai;var fi={Deflate:ii,deflate:oi,deflateRaw:si,gzip:ai,Inflate:Bi,inflate:Ei,inflateRaw:ci,ungzip:Ci,constants:Qr},li=5,ui=11,_i=13,Ii=14;function Di(t,e,r,n){var A=t|e<<8,i=A>>11&31,o=A>>5&63,s=31&A;return r[n+0]=i<<3|i>>2,r[n+1]=o<<2|o>>4,r[n+2]=s<<3|s>>2,r[n+3]=255,A}var hi=new Uint8Array(16),Ri=new Uint8Array(16);function Ti(t,e,r,n){var A=0;0!=(6&n)&&(A=8),function(t,e,r,n){for(var A=Di(e[r+0],e[r+1],hi,0),i=Di(e[r+2],e[r+3],hi,4),o=0;o<3;o++){var s=hi[o],a=hi[4+o];n&&A<=i?(hi[8+o]=(s+a)/2,hi[12+o]=0):(hi[8+o]=(2*s+a)/3,hi[12+o]=(s+2*a)/3)}for(hi[11]=255,hi[15]=n&&A<=i?0:255,o=0;o<4;++o){var B=e[r+4+o];Ri[4*o+0]=3&B,Ri[4*o+1]=B>>2&3,Ri[4*o+2]=B>>4&3,Ri[4*o+3]=B>>6&3}for(o=0;o<16;++o)for(var E=4*Ri[o],c=0;c<4;++c)t[4*o+c]=hi[E+c]}(t,e,r+A,0!=(1&n)),0!=(2&n)?function(t,e,r){for(var n=0;n<8;++n){var A=bytes[r+n],i=15&A,o=240&A;t[8*n+3]=i|i<<4,t[8*n+7]=o|o>>4}}(t,0,r):0!=(4&n)&&function(t,e,r){var n=e[r+0],A=e[r+1];if(hi[0]=n,hi[1]=A,n<=A){for(var i=1;i<5;++i)hi[1+i]=((5-i)*n+i*A)/5;hi[6]=0,hi[7]=255}else for(i=1;i<7;++i)hi[1+i]=((7-i)*n+i*A)/7;r+=2;var o=0;for(i=0;i<2;++i){for(var s=0,a=0;a<3;++a)s|=e[r++]<<8*a;for(a=0;a<8;++a){var B=s>>3*a&7;Ri[o++]=B}}for(i=0;i<16;++i)t[4*i+3]=hi[Ri[i]]}(t,e,r)}var Fi=new Uint16Array(4);\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 */\nvar Pi=new Uint8Array(64);function Oi(t){}Oi.decode=function(t,e,r,n,A){if(null!=t&&null!=n&&0!=r&&0!=e){var i=0;1&(i=A>11||5===A?4:33)&&32&i?function(t,e,r,n){for(var A=t,i=0,o=0,s=0,a=0,B=0,E=0,c=0,C=0,f=0,l=e/4,u=r/4,_=0;_<u;_++)for(var I=0;I<l;I++)s=4*((u-_)*l+I),Fi[0]=n[s],Fi[1]=n[s+1],a=31&Fi[0],B=2016&Fi[0],E=63488&Fi[0],c=31&Fi[1],C=2016&Fi[1],f=63488&Fi[1],Fi[2]=5*a+3*c>>3|5*B+3*C>>3&2016|5*E+3*f>>3&63488,Fi[3]=5*c+3*a>>3|5*C+3*B>>3&2016|5*f+3*E>>3&63488,i=n[s+2],A[o=4*_*e+4*I]=Fi[3&i],A[o+1]=Fi[i>>2&3],A[o+2]=Fi[i>>4&3],A[o+3]=Fi[i>>6&3],A[o+=e]=Fi[i>>8&3],A[o+1]=Fi[i>>10&3],A[o+2]=Fi[i>>12&3],A[o+3]=Fi[i>>14],i=n[s+3],A[o+=e]=Fi[3&i],A[o+1]=Fi[i>>2&3],A[o+2]=Fi[i>>4&3],A[o+3]=Fi[i>>6&3],A[o+=e]=Fi[i>>8&3],A[o+1]=Fi[i>>10&3],A[o+2]=Fi[i>>12&3],A[o+3]=Fi[i>>14]}(t,e,r,n):function(t,e,r,n,A,i){for(var o=0!=(1&A)?8:16,s=0,a=0;a<r;a+=4)for(var B=0;B<e;B+=4){Ti(Pi,n,s,A);for(var E=0,c=0;c<4;++c)for(var C=0;C<4;++C){var f=B+C,l=a+c;if(f<e&&l<r){var u=4*(e*(r-l)+f);if(i===_i||i===Ii)t[u+2]=Pi[E++],t[u+1]=Pi[E++],t[u+0]=Pi[E++],t[u+3]=Pi[E++];else for(var _=0;_<4;++_)t[u++]=Pi[E++]}else E+=4}s+=o}}(t,e,r,n,i,A)}};var Li=function(){var t=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),e=new Uint8Array([32,0,65,2,1,106,34,33,3,128,11,4,13,64,6,253,10,7,15,116,127,5,8,12,40,16,19,54,20,9,27,255,113,17,42,67,24,23,146,148,18,14,22,45,70,69,56,114,101,21,25,63,75,136,108,28,118,29,73,115]);if("object"!=typeof WebAssembly)return{supported:!1};var r,n="B9h79tEBBBE8fV9gBB9gVUUUUUEU9gIUUUB9gEUEU9gIUUUEUIKQBEEEDDDILLLVE9wEEEVIEBEOWEUEC+Q/IEKR/LEdO9tw9t9vv95DBh9f9f939h79t9f9j9h229f9jT9vv7BB8a9tw79o9v9wT9f9kw9j9v9kw9WwvTw949C919m9mwvBEy9tw79o9v9wT9f9kw9j9v9kw69u9kw949C919m9mwvBDe9tw79o9v9wT9f9kw9j9v9kw69u9kw949Twg91w9u9jwBIl9tw79o9v9wT9f9kw9j9v9kws9p2Twv9P9jTBLk9tw79o9v9wT9f9kw9j9v9kws9p2Twv9R919hTBVl9tw79o9v9wT9f9kw9j9v9kws9p2Twvt949wBOL79iv9rBRQ+x8yQDBK/qMEZU8jJJJJBCJ/EB9rGV8kJJJJBC9+HODNADCEFAL0MBCUHOAIrBBC+gE9HMBAVAIALFGRAD9rADZ1JJJBHWCJ/ABAD9uC/wfBgGOCJDAOCJD6eHdAICEFHLCBHQDNINAQAE9PMEAdAEAQ9rAQAdFAE6eHKDNDNADtMBAKCSFGOC9wgHXAOCL4CIFCD4HMAWCJDFHpCBHSALHZINDNARAZ9rAM9PMBCBHLXIKAZAMFHLDNAXtMBCBHhCBHIINDNARAL9rCk9PMBCBHLXVKAWCJ/CBFAIFHODNDNDNDNDNAZAICO4FrBBAhCOg4CIgpLBEDIBKAO9CB83IBAOCWF9CB83IBXIKAOALrBLALrBBGoCO4GaAaCIsGae86BBAOCEFALCLFAaFGarBBAoCL4CIgGcAcCIsGce86BBAOCDFAaAcFGarBBAoCD4CIgGcAcCIsGce86BBAOCIFAaAcFGarBBAoCIgGoAoCIsGoe86BBAOCLFAaAoFGarBBALrBEGoCO4GcAcCIsGce86BBAOCVFAaAcFGarBBAoCL4CIgGcAcCIsGce86BBAOCOFAaAcFGarBBAoCD4CIgGcAcCIsGce86BBAOCRFAaAcFGarBBAoCIgGoAoCIsGoe86BBAOCWFAaAoFGarBBALrBDGoCO4GcAcCIsGce86BBAOCdFAaAcFGarBBAoCL4CIgGcAcCIsGce86BBAOCQFAaAcFGarBBAoCD4CIgGcAcCIsGce86BBAOCKFAaAcFGarBBAoCIgGoAoCIsGoe86BBAOCXFAaAoFGorBBALrBIGLCO4GaAaCIsGae86BBAOCMFAoAaFGorBBALCL4CIgGaAaCIsGae86BBAOCpFAoAaFGorBBALCD4CIgGaAaCIsGae86BBAOCSFAoAaFGOrBBALCIgGLALCIsGLe86BBAOALFHLXDKAOALrBWALrBBGoCL4GaAaCSsGae86BBAOCEFALCWFAaFGarBBAoCSgGoAoCSsGoe86BBAOCDFAaAoFGorBBALrBEGaCL4GcAcCSsGce86BBAOCIFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCLFAoAaFGorBBALrBDGaCL4GcAcCSsGce86BBAOCVFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCOFAoAaFGorBBALrBIGaCL4GcAcCSsGce86BBAOCRFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCWFAoAaFGorBBALrBLGaCL4GcAcCSsGce86BBAOCdFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCQFAoAaFGorBBALrBVGaCL4GcAcCSsGce86BBAOCKFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCXFAoAaFGorBBALrBOGaCL4GcAcCSsGce86BBAOCMFAoAcFGorBBAaCSgGaAaCSsGae86BBAOCpFAoAaFGorBBALrBRGLCL4GaAaCSsGae86BBAOCSFAoAaFGOrBBALCSgGLALCSsGLe86BBAOALFHLXEKAOAL8pBB83BBAOCWFALCWF8pBB83BBALCZFHLKAhCDFHhAICZFGIAX6MBKKDNALMBCBHLXIKDNAKtMBAWASFrBBHhCBHOApHIINAIAWCJ/CBFAOFrBBGZCE4CBAZCEg9r7AhFGh86BBAIADFHIAOCEFGOAK9HMBKKApCEFHpALHZASCEFGSAD9HMBKKABAQAD2FAWCJDFAKAD2Z1JJJB8aAWAWCJDFAKCUFAD2FADZ1JJJB8aKAKCBALeAQFHQALMBKC9+HOXEKCBC99ARAL9rADCAADCA0eseHOKAVCJ/EBF8kJJJJBAOK+OoEZU8jJJJJBC/AE9rGV8kJJJJBC9+HODNAECI9uGRChFAL0MBCUHOAIrBBGWC/wEgC/gE9HMBAWCSgGdCE0MBAVC/ABFCfECJEZ+JJJJB8aAVCuF9CU83IBAVC8wF9CU83IBAVCYF9CU83IBAVCAF9CU83IBAVCkF9CU83IBAVCZF9CU83IBAV9CU83IWAV9CU83IBAIALFC9wFHQAICEFGWARFHKDNAEtMBCMCSAdCEseHXABHICBHdCBHMCBHpCBHLCBHOINDNAKAQ9NMBC9+HOXIKDNDNAWrBBGRC/vE0MBAVC/ABFARCL4CU7AOFCSgCITFGSYDLHZASYDBHhDNARCSgGSAX9PMBAVARCU7ALFCSgCDTFYDBAdASeHRAStHSDNDNADCD9HMBABAh87EBABCLFAR87EBABCDFAZ87EBXEKAIAhbDBAICWFARbDBAICLFAZbDBKAdASFHdAVC/ABFAOCITFGoARbDBAoAZbDLAVALCDTFARbDBAVC/ABFAOCEFCSgGOCITFGZAhbDBAZARbDLALASFHLAOCEFHOXDKDNDNASCSsMBAMASFASC987FCEFHMXEKAK8sBBGSCfEgHRDNDNASCU9MMBAKCEFHKXEKAK8sBEGSCfBgCRTARCfBgvHRDNASCU9MMBAKCDFHKXEKAK8sBDGSCfBgCpTARvHRDNASCU9MMBAKCIFHKXEKAK8sBIGSCfBgCxTARvHRDNASCU9MMBAKCLFHKXEKAKrBLC3TARvHRAKCVFHKKARCE4CBARCEg9r7AMFHMKDNDNADCD9HMBABAh87EBABCLFAM87EBABCDFAZ87EBXEKAIAhbDBAICWFAMbDBAICLFAZbDBKAVC/ABFAOCITFGRAMbDBARAZbDLAVALCDTFAMbDBAVC/ABFAOCEFCSgGOCITFGRAhbDBARAMbDLALCEFHLAOCEFHOXEKDNARCPE0MBAVALAQARCSgFrBBGSCL4GZ9rCSgCDTFYDBAdCEFGhAZeHRAVALAS9rCSgCDTFYDBAhAZtGoFGhASCSgGZeHSAZtHZDNDNADCD9HMBABAd87EBABCLFAS87EBABCDFAR87EBXEKAIAdbDBAICWFASbDBAICLFARbDBKAVALCDTFAdbDBAVC/ABFAOCITFGaARbDBAaAdbDLAVALCEFGLCSgCDTFARbDBAVC/ABFAOCEFCSgCITFGaASbDBAaARbDLAVALAoFCSgGLCDTFASbDBAVC/ABFAOCDFCSgGOCITFGRAdbDBARASbDLAOCEFHOALAZFHLAhAZFHdXEKAdCBAKrBBGaeGZARC/+EsGcFHRAaCSgHhDNDNAaCL4GoMBARCEFHSXEKARHSAVALAo9rCSgCDTFYDBHRKDNDNAhMBASCEFHdXEKASHdAVALAa9rCSgCDTFYDBHSKDNDNActMBAKCEFHaXEKAK8sBEGaCfEgHZDNDNAaCU9MMBAKCDFHaXEKAK8sBDGaCfBgCRTAZCfBgvHZDNAaCU9MMBAKCIFHaXEKAK8sBIGaCfBgCpTAZvHZDNAaCU9MMBAKCLFHaXEKAK8sBLGaCfBgCxTAZvHZDNAaCU9MMBAKCVFHaXEKAKCOFHaAKrBVC3TAZvHZKAZCE4CBAZCEg9r7AMFGMHZKDNDNAoCSsMBAaHcXEKAa8sBBGKCfEgHRDNDNAKCU9MMBAaCEFHcXEKAa8sBEGKCfBgCRTARCfBgvHRDNAKCU9MMBAaCDFHcXEKAa8sBDGKCfBgCpTARvHRDNAKCU9MMBAaCIFHcXEKAa8sBIGKCfBgCxTARvHRDNAKCU9MMBAaCLFHcXEKAaCVFHcAarBLC3TARvHRKARCE4CBARCEg9r7AMFGMHRKDNDNAhCSsMBAcHKXEKAc8sBBGKCfEgHSDNDNAKCU9MMBAcCEFHKXEKAc8sBEGKCfBgCRTASCfBgvHSDNAKCU9MMBAcCDFHKXEKAc8sBDGKCfBgCpTASvHSDNAKCU9MMBAcCIFHKXEKAc8sBIGKCfBgCxTASvHSDNAKCU9MMBAcCLFHKXEKAcCVFHKAcrBLC3TASvHSKASCE4CBASCEg9r7AMFGMHSKDNDNADCD9HMBABAZ87EBABCLFAS87EBABCDFAR87EBXEKAIAZbDBAICWFASbDBAICLFARbDBKAVC/ABFAOCITFGaARbDBAaAZbDLAVALCDTFAZbDBAVC/ABFAOCEFCSgCITFGaASbDBAaARbDLAVALCEFGLCSgCDTFARbDBAVC/ABFAOCDFCSgCITFGRAZbDBARASbDLAVALAotAoCSsvFGLCSgCDTFASbDBALAhtAhCSsvFHLAOCIFHOKAWCEFHWABCOFHBAICXFHIAOCSgHOALCSgHLApCIFGpAE6MBKKCBC99AKAQseHOKAVC/AEF8kJJJJBAOK/tLEDU8jJJJJBCZ9rHVC9+HODNAECVFAL0MBCUHOAIrBBC/+EgC/QE9HMBAV9CB83IWAICEFHOAIALFC98FHIDNAEtMBDNADCDsMBINDNAOAI6MBC9+SKAO8sBBGDCfEgHLDNDNADCU9MMBAOCEFHOXEKAO8sBEGDCfBgCRTALCfBgvHLDNADCU9MMBAOCDFHOXEKAO8sBDGDCfBgCpTALvHLDNADCU9MMBAOCIFHOXEKAO8sBIGDCfBgCxTALvHLDNADCU9MMBAOCLFHOXEKAOrBLC3TALvHLAOCVFHOKAVCWFALCEgCDTvGDALCD4CBALCE4CEg9r7ADYDBFGLbDBABALbDBABCLFHBAECUFGEMBXDKKINDNAOAI6MBC9+SKAO8sBBGDCfEgHLDNDNADCU9MMBAOCEFHOXEKAO8sBEGDCfBgCRTALCfBgvHLDNADCU9MMBAOCDFHOXEKAO8sBDGDCfBgCpTALvHLDNADCU9MMBAOCIFHOXEKAO8sBIGDCfBgCxTALvHLDNADCU9MMBAOCLFHOXEKAOrBLC3TALvHLAOCVFHOKABALCD4CBALCE4CEg9r7AVCWFALCEgCDTvGLYDBFGD87EBALADbDBABCDFHBAECUFGEMBKKCBC99AOAIseHOKAOK+lVOEUE99DUD99EUD99DNDNADCL9HMBAEtMEINDNDNjBBBzjBBB+/ABCDFGD8sBB+yAB8sBBGI+yGL+L+TABCEFGV8sBBGO+yGR+L+TGWjBBBB9gGdeAWjBB/+9CAWAWnjBBBBAWAdeGQAQ+MGKAICU9KeALmGLALnAQAKAOCU9KeARmGQAQnmm+R+VGRnmGW+LjBBB9P9dtMBAW+oHIXEKCJJJJ94HIKADAI86BBDNDNjBBBzjBBB+/AQjBBBB9geAQARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKAVAD86BBDNDNjBBBzjBBB+/ALjBBBB9geALARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKABAD86BBABCLFHBAECUFGEMBXDKKAEtMBINDNDNjBBBzjBBB+/ABCLFGD8uEB+yAB8uEBGI+yGL+L+TABCDFGV8uEBGO+yGR+L+TGWjBBBB9gGdeAWjB/+fsAWAWnjBBBBAWAdeGQAQ+MGKAICU9KeALmGLALnAQAKAOCU9KeARmGQAQnmm+R+VGRnmGW+LjBBB9P9dtMBAW+oHIXEKCJJJJ94HIKADAI87EBDNDNjBBBzjBBB+/AQjBBBB9geAQARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKAVAD87EBDNDNjBBBzjBBB+/ALjBBBB9geALARnmGW+LjBBB9P9dtMBAW+oHDXEKCJJJJ94HDKABAD87EBABCWFHBAECUFGEMBKKK/SILIUI99IUE99DNAEtMBCBHIABHLINDNDNj/zL81zALCOF8uEBGVCIv+y+VGOAL8uEB+ynGRjB/+fsnjBBBzjBBB+/ARjBBBB9gemGW+LjBBB9P9dtMBAW+oHdXEKCJJJJ94HdKALCLF8uEBHQALCDF8uEBHKABAVCEFCIgAIvCETFAd87EBDNDNAOAK+ynGWjB/+fsnjBBBzjBBB+/AWjBBBB9gemGX+LjBBB9P9dtMBAX+oHKXEKCJJJJ94HKKABAVCDFCIgAIvCETFAK87EBDNDNAOAQ+ynGOjB/+fsnjBBBzjBBB+/AOjBBBB9gemGX+LjBBB9P9dtMBAX+oHQXEKCJJJJ94HQKABAVCUFCIgAIvCETFAQ87EBDNDNjBBJzARARn+TAWAWn+TAOAOn+TGRjBBBBARjBBBB9ge+RjB/+fsnjBBBzmGR+LjBBB9P9dtMBAR+oHQXEKCJJJJ94HQKABAVCIgAIvCETFAQ87EBALCWFHLAICLFHIAECUFGEMBKKK6BDNADCD4AE2GEtMBINABABYDBGDCWTCW91+yADCk91ClTCJJJ/8IF++nuDBABCLFHBAECUFGEMBKKK9TEIUCBCBYDJ1JJBGEABCIFC98gFGBbDJ1JJBDNDNABzBCZTGD9NMBCUHIABAD9rCffIFCZ4NBCUsMEKAEHIKAIK/lEEEUDNDNAEABvCIgtMBABHIXEKDNDNADCZ9PMBABHIXEKABHIINAIAEYDBbDBAICLFAECLFYDBbDBAICWFAECWFYDBbDBAICXFAECXFYDBbDBAICZFHIAECZFHEADC9wFGDCS0MBKKADCL6MBINAIAEYDBbDBAECLFHEAICLFHIADC98FGDCI0MBKKDNADtMBINAIAErBB86BBAICEFHIAECEFHEADCUFGDMBKKABK/AEEDUDNDNABCIgtMBABHIXEKAECfEgC+B+C+EW2HLDNDNADCZ9PMBABHIXEKABHIINAIALbDBAICXFALbDBAICWFALbDBAICLFALbDBAICZFHIADC9wFGDCS0MBKKADCL6MBINAIALbDBAICLFHIADC98FGDCI0MBKKDNADtMBINAIAE86BBAICEFHIADCUFGDMBKKABKKKEBCJWKLZ9kBB";WebAssembly.validate(t)&&(n="B9h79tEBBBE5V9gBB9gVUUUUUEU9gIUUUB9gDUUB9gEUEUIMXBBEBEEDIDIDLLVE9wEEEVIEBEOWEUEC+Q/aEKR/LEdO9tw9t9vv95DBh9f9f939h79t9f9j9h229f9jT9vv7BB8a9tw79o9v9wT9f9kw9j9v9kw9WwvTw949C919m9mwvBDy9tw79o9v9wT9f9kw9j9v9kw69u9kw949C919m9mwvBLe9tw79o9v9wT9f9kw9j9v9kw69u9kw949Twg91w9u9jwBVl9tw79o9v9wT9f9kw9j9v9kws9p2Twv9P9jTBOk9tw79o9v9wT9f9kw9j9v9kws9p2Twv9R919hTBWl9tw79o9v9wT9f9kw9j9v9kws9p2Twvt949wBQL79iv9rBKQ/j6XLBZIK9+EVU8jJJJJBCZ9rHBCBHEINCBHDCBHIINABCWFADFAICJUAEAD4CEgGLe86BBAIALFHIADCEFGDCW9HMBKAEC+Q+YJJBFAI86BBAECITC+Q1JJBFAB8pIW83IBAECEFGECJD9HMBKK1HLSUD97EUO978jJJJJBCJ/KB9rGV8kJJJJBC9+HODNADCEFAL0MBCUHOAIrBBC+gE9HMBAVAIALFGRAD9rAD/8QBBCJ/ABAD9uC/wfBgGOCJDAOCJD6eHWAICEFHOCBHdDNINAdAE9PMEAWAEAd9rAdAWFAE6eHQDNDNADtMBAQCSFGLC9wgGKCI2HXAKCETHMALCL4CIFCD4HpCBHSINAOHZCBHhDNINDNARAZ9rAp9PMBCBHOXVKAVCJ/CBFAhAK2FHoAZApFHOCBHIDNAKC/AB6MBARAO9rC/gB6MBCBHLINAoALFHIDNDNDNDNDNAZALCO4FrBBGaCIgpLBEDIBKAICBPhPKLBXIKAIAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLBAOCLFAlPqBFAqC+Q+YJJBFrBBFHOXDKAIAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLBAOCWFAlPqBFAqC+Q+YJJBFrBBFHOXEKAIAOPBBBPKLBAOCZFHOKDNDNDNDNDNAaCD4CIgpLBEDIBKAICBPhPKLZXIKAIAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLZAOCLFAlPqBFAqC+Q+YJJBFrBBFHOXDKAIAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLZAOCWFAlPqBFAqC+Q+YJJBFrBBFHOXEKAIAOPBBBPKLZAOCZFHOKDNDNDNDNDNAaCL4CIgpLBEDIBKAICBPhPKLAXIKAIAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLAAOCLFAlPqBFAqC+Q+YJJBFrBBFHOXDKAIAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLAAOCWFAlPqBFAqC+Q+YJJBFrBBFHOXEKAIAOPBBBPKLAAOCZFHOKDNDNDNDNDNAaCO4pLBEDIBKAICBPhPKL8wXIKAIAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGaCITC+Q1JJBFPBIBAaC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGaCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKL8wAOCLFAlPqBFAaC+Q+YJJBFrBBFHOXDKAIAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGaCITC+Q1JJBFPBIBAaC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGaCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKL8wAOCWFAlPqBFAaC+Q+YJJBFrBBFHOXEKAIAOPBBBPKL8wAOCZFHOKALC/ABFHIALCJEFAK0MEAIHLARAO9rC/fB0MBKKDNAIAK9PMBAICI4HLINDNARAO9rCk9PMBCBHOXRKAoAIFHaDNDNDNDNDNAZAICO4FrBBALCOg4CIgpLBEDIBKAaCBPhPKLBXIKAaAOPBBLAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlGcCDP+MEAcPMBZEhDoIaLcVxOqRlC+D+G+MkPhP9OGxCIPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLBAOCLFAlPqBFAqC+Q+YJJBFrBBFHOXDKAaAOPBBWAOPBBBGcCLP+MEAcPMBZEhDoIaLcVxOqRlC+P+e+8/4BPhP9OGxCSPSP8jGcP5B9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBAqC+Q+YJJBFPBBBGlAlPMBBBBBBBBBBBBBBBBAcP5E9CJf/8/4/w/g/AB9+9Cu1+nGqCITC+Q1JJBFPBIBP9uPMBEDILVORZhoacxqlPpAxAcP9SPKLBAOCWFAlPqBFAqC+Q+YJJBFrBBFHOXEKAaAOPBBBPKLBAOCZFHOKALCDFHLAICZFGIAK6MBKKDNAOtMBAOHZAhCEFGhCLsMDXEKKCBHOXIKDNAKtMBAVCJDFASFHIAVASFPBDBHlCBHaINAIAVCJ/CBFAaFGLPBLBGxCEP9tAxCEPSGcP9OP9hP9RGxALAKFPBLBGkCEP9tAkAcP9OP9hP9RGkPMBZEhDoIaLcVxOqRlGyALAMFPBLBG8aCEP9tA8aAcP9OP9hP9RG8aALAXFPBLBGeCEP9tAeAcP9OP9hP9RGePMBZEhDoIaLcVxOqRlG3PMBEZhDIoaLVcxORqlGcAcPMBEDIBEDIBEDIBEDIAlP9uGlPeBbDBAIADFGLAlAcAcPMLVORLVORLVORLVORP9uGlPeBbDBALADFGLAlAcAcPMWdQKWdQKWdQKWdQKP9uGlPeBbDBALADFGLAlAcAcPMXMpSXMpSXMpSXMpSP9uGlPeBbDBALADFGLAlAyA3PMWdkyQK8aeXM35pS8e8fGcAcPMBEDIBEDIBEDIBEDIP9uGlPeBbDBALADFGLAlAcAcPMLVORLVORLVORLVORP9uGlPeBbDBALADFGLAlAcAcPMWdQKWdQKWdQKWdQKP9uGlPeBbDBALADFGLAlAcAcPMXMpSXMpSXMpSXMpSP9uGlPeBbDBALADFGLAlAxAkPMWkdyQ8aKeX3M5p8eS8fGxA8aAePMWkdyQ8aKeX3M5p8eS8fGkPMBEZhDIoaLVcxORqlGcAcPMBEDIBEDIBEDIBEDIP9uGlPeBbDBALADFGLAlAcAcPMLVORLVORLVORLVORP9uGlPeBbDBALADFGLAlAcAcPMWdQKWdQKWdQKWdQKP9uGlPeBbDBALADFGLAlAcAcPMXMpSXMpSXMpSXMpSP9uGlPeBbDBALADFGLAlAxAkPMWdkyQK8aeXM35pS8e8fGcAcPMBEDIBEDIBEDIBEDIP9uGlPeBbDBALADFGLAlAcAcPMLVORLVORLVORLVORP9uGlPeBbDBALADFGLAlAcAcPMWdQKWdQKWdQKWdQKP9uGlPeBbDBALADFGLAlAcAcPMXMpSXMpSXMpSXMpSP9uGlPeBbDBALADFHIAaCZFGaAK6MBKKASCLFGSAD6MBKKABAdAD2FAVCJDFAQAD2/8QBBAVAVCJDFAQCUFAD2FAD/8QBBKAQCBAOeAdFHdAOMBKC9+HOXEKCBC99ARAO9rADCAADCA0eseHOKAVCJ/KBF8kJJJJBAOKWBZ+BJJJBK+KoEZU8jJJJJBC/AE9rGV8kJJJJBC9+HODNAECI9uGRChFAL0MBCUHOAIrBBGWC/wEgC/gE9HMBAWCSgGdCE0MBAVC/ABFCfECJE/8KBAVCuF9CU83IBAVC8wF9CU83IBAVCYF9CU83IBAVCAF9CU83IBAVCkF9CU83IBAVCZF9CU83IBAV9CU83IWAV9CU83IBAIALFC9wFHQAICEFGWARFHKDNAEtMBCMCSAdCEseHXABHICBHdCBHMCBHpCBHLCBHOINDNAKAQ9NMBC9+HOXIKDNDNAWrBBGRC/vE0MBAVC/ABFARCL4CU7AOFCSgCITFGSYDLHZASYDBHhDNARCSgGSAX9PMBAVARCU7ALFCSgCDTFYDBAdASeHRAStHSDNDNADCD9HMBABAh87EBABCLFAR87EBABCDFAZ87EBXEKAIAhbDBAICWFARbDBAICLFAZbDBKAdASFHdAVC/ABFAOCITFGoARbDBAoAZbDLAVALCDTFARbDBAVC/ABFAOCEFCSgGOCITFGZAhbDBAZARbDLALASFHLAOCEFHOXDKDNDNASCSsMBAMASFASC987FCEFHMXEKAK8sBBGSCfEgHRDNDNASCU9MMBAKCEFHKXEKAK8sBEGSCfBgCRTARCfBgvHRDNASCU9MMBAKCDFHKXEKAK8sBDGSCfBgCpTARvHRDNASCU9MMBAKCIFHKXEKAK8sBIGSCfBgCxTARvHRDNASCU9MMBAKCLFHKXEKAKrBLC3TARvHRAKCVFHKKARCE4CBARCEg9r7AMFHMKDNDNADCD9HMBABAh87EBABCLFAM87EBABCDFAZ87EBXEKAIAhbDBAICWFAMbDBAICLFAZbDBKAVC/ABFAOCITFGRAMbDBARAZbDLAVALCDTFAMbDBAVC/ABFAOCEFCSgGOCITFGRAhbDBARAMbDLALCEFHLAOCEFHOXEKDNARCPE0MBAVALAQARCSgFrBBGSCL4GZ9rCSgCDTFYDBAdCEFGhAZeHRAVALAS9rCSgCDTFYDBAhAZtGoFGhASCSgGZeHSAZtHZDNDNADCD9HMBABAd87EBABCLFAS87EBABCDFAR87EBXEKAIAdbDBAICWFASbDBAICLFARbDBKAVALCDTFAdbDBAVC/ABFAOCITFGaARbDBAaAdbDLAVALCEFGLCSgCDTFARbDBAVC/ABFAOCEFCSgCITFGaASbDBAaARbDLAVALAoFCSgGLCDTFASbDBAVC/ABFAOCDFCSgGOCITFGRAdbDBARASbDLAOCEFHOALAZFHLAhAZFHdXEKAdCBAKrBBGaeGZARC/+EsGcFHRAaCSgHhDNDNAaCL4GoMBARCEFHSXEKARHSAVALAo9rCSgCDTFYDBHRKDNDNAhMBASCEFHdXEKASHdAVALAa9rCSgCDTFYDBHSKDNDNActMBAKCEFHaXEKAK8sBEGaCfEgHZDNDNAaCU9MMBAKCDFHaXEKAK8sBDGaCfBgCRTAZCfBgvHZDNAaCU9MMBAKCIFHaXEKAK8sBIGaCfBgCpTAZvHZDNAaCU9MMBAKCLFHaXEKAK8sBLGaCfBgCxTAZvHZDNAaCU9MMBAKCVFHaXEKAKCOFHaAKrBVC3TAZvHZKAZCE4CBAZCEg9r7AMFGMHZKDNDNAoCSsMBAaHcXEKAa8sBBGKCfEgHRDNDNAKCU9MMBAaCEFHcXEKAa8sBEGKCfBgCRTARCfBgvHRDNAKCU9MMBAaCDFHcXEKAa8sBDGKCfBgCpTARvHRDNAKCU9MMBAaCIFHcXEKAa8sBIGKCfBgCxTARvHRDNAKCU9MMBAaCLFHcXEKAaCVFHcAarBLC3TARvHRKARCE4CBARCEg9r7AMFGMHRKDNDNAhCSsMBAcHKXEKAc8sBBGKCfEgHSDNDNAKCU9MMBAcCEFHKXEKAc8sBEGKCfBgCRTASCfBgvHSDNAKCU9MMBAcCDFHKXEKAc8sBDGKCfBgCpTASvHSDNAKCU9MMBAcCIFHKXEKAc8sBIGKCfBgCxTASvHSDNAKCU9MMBAcCLFHKXEKAcCVFHKAcrBLC3TASvHSKASCE4CBASCEg9r7AMFGMHSKDNDNADCD9HMBABAZ87EBABCLFAS87EBABCDFAR87EBXEKAIAZbDBAICWFASbDBAICLFARbDBKAVC/ABFAOCITFGaARbDBAaAZbDLAVALCDTFAZbDBAVC/ABFAOCEFCSgCITFGaASbDBAaARbDLAVALCEFGLCSgCDTFARbDBAVC/ABFAOCDFCSgCITFGRAZbDBARASbDLAVALAotAoCSsvFGLCSgCDTFASbDBALAhtAhCSsvFHLAOCIFHOKAWCEFHWABCOFHBAICXFHIAOCSgHOALCSgHLApCIFGpAE6MBKKCBC99AKAQseHOKAVC/AEF8kJJJJBAOK/tLEDU8jJJJJBCZ9rHVC9+HODNAECVFAL0MBCUHOAIrBBC/+EgC/QE9HMBAV9CB83IWAICEFHOAIALFC98FHIDNAEtMBDNADCDsMBINDNAOAI6MBC9+SKAO8sBBGDCfEgHLDNDNADCU9MMBAOCEFHOXEKAO8sBEGDCfBgCRTALCfBgvHLDNADCU9MMBAOCDFHOXEKAO8sBDGDCfBgCpTALvHLDNADCU9MMBAOCIFHOXEKAO8sBIGDCfBgCxTALvHLDNADCU9MMBAOCLFHOXEKAOrBLC3TALvHLAOCVFHOKAVCWFALCEgCDTvGDALCD4CBALCE4CEg9r7ADYDBFGLbDBABALbDBABCLFHBAECUFGEMBXDKKINDNAOAI6MBC9+SKAO8sBBGDCfEgHLDNDNADCU9MMBAOCEFHOXEKAO8sBEGDCfBgCRTALCfBgvHLDNADCU9MMBAOCDFHOXEKAO8sBDGDCfBgCpTALvHLDNADCU9MMBAOCIFHOXEKAO8sBIGDCfBgCxTALvHLDNADCU9MMBAOCLFHOXEKAOrBLC3TALvHLAOCVFHOKABALCD4CBALCE4CEg9r7AVCWFALCEgCDTvGLYDBFGD87EBALADbDBABCDFHBAECUFGEMBKKCBC99AOAIseHOKAOK/xVDIUO978jJJJJBCA9rGI8kJJJJBDNDNADCL9HMBDNAEC98gGLtMBABHDCBHVINADADPBBBGOCkP+rECkP+sEP/6EGRAOCWP+rECkP+sEP/6EARP/gEAOCZP+rECkP+sEP/6EGWP/gEP/kEP/lEGdCBPhP+2EGQARCJJJJ94PhGKP9OP9RP/kEGRjBB/+9CPaARARP/mEAdAdP/mEAWAQAWAKP9OP9RP/kEGRARP/mEP/kEP/kEP/jEP/nEGWP/mEjBBN0PaGQP/kECfEPhP9OAOCJJJ94PhP9OP9QARAWP/mEAQP/kECWP+rECJ/+IPhP9OP9QAdAWP/mEAQP/kECZP+rECJJ/8RPhP9OP9QPKBBADCZFHDAVCLFGVAL6MBKKALAE9PMEAIAECIgGVCDTGDvCBCZAD9r/8KBAIABALCDTFGLAD/8QBBDNAVtMBAIAIPBLBGOCkP+rECkP+sEP/6EGRAOCWP+rECkP+sEP/6EARP/gEAOCZP+rECkP+sEP/6EGWP/gEP/kEP/lEGdCBPhP+2EGQARCJJJJ94PhGKP9OP9RP/kEGRjBB/+9CPaARARP/mEAdAdP/mEAWAQAWAKP9OP9RP/kEGRARP/mEP/kEP/kEP/jEP/nEGWP/mEjBBN0PaGQP/kECfEPhP9OAOCJJJ94PhP9OP9QARAWP/mEAQP/kECWP+rECJ/+IPhP9OP9QAdAWP/mEAQP/kECZP+rECJJ/8RPhP9OP9QPKLBKALAIAD/8QBBXEKABAEC98gGDZ+HJJJBADAE9PMBAIAECIgGLCITGVFCBCAAV9r/8KBAIABADCITFGDAV/8QBBAIALZ+HJJJBADAIAV/8QBBKAICAF8kJJJJBK+yIDDUR97DNAEtMBCBHDINABCZFGIAIPBBBGLCBPhGVCJJ98P3ECJJ98P3IGOP9OABPBBBGRALPMLVORXMpScxql358e8fCffEPhP9OP/6EARALPMBEDIWdQKZhoaky8aeGLCZP+sEP/6EGWP/gEALCZP+rECZP+sEP/6EGdP/gEP/kEP/lEGLjB/+fsPaAdALAVP+2EGVAdCJJJJ94PhGQP9OP9RP/kEGdAdP/mEALALP/mEAWAVAWAQP9OP9RP/kEGLALP/mEP/kEP/kEP/jEP/nEGWP/mEjBBN0PaGVP/kECZP+rEAdAWP/mEAVP/kECffIPhP9OP9QGdALAWP/mEAVP/kECUPSCBPlDCBPlICBPlOCBPlRCBPlQCBPlKCBPlpCBPlSP9OGLPMWdkyQK8aeXM35pS8e8fP9QPKBBABARAOP9OAdALPMBEZhDIoaLVcxORqlP9QPKBBABCAFHBADCLFGDAE6MBKKK94EIU8jJJJJBCA9rGI8kJJJJBABAEC98gGLZ+JJJJBDNALAE9PMBAIAECIgGVCITGEFCBCAAE9r/8KBAIABALCITFGBAE/8QBBAIAVZ+JJJJBABAIAE/8QBBKAICAF8kJJJJBK/hILDUE97EUV978jJJJJBCZ9rHDDNAEtMBCBHIINADABPBBBGLABCZFGVPBBBGOPMLVORXMpScxql358e8fGRCZP+sEGWCLP+rEPKLBABjBBJzPaj/zL81zPaAWCIPhP9QP/6EP/nEGWALAOPMBEDIWdQKZhoaky8aeGLCZP+rECZP+sEP/6EP/mEGOAOP/mEAWALCZP+sEP/6EP/mEGdAdP/mEAWARCZP+rECZP+sEP/6EP/mEGRARP/mEP/kEP/kEP/lECBPhP+4EP/jEjB/+fsPaGWP/mEjBBN0PaGLP/kECffIPhGQP9OAdAWP/mEALP/kECZP+rEP9QGdARAWP/mEALP/kECZP+rEAOAWP/mEALP/kEAQP9OP9QGWPMBEZhDIoaLVcxORqlGLP5BADPBLBPeB+t+J83IBABCWFALP5EADPBLBPeE+t+J83IBAVAdAWPMWdkyQK8aeXM35pS8e8fGWP5BADPBLBPeD+t+J83IBABCkFAWP5EADPBLBPeI+t+J83IBABCAFHBAICLFGIAE6MBKKK/3EDIUE978jJJJJBC/AB9rHIDNADCD4AE2GLC98gGVtMBCBHDABHEINAEAEPBBBGOCWP+rECWP+sEP/6EAOCkP+sEClP+rECJJJ/8IPhP+uEP/mEPKBBAECZFHEADCLFGDAV6MBKKDNAVAL9PMBAIALCIgGDCDTGEvCBC/ABAE9r/8KBAIABAVCDTFGVAE/8QBBDNADtMBAIAIPBLBGOCWP+rECWP+sEP/6EAOCkP+sEClP+rECJJJ/8IPhP+uEP/mEPKLBKAVAIAE/8QBBKK9TEIUCBCBYDJ1JJBGEABCIFC98gFGBbDJ1JJBDNDNABzBCZTGD9NMBCUHIABAD9rCffIFCZ4NBCUsMEKAEHIKAIKKKEBCJWKLZ9tBB");var A=WebAssembly.instantiate(function(t){for(var r=new Uint8Array(t.length),n=0;n<t.length;++n){var A=t.charCodeAt(n);r[n]=A>96?A-71:A>64?A-65:A>47?A+4:A>46?63:62}var i=0;for(n=0;n<t.length;++n)r[i++]=r[n]<60?e[r[n]]:64*(r[n]-60)+r[++n];return r.buffer.slice(0,i)}(n),{}).then((function(t){(r=t.instance).exports.__wasm_call_ctors()}));function i(t,e,n,A,i,o){var s=r.exports.sbrk,a=n+3&-4,B=s(a*A),E=s(i.length),c=new Uint8Array(r.exports.memory.buffer);c.set(i,E);var C=t(B,n,A,E,i.length);if(0==C&&o&&o(B,a,A),e.set(c.subarray(B,B+n*A)),s(B-s(0)),0!=C)throw new Error("Malformed buffer data: "+C)}var o={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},s={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:A,supported:!0,decodeVertexBuffer:function(t,e,n,A,s){i(r.exports.meshopt_decodeVertexBuffer,t,e,n,A,r.exports[o[s]])},decodeIndexBuffer:function(t,e,n,A){i(r.exports.meshopt_decodeIndexBuffer,t,e,n,A)},decodeIndexSequence:function(t,e,n,A){i(r.exports.meshopt_decodeIndexSequence,t,e,n,A)},decodeGltfBuffer:function(t,e,n,A,a,B){i(r.exports[s[a]],t,e,n,A,r.exports[o[B]])}}}();function yi(){}yi.s3tc=!0,yi.pvrtc=!1,yi.etc1=!1;const Mi=1,Ni=2,Si=3,Ui=0,di=1,Gi=2,mi={0:Uint32Array.BYTES_PER_ELEMENT,1:Float32Array.BYTES_PER_ELEMENT,2:Float64Array.BYTES_PER_ELEMENT},bi=10,pi=11,wi=1,Hi=2,Ki=16,gi=32,Vi=1,Ji=4,vi=16,Xi=32,Zi=64,ki=128,xi=512,Wi=1024;function Qi(t,e,r){r=t.byteLength;return t=t.subarray(0,0+r),new TextDecoder("utf-8").decode(t)}function ji(t,e,r){let n=e.getUint32(r,!0);return r+=Uint32Array.BYTES_PER_ELEMENT,{string:Qi(new Uint8Array(t,r,n)),bytesOffset:r+=n,length:n}}function Yi(t,e,r,n){let A={},i=[],o=new Array(16);for(let t=0;t<16;t++)o[t]=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;A.matrix=o,A.skeletonNames=i;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<s;n++){let n=ji(t,e,r);i.push(n.string),r=n.bytesOffset}return n.push(A),r}function zi(t,e,r,n,A){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 o={};o.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,o.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,o.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;let s=e.getFloat64(r,!0);if(r+=Float64Array.BYTES_PER_ELEMENT,i.boundingSphere={center:o,radius:s},3===A){const t={};t.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,t.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,t.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;const n={};n.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,n.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,n.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;const A={};A.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,A.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,A.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;const o={};o.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,o.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,o.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,i.obb={xExtent:n,yExtent:A,zExtent:o,obbCenter:t}}let a=ji(t,e,r),B=a.string;r=a.bytesOffset;let E=B.indexOf("Geometry");if(-1!==E){let t=B.substring(E);B=B.replace(t,"")}i.childTile=B,i.geodes=[];let c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<c;n++)r=Yi(t,e,r,i.geodes);if(n.push(i),3===A){r=ji(t,e,r).bytesOffset}return r}function qi(t,e,r,n){let A=e.getUint32(r,!0);if(n.verticesCount=A,(r+=Uint32Array.BYTES_PER_ELEMENT)<=0)return r;let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);o=i*Float32Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let s=A*i*Float32Array.BYTES_PER_ELEMENT,a=new Uint8Array(t,r,s);r+=s;let B=n.vertexAttributes,E=n.attrLocation;return E.aPosition=B.length,B.push({index:E.aPosition,typedArray:a,componentsPerAttribute:i,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function $i(t,e,r,n){let A=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,A<=0)return r;let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let s=A*i*Float32Array.BYTES_PER_ELEMENT,a=new Uint8Array(t,r,s);r+=s;let B=n.vertexAttributes,E=n.attrLocation;return E.aNormal=B.length,B.push({index:E.aNormal,typedArray:a,componentsPerAttribute:i,componentDatatype:5126,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}function to(t,e,r,n){let A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let i,o=n.verticesCount;if(A>0){e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=2*Uint8Array.BYTES_PER_ELEMENT;let n=A*Uint8Array.BYTES_PER_ELEMENT*4;i=new Uint8Array(t,r,n).slice(0,n),r+=n}else{i=new Uint8Array(4*o);for(let t=0;t<o;t++)i[4*t]=255,i[4*t+1]=255,i[4*t+2]=255,i[4*t+3]=255}let s=n.vertexAttributes,a=n.attrLocation;return a.aColor=s.length,s.push({index:a.aColor,typedArray:i,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),n.vertexColor=i,r}function eo(t,e,r,n){let A=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,A<=0)return r;e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=2*Uint8Array.BYTES_PER_ELEMENT;let i=A*Uint8Array.BYTES_PER_ELEMENT*4,o=new Uint8Array(t,r,i);r+=i;let s=n.vertexAttributes,a=n.attrLocation;return a.aSecondColor=s.length,s.push({index:a.aSecondColor,typedArray:o,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:4,normalize:!0}),r}function ro(t,e,r,n){let A=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;for(let i=0;i<A;i++){let A=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 s=A*o*Float32Array.BYTES_PER_ELEMENT,a=new Uint8Array(t,r,s);r+=s;let B="aTexCoord"+i,E=n.vertexAttributes,c=n.attrLocation;c[B]=E.length,E.push({index:c[B],typedArray:a,componentsPerAttribute:o,componentDatatype:5126,offsetInBytes:0,strideInBytes:o*Float32Array.BYTES_PER_ELEMENT,normalize:!1})}return r}function no(t,e,r,n){let A=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let i=n.vertexAttributes,o=n.attrLocation;for(let s=0;s<A;s++){let A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let a=A*s*Float32Array.BYTES_PER_ELEMENT;if(17===s||29===s){let e=new Uint8Array(t,r,a);n.instanceCount=A,n.instanceMode=s,n.instanceBuffer=e,n.instanceIndex=1;let B,E=s*A*4,c=e.slice(0,E);n.vertexColorInstance=c,17===s?(B=17*Float32Array.BYTES_PER_ELEMENT,o.uv2=i.length,i.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:B,instanceDivisor:1}),o.uv3=i.length,i.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv4=i.length,i.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.secondary_colour=i.length,i.push({index:o.secondary_colour,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv6=i.length,i.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1})):29===s&&(B=29*Float32Array.BYTES_PER_ELEMENT,o.uv1=i.length,i.push({index:o.uv1,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:0,strideInBytes:B,instanceDivisor:1,byteLength:a}),o.uv2=i.length,i.push({index:o.uv2,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:4*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv3=i.length,i.push({index:o.uv3,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:8*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv4=i.length,i.push({index:o.uv4,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:12*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv5=i.length,i.push({index:o.uv5,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:16*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv6=i.length,i.push({index:o.uv6,componentsPerAttribute:4,componentDatatype:5126,normalize:!1,offsetInBytes:20*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv7=i.length,i.push({index:o.uv7,componentsPerAttribute:3,componentDatatype:5126,normalize:!1,offsetInBytes:24*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.secondary_colour=i.length,i.push({index:o.secondary_colour,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:27*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}),o.uv9=i.length,i.push({index:o.uv9,componentsPerAttribute:4,componentDatatype:5121,normalize:!0,offsetInBytes:28*Float32Array.BYTES_PER_ELEMENT,strideInBytes:B,instanceDivisor:1}))}else{let t=A*s;n.instanceBounds=new Float32Array(t);for(let A=0;A<t;A++)n.instanceBounds[A]=e.getFloat32(r+A*Float32Array.BYTES_PER_ELEMENT,!0)}r+=a}return r}function Ao(t,e,r,n,A){if(3===A&&(e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT),r=to(t,e,r=$i(t,e,r=qi(t,e,r,n),n),n),3!==A&&(r=eo(t,e,r,n)),r=no(t,e,r=ro(t,e,r,n),n),3===A){r=function(t,e,r,n){const A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let i=0;i<A;i++){const A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;const o=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;const s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;const a=A*o*mi[s],B=new Uint8Array(t,r,a);r+=a;const E=n.vertexAttributes,c=n.attrLocation,C="aCustom"+i;c[C]=E.length,E.push({index:c[C],typedArray:B,componentsPerAttribute:o,componentDatatype:5126,offsetInBytes:0,strideInBytes:0,normalize:!1})}return r}(t,e,r,n);const A=ji(t,e,r);r=A.bytesOffset,n.customVertexAttribute=JSON.parse(A.string);const i="aCustom"+n.customVertexAttribute.TextureCoordMatrix,o="aCustom"+n.customVertexAttribute.VertexWeight;void 0!==n.attrLocation[i]&&(n.attrLocation.aTextureCoordMatrix=n.attrLocation[i],delete n.attrLocation[i]),void 0!==n.attrLocation[o]&&(n.attrLocation.aVertexWeight=n.attrLocation[o],delete n.attrLocation[o]);let s=r%4;s&&(s=4-s),r=function(t,e,r,n){const A=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,A<=0)return r;const i=e.getUint16(r,!0);return r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT,r+=A*i*Float32Array.BYTES_PER_ELEMENT}(0,e,r+=s)}return r}function io(t,e,r,n,A,i){let o,s=0;const a=A.vertexAttributes,B=A.attrLocation;switch(e){case Ji:case vi:case Xi:s=2*Uint16Array.BYTES_PER_ELEMENT,0!=(16&i)||e!==vi&&e!==Xi||(s=2*Float32Array.BYTES_PER_ELEMENT),o=new Uint8Array(t*s);break;case Zi:case ki:s=4*Uint8Array.BYTES_PER_ELEMENT,o=new Uint8Array(4*t);break;case xi:case Wi:s=Float32Array.BYTES_PER_ELEMENT*r,o=new Uint8Array(t*r*4);break;default:s=4*Uint16Array.BYTES_PER_ELEMENT,o=new Uint8Array(t*s)}let E,c;switch(Li.decodeVertexBuffer(o,t,s,n,n.length),e){case Vi:B.aPosition=a.length,a.push({index:B.aPosition,typedArray:new Uint16Array(o.buffer,0,o.length/2),componentsPerAttribute:4,componentDatatype:5122,offsetInBytes:0,strideInBytes:0,normalize:!1}),A.verticesCount=t;break;case Ji:B.aNormal=a.length,a.push({index:B.aNormal,typedArray:new Int16Array(o.buffer,0,o.length/2),componentsPerAttribute:2,componentDatatype:5122,offsetInBytes:0,strideInBytes:0,normalize:!1});break;case vi:0==(16&i)?(c=5126,E=new Float32Array(o.buffer,0,o.length/4)):(c=5122,E=new Uint16Array(o.buffer,0,o.length/2)),B.aTexCoord0=a.length,a.push({index:B.aTexCoord0,typedArray:E,componentsPerAttribute:2,componentDatatype:c,offsetInBytes:0,strideInBytes:0,normalize:!1});break;case Xi:0==(16&i)?(c=5126,E=new Float32Array(o.buffer,0,o.length/4)):(c=5122,E=new Uint16Array(o.buffer,0,o.length/2)),B.aTexCoord1=a.length,a.push({index:B.aTexCoord1,typedArray:E,componentsPerAttribute:2,componentDatatype:c,offsetInBytes:0,strideInBytes:0,normalize:!1});break;case Zi:B.aColor=a.length,a.push({index:B.aColor,typedArray:o,componentsPerAttribute:4,componentDatatype:5121,offsetInBytes:0,strideInBytes:0,normalize:!0});break;case ki:B.aSecondColor=a.length,a.push({index:B.aSecondColor,typedArray:o,componentsPerAttribute:4,componentDatatype:5120,offsetInBytes:0,strideInBytes:0,normalize:!1});break;case xi:B.aCustom0=a.length,a.push({index:B.aCustom0,typedArray:new Float32Array(o.buffer,0,o.length/4),componentsPerAttribute:r,componentDatatype:5126,offsetInBytes:0,strideInBytes:0,normalize:!1});break;case Wi:B.aCustom1=a.length,a.push({index:B.aCustom1,typedArray:new Float32Array(o.buffer,0,o.length/4),componentsPerAttribute:r,componentDatatype:5126,offsetInBytes:0,strideInBytes:0,normalize:!1})}}function oo(t,e,r,n,A){const i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT,n.compressOptions=i;const o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT,n.minVerticesValue={x:0,y:0,z:0,w:0},n.minTexCoordValue=[{x:0,y:0},{x:0,y:0}],n.texCoordCompressConstant=[{x:0,y:0,z:0},{x:0,y:0,z:0}];for(let A=0;A<o;A++){const s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT,n.vertCompressConstant=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.minVerticesValue.x=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,n.minVerticesValue.y=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,n.minVerticesValue.z=e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT;const a=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const B=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const E=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const c=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const C=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const f=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const l=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT;const u=e.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT,n.minTexCoordValue[0].x=E,n.minTexCoordValue[0].y=c,n.minTexCoordValue[1].x=l,n.minTexCoordValue[1].y=u,n.texCoordCompressConstant[0].x=a,n.texCoordCompressConstant[0].y=B,n.texCoordCompressConstant[1].x=C,n.texCoordCompressConstant[1].y=f;const _=e.getInt32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT;for(let A=0;A<_;A++){const A=e.getInt32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT;let o=0;A!==xi&&A!==Wi||(o=e.getInt32(r,!0),r+=Int32Array.BYTES_PER_ELEMENT);const a=e.getInt32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT;const B=new Uint8Array(t,r,a);let E=(r+=Uint8Array.BYTES_PER_ELEMENT*a)%4;E&&(E=4-E),r+=E,io(s,A,o,B,n,i)}let I=ji(t,e,r);r=I.bytesOffset,n.customVertexAttribute=JSON.parse(I.string);let D="aCustom"+n.customVertexAttribute.TextureCoordMatrix,h="aCustom"+n.customVertexAttribute.VertexWeight;void 0!==n.attrLocation[D]&&(n.attrLocation.aTextureCoordMatrix=n.attrLocation[D],A===o-1&&delete n.attrLocation[D]),void 0!==n.attrLocation[h]&&(n.attrLocation.aVertexWeight=n.attrLocation[h],A===o-1&&delete n.attrLocation[h]);let R=r%4;R&&(R=4-R),r+=R}return r}function so(t,e,r,n,A){const i=e.getInt32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT;for(let A=0;A<i;A++){const A={},i=e.getInt32(r,!0);if(r+=Int32Array.BYTES_PER_ELEMENT,i<1)continue;const o=e.getInt8(r,!0);r+=Int8Array.BYTES_PER_ELEMENT,e.getInt8(r,!0),r+=Int8Array.BYTES_PER_ELEMENT;const s=e.getInt8(r,!0);r+=Int8Array.BYTES_PER_ELEMENT,e.getInt8(r,!0),r+=Int8Array.BYTES_PER_ELEMENT;const a=e.getInt32(r,!0);let B;r+=Int32Array.BYTES_PER_ELEMENT,13!==s?(B=new Uint8Array(t,r,a),r+=Uint8Array.BYTES_PER_ELEMENT*a):(B=new Uint32Array(t,r,a),r+=Uint32Array.BYTES_PER_ELEMENT*a);let E,c=r%4;c&&(c=4-c),r+=c,13!==s?(E=new Uint8Array(i*Uint32Array.BYTES_PER_ELEMENT),Li.decodeIndexBuffer(E,i,Uint32Array.BYTES_PER_ELEMENT,B)):E=B;const C=e.getInt32(r,!0);r+=Int32Array.BYTES_PER_ELEMENT,A.indexType=o;const f=0===o?new Uint16Array(i):new Uint32Array(i);A.indicesCount=i;const l=new Uint32Array(E.buffer,E.byteOffset,E.byteLength/4);f.set(l,0),A.indicesTypedArray=f,A.primitiveType=s;for(let n=0;n<C;n++){const n=ji(t,e,r);r=n.bytesOffset,A.materialCode=n.string}n.push(A),c=r%4,c&&(c=4-c),r+=c}return r}function ao(t,e,r,n){let A=e.getUint32(r,!0);return n.compressOptions=A,r+=Uint32Array.BYTES_PER_ELEMENT,r=(A&wi)===wi?function(t,e,r,n){let A=e.getUint32(r,!0);if(n.verticesCount=A,(r+=Uint32Array.BYTES_PER_ELEMENT)<=0)return r;let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=e.getUint16(r,!0);o=i*Int16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;let s=e.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT;let a={};a.x=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,a.y=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,a.z=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,a.w=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.vertCompressConstant=s,n.minVerticesValue=a;let B=A*i*Int16Array.BYTES_PER_ELEMENT,E=new Uint8Array(t,r,B);r+=B;let c=n.vertexAttributes,C=n.attrLocation;return C.aPosition=c.length,c.push({index:C.aPosition,typedArray:E,componentsPerAttribute:i,componentDatatype:5122,offsetInBytes:0,strideInBytes:o,normalize:!1}),r}(t,e,r,n):qi(t,e,r,n),r=(A&Hi)===Hi?function(t,e,r,n){let A=e.getUint32(r,!0);if(r+=Uint32Array.BYTES_PER_ELEMENT,A<=0)return r;e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let i=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT;let o=2*A*Int16Array.BYTES_PER_ELEMENT,s=new Uint8Array(t,r,o);r+=o;let a=n.vertexAttributes,B=n.attrLocation;return B.aNormal=a.length,a.push({index:B.aNormal,typedArray:s,componentsPerAttribute:2,componentDatatype:5122,offsetInBytes:0,strideInBytes:i,normalize:!1}),r}(t,e,r,n):$i(t,e,r,n),r=eo(t,e,r=to(t,e,r,n),n),r=(A&Ki)===Ki?function(t,e,r,n){n.texCoordCompressConstant=[],n.minTexCoordValue=[];let A=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,r+=Uint16Array.BYTES_PER_ELEMENT;for(let i=0;i<A;i++){let A=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 s=e.getUint16(r,!0);r+=Uint16Array.BYTES_PER_ELEMENT,e.getUint16(r,!0),r+=Uint16Array.BYTES_PER_ELEMENT;let a=e.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT,n.texCoordCompressConstant.push(a);let B={};B.x=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,B.y=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,B.z=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,B.w=e.getFloat32(r,!0),r+=Float32Array.BYTES_PER_ELEMENT,n.minTexCoordValue.push(B);let E=o*s*Int16Array.BYTES_PER_ELEMENT,c=new Uint8Array(t,r,E),C=(r+=E)%4;0!==C&&(r+=4-C);let f="aTexCoord"+i,l=n.vertexAttributes,u=n.attrLocation;if(u[f]=l.length,l.push({index:u[f],typedArray:c,componentsPerAttribute:s,componentDatatype:5122,offsetInBytes:0,strideInBytes:s*Int16Array.BYTES_PER_ELEMENT,normalize:!1}),A){E=o*Float32Array.BYTES_PER_ELEMENT;let e=new Uint8Array(t,r,E);r+=E,n.texCoordZMatrix=!0,f="aTexCoordZ"+i,u[f]=l.length,l.push({index:u[f],typedArray:e,componentsPerAttribute:1,componentDatatype:5126,offsetInBytes:0,strideInBytes:Float32Array.BYTES_PER_ELEMENT,normalize:!1})}}return r}(t,e,r,n):ro(t,e,r,n),(A&gi)===gi&&(n.textureCoordIsW=!0),r=no(t,e,r,n)}function Bo(t,e,r,n,A){let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let o=0;o<i;o++){let i={};3===A&&(e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT);let o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let s=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,o>0){let e,n=null;1===s||3===s?(e=o*Uint32Array.BYTES_PER_ELEMENT,n=new Uint8Array(t,r,e)):(e=o*Uint16Array.BYTES_PER_ELEMENT,n=new Uint8Array(t,r,e),o%2!=0&&(e+=2)),i.indicesTypedArray=n,r+=e}i.indicesCount=o,i.indexType=s,i.primitiveType=a;let B=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let n=0;n<B;n++){let n=ji(t,e,r),A=n.string;r=n.bytesOffset,i.materialCode=A}if(0!==r%4){r+=4-r%4}n.push(i)}return r}let Eo={red:0,green:0,blue:0,alpha:0};function co(t,e,r){let n=t.vertexAttributes,A=t.attrLocation,i=n.length;A[1===r?"instanceId":"batchId"]=i,n.push({index:i,typedArray:e,componentsPerAttribute:1,componentDatatype:5126,offsetInBytes:0,strideInBytes:0,instanceDivisor:r})}yi.parseBuffer=function(t){let e=0,r={version:void 0,groupNode:void 0,geoPackage:{},matrials:void 0,texturePackage:{}},n=new DataView(t);r.version=n.getFloat32(e,!0),e+=Float32Array.BYTES_PER_ELEMENT,r.version>=2&&(n.getUint32(e,!0),e+=Uint32Array.BYTES_PER_ELEMENT),r.version>=3&&(n.getUint32(e,!0),e+=Uint32Array.BYTES_PER_ELEMENT),n.getUint32(e,!0),e+=Uint32Array.BYTES_PER_ELEMENT;let A=function(t,e){let r=new Uint8Array(t,e);return fi.inflate(r).buffer}(t,e);n=new DataView(A),e=0;let i=n.getUint32(e,!0);return e+=Uint32Array.BYTES_PER_ELEMENT,e=function(t,e,r,n){let A={},i=[];e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let o=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let A=0;A<o;A++)r=zi(t,e,r,i,n.version);A.pageLods=i;let s=r%4;return 0!==s&&(r+=4-s),n.groupNode=A,r}(A,n,e,r),e=function(t,e,r,n,A){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let o=0;o<i;o++){3===A&&(e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT);let i=ji(t,e,r),o=i.string;r=i.bytesOffset;let s=i.length%4;0!==s&&(r+=4-s);let a=e.getUint32(r,!0);if(r+=Int32Array.BYTES_PER_ELEMENT,3===A)switch(a){case Ui:a=Mi;break;case di:a=Si;break;case Gi:a=Ni}let B={vertexAttributes:[],attrLocation:{},instanceCount:0,instanceMode:0,instanceIndex:-1};a===Mi?r=Ao(t,e,r,B,A):a===Ni&&3===A?r=oo(t,e,r,B):a===Ni&&(r=ao(t,e,r,B));let E,c=[];r=a===Ni&&3===A?so(t,e,r,c):Bo(t,e,r,c,A),2===c.length&&13===c[1].primitiveType&&c[1].indicesCount>=3&&(E=S3MEdgeProcessor.createEdgeDataByIndices(B,c[1])),n[o]={vertexPackage:B,arrIndexPackage:c,edgeGeometry:E},3===A&&(e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT,e.getFloat64(r,!0),r+=Float64Array.BYTES_PER_ELEMENT)}3!==A&&(r+=e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT);return r}(A,n,e,r.geoPackage,r.version),e=function(t,e,r,n){e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;for(let i=0;i<A;i++){let A=ji(t,e,r),i=A.string;r=A.bytesOffset;let o=A.length%4;0!==o&&(r+=4-o),e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let B=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let E=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let C=new Uint8Array(t,r,E);r+=E;let f=c===bi||c===pi?33776:33779;if(22===B&&(f=36196),!yi.s3tc&&(33776===f||33779===f)){let t=new Uint8Array(s*a*4);Oi.decode(t,s,a,C,c),C=t,B=0,f=c===bi||c===bi?273:4369}n[i]={id:i,width:s,height:a,compressType:B,nFormat:c,internalFormat:f,arrayBufferView:C}}return r}(A,n,e,r.texturePackage),e=function(t,e,r,n){let A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let i=Qi(new Uint8Array(t,r,A));return r+=A,n.materials=JSON.parse(i),r}(A,n,e,r),function(t,e,r,n,A,i){if(3===i&&(n=e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT),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=ji(t,e,r),o=n.string;r=n.bytesOffset;let s=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a={};if(A[o].pickInfo=a,-1==A[o].vertexPackage.instanceIndex){let t=new Float32Array(A[o].vertexPackage.verticesCount);for(let n=0;n<s;n++){let A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=[];for(let A=0;A<i;A++){let A=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT,t.fill(n,A,A+i),o.push({vertexColorOffset:A,vertexColorCount:i,batchId:n})}a[A]=o}co(A[o].vertexPackage,t,void 0)}else{let t=A[o].vertexPackage.instanceCount,n=A[o].vertexPackage.instanceBuffer,B=A[o].vertexPackage.instanceMode,E=new Float32Array(t),c=[];for(let t=0;t<s;t++){let t=e.getUint32(r,!0);c.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===i&&(e.getUint32(r,!0),r+=Uint32Array.BYTES_PER_ELEMENT)}let C=17===B?16:28;C*=Float32Array.BYTES_PER_ELEMENT;for(let e=0;e<t;e++){E[e]=e;let t=e*B*Float32Array.BYTES_PER_ELEMENT+C;Cesium.Color.unpack(n,t,Eo);let r=2===i?c[e]:Eo.red+256*Eo.green+65536*Eo.blue;void 0===a[r]&&(a[r]={vertexColorCount:1,instanceIds:[],vertexColorOffset:e}),a[r].instanceIds.push(e)}co(A[o].vertexPackage,E,1)}}}}(A,n,e,i,r.geoPackage,r.version),r};class Co{constructor(t,e,{width:r,height:n,colorDepth:A,format:i}){if(this.format=i,this.offset=e,this.depth=A,this.stride=\n/*!\n * decode-bmp\n * https://github.com/LinusU/decode-bmp\n * MIT License\n */\nfunction(t){const e=t%4;return e?t+4-e:t}(r*this.depth/8),this.size=this.stride*n,this.data=t.subarray(this.offset,this.offset+this.size),this.size!==this.data.byteLength)throw new Error("Truncated bitmap data")}get(t,e,r){const n=this.format.indexOf(r);if(1===this.depth){return(this.data[e*this.stride+(t/8|0)]&1<<7-t%8*1)>>7-t%8*1}if(2===this.depth){return(this.data[e*this.stride+(t/4|0)]&3<<6-t%4*2)>>>6-t%4*2}if(4===this.depth){return(this.data[e*this.stride+(t/2|0)]&15<<4-t%2*4)>>>4-t%2*4}return this.data[e*this.stride+t*(this.depth/8)+n]}}function fo(t,e,r,n,{width:A=0,height:i=0,icon:o=!1}={}){const s=new DataView(e,r,n);let a,B,E,c,C;o?(a=s.getUint32(0,!0),B=s.getUint32(4,!0)/1|0,E=s.getUint32(8,!0)/2|0,c=s.getUint16(14,!0),C=s.getUint32(32,!0)):(!function(t){if(19778!==t)throw new Error(`Invalid magic byte 0x${t.toString(16)}`)}(s.getUint16(0,!0)),a=14+s.getUint32(14,!0),B=s.getUint32(18,!0),E=s.getUint32(22,!0),c=s.getUint16(28,!0),C=s.getUint32(46,!0)),0===C&&c<=8&&(C=1<<c);const f=0===B?A:B,l=0===E?i:E,u=new Uint8Array(s.buffer,s.byteOffset+a,s.byteLength-a),_=t.byteLength===f*l*4,I=C?function(t,e,r,{width:n,height:A,colorDepth:i,colorCount:o,icon:s}){if(8!==i&&4!==i&&2!==i&&1!==i)throw new Error(`A color depth of ${i} is not supported`);const a=new Co(r,0,{width:o,height:1,colorDepth:32,format:"BGRA"}),B=new Co(r,a.offset+a.size,{width:n,height:A,colorDepth:i,format:"C"}),E=s?new Co(r,B.offset+B.size,{width:n,height:A,colorDepth:1,format:"A"}):null,c=t;let C=0;for(let t=0;t<A;t++)for(let r=0;r<n;r++){const n=B.get(r,A-t-1,"C");c[C++]=a.get(n,0,"R"),c[C++]=a.get(n,0,"G"),c[C++]=a.get(n,0,"B"),e&&(c[C++]=E&&E.get(r,A-t-1,"A")?0:255)}return c}(t,_,u,{width:f,height:l,colorDepth:c,colorCount:C,icon:o}):function(t,e,r,{width:n,height:A,colorDepth:i,icon:o}){if(32!==i&&24!==i)throw new Error(`A color depth of ${i} is not supported`);const s=new Co(r,0,{width:n,height:A,colorDepth:i,format:"BGRA"}),a=24===i&&o?new Co(r,s.offset+s.size,{width:n,height:A,colorDepth:1,format:"A"}):null,B=t;let E=0;for(let t=0;t<A;t++)for(let r=0;r<n;r++)B[E++]=s.get(r,A-t-1,"R"),B[E++]=s.get(r,A-t-1,"G"),B[E++]=s.get(r,A-t-1,"B"),e&&(B[E++]=32===i?s.get(r,A-t-1,"A"):a&&a.get(r,A-t-1,"A")?0:255);return B}(t,_,u,{width:f,height:l,colorDepth:c,icon:o});return I}var lo=Object.freeze({DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:33995,TEXTURE12:33996,TEXTURE13:33997,TEXTURE14:33998,TEXTURE15:33999,TEXTURE16:34e3,TEXTURE17:34001,TEXTURE18:34002,TEXTURE19:34003,TEXTURE20:34004,TEXTURE21:34005,TEXTURE22:34006,TEXTURE23:34007,TEXTURE24:34008,TEXTURE25:34009,TEXTURE26:34010,TEXTURE27:34011,TEXTURE28:34012,TEXTURE29:34013,TEXTURE30:34014,TEXTURE31:34015,ACTIVE_TEXTURE:34016,REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,INT_VEC2:35667,INT_VEC3:35668,INT_VEC4:35669,BOOL:35670,BOOL_VEC2:35671,BOOL_VEC3:35672,BOOL_VEC4:35673,FLOAT_MAT2:35674,FLOAT_MAT3:35675,FLOAT_MAT4:35676,SAMPLER_2D:35678,SAMPLER_CUBE:35680,VERTEX_ATTRIB_ARRAY_ENABLED:34338,VERTEX_ATTRIB_ARRAY_SIZE:34339,VERTEX_ATTRIB_ARRAY_STRIDE:34340,VERTEX_ATTRIB_ARRAY_TYPE:34341,VERTEX_ATTRIB_ARRAY_NORMALIZED:34922,VERTEX_ATTRIB_ARRAY_POINTER:34373,VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:34975,IMPLEMENTATION_COLOR_READ_TYPE:35738,IMPLEMENTATION_COLOR_READ_FORMAT:35739,COMPILE_STATUS:35713,LOW_FLOAT:36336,MEDIUM_FLOAT:36337,HIGH_FLOAT:36338,LOW_INT:36339,MEDIUM_INT:36340,HIGH_INT:36341,FRAMEBUFFER:36160,RENDERBUFFER:36161,RGBA4:32854,RGB5_A1:32855,RGB565:36194,DEPTH_COMPONENT16:33189,STENCIL_INDEX:6401,STENCIL_INDEX8:36168,DEPTH_STENCIL:34041,RENDERBUFFER_WIDTH:36162,RENDERBUFFER_HEIGHT:36163,RENDERBUFFER_INTERNAL_FORMAT:36164,RENDERBUFFER_RED_SIZE:36176,RENDERBUFFER_GREEN_SIZE:36177,RENDERBUFFER_BLUE_SIZE:36178,RENDERBUFFER_ALPHA_SIZE:36179,RENDERBUFFER_DEPTH_SIZE:36180,RENDERBUFFER_STENCIL_SIZE:36181,FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:36048,FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:36049,FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:36050,FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:36051,COLOR_ATTACHMENT0:36064,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306,NONE:0,FRAMEBUFFER_COMPLETE:36053,FRAMEBUFFER_INCOMPLETE_ATTACHMENT:36054,FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:36055,FRAMEBUFFER_INCOMPLETE_DIMENSIONS:36057,FRAMEBUFFER_UNSUPPORTED:36061,FRAMEBUFFER_BINDING:36006,RENDERBUFFER_BINDING:36007,MAX_RENDERBUFFER_SIZE:34024,INVALID_FRAMEBUFFER_OPERATION:1286,UNPACK_FLIP_Y_WEBGL:37440,UNPACK_PREMULTIPLY_ALPHA_WEBGL:37441,CONTEXT_LOST_WEBGL:37442,UNPACK_COLORSPACE_CONVERSION_WEBGL:37443,BROWSER_DEFAULT_WEBGL:37444,COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:35840,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:35841,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:35842,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:35843,COMPRESSED_RGBA_ASTC_4x4_WEBGL:37808,COMPRESSED_RGB_ETC1_WEBGL:36196,COMPRESSED_RGBA_BPTC_UNORM:36492,HALF_FLOAT_OES:36193,DOUBLE:5130,READ_BUFFER:3074,UNPACK_ROW_LENGTH:3314,UNPACK_SKIP_ROWS:3315,UNPACK_SKIP_PIXELS:3316,PACK_ROW_LENGTH:3330,PACK_SKIP_ROWS:3331,PACK_SKIP_PIXELS:3332,COLOR:6144,DEPTH:6145,STENCIL:6146,RED:6403,RGB8:32849,RGBA8:32856,RGB10_A2:32857,TEXTURE_BINDING_3D:32874,UNPACK_SKIP_IMAGES:32877,UNPACK_IMAGE_HEIGHT:32878,TEXTURE_3D:32879,TEXTURE_WRAP_R:32882,MAX_3D_TEXTURE_SIZE:32883,UNSIGNED_INT_2_10_10_10_REV:33640,MAX_ELEMENTS_VERTICES:33e3,MAX_ELEMENTS_INDICES:33001,TEXTURE_MIN_LOD:33082,TEXTURE_MAX_LOD:33083,TEXTURE_BASE_LEVEL:33084,TEXTURE_MAX_LEVEL:33085,MIN:32775,MAX:32776,DEPTH_COMPONENT24:33190,MAX_TEXTURE_LOD_BIAS:34045,TEXTURE_COMPARE_MODE:34892,TEXTURE_COMPARE_FUNC:34893,CURRENT_QUERY:34917,QUERY_RESULT:34918,QUERY_RESULT_AVAILABLE:34919,STREAM_READ:35041,STREAM_COPY:35042,STATIC_READ:35045,STATIC_COPY:35046,DYNAMIC_READ:35049,DYNAMIC_COPY:35050,MAX_DRAW_BUFFERS:34852,DRAW_BUFFER0:34853,DRAW_BUFFER1:34854,DRAW_BUFFER2:34855,DRAW_BUFFER3:34856,DRAW_BUFFER4:34857,DRAW_BUFFER5:34858,DRAW_BUFFER6:34859,DRAW_BUFFER7:34860,DRAW_BUFFER8:34861,DRAW_BUFFER9:34862,DRAW_BUFFER10:34863,DRAW_BUFFER11:34864,DRAW_BUFFER12:34865,DRAW_BUFFER13:34866,DRAW_BUFFER14:34867,DRAW_BUFFER15:34868,MAX_FRAGMENT_UNIFORM_COMPONENTS:35657,MAX_VERTEX_UNIFORM_COMPONENTS:35658,SAMPLER_3D:35679,SAMPLER_2D_SHADOW:35682,FRAGMENT_SHADER_DERIVATIVE_HINT:35723,PIXEL_PACK_BUFFER:35051,PIXEL_UNPACK_BUFFER:35052,PIXEL_PACK_BUFFER_BINDING:35053,PIXEL_UNPACK_BUFFER_BINDING:35055,FLOAT_MAT2x3:35685,FLOAT_MAT2x4:35686,FLOAT_MAT3x2:35687,FLOAT_MAT3x4:35688,FLOAT_MAT4x2:35689,FLOAT_MAT4x3:35690,SRGB:35904,SRGB8:35905,SRGB8_ALPHA8:35907,COMPARE_REF_TO_TEXTURE:34894,RGBA32F:34836,RGB32F:34837,RGBA16F:34842,RGB16F:34843,VERTEX_ATTRIB_ARRAY_INTEGER:35069,MAX_ARRAY_TEXTURE_LAYERS:35071,MIN_PROGRAM_TEXEL_OFFSET:35076,MAX_PROGRAM_TEXEL_OFFSET:35077,MAX_VARYING_COMPONENTS:35659,TEXTURE_2D_ARRAY:35866,TEXTURE_BINDING_2D_ARRAY:35869,R11F_G11F_B10F:35898,UNSIGNED_INT_10F_11F_11F_REV:35899,RGB9_E5:35901,UNSIGNED_INT_5_9_9_9_REV:35902,TRANSFORM_FEEDBACK_BUFFER_MODE:35967,MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS:35968,TRANSFORM_FEEDBACK_VARYINGS:35971,TRANSFORM_FEEDBACK_BUFFER_START:35972,TRANSFORM_FEEDBACK_BUFFER_SIZE:35973,TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN:35976,RASTERIZER_DISCARD:35977,MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS:35978,MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS:35979,INTERLEAVED_ATTRIBS:35980,SEPARATE_ATTRIBS:35981,TRANSFORM_FEEDBACK_BUFFER:35982,TRANSFORM_FEEDBACK_BUFFER_BINDING:35983,RGBA32UI:36208,RGB32UI:36209,RGBA16UI:36214,RGB16UI:36215,RGBA8UI:36220,RGB8UI:36221,RGBA32I:36226,RGB32I:36227,RGBA16I:36232,RGB16I:36233,RGBA8I:36238,RGB8I:36239,RED_INTEGER:36244,RGB_INTEGER:36248,RGBA_INTEGER:36249,SAMPLER_2D_ARRAY:36289,SAMPLER_2D_ARRAY_SHADOW:36292,SAMPLER_CUBE_SHADOW:36293,UNSIGNED_INT_VEC2:36294,UNSIGNED_INT_VEC3:36295,UNSIGNED_INT_VEC4:36296,INT_SAMPLER_2D:36298,INT_SAMPLER_3D:36299,INT_SAMPLER_CUBE:36300,INT_SAMPLER_2D_ARRAY:36303,UNSIGNED_INT_SAMPLER_2D:36306,UNSIGNED_INT_SAMPLER_3D:36307,UNSIGNED_INT_SAMPLER_CUBE:36308,UNSIGNED_INT_SAMPLER_2D_ARRAY:36311,DEPTH_COMPONENT32F:36012,DEPTH32F_STENCIL8:36013,FLOAT_32_UNSIGNED_INT_24_8_REV:36269,FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING:33296,FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE:33297,FRAMEBUFFER_ATTACHMENT_RED_SIZE:33298,FRAMEBUFFER_ATTACHMENT_GREEN_SIZE:33299,FRAMEBUFFER_ATTACHMENT_BLUE_SIZE:33300,FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE:33301,FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE:33302,FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE:33303,FRAMEBUFFER_DEFAULT:33304,UNSIGNED_INT_24_8:34042,DEPTH24_STENCIL8:35056,UNSIGNED_NORMALIZED:35863,DRAW_FRAMEBUFFER_BINDING:36006,READ_FRAMEBUFFER:36008,DRAW_FRAMEBUFFER:36009,READ_FRAMEBUFFER_BINDING:36010,RENDERBUFFER_SAMPLES:36011,FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER:36052,MAX_COLOR_ATTACHMENTS:36063,COLOR_ATTACHMENT1:36065,COLOR_ATTACHMENT2:36066,COLOR_ATTACHMENT3:36067,COLOR_ATTACHMENT4:36068,COLOR_ATTACHMENT5:36069,COLOR_ATTACHMENT6:36070,COLOR_ATTACHMENT7:36071,COLOR_ATTACHMENT8:36072,COLOR_ATTACHMENT9:36073,COLOR_ATTACHMENT10:36074,COLOR_ATTACHMENT11:36075,COLOR_ATTACHMENT12:36076,COLOR_ATTACHMENT13:36077,COLOR_ATTACHMENT14:36078,COLOR_ATTACHMENT15:36079,FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:36182,MAX_SAMPLES:36183,HALF_FLOAT:5131,RG:33319,RG_INTEGER:33320,R8:33321,RG8:33323,R16F:33325,R32F:33326,RG16F:33327,RG32F:33328,R8I:33329,R8UI:33330,R16I:33331,R16UI:33332,R32I:33333,R32UI:33334,RG8I:33335,RG8UI:33336,RG16I:33337,RG16UI:33338,RG32I:33339,RG32UI:33340,VERTEX_ARRAY_BINDING:34229,R8_SNORM:36756,RG8_SNORM:36757,RGB8_SNORM:36758,RGBA8_SNORM:36759,SIGNED_NORMALIZED:36764,COPY_READ_BUFFER:36662,COPY_WRITE_BUFFER:36663,COPY_READ_BUFFER_BINDING:36662,COPY_WRITE_BUFFER_BINDING:36663,UNIFORM_BUFFER:35345,UNIFORM_BUFFER_BINDING:35368,UNIFORM_BUFFER_START:35369,UNIFORM_BUFFER_SIZE:35370,MAX_VERTEX_UNIFORM_BLOCKS:35371,MAX_FRAGMENT_UNIFORM_BLOCKS:35373,MAX_COMBINED_UNIFORM_BLOCKS:35374,MAX_UNIFORM_BUFFER_BINDINGS:35375,MAX_UNIFORM_BLOCK_SIZE:35376,MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS:35377,MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS:35379,UNIFORM_BUFFER_OFFSET_ALIGNMENT:35380,ACTIVE_UNIFORM_BLOCKS:35382,UNIFORM_TYPE:35383,UNIFORM_SIZE:35384,UNIFORM_BLOCK_INDEX:35386,UNIFORM_OFFSET:35387,UNIFORM_ARRAY_STRIDE:35388,UNIFORM_MATRIX_STRIDE:35389,UNIFORM_IS_ROW_MAJOR:35390,UNIFORM_BLOCK_BINDING:35391,UNIFORM_BLOCK_DATA_SIZE:35392,UNIFORM_BLOCK_ACTIVE_UNIFORMS:35394,UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:35395,UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:35396,UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:35398,INVALID_INDEX:4294967295,MAX_VERTEX_OUTPUT_COMPONENTS:37154,MAX_FRAGMENT_INPUT_COMPONENTS:37157,MAX_SERVER_WAIT_TIMEOUT:37137,OBJECT_TYPE:37138,SYNC_CONDITION:37139,SYNC_STATUS:37140,SYNC_FLAGS:37141,SYNC_FENCE:37142,SYNC_GPU_COMMANDS_COMPLETE:37143,UNSIGNALED:37144,SIGNALED:37145,ALREADY_SIGNALED:37146,TIMEOUT_EXPIRED:37147,CONDITION_SATISFIED:37148,WAIT_FAILED:37149,SYNC_FLUSH_COMMANDS_BIT:1,VERTEX_ATTRIB_ARRAY_DIVISOR:35070,ANY_SAMPLES_PASSED:35887,ANY_SAMPLES_PASSED_CONSERVATIVE:36202,SAMPLER_BINDING:35097,RGB10_A2UI:36975,INT_2_10_10_10_REV:36255,TRANSFORM_FEEDBACK:36386,TRANSFORM_FEEDBACK_PAUSED:36387,TRANSFORM_FEEDBACK_ACTIVE:36388,TRANSFORM_FEEDBACK_BINDING:36389,COMPRESSED_R11_EAC:37488,COMPRESSED_SIGNED_R11_EAC:37489,COMPRESSED_RG11_EAC:37490,COMPRESSED_SIGNED_RG11_EAC:37491,COMPRESSED_RGB8_ETC2:37492,COMPRESSED_SRGB8_ETC2:37493,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:37494,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:37495,COMPRESSED_RGBA8_ETC2_EAC:37496,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:37497,TEXTURE_IMMUTABLE_FORMAT:37167,MAX_ELEMENT_INDEX:36203,TEXTURE_IMMUTABLE_LEVELS:33503,MAX_TEXTURE_MAX_ANISOTROPY_EXT:34047}),uo={UNSIGNED_BYTE:lo.UNSIGNED_BYTE,UNSIGNED_SHORT:lo.UNSIGNED_SHORT,UNSIGNED_INT:lo.UNSIGNED_INT,FLOAT:lo.FLOAT,HALF_FLOAT:lo.HALF_FLOAT_OES,UNSIGNED_INT_24_8:lo.UNSIGNED_INT_24_8,UNSIGNED_SHORT_4_4_4_4:lo.UNSIGNED_SHORT_4_4_4_4,UNSIGNED_SHORT_5_5_5_1:lo.UNSIGNED_SHORT_5_5_5_1,UNSIGNED_SHORT_5_6_5:lo.UNSIGNED_SHORT_5_6_5,toWebGLConstant:function(t,e){switch(t){case uo.UNSIGNED_BYTE:return lo.UNSIGNED_BYTE;case uo.UNSIGNED_SHORT:return lo.UNSIGNED_SHORT;case uo.UNSIGNED_INT:return lo.UNSIGNED_INT;case uo.FLOAT:return lo.FLOAT;case uo.HALF_FLOAT:return e.webgl2?lo.HALF_FLOAT:lo.HALF_FLOAT_OES;case uo.UNSIGNED_INT_24_8:return lo.UNSIGNED_INT_24_8;case uo.UNSIGNED_SHORT_4_4_4_4:return lo.UNSIGNED_SHORT_4_4_4_4;case uo.UNSIGNED_SHORT_5_5_5_1:return lo.UNSIGNED_SHORT_5_5_5_1;case uo.UNSIGNED_SHORT_5_6_5:return uo.UNSIGNED_SHORT_5_6_5}},isPacked:function(t){return t===uo.UNSIGNED_INT_24_8||t===uo.UNSIGNED_SHORT_4_4_4_4||t===uo.UNSIGNED_SHORT_5_5_5_1||t===uo.UNSIGNED_SHORT_5_6_5},sizeInBytes:function(t){switch(t){case uo.UNSIGNED_BYTE:return 1;case uo.UNSIGNED_SHORT:case uo.UNSIGNED_SHORT_4_4_4_4:case uo.UNSIGNED_SHORT_5_5_5_1:case uo.UNSIGNED_SHORT_5_6_5:case uo.HALF_FLOAT:return 2;case uo.UNSIGNED_INT:case uo.FLOAT:case uo.UNSIGNED_INT_24_8:return 4}},validate:function(t){return t===uo.UNSIGNED_BYTE||t===uo.UNSIGNED_SHORT||t===uo.UNSIGNED_INT||t===uo.FLOAT||t===uo.HALF_FLOAT||t===uo.UNSIGNED_INT_24_8||t===uo.UNSIGNED_SHORT_4_4_4_4||t===uo.UNSIGNED_SHORT_5_5_5_1||t===uo.UNSIGNED_SHORT_5_6_5}},_o=Object.freeze(uo),Io={DEPTH_COMPONENT:lo.DEPTH_COMPONENT,DEPTH_STENCIL:lo.DEPTH_STENCIL,ALPHA:lo.ALPHA,RGB:lo.RGB,RGBA:lo.RGBA,LUMINANCE:lo.LUMINANCE,LUMINANCE_ALPHA:lo.LUMINANCE_ALPHA,RGB_DXT1:lo.COMPRESSED_RGB_S3TC_DXT1_EXT,RGBA_DXT1:lo.COMPRESSED_RGBA_S3TC_DXT1_EXT,RGBA_DXT3:lo.COMPRESSED_RGBA_S3TC_DXT3_EXT,RGBA_DXT5:lo.COMPRESSED_RGBA_S3TC_DXT5_EXT,RGB_PVRTC_4BPPV1:lo.COMPRESSED_RGB_PVRTC_4BPPV1_IMG,RGB_PVRTC_2BPPV1:lo.COMPRESSED_RGB_PVRTC_2BPPV1_IMG,RGBA_PVRTC_4BPPV1:lo.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,RGBA_PVRTC_2BPPV1:lo.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,RGBA_ASTC:lo.COMPRESSED_RGBA_ASTC_4x4_WEBGL,RGB_ETC1:lo.COMPRESSED_RGB_ETC1_WEBGL,RGB8_ETC2:lo.COMPRESSED_RGB8_ETC2,RGBA8_ETC2_EAC:lo.COMPRESSED_RGBA8_ETC2_EAC,RGBA_BC7:lo.COMPRESSED_RGBA_BPTC_UNORM,componentsLength:function(t){switch(t){case Io.RGB:return 3;case Io.RGBA:return 4;case Io.LUMINANCE_ALPHA:return 2;case Io.ALPHA:case Io.LUMINANCE:default:return 1}},validate:function(t){return t===Io.DEPTH_COMPONENT||t===Io.DEPTH_STENCIL||t===Io.ALPHA||t===Io.RGB||t===Io.RGBA||t===Io.LUMINANCE||t===Io.LUMINANCE_ALPHA||t===Io.RGB_DXT1||t===Io.RGBA_DXT1||t===Io.RGBA_DXT3||t===Io.RGBA_DXT5||t===Io.RGB_PVRTC_4BPPV1||t===Io.RGB_PVRTC_2BPPV1||t===Io.RGBA_PVRTC_4BPPV1||t===Io.RGBA_PVRTC_2BPPV1||t===Io.RGBA_ASTC||t===Io.RGB_ETC1||t===Io.RGB8_ETC2||t===Io.RGBA8_ETC2_EAC||t===Io.RGBA_BC7},isColorFormat:function(t){return t===Io.ALPHA||t===Io.RGB||t===Io.RGBA||t===Io.LUMINANCE||t===Io.LUMINANCE_ALPHA},isDepthFormat:function(t){return t===Io.DEPTH_COMPONENT||t===Io.DEPTH_STENCIL},isCompressedFormat:function(t){return t===Io.RGB_DXT1||t===Io.RGBA_DXT1||t===Io.RGBA_DXT3||t===Io.RGBA_DXT5||t===Io.RGB_PVRTC_4BPPV1||t===Io.RGB_PVRTC_2BPPV1||t===Io.RGBA_PVRTC_4BPPV1||t===Io.RGBA_PVRTC_2BPPV1||t===Io.RGBA_ASTC||t===Io.RGB_ETC1||t===Io.RGB8_ETC2||t===Io.RGBA8_ETC2_EAC||t===Io.RGBA_BC7},isDXTFormat:function(t){return t===Io.RGB_DXT1||t===Io.RGBA_DXT1||t===Io.RGBA_DXT3||t===Io.RGBA_DXT5},isPVRTCFormat:function(t){return t===Io.RGB_PVRTC_4BPPV1||t===Io.RGB_PVRTC_2BPPV1||t===Io.RGBA_PVRTC_4BPPV1||t===Io.RGBA_PVRTC_2BPPV1},isASTCFormat:function(t){return t===Io.RGBA_ASTC},isETC1Format:function(t){return t===Io.RGB_ETC1},isETC2Format:function(t){return t===Io.RGB8_ETC2||t===Io.RGBA8_ETC2_EAC},isBC7Format:function(t){return t===Io.RGBA_BC7},compressedTextureSizeInBytes:function(t,e,r){switch(t){case Io.RGB_DXT1:case Io.RGBA_DXT1:case Io.RGB_ETC1:case Io.RGB8_ETC2:return Math.floor((e+3)/4)*Math.floor((r+3)/4)*8;case Io.RGBA_DXT3:case Io.RGBA_DXT5:case Io.RGBA_ASTC:case Io.RGBA8_ETC2_EAC:return Math.floor((e+3)/4)*Math.floor((r+3)/4)*16;case Io.RGB_PVRTC_4BPPV1:case Io.RGBA_PVRTC_4BPPV1:return Math.floor((Math.max(e,8)*Math.max(r,8)*4+7)/8);case Io.RGB_PVRTC_2BPPV1:case Io.RGBA_PVRTC_2BPPV1:return Math.floor((Math.max(e,16)*Math.max(r,8)*2+7)/8);case Io.RGBA_BC7:return Math.ceil(e/4)*Math.ceil(r/4)*16;default:return 0}},textureSizeInBytes:function(t,e,r,n){var A=Io.componentsLength(t);return _o.isPacked(e)&&(A=1),A*_o.sizeInBytes(e)*r*n},alignmentInBytes:function(t,e,r){var n=Io.textureSizeInBytes(t,e,r,1)%4;return 0===n?4:2===n?2:1},createTypedArray:function(t,e,r,n){var A=_o.sizeInBytes(e);return new(A===Uint8Array.BYTES_PER_ELEMENT?Uint8Array:A===Uint16Array.BYTES_PER_ELEMENT?Uint16Array:A===Float32Array.BYTES_PER_ELEMENT&&e===_o.FLOAT?Float32Array:Uint32Array)(Io.componentsLength(t)*r*n)},flipY:function(t,e,r,n,A){if(1===A)return t;for(var i=Io.createTypedArray(e,r,n,A),o=Io.componentsLength(e),s=n*o,a=0;a<A;++a)for(var B=a*n*o,E=(A-a-1)*n*o,c=0;c<s;++c)i[E+c]=t[B+c];return i},toInternalFormat:function(t,e,r){if(!r.webgl2)return t;if(t===Io.DEPTH_STENCIL)return lo.DEPTH24_STENCIL8;if(t===Io.DEPTH_COMPONENT){if(e===_o.UNSIGNED_SHORT)return lo.DEPTH_COMPONENT16;if(e===_o.UNSIGNED_INT)return lo.DEPTH_COMPONENT24}if(e===_o.FLOAT)switch(t){case Io.RGBA:return lo.RGBA32F;case Io.RGB:return lo.RGB32F;case Io.RG:return lo.RG32F;case Io.R:return lo.R32F}if(e===_o.HALF_FLOAT)switch(t){case Io.RGBA:return lo.RGBA16F;case Io.RGB:return lo.RGB16F;case Io.RG:return lo.RG16F;case Io.R:return lo.R16F}return t}},Do=Object.freeze(Io);function ho(t,e,r,n,A,i){const o=function(t,e,r,n){let A=t.length,i=r,o=n,s=0;for(;i>0&&o>0;){if(s+=Do.compressedTextureSizeInBytes(e,i,o),i>>=1,o>>=1,0===i&&0===o)break;i=Math.max(i,1),o=Math.max(o,1)}return s===A}(t,r,A,i);if(!o)return null;const s=6410===r||4369===r;let a=0,B=A,E=i;const c=[];do{let n=Do.compressedTextureSizeInBytes(r,B,E),A=new Uint8Array(t.buffer,e+a,n);c.push(A),B=Math.max(B>>1,1),E=Math.max(E>>1,1),a+=n}while(a<t.byteLength&&o);return{flipY:s,mipmap:c}}const Ro=1,To=2,Fo=4,Po=16;function Oo(t,e){const r={};if(t.compressOptions){let e=t.compressOptions;(e&Ro)===Ro&&(r.COMPRESS_VERTEX=1),(e&To)===To&&(r.COMPRESS_NORMAL=1),(e&Fo)===Fo&&(r.COMPRESS_COLOR=1),(e&Po)===Po&&(r.COMPRESS_TEXCOORD=1)}e.push(r)}function Lo(t){if(t&&Tt(t)){const e=[];for(const r in t)e.push(t[r]);return e}return t}function yo(t,e){const r={},n=t.compressOptions;(n&Ro)===Ro&&(r.decode_position_min=Lo(t.minVerticesValue),r.decode_position_normConstant=Lo(t.vertCompressConstant)),(n&To)===To&&(r.normal_rangeConstant=Lo(t.normalRangeConstant)),(n&Po)===Po&&(t.texCoordCompressConstant.length>0&&(r.decode_texCoord0_min=Lo(t.minTexCoordValue[0]),r.decode_texCoord0_normConstant=Lo(t.texCoordCompressConstant[0]),r.decode_texCoord0_vNormConstant=Lo(t.texCoordCompressConstant[0])),t.texCoordCompressConstant.length>1&&(r.decode_texCoord1_min=Lo(t.minTexCoordValue[1]),r.decode_texCoord1_normConstant=Lo(t.texCoordCompressConstant[1]),r.decode_texCoord1_vNormConstant=Lo(t.texCoordCompressConstant[1])),t.texCoordCompressConstant.length>2&&(r.decode_texCoord2_min=Lo(t.minTexCoordValue[2]),r.decode_texCoord2_normConstant=Lo(t.texCoordCompressConstant[2])),t.texCoordCompressConstant.length>3&&(r.decode_texCoord3_min=Lo(t.minTexCoordValue[3]),r.decode_texCoord3_normConstant=Lo(t.texCoordCompressConstant[3])),t.texCoordCompressConstant.length>4&&(r.decode_texCoord4_min=Lo(t.minTexCoordValue[4]),r.decode_texCoord4_normConstant=Lo(t.texCoordCompressConstant[4])),t.texCoordCompressConstant.length>5&&(r.decode_texCoord5_min=Lo(t.minTexCoordValue[5]),r.decode_texCoord5_normConstant=Lo(t.texCoordCompressConstant[5])),t.texCoordCompressConstant.length>6&&(r.decode_texCoord6_min=Lo(t.minTexCoordValue[6]),r.decode_texCoord6_normConstant=Lo(t.texCoordCompressConstant[6])),t.texCoordCompressConstant.length>7&&(r.decode_texCoord7_min=Lo(t.minTexCoordValue[7]),r.decode_texCoord7_normConstant=Lo(t.texCoordCompressConstant[7]))),e.push(r)}function Mo(t,e){var r,n,A,i=t.bytesOffset,o=yi.parseBuffer(t.buffer,i),s=o.geoPackage,a=o.groupNode.pageLods,B=[],E=[],c=[],C=[],f=[],l=[],u=[],_=[],I=[];if(!a[0].geodes[0])return null;var D=a[0].geodes[0].matrix;const h=[];for(var R={},T=0;T<o.materials.material.length;T++)R[o.materials.material[T].material.id]=o.materials.material[T].material;var F=Number.MAX_VALUE,P=Number.MAX_VALUE,O=Number.MAX_VALUE,L=Number.MIN_VALUE,y=Number.MIN_VALUE,M=Number.MIN_VALUE;for(var N in s){var S=s[N].vertexPackage;r=S.verticesCount;var U=S.vertexAttributes[0].typedArray.buffer,d=S.vertexAttributes[0].typedArray.byteOffset,G=S.vertexAttributes[0].componentsPerAttribute;A=new(fe(S.vertexAttributes[0].componentDatatype))(U,S.vertexAttributes[0].offsetInBytes+d,r*G);const t=Lo(S.minVerticesValue)||[0,0,0],e=Lo(S.vertCompressConstant)||0;for(let n=0;n<r;n++){var m=A[n*G]*e+t[0],b=A[n*G+1]*e+t[1],p=A[n*G+2]*e+t[2];F=Math.min(F,m),P=Math.min(P,b),O=Math.min(O,p),L=Math.max(L,m),y=Math.max(y,b),M=Math.max(M,p)}B.push(A),$o("aColor",S,U,r,C),$o("aTexCoord0",S,U,r,c),$o("aTextureCoordMatrix",S,U,r,h),$o("batchId",S,U,r,f),Oo(S,u),yo(S,_);var w=s[N].arrIndexPackage[0].indicesTypedArray,H=w.byteLength/s[N].arrIndexPackage[0].indicesCount;n=new(4===H?Uint32Array:2===H?Uint16Array:Uint8Array)(w.buffer,(s[N].arrIndexPackage[0].bytesOffset||0)+w.byteOffset,s[N].arrIndexPackage[0].indicesCount),E.push(n),n.length,I.push(r);var K=s[N].arrIndexPackage[0].materialCode;l.push(R[K])}var g=[F,P,O],V=[L,y,M];const J=function(t,e,r,n,A,i,o,s,a,B,E,c,C,f,l,u,_,I){let D=0;for(const t in a)a[t].width*a[t].height*4>D&&(D=a[t].width*a[t].height*4);(!So||D>So)&&(No=new Uint8ClampedArray(D+122),So=D);const h=[],R={magFilter:9729,minFilter:9729,wrapS:10497,wrapT:10497},T={},F={},P=[],O=[],L=[];for(let B=0;B<r.length;B++){const D=e[B],y=t[B],M=r[B],N=A&&A[B]&&A[B],S=i&&i[B],U=n&&n[B]&&n[B],d=o&&o[B]&&o[B],G=s&&s[B]&&s[B],m={POSITION:{array:M,componentType:le(M.constructor),count:y,byteOffset:M.byteOffset,byteStride:0,byteLength:M.byteLength,type:ue(M.length/y),itemSize:M.length/y,name:"POSITION",min:E,max:c}};P.indexOf(M.buffer)<0&&P.push(M.buffer),N&&ts(m,"TEXCOORD_0",N,y,P),S&&ts(m,"TextureCoordMatrix",S,y,P),U&&ts(m,"NORMAL",U,y,P),d&&ts(m,"COLOR_0",d,y,P),G&&ts(m,"_BATCHID",G,y,P);const b={attributes:m,material:B,compressDefines:l[B],compressUniforms:u[B],indices:{array:D.slice(),itemSize:1,byteLength:D.byteLength,byteOffset:0,byteStride:0,name:D,count:D.length,componentType:5123},mode:4};P.push(b.indices.array.buffer);const p={primitives:[b],index:B};F[B]=p;const w={mesh:B,nodeIndex:B,matrix:I};T[B]=w,O.push({nodes:[w]});const H=f[B],K={uFillForeColor:[1,1,1,1]};let g=H.ambient;K.ambientColor=[g.r,g.g,g.b,g.a];let V=H.diffuse;K.uDiffuseColor=[V.r,V.g,V.b,V.a];let J=H.specular;K.specularColor=[J.r,J.g,J.b,J.a],K.shininess=H.shininess,K.bTransparentSorting=H.transparentsorting;let v=H.textureunitstates;if(v.length){K.uTexMatrix=v[0].textureunitstate.texmodmatrix;const t=a[v[0].textureunitstate.id];if(K.uTexture0Width=t.width,v[1]){const t=a[v[1].textureunitstate.id];K.uTexture1Width=t.width}}L.push({pbrMetallicRoughness:{baseColorFactor:[.8,.8,.8,1],metallicFactor:0,roughnessFactor:.5},extensions:{KHR_techniques_webgl:{technique:0,values:K}}}),h.push(mo(B,f,C,a,_).then((t=>{if(!t)return null;const{array:e,mipmap:r,width:n,height:A,format:i,flipY:o}=t;if(e&&P.indexOf(e.buffer)<0&&P.push(e.buffer),r)for(let t=0;t<r.length;t++)e&&P.indexOf(r[t].buffer)<0&&P.push(r[t].buffer);let s=R;return r&&(s={magFilter:R.magFilter,minFilter:9987,wrapS:R.wrapS,wrapT:R.wrapT}),{materialIndex:B,image:{mipmap:r,array:e,flipY:!!o,width:n,height:A,mimeType:"image/bmp"},sampler:s,format:i,source:B}})))}return Promise.all(h).then((t=>{t=t.filter((t=>!!t));for(let e=0;e<t.length;e++){const{materialIndex:r}=t[e];let n="uTexture";L[r].extensions.KHR_techniques_webgl.values.uTexture&&(n="uTexture2"),L[r].extensions.KHR_techniques_webgl.values[n]={"index":e,"texCoord":r},delete t[e].materialIndex}return{transferables:P,gltf:{"asset":{"generator":"S3M","version":"2.0"},"scene":0,"scenes":O,"nodes":T,"meshes":F,"materials":L,"skins":[],"animations":null,"textures":t,"transferables":[{},{},{},{},{}]}}}))}(I,E,B,null,c,h,C,f,o.texturePackage,0,g,V,[],l,u,_,e,D);return J.then((({gltf:t,transferables:e})=>({gltf:t,featureTable:{"BATCH_LENGTH":0},transferables:e,pageLods:a})))}yi.multiplyByPoint=function(t,e,r){var n=e.x,A=e.y,i=e.z,o=t[0]*n+t[4]*A+t[8]*i+t[12],s=t[1]*n+t[5]*A+t[9]*i+t[13],a=t[2]*n+t[6]*A+t[10]*i+t[14];return r.x=o,r.y=s,r.z=a,r};let No,So=0;let Uo=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(On){}t&&"undefined"!=typeof createImageBitmap&&(Uo=!0)}const Go={};function mo(t,e,r,n,A){const i=No;return new Promise((function(r){!function(t){if(e[t].textureunitstates[0]){var o=e[t].textureunitstates[0].textureunitstate.id,s=n[o],a=s.arrayBufferView,B=s.nFormat,E=s.internalFormat;if(function(t){return t===Vo||t===Jo||t===vo||t===Xo||t===Zo||t===ko||t===xo||t===Wo||t===Qo||t===jo||t===Yo||t===zo||t===qo}(E)&&s.width===s.height){const t=ho(a,a.byteOffset,E,0,s.width,s.height);if(t){const{mipmap:e,flipY:n}=t;return void r({format:E,mipmap:e,flipY:n,width:s.width,height:s.height})}}let c;c=B>ui||B===li?122+s.width*s.height*4:61+s.width*s.height,Oi.decode(i.subarray(122),s.width,s.height,a,B),function(t,e,r){var n=r*(4*e+e%4),A=n+o,i=new DataView(t),o=0;i.setUint16(o,19778,!0),o+=2,i.setUint32(o,A,!0),o+=4,i.setUint32(o,0,!0),o+=4,i.setUint32(o,122,!0),o+=4,i.setUint32(o,108,!0),o+=4,i.setUint32(o,e,!0),o+=4,i.setUint32(o,r,!0),o+=4,i.setUint16(o,1,!0),o+=2,i.setUint16(o,32,!0),o+=2,i.setUint32(o,this.compress,!0),o+=4,i.setUint32(o,n,!0),o+=4,i.setUint32(o,2835,!0),o+=4,i.setUint32(o,2835,!0),o+=4,i.setUint8(o,0,!0),o+=4,i.setUint32(o,0,!0),o+=4,i.setUint32(o,16711680,!0),o+=4,i.setUint32(o,65280,!0),o+=4,i.setUint32(o,255,!0),o+=4,i.setUint32(o,4278190080,!0),o+=4,i.setUint32(o,1466527264,!0),o+=4}(i.buffer,s.width,s.height);let{width:C,height:f}=s;bo(C)||(C=po(C)),bo(f)||(f=po(f));const l=A;let u;l&&(C=Math.min(l,C),f=Math.min(l,f));let _=6408;const I=s.width*s.height*4;!Uo||C===s.width&&f===s.height?(u=new Uint8Array(3*I/4),_=6407):(Go[I]||(Go[I]=new Uint8Array(I)),u=Go[I]),u=fo(u,i.buffer,0,c),!Uo||C===s.width&&f===s.height||(u=function(t,e,r,n,A){wo||(wo=new OffscreenCanvas(2,2),Ho=wo.getContext("2d"),Ko=new OffscreenCanvas(2,2),go=Ko.getContext("2d",{willReadFrequently:!0}));const i=new ImageData(new Uint8ClampedArray(t.buffer),e,r);return wo.width=e,wo.height=r,Ho.putImageData(i,0,0),Ko.width=n,Ko.height=A,go.drawImage(wo,0,0,n,A),go.getImageData(0,0,n,A).data}(u,s.width,s.height,C,f)),u.buffer===(Go[I]&&Go[I].buffer)&&(u=new Uint8Array(u)),r({array:u,width:C,height:f,format:_})}else r(null)}(t)}))}function bo(t){return 0==(t&t-1)&&0!==t}function po(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}let wo,Ho,Ko,go;const Vo=33776,Jo=33777,vo=33778,Xo=33779,Zo=35840,ko=35841,xo=35842,Wo=35843,Qo=37808,jo=36196,Yo=37492,zo=37496,qo=36492;function $o(t,e,r,n,A){var i=e.attrLocation[t];if(i){const t=e.vertexAttributes[i];if(t.typedArray.buffer!==r)A.push(t.typedArray);else{var o=t.componentsPerAttribute;var s=new(fe(t.componentDatatype))(r,t.offsetInBytes+t.typedArray.byteOffset,n*o);A.push(s)}}else A.push(void 0)}function ts(t,e,r,n,A){t[e]={array:r,componentType:le(r.constructor),count:n,byteOffset:r.byteOffset,byteStride:0,byteLength:r.byteLength,type:ue(r.length/n),itemSize:r.length/n,name:e},A.indexOf(r.buffer)<0&&A.push(r.buffer)}var es=os("DXT1"),rs=os("DXT3"),ns=os("DXT5"),As=os("DX10"),is=function(t){var e,r,n=new Int32Array(t,0,31);if(542327876!==n[0])throw new Error("Invalid magic number in DDS header");if(4&!n[20])throw new Error("Unsupported format, must contain a FourCC code");var A=n[21];switch(A){case es:e=8,r="dxt1";break;case rs:e=16,r="dxt3";break;case ns:e=16,r="dxt5";break;case 116:r="rgba32f";break;case As:var i=new Uint32Array(t.slice(128,148));r=i[0];var o=i[1];if(i[2],i[3],i[4],3!==o||2!==r)throw new Error("Unsupported DX10 texture format "+r);r="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(s=A,String.fromCharCode(255&s,s>>8&255,s>>16&255,s>>24&255)))}var s;var a=n[2],B=1;131072&a&&(B=Math.max(1,n[7]));var E=!1;512&n[28]&&(E=!0);var c,C=n[4],f=n[3],l=n[1]+4,u=C,_=f,I=[];A===As&&(l+=20);if(E)for(var D=0;D<6;D++){if("rgba32f"!==r)throw new Error("Only RGBA32f cubemaps are supported");C=u,f=_;for(var h=Math.log(C)/Math.log(2)+1,R=0;R<h;R++)c=C*f*16,I.push({offset:l,length:c,shape:[C,f]}),R<B&&(l+=c),C=Math.floor(C/2),f=Math.floor(f/2)}else for(R=0;R<B;R++)c=Math.max(4,C)/4*Math.max(4,f)/4*e,I.push({offset:l,length:c,shape:[C,f]}),l+=c,C=Math.floor(C/2),f=Math.floor(f/2);return{shape:[u,_],images:I,format:r,flags:a,cubemap:E}};function os(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}const ss=Math.PI/180,as=6378137*Math.PI/180,Bs=85.0511287798;function Es(t,e,r){if("EPSG:3857"===r)return function(t,e){const r=Bs,n=e[0],A=Math.max(Math.min(r,e[1]),-r);let i;i=0===A?0:Math.log(Math.tan((90+A)*ss/2))/ss;return t[0]=n*as,t[1]=i*as,t}(t,e);if("EPSG:4326"===r||"EPSG:4490"===r||"identity"===r)return cs(t,e);if("baidu"===r)return cs(t,e);throw new Error("unsupported projection:"+r)}function cs(t,e){return t[0]=e[0],t[1]=e[1],t}const Cs=i([]),fs=Re().draco,ls=Re().ktx2,us={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},_s={"position":{name:"POSITION",accessor:{"componentType":5126,"type":"VEC3"}},"normal":{name:"NORMAL",accessor:{"componentType":5126,"type":"VEC3"}},"uv0":{name:"TEXCOORD_0",accessor:{"componentType":5126,"type":"VEC2"}},"color":{name:"COLOR_0",accessor:{"componentType":5121,"type":"VEC4"}},"uv-region":{name:"uvRegion",accessor:{"componentType":5123,"type":"VEC4"}},"feature-index":{name:"_BATCHID",accessor:{"componentType":5125,"type":"SCALAR"}},"faceRange":{name:"faceRange",accessor:{"componentType":5125,"type":"VEC2"}}};function Is(t,e,r,n){const A=[],o=[],s=[];for(let e=0;e<t.meshes.length;e++){const{geometry:r,material:n}=t.meshes[e];let i=Y.getArrayBuffer(r.url);i.xhr.url=r.url,s.push(i.xhr);const a=i.then((t=>({buffer:t})));A.push(a);const B=[];if(Ls(n,B),B.length){const t=B.map((t=>{const e=Y.getArrayBuffer(t.url);return e.xhr.url=t.url,s.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));A.push(...t)}o[e]=B.length}const a=Promise.all(A).then((A=>{for(let t=0;t<A.length;t++)if(!A[t]||!A[t].buffer)return Promise.resolve(null);const s=[];let a=0;for(let t=0;t<o.length;t++){const e=o[t];s.push({geoBuffer:{data:A[a].buffer.data},textureBuffers:A.slice(a+1,e+a+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),a+=1+e}const B=function(t,e,r,n,A){const o={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},s=[];for(let a=0;a<t.meshes.length;a++){let B,{geometry:E,material:c}=t.meshes[a];const C=e[a].geoBuffer.data;if(!C)continue;B=ds(C)?hs(o,a,E,C,t.transform,t.center,A):Ts(o,a,E,C,t.transform,t.center,A),s.push(B),o.nodes[a]={mesh:a,nodeIndex:a,matrix:i([])},o.scenes[0].nodes[a]=o.nodes[a],c||(c=us);const f=Ps(a,o,c,e[a].textureBuffers,r,n);s.push(f)}return Promise.all(s).then((()=>({gltf:o,featureTable:{BATCH_LENGTH:0},transferables:o.transferables})))}(t,s,e,n,r);return B}));return a.xhr=s,a}const Ds={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function hs(t,e,r,n,A,i,o){const s=r.info.compressedAttributes.attributes.reduce(((t,e,r)=>{const n=_s[e];if(!n)return t;return t[n.name||e]=r,t}),{});return fs(n,{attributes:s,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((r=>Fs(r,t,e,A,i,o)))}var Rs={position:function(t,e,r){const n=3*t.vertexCount,A=new Float32Array(e,r,n);return t.position={array:A,componentType:5126,itemSize:3,count:n/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},r+=4*n},normal:function(t,e,r){var n=3*t.vertexCount;const A=new Float32Array(e,r,n);return t.normal={array:A,componentType:5126,itemSize:3,count:n/3,type:"VEC3"},r+=4*n},uv0:function(t,e,r){var n=2*t.vertexCount;const A=new Float32Array(e,r,n);return t.uv0={array:A,componentType:5126,itemSize:2,count:n/2,type:"VEC2"},r+=4*n},color:function(t,e,r){var n=4*t.vertexCount;const A=new Uint8Array(e,r,n);return t.color={array:A,componentType:5121,itemSize:4,count:n/4,type:"VEC4"},r+=n},featureId:function(t,e,r){return r+=8*t.featureCount},id:function(t,e,r){return r+=8*t.featureCount},faceRange:function(t,e,r){var n=2*t.featureCount;const A=new Uint32Array(e,r,n);return t.faceRange={array:A,componentType:5125,itemSize:2,count:n/2,type:"VEC2"},r+=4*n},uvRegion:function(t,e,r){var n=4*t.vertexCount;const A=new Uint16Array(e,r,n);return t["uv-region"]={array:A,componentType:5123,itemSize:4,count:n/4,type:"VEC4"},r+=2*n},region:function(t,e,r){var n=4*t.vertexCount;const A=new Uint16Array(e,r,n);return t["uv-region"]={array:A,componentType:5123,itemSize:4,count:n/4,type:"VEC4"},r+=2*n}};function Ts(t,e,r,n,A,i,o){const s={vertexCount:0},a=new DataView(n);try{var B=0;s.vertexCount=a.getUint32(B,1),B+=4,s.featureCount=a.getUint32(B,1),B+=4;const t=r.info.ordering?null:r.info;if(t){const e=[];for(const r in t)"offset"!==r&&""!==r&&e.push(r);for(var E=0;E<e.length;E++)Rs[e[E]]?B=Rs[e[E]](s,n,B):console.error("Unknown decoder for",e[E])}else{const t=r.info;let e=t.ordering,A=t.featureAttributeOrder;const i=null;i&&i.geometryData&&i.geometryData[0]&&i.geometryData[0].params;for(var c=0;c<e.length;c++){var C=Rs[e[c]];C||console.log(e[c]),B=C(s,n,B)}for(var f=0;f<A.length;f++){var l=Rs[A[f]];l||console.log(A[f]),B=l(s,n,B)}}}catch(t){}s.scale_x=1,s.scale_y=1;const u={};for(const t in s){const e=_s[t]&&_s[t].name;e&&(u[e]=s[t])}if(s.faceRange){const t=s.faceRange.array,e=t.length/2,r=(_=e)<=255?Uint8Array:_<=65535?Uint16Array:Uint32Array,n=new r(u.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const r=e/2,A=t[e],i=t[e+1];for(let t=A;t<=i;t++)n[3*t]=r,n[3*t+1]=r,n[3*t+2]=r}u._BATCHID={componentType:le(r),array:n,itemSize:1,count:n.length,type:"SCALAR"}}var _;return Fs({attributes:u},t,e,A,i,o)}function Fs(t,e,r,n,A,i){const o={attributes:t.attributes,material:r,indices:t.indices,mode:4};!function(t){const e=t.array,r=t.meta&&t.meta["i3s-scale_x"],n=t.meta&&t.meta["i3s-scale_y"];if(r&&n&&(1!==r||1!==n))for(let t=0;t<e.length;t+=3)e[t]*=r.value,e[t+1]*=n.value}(t.attributes.POSITION);const s=function(t,e,r,n){const A=r;let i,o=[0,0,0,1],s=[0,0];const a=Es([],r,n);a[2]=r[2];const B=e&&E(Cs,e);return He(t,(t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],B||(o=O(o,o,e)),A&&_(o,o,A),Es(s,o,n),i=o[2],t[0]=s[0]-a[0],t[1]=s[1]-a[1],t[2]=i-a[2],t))),a}(t.attributes.POSITION,n,A,i);e.meshes[r]={primitives:[o],index:r},e.extensions.MAPTALKS_RTC={projCenter:s},e.extensions.CESIUM_RTC={rtcCoord:A};for(const r in t.attributes)Us(e.transferables,t.attributes[r].array.buffer);return t.indices&&Us(e.transferables,t.indices.array.buffer),o}function Ps(t,e,r,n,A,i){const o=n.map((t=>function(t,e,r,n,A){if("dds"===e){const e=is(t),n=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),A="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:n,width:e.shape[0],height:e.shape[1],mimeType:r},sampler:Ds,format:A})}if("png"===e||"jpg"===e)return function(t,e){ys||(ys=new OffscreenCanvas(2,2),Ms=ys.getContext("2d",{willReadFrequently:!0}));const r=new Blob([new Uint8Array(t)]);return createImageBitmap(r).then((t=>{let{width:r,height:n}=t;Ns(r)||(r=Ss(r)),Ns(n)||(n=Ss(n));const A=e;A&&(r=Math.min(A,r),n=Math.min(A,n)),ys.width=r,ys.height=n,Ms.drawImage(t,0,0,r,n),t.close();const i=Ms.getImageData(0,0,r,n);return{width:r,height:n,array:new Uint8Array(i.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,A).then((t=>{t.mimeType=r;return{image:t,sampler:Ds,format:6408}}));if("ktx2"===e)return ls(t,n).then((t=>(t.mimeType=r,{image:t,sampler:Ds,format:t.format})))}(t.data,t.format,t.mimeType,A,i).then((t=>{if(t.image)if(t.image.array)Us(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let r=0;r<t.image.mipmap.length;r++)Us(e.transferables,t.image.mipmap[r].buffer);return t}))));return Promise.all(o).then((n=>{Os(t,e,r,n)}))}function Os(t,e,r,n){const A=JSON.parse(JSON.stringify(r)),i=e.textures;n.ptr||(n.ptr=0);for(const t in r)r[t]&&r[t].url?(i.push(n[n.ptr++]),A[t]={index:i.length-1},void 0!==r[t].factor&&(A[t].scale=r[t].factor)):Tt(r[t])&&(A[t]=Os(-1,e,r[t],n));return t>=0&&(e.materials[t]=A),A}function Ls(t,e){for(const r in t)t[r]&&t[r].url?e.push({url:t[r].url,mimeType:t[r].mimeType,format:t[r].format}):Tt(t[r])&&Ls(t[r],e)}let ys,Ms;function Ns(t){return 0==(t&t-1)&&0!==t}function Ss(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Us(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function ds(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}const Gs=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],ms=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],bs="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let ps,ws,Hs=!1;if("undefined"!=typeof OffscreenCanvas){try{ws=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(On){}ws&&"undefined"!=typeof createImageBitmap&&(Hs=!0)}const Ks=i([]),gs=[0,0,0],Vs=[],Js=[],vs=[],Xs=[];class Zs{constructor(t,e,r,n){this.id=t,this.options=e,this.Pt=this.requestImage.bind(this),this.Ot=r,this.Lt={},n(null,{},[])}yt(t){this.Mt||(this.i=t,this.Nt=new ye,this.Mt=new Te(this.Pt,lt,t),this.St=new Fe(this.Pt,lt,t))}requestImage(t,e){Hs?fetch(t).then((t=>t.blob())).then((t=>createImageBitmap(t))).then((t=>{ps.width=t.width,ps.height=t.height,ws.drawImage(t,0,0);const r=ws.getImageData(0,0,ps.width,ps.height);e(null,{width:t.width,height:t.height,data:new Uint8Array(r.data)})})):this.Ot("requestImage",{url:t},null,e)}loadTile(t,e){this.yt(t.supportedFormats);const r=t.url,n=t.arraybuffer;if(function(t){return t.indexOf("i3s:")>=0}(r)){const n=t.i3sInfo,A=this.options.services[t.rootIdx].maxTextureSize||1024,i=Is(n,t.supportedFormats,this.options.projection,A);return i.then((t=>{if(delete this.Lt[r],!t)return void e({status:404,url:r,i3sInfo:n});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:n});t.gltf.url=r;const{transferables:A}=t;t.magic="b3dm",e(null,t,A)})),void(this.Lt[r]=i.xhr)}if(n){delete this.Lt[r];const A=new DataView(n),i=Jt(A,0);if("{"===i[0]||" "===i[0]||"<"===i[0]){const A=function(t,e,r){if(bs){const n=new Uint8Array(t,e,r);return bs.decode(n)}return yt(new Uint8Array(t,e,r))}(n,0,n.byteLength),i=JSON.parse(A);this.Ut(t.rootIdx,i,n,r,e)}else{const o=A.getFloat32(0,!0);1===o||2===o||3===o?this.dt(n,r,t,e):this.Gt(n,r,t,i,e)}}else{const n=this.options.services[t.rootIdx];let A=n.urlParams;A&&(A=(r.indexOf("?")>0?"&":"?")+A);const i=r.replace(/\\+/g,"%2B");let o=Y.getArrayBuffer(i+(A||""),n.fetchOptions);const s=o.xhr;o=o.then((n=>{delete this.Lt[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this.Lt[r],e(t)})),this.Lt[r]=s}}Gt(t,e,r,n,A){const i=this.options.services[r.rootIdx];if("b3dm"===n){this.Mt.load(e,t,0,0,{maxTextureSize:i.maxTextureSize||1024}).then((t=>{if(t.error)return void A(t);const{content:e,transferables:n}=this.bt(t,r);A(null,e,n)})).catch((t=>{A(t)}))}else if("pnts"===n){const n=r.transform;this.Nt.load(e,t).then((t=>{const{content:e,transferables:i}=this.wt(t,n,r.rootIdx);A(null,e,i)}))}else if("i3dm"===n){const n=r.transform;this.St.load(e,t,0,0,{maxTextureSize:i.maxTextureSize||1024}).then((t=>{const{content:e,transferables:i}=this.wt(t,n,r.rootIdx);A(null,e,i)}))}else if("cmpt"===n){new Ne(this.Pt,lt,this.i,i.maxTextureSize||1024).load(e,t,0,0,{maxTextureSize:i.maxTextureSize||1024}).then((t=>{const{content:e,transferables:n}=this.Ht(t,r);A(null,e,n)})).catch((t=>{A(t)}))}}dt(t,e,r,n){Mo({buffer:t,bytesOffset:0},this.options.services[r.rootIdx].maxTextureSize||1024).then((t=>{t.gltf.url=e;const{content:A,transferables:i}=this.bt(t,r);if(A.magic="b3dm",t.pageLods){const e=this.Kt(t.pageLods);e.length&&(A.children=e)}n(null,A,i)}))}Kt(t){const e=[];for(let r=0;r<t.length;r++){const n=t[r];if(!n.childTile)continue;const A={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(A)}return e}Ut(t,e,r,n,A){return e.dataType&&e.position?void A(null,Ve(e)):(e.capabilities,void A(null,e))}Ht(t,e){const{tiles:r}=t,n={magic:"cmpt",content:[]},A=[];for(let t=0;t<r.length;t++){const{magic:i}=r[t];if("b3dm"===i){const{content:i,transferables:o}=this.bt(r[t],e);Qs(A,o),n.content.push(i)}else if("i3dm"===i||"pnts"===i){const{transform:i,rootIdx:o}=e,{content:s,transferables:a}=this.wt(r[t],i,o);Qs(A,a),n.content.push(s)}else if("cmpt"===i){const{content:i,transferables:o}=this.Ht(r[t],e);Qs(A,o),n.content.push(i)}}return{content:n,transferables:A}}bt(t,e){const{gltf:r,transferables:n,featureTable:A}=t,i=function(t){if(!t||!t.meshes)return!1;const e="visited";let r=1;const n=[];for(const A in t.meshes){const i=t.meshes[A],{primitives:o}=i;if(o)for(let t=0;t<o.length;t++){const A=o[t].attributes&&o[t].attributes.POSITION;if(!A||!A.array)continue;A.array.buffer[e]||(A.array.buffer[e]=r++);const i=r-1+"-"+(A.byteOffset||0);if(n.indexOf(i)>=0)return!0;n.push(i)}}return!1}(r);return this.gt(t.gltf),t.gltf.asset||(t.gltf.asset={}),i?(t.gltf.asset.sharePosition=!0,this.Vt(r,A,e.upAxis,e.transform)):this.Jt(r,A,e.upAxis,e.transform),delete t.transferables,{content:t,transferables:n}}wt(t,e,r){const{featureTable:A}=t,i=t.pnts||t.i3dm;let o=A&&A.RTC_CENTER||[0,0,0];if(A.EAST_NORTH_UP&&!i.NORMAL_UP&&!i.NORMAL_UP_OCT32P){const e=new Float32Array(3*i.POSITION.array.length),r=[],A=[],s=[];He(i.POSITION,((t,i)=>{_(s,t,o),oe(s,null,r),n(A,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)),A)})),i.INSTANCE_ROTATION={byteStride:0,byteOffset:0,itemSize:9,componentType:5126,array:e},t.transferables.push(e.buffer)}const s={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};xs(i.POSITION.array,3,o,Ks,s);const a=Ws(s),B=l([],a),E=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];He(i.POSITION,(t=>{t[0]=t[0]+o[0]-B[0],t[1]=t[1]+o[1]-B[1],t[2]=t[2]+o[2]-B[2],t[0]<E[0]&&(E[0]=t[0]),t[1]<E[1]&&(E[1]=t[1]),t[2]<E[2]&&(E[2]=t[2]),t[0]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])})),i.POSITION.min=E,i.POSITION.max=c,e&&O(a,a,e);const C=this.vt(a);t.rtcCenter=B,t.rtcCoord=C,t.rootIdx=r;const f=t.transferables;return delete t.transferables,{content:t,transferables:f}}gt(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],A=r[1],i=r[2],o=r[3];let s=!0;for(let t=4;t<r.length;t+=4)if(r[t]!==n||r[t+1]!==A||r[t+2]!==i||r[t+3]!==o){s=!1;break}s&&(e[t].image.color=[n/255,A/255,i/255,o/255],delete e[t].image.array)}}}abortTileLoading(t,e){const r=this.Lt[t.url];if(Array.isArray(r))for(let t=0;t<r.length;t++)r[t].abort();else r&&r.abort&&r.abort();delete this.Lt[t.url],e(null)}Xt(t,e,r,n){let A=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center,s=Gs;"X"===(r=r&&r.toUpperCase())?s=ms:"Z"===r&&(s=Ks),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),A&&(t.extensions.CESIUM_RTC.center=A),t.extensions.MAPTALKS_RTC={};const a={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Se(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=i(Vs);t.matrices&&js(e,t.matrices);const r=t.attributes.POSITION.array,B=t.attributes.POSITION.itemSize;o(e,s,e),n&&o(e,n,e),xs(r,B,A||gs,e,a,t.compressUniforms)}));const B=Ws(a);return{rtcCenter:A,modelCenter:B,upAxisTransform:s}}Vt(t,e,r,n){const{modelCenter:A,upAxisTransform:s,rtcCenter:a}=this.Xt(t,e,r),B=l([],A);n&&O(A,A,n),t.extensions.CESIUM_RTC.rtcCoord=this.vt(A),a||(Se(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=i(Vs);t.matrices&&js(r,t.matrices),o(r,s,r);const n=function(t,e){var r=e[0],n=e[1],A=e[2],i=e[3],o=e[4],s=e[5],a=e[6],B=e[7],E=e[8],c=e[9],C=e[10],f=e[11],l=e[12],u=e[13],_=e[14],I=e[15],D=r*s-n*o,h=r*a-A*o,R=r*B-i*o,T=n*a-A*s,F=n*B-i*s,P=A*B-i*a,O=E*u-c*l,L=E*_-C*l,y=E*I-f*l,M=c*_-C*u,N=c*I-f*u,S=C*I-f*_,U=D*S-h*N+R*M+T*y-F*L+P*O;return U?(U=1/U,t[0]=(s*S-a*N+B*M)*U,t[1]=(A*N-n*S-i*M)*U,t[2]=(u*P-_*F+I*T)*U,t[3]=(C*F-c*P-f*T)*U,t[4]=(a*y-o*S-B*L)*U,t[5]=(r*S-A*y+i*L)*U,t[6]=(_*R-l*P-I*h)*U,t[7]=(E*P-C*R+f*h)*U,t[8]=(o*N-s*y+B*O)*U,t[9]=(n*y-r*N-i*O)*U,t[10]=(l*F-u*R+I*D)*U,t[11]=(c*R-E*F-f*D)*U,t[12]=(s*L-o*M-a*O)*U,t[13]=(r*M-n*L+A*O)*U,t[14]=(u*h-l*T-_*D)*U,t[15]=(E*T-c*h+C*D)*U,t):null}(Js,r),A=[1/0,1/0,1/0],a=[-1/0,-1/0,-1/0];He(e,(t=>{O(t,t,r),t[0]=t[0]-B[0],t[1]=t[1]-B[1],t[2]=t[2]-B[2],O(t,t,n),t[0]<A[0]&&(A[0]=t[0]),t[1]<A[1]&&(A[1]=t[1]),t[2]<A[2]&&(A[2]=t[2]),t[0]>a[0]&&(a[0]=t[0]),t[1]>a[1]&&(a[1]=t[1]),t[2]>a[2]&&(a[2]=t[2])})),e.min=A,e.max=a,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=B)}Jt(t,e,r,n){const{modelCenter:A,rtcCenter:i}=this.Xt(t,e,r,n),o=this.Zt(A);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.CESIUM_RTC.rtcCoord=this.vt(A),Se(t,(e=>{if(e.attributes&&e.attributes.POSITION){e.attributes.NORMAL&&this.kt(e.attributes.NORMAL,e.matrices,r),e.attributes.TANGENT&&this.kt(e.attributes.TANGENT,e.matrices,r);const{newPositions:A}=this.xt(e.attributes.POSITION,e.matrices,i,t.extensions.MAPTALKS_RTC,r,n,e.compressUniforms);let{componentType:o}=e.attributes.POSITION;5126!==o&&(e.attributes.POSITION.array=new Float32Array(A))}}));for(const e in t.nodes){t.nodes[e].matrix=Ks}}Zt(t){0===M(t)?u(vs,0,0,-6378137):pt(vs,t);const e=this.options.projection;Es(Xs,vs,e);const r=vs[2],n=[];return n[0]=Xs[0],n[1]=Xs[1],n[2]=r,n}kt(t,e,r){let i;i="Y"===r?Gs:"X"===r?ms:Ks;const o=A([],i);if(js(o,e),E(o,Ks))return;const s=n([],o),a=[];He(t,(t=>(function(t,e,r){var n=e[0],A=e[1],i=e[2];t[0]=n*r[0]+A*r[3]+i*r[6],t[1]=n*r[1]+A*r[4]+i*r[7],t[2]=n*r[2]+A*r[5]+i*r[8]}(a,t,s),T(a,a),l(t,a),a)))}xt(t,e,r,n,A,o,s){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return;const a=i([]);js(a,e);const B=this.options.projection;A=A&&A.toUpperCase();const c=r;let C=null;"Y"===A?C=Gs:"X"===A&&(C=ms);let f=[0,0,0,1],l=[0,0,0],I=[0,0];const D=n.projCenter,h=o&&E(Ks,o),R=t.min=t.min||[],T=t.max=t.max||[];u(R,1/0,1/0,1/0),u(T,-1/0,-1/0,-1/0);const F=s||{},{decode_position_min:P,decode_position_normConstant:L}=F;let y=[0,0,0,0],N=1;P&&(y=P),L&&(N=L);const S=[];return He(t,(t=>{if(f[0]=t[0]*N+y[0],f[1]=t[1]*N+y[1],f[2]=t[2]*N+y[2],f=O(f,f,a),C&&(f=O(f,f,C)),c&&_(f,f,c),o&&!h&&(f=O(f,f,o)),0===M(f)?u(l,0,0,-6378137):pt(l,f),Es(I,l,B),t instanceof Float32Array)t[0]=I[0]-D[0],t[1]=I[1]-D[1],t[2]=l[2]-D[2];else{const e=I[0]-D[0],r=I[1]-D[1],n=l[2]-D[2];S.push(e),S.push(r),S.push(n),S.push(t[3])}return t[0]<R[0]&&(R[0]=t[0]),t[1]<R[1]&&(R[1]=t[1]),t[2]<R[2]&&(R[2]=t[2]),t[0]>T[0]&&(T[0]=t[0]),t[1]>T[1]&&(T[1]=t[1]),t[2]>T[2]&&(T[2]=t[2]),t})),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:D,newPositions:S}}vt(t){return 0===M(t)?u([],0,0,-6378137):pt([],t)}onRemove(){}}const ks=[];function xs(t,e,r,n,A,i){const o=i||{},{decode_position_min:s,decode_position_normConstant:a}=o;let B=[0,0,0,0],E=1;s&&(B=s),a&&(E=a);for(let i=0,o=t.length;i<o;i+=e){const{xmin:o,ymin:s,xmax:a,ymax:c,hmin:C,hmax:f}=A;u(ks,t[i]*E+B[0],t[i+1]*E+B[1],t[i+2]*E+B[2]),O(ks,ks,n);const l=_(ks,r,ks);l[0]<o&&(A.xmin=l[0]),l[0]>a&&(A.xmax=l[0]),l[1]<s&&(A.ymin=l[1]),l[1]>c&&(A.ymax=l[1]),e>2&&(l[2]<C&&(A.hmin=l[2]),l[2]>f&&(A.hmax=l[2]))}}function Ws(t){const{xmax:e,ymax:r,xmin:n,ymin:A,hmin:i,hmax:o}=t,s=[(n+e)/2,(A+r)/2,(i+o)/2];return e===-1/0&&(s[0]=0),r===-1/0&&(s[1]=0),o===-1/0&&(s[2]=0),isNaN(s[2])&&(s[2]=0),s}function Qs(t,e){for(let r=0;r<e.length;r++)t.indexOf(e[r])<0&&t.push(e[r])}function js(t,e){const r=t;for(let t=e.length-1;t>=0;t--)o(r,e[t],r);return r}let Ys=0;class zs{constructor(t){this.workerId=t,this.workers={},this.Wt={}}addLayer({actorId:t,mapId:e,layerId:r,params:n},A){if(this.Qt(e,r))return;const i=this.jt(e,r),o=n.options,s=this.send.bind(this,t);this.workers[i]=new Zs(r,o,s,A)}removeLayer({mapId:t,layerId:e},r){const n=this.Qt(t,e),A=this.jt(t,e);delete this.workers[A],n&&n.onRemove(r)}loadTile({mapId:t,layerId:e,params:r},n){const A=this.Qt(t,e);A&&A.loadTile(r,n)}abortTileLoading({mapId:t,layerId:e,params:r},n){const A=this.Qt(t,e);A&&A.abortTileLoading(r,n)}receive(t){const e=t.callback,r=this.Wt[e];delete this.Wt[e],r&&t.error?r(new Error(t.error)):r&&r(null,t.data)}send(t,e,r,n,A){const i=A?`${t}-${Ys++}`:null;A&&(this.Wt[i]=A),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:r,callback:String(i)},n||[])}jt(t,e){return`${t}-${e}`}Qt(t,e){const r=this.jt(t,e);return this.workers[r]}}t.initialize=function(){},t.onmessage=function(t,e){const r=t.data;this.dispatcher||(this.dispatcher=new zs(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)=>{t instanceof Error&&(t={message:t.message}),e(t,r,n)}))},Object.defineProperty(t,"Yt",{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
|
|
12
|
+
var f=[],h=0;h<6;h++)f[h]=[];var u=[];function E(t,e,r){_(t);for(var n=0;n<6;n++)if(!r||"0"!==r.charAt(n)){var i=f[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],C(i,u)<0)return!1}return!0}function B(t,e){var r=e,n=t,i=e,s=n[0],o=n[1],a=n[2],A=Math.abs(s*i[3]+o*i[6]+a*i[9])+Math.abs(s*i[4]+o*i[7]+a*i[10])+Math.abs(s*i[5]+o*i[8]+a*i[11]),c=C(t,r);return!(c<=-A)}function _(t){var e=t,r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],A=e[6],c=e[7],l=e[8],h=e[9],u=e[10],E=e[11],B=e[12],_=e[13],C=e[14],T=e[15];d(f[0],s-r,c-o,E-l,T-B),d(f[1],s+r,c+o,E+l,T+B),d(f[2],s+n,c+a,E+h,T+_),d(f[3],s-n,c-a,E-h,T-_),d(f[4],s-i,c-A,E-u,T-C),d(f[5],s+i,c+A,E+u,T+C)}function d(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 C(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]}function T(t){return null==t}function m(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 g(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function p(t){return"object"==typeof t&&!!t}function y(t){return"number"==typeof t&&!isNaN(t)}function R(t){return t*Math.PI/180}function I(t){return t/Math.PI*180}function b(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function P(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const M=[1,1,1,1,2,2,3,0];function N(t){const e=t.length;let r="";for(let n=0;n<e;){let i=t[n++];if(128&i){let r=M[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 S(t,e,r){return t[3*r]=e[0],t[3*r+1]=e[1],t[3*r+2]=e[2],t}function L(t){return t.flat?t.flat(1/0):t.reduce(((t,e)=>t.concat(e)),[])}function D(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function O(t){return 0===t.indexOf("data:")}function F(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}function x(t){for(let e=1;e<arguments.length;e++){const r=arguments[e];if(r)for(let e=0,n=r.length;e<n;e++)t.push(r[e])}return t.length}var w=Object.freeze({__proto__:null,isNil:T,extend:m,isFunction:g,isObject:p,isNumber:y,toRadian:R,toDegree:I,getAbsoluteURL:b,sign:P,stringFromUTF8Array:N,setColumn3:S,flatArr:L,getBatchIdArrayType:D,isBase64:O,base64URLToArrayBuffer:F,pushIn:x});var v="undefined"!=typeof Float32Array?Float32Array:Array;function U(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 G(t,e,r){var n=e[0],i=e[1],s=e[2],o=e[3],a=e[4],A=e[5],c=e[6],l=e[7],f=e[8],h=e[9],u=e[10],E=e[11],B=e[12],_=e[13],d=e[14],C=e[15],T=r[0],m=r[1],g=r[2],p=r[3];return t[0]=T*n+m*a+g*f+p*B,t[1]=T*i+m*A+g*h+p*_,t[2]=T*s+m*c+g*u+p*d,t[3]=T*o+m*l+g*E+p*C,T=r[4],m=r[5],g=r[6],p=r[7],t[4]=T*n+m*a+g*f+p*B,t[5]=T*i+m*A+g*h+p*_,t[6]=T*s+m*c+g*u+p*d,t[7]=T*o+m*l+g*E+p*C,T=r[8],m=r[9],g=r[10],p=r[11],t[8]=T*n+m*a+g*f+p*B,t[9]=T*i+m*A+g*h+p*_,t[10]=T*s+m*c+g*u+p*d,t[11]=T*o+m*l+g*E+p*C,T=r[12],m=r[13],g=r[14],p=r[15],t[12]=T*n+m*a+g*f+p*B,t[13]=T*i+m*A+g*h+p*_,t[14]=T*s+m*c+g*u+p*d,t[15]=T*o+m*l+g*E+p*C,t}function H(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function K(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function V(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,A=i+i,c=r*o,l=n*o,f=n*a,h=i*o,u=i*a,E=i*A,B=s*o,_=s*a,d=s*A;return t[0]=1-f-E,t[1]=l+d,t[2]=h-_,t[3]=0,t[4]=l-d,t[5]=1-c-E,t[6]=u+B,t[7]=0,t[8]=h+_,t[9]=u-B,t[10]=1-c-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function k(){var t=new v(3);return v!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function X(t){var e=t[0],r=t[1],n=t[2];return Math.sqrt(e*e+r*r+n*n)}function Y(t,e,r){var n=new v(3);return n[0]=t,n[1]=e,n[2]=r,n}function J(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 Z(t,e,r){return t[0]=e[0]+r[0],t[1]=e[1]+r[1],t[2]=e[2]+r[2],t}function W(t,e,r){return t[0]=e[0]-r[0],t[1]=e[1]-r[1],t[2]=e[2]-r[2],t}function j(t,e,r){return t[0]=e[0]*r[0],t[1]=e[1]*r[1],t[2]=e[2]*r[2],t}function Q(t,e,r){return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t}function q(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 $(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function tt(t,e,r){var n=e[0],i=e[1],s=e[2],o=r[0],a=r[1],A=r[2];return t[0]=i*A-s*a,t[1]=s*o-n*A,t[2]=n*a-i*o,t}var et=W,rt=j,nt=X;function it(t,e,r,n,i){return t[0]=e,t[1]=r,t[2]=n,t[3]=i,t}function st(){var t=new v(4);return v!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function ot(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function at(t,e,r,n){var i=e[0],s=e[1],o=e[2],a=e[3],A=r[0],c=r[1],l=r[2],f=r[3],h=void 0,u=void 0,E=void 0,B=void 0,_=void 0;return(u=i*A+s*c+o*l+a*f)<0&&(u=-u,A=-A,c=-c,l=-l,f=-f),1-u>1e-6?(h=Math.acos(u),E=Math.sin(h),B=Math.sin((1-n)*h)/E,_=Math.sin(n*h)/E):(B=1-n,_=n),t[0]=B*i+_*A,t[1]=B*s+_*c,t[2]=B*o+_*l,t[3]=B*a+_*f,t}k(),function(){var t,e=(t=new v(4),v!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var At,ct=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};k(),Y(1,0,0),Y(0,1,0),st(),st(),At=new v(9),v!=Float32Array&&(At[1]=0,At[2]=0,At[3]=0,At[5]=0,At[6]=0,At[7]=0),At[0]=1,At[4]=1,At[8]=1;
|
|
13
13
|
/*!
|
|
14
14
|
* @maptalks/gltf-loader v0.27.2
|
|
15
15
|
* LICENSE : UNLICENSED
|
|
16
16
|
* (c) 2016-2022 maptalks.org
|
|
17
17
|
*/
|
|
18
|
-
let ft=0;function ut(t){return null==t}function ht(t){return!ut(t)}function _t(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 dt(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 Et(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function Tt(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 mt=[],At=[],pt=[],yt=[0,0,0],gt=ot([]),Rt=[1,1,1];function bt(t,e,r,n,i,s,o){const a=dt(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}0===i&&(i=n*a.BYTES_PER_ELEMENT);const c=new Uint8Array(n*a.BYTES_PER_ELEMENT);for(let o=0;o<r;o++){let r=null;const l=new Uint8Array(e,i*o+s,n*a.BYTES_PER_ELEMENT);c.set(l),r=new a(c.buffer,0,n);for(let e=0;e<n;e++)t[o*n+e]=r[e]}return t}const It="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Nt(t,e,r){const n=new Uint8Array(t,e,r);return It.decode(n)}const St={get:function(t,e={}){e||(e={});const r=new AbortController,n=r.signal,i=_t({},e);i.signal=n,i.method||(i.method="GET");const s=fetch(t,i).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 s.xhr=r,s},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",St.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?St.jsonp(t):((e=e||{}).responseType="json",St.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+ft++;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 wt{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(Et(t.uri)){const n=this.buffers[t.id]=Tt(t.uri),i=this.u(e,n);return this.getImageByBuffer(i,r)}return this.l[t.id]=St.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;return this.l[t.id]?this.l[t.id].then((()=>this.images[t.id])):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 Ot=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class Mt{constructor(t,e,r){this.rootPath=t,this.gltf=e,this._=!1,this.glbBuffer=r,this.buffers={},this.requests={},this.accessors={},this.T()}m(t,e){const r=this.gltf,n=r.accessors[e];if(void 0===n.bufferView)return this.accessors[n.id]=this.A(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.p(i).then((r=>{const{buffer:i,byteOffset:s}=r;return this.accessors[n.id]=this.A(t,e,i,s)}))}p(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(Et(e.uri)){const t=this.buffers[e.id]=Tt(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const r=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||r?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=St.getArrayBuffer(t,null).then((n=>(r&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=n.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}A(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,c=this.g(s.type),l=dt(s.componentType),f=o.byteStride||0,u={array:void 0,name:t,accessorName:e,byteLength:s.count*c*l.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:c};if(s.min&&(u.min=s.min),s.max&&(u.max=s.max),r)if(this._)u.byteStride=f,u.byteOffset=a+(s.byteOffset||0),!f||f===c*l.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(u.array=this.R(r,s.count,c,a+(s.byteOffset||0),l),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 l(s.count*c);u.array=bt(t,r,s.count,c,f,a+(s.byteOffset||0),s.componentType)}else u.byteStride=0,u.array=this.R(r,s.count,c,a+(s.byteOffset||0),l),u.byteOffset=u.array.byteOffset;else{u.array=new l(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}T(){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)}R(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=Ot.indexOf(t);return Ot[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.p(e).then((n=>{const{buffer:i,byteOffset:s}=n,o=Nt(i,s+(e.byteOffset||0),r);return t.content=o,t}))}if(t.uri){if(Et(t.uri)){const e=Tt(t.uri),r=Nt(e,0,e.byteLength);return t.content=r,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return St.get(e).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(r).then((()=>t))}}class Ct extends wt{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 Mt(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(ht(t.name)&&(e.name=t.name),ht(t.children)&&(e.children=t.children),ht(t.jointName)&&(e.jointName=t.jointName),ht(t.matrix)&&(e.matrix=t.matrix),ht(t.rotation)&&(e.rotation=t.rotation),ht(t.scale)&&(e.scale=t.scale),ht(t.translation)&&(e.translation=t.translation),ht(t.extras)&&(e.extras=t.extras),ht(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=k(mt,e.translation||yt),n=V(At,e.rotation||gt),i=H(pt,e.scale||Rt);return G(i,n,i),G(t,r,i)}return D(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}I(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}N(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.N(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 Ut extends wt{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 Mt(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 _t(e,t),!ht(t.weights)&&this.gltf.meshes&&ht(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.N(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}};_t(n,e);const i=ht(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return i&&(n.sampler=i),t.format&&(n.format=t.format),n}))}N(t){if(!ht(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)}M(t,e){const r=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)r[e]=String.fromCharCode(t[e]);return r.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(r)))}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++)(ht(t[r].input)||ht(t[r].output))&&(e.push(this.accessor.m("input",t[r].input)),e.push(this.accessor.m("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 xt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class vt{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 vt.readV1(n,e);if(2===i)return vt.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=Bt(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 c=s.getUint32(o,!0);if(o+=4,1313821514===c)r=Bt(t,e+12+o,a);else if(5130562===c){i=e+12+o,n=a;break}o+=a}return{json:JSON.parse(r),glbBuffer:{byteOffset:i,buffer:t,byteLength:n}}}}function Bt(t,e,r){if(xt){const n=new Uint8Array(t,e,r);return xt.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=Lt[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 Lt=[1,1,1,1,2,2,3,0],Pt=[0,0,0],Ft=[0,0,0,1],Dt=[1,1,1],Gt={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},kt={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},Ht={C(t,e,r,n,i,s,o,a){const c=ht(t)?e.animations:[e.animations[0]],l={};for(let e=0;e<c.length;e++){const f=c[e],u=f.name||e;if(ht(t)&&u!==t)continue;const h=f.channelsMap[r];if(h)for(let t=0;t<h.length;t++){const e=h[t];"translation"===e.target.path?(this.U(i,f.samplers[e.sampler],n,1),l.translation=q(Pt,i)):"rotation"===e.target.path?(this.v(s,f.samplers[e.sampler],n,1),l.rotation=lt(Ft,s)):"scale"===e.target.path?(this.U(o,f.samplers[e.sampler],n,1),l.scale=q(Dt,o)):"weights"===e.target.path&&a&&(this.U(a,f.samplers[e.sampler],n,a.length),l.weights=a)}}return l},U(t,e,r,n){switch(e.interpolation){case"LINEAR":{const i=this.B(kt,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(kt,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(kt,e,r,3*n);i&&(t=this.L(t,i,e.input.array,3*n));break}}return t},v(t,e,r){switch(e.interpolation){case"LINEAR":{const n=this.B(kt,e,r,1);n&&at(t,n.PREVIOUS,n.NEXT,n.INTERPOLATION);break}case"STEP":{const n=this.B(kt,e,r,1);n&&(t=it(t,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.B(kt,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.L(t,n,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},P(t,e){const r=t.length;let n,i,s,o=0,a=r-1,c=Math.floor((o+a)/2);for(;o<=r-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const r=t[c];return n=c,i=c+1,s=(e-r)/(t[c+1]-r),{preIndx:n,nextIndex:i,interpolation:s}}e<t[c]?(a=c,c=Math.floor((o+a)/2)):t[c+1]<e&&(o=c,c=Math.floor((o+a)/2))}return null},B(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.P(i,r);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:l,interpolation:f}=a;t.PREINDEX=c,t.NEXTINDEX=l,t.INTERPOLATION=f;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},L(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],c=(o-s)*e.PREVIOUS[2*n+r],l=e.NEXT[3+r],f=(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)*c+(2*-Math.pow(i,3)+3*Math.pow(i,2))*l+(Math.pow(i,3)-Math.pow(i,2))*f;t[r]=u}return t},getAnimationClip(t,e,r,n){const i=t.nodes[e]&&t.nodes[e].weights;return Z(Pt,...Gt.TRANSLATION),it(Ft,...Gt.ROTATION),Z(Dt,...Gt.SCALE),this.C(n,t,e,r,Pt,Ft,Dt,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?ht(e)?r[e]:r[Object.keys(r)[0]]:null}};let Vt=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Zr){}t&&"undefined"!=typeof createImageBitmap&&(Vt=!0)}const zt="undefined"==typeof document?null:document.createElement("canvas");class Xt{constructor(t,e,r){if(this.options=r||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:r,glbBuffer:n}=vt.read(e.buffer,e.byteOffset,e.byteLength);this.F(t,r,n)}else this.F(t,e);this.D=new Mt(this.rootPath,this.gltf,this.glbBuffer),this.G()}G(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}k(){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.X(),i=this.k();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 Ht.getAnimationClip(t,e,r,n)}static getAnimationTimeSpan(t,e){return Ht.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return dt(t)}static readInterleavedArray(t,e,r,n,i,s,o){return bt(t,e,r,n,i,s,o)}F(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=Vt?jt.bind(this):this.options.requestImage||Yt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new Ut(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 Ct(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"))}Y(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(r=t.children[0])&&isFinite(r)||function(t){return!ut(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.Y(r,e)}));t.children=n}var r;return t}H(t){return this.q(t).then((t=>{const e=this.scenes=[];let r;for(const e in t)t[e]=this.Y(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.I(this.gltf.materials);n.materials=t}return n}))}q(t){return this.Z(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}))}j(){this.skins=[];const t=[];return this.adapter.iterate(((e,r,n)=>{t.push(this.W(r).then((t=>{t.index=n,this.skins.push(t)})))}),"skins"),t}W(t){const e=t.inverseBindMatrices;return this.adapter.accessor.m("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 ht(t)?this.adapter.getAnimations(t):null}Z(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.j()),Promise.all(e)}K(t,e){const r=t.primitives.map((t=>this.$(t,e))).filter((t=>!!t));return Promise.all(r).then((e=>{const r={};return _t(r,t),r.primitives=e,r}))}X(){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}))}$(t,e){let r;const n=[],i=t.extensions;if(ht(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.m(`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],c=this.D.p(a).then((r=>{const{buffer:n,byteOffset:i}=r;let{byteOffset:s,byteLength:c}=a;s||(s=0);const l=new DataView(n,i+s,c),f={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(l,f).then((t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e}))}));n.push(c),r=Promise.all(n)}else{const e=t.attributes;for(const t in e){const r=this.adapter.accessor.m(t,e[t]);r&&n.push(r)}if(ht(t.indices)){const e=this.adapter.accessor.m("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;K(t,t,i),j(t,t,s),K(r,r,i),j(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=ht(t.mode)?t.mode:4,ht(t.extras)&&(s.extras=t.extras),s}))}}function Yt(t,e){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!zt)return void e(new Error("There is no canvas to draw image!"));zt.width=r.width,zt.height=r.height;const t=zt.getContext("2d",{willReadFrequently:!0});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 qt,Zt;function jt(t,e){qt||(qt=new OffscreenCanvas(2,2),Zt=qt.getContext("2d",{willReadFrequently:!0})),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;Wt(r)||(r=Qt(r)),Wt(n)||(n=Qt(n));const i=this.options.maxTextureSize;i&&(r=Math.min(i,r),n=Math.min(i,n)),qt.width=r,qt.height=n,Zt.drawImage(t,0,0,r,n),t.close();const s=Zt.getImageData(0,0,r,n);e(null,{width:r,height:n,data:new Uint8Array(s.data)})})).catch((t=>{console.warn(t),e(t)}))}function Wt(t){return 0==(t&t-1)&&0!==t}function Qt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}const Kt="undefined"==typeof document?null:document.createElement("canvas");class $t 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(!Kt)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=te(e));Jt(r)||(r=te(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,o=i.substring(s);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${r})`),n}(r);Kt.width=t.width,Kt.height=t.height;const n=Kt.getContext("2d",{willReadFrequently:!0});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 te(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}class ee{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 re(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=[];le(n[r],i,t,e)}}}const ne=[],ie=[],se=[],oe=[0,0,0],ae=ot([]),ce=[1,1,1];function le(t,e,r,n){const i=e.slice(0);if(t.matrix)i.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=k(ne,t.translation||oe),r=V(ie,t.rotation||ae),n=H(se,t.scale||ce);G(n,r,n);const s=G([],e,n);i.push(s)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)le(t.children[e],i,r,n);if(void 0!==t.mesh){const e=t.mesh,s=r.meshes[e];if(s){const t=i.slice(0),o=s.primitives;for(let i=0,s=o.length;i<s;i++){const s=o[i];s&&(s.matrices=t,n(s,e,i,r))}}}}function fe(t,e,r){let{componentType:n,byteOffset:i,byteStride:s,itemSize:o}=e;const a=e.array.buffer,c=n?Xt.getTypedArrayCtor(n):e.array.constructor;if(i=void 0===i?e.array.byteOffset:i,s=s||0,!s||s===o*c.BYTES_PER_ELEMENT&&i%c.BYTES_PER_ELEMENT==0){const e=new c(a,i+r*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}s||(s=o*c.BYTES_PER_ELEMENT);const l=new Uint8Array(a,s*r+i,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(l),t}function ue(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 he=new Array(3),_e=new Array(3),de=[40680631590769,40680631590769,40408299984661.445];function Ee(t,e,r,n){const i=de,s=Math.cos(r);he[0]=s*Math.cos(e),he[1]=s*Math.sin(e),he[2]=Math.sin(r),Ne(he,he),Q(_e,i,he);const o=Math.sqrt(J(he,_e));var a,c,l;return c=_e,l=o,(a=_e)[0]=c[0]/l,a[1]=c[1]/l,a[2]=c[2]/l,K(he,he,n),j(t,_e,he)}const Te=[1/6378137,1/6378137,1/6356752.314245179],me=[1/40680631590769,1/40680631590769,1/40408299984661.445],Ae=new Array(3),pe=new Array(3),ye=new Array(3);function ge(t,e){const r=me,n=function(t,e,r,n,i){const s=e[0],o=e[1],a=e[2],c=r[0],l=r[1],f=r[2],u=s*s*c*c,h=o*o*l*l,_=a*a*f*f,d=u+h+_,E=Math.sqrt(1/d),T=K(Re,e,E);if(d<i)return isFinite(E)?T:void 0;const m=n[0],A=n[1],p=n[2],y=be;y[0]=T[0]*m*2,y[1]=T[1]*A*2,y[2]=T[2]*p*2;let g,R,b,I,N,S,w,O,M,C,U,x=(1-E)*Ie(e)/(.5*Ie(y)),v=0;do{x-=v,b=1/(1+x*m),I=1/(1+x*A),N=1/(1+x*p),S=b*b,w=I*I,O=N*N,M=S*b,C=w*I,U=O*N,g=u*S+h*w+_*O-1,R=u*M*m+h*C*A+_*U*p;v=g/(-2*R)}while(Math.abs(g)>1e-12);return t[0]=s*b,t[1]=o*I,t[2]=a*N,t}(Ae,e,Te,r,.1);let i=rt(pe,n,r);i=Ne(i,i);const s=et(ye,e,n),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=w(J(s,e))*Ie(s);return t[0]=N(o),t[1]=N(a),t[2]=c,t}const Re=new Array(3),be=new Array(3);function Ie(t){return X(t)}function Ne(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 Se(t,e){return Q(e,t,me),$(e,e)}function we(t,e){var r=t[0],n=t[1],i=Math.cos(n),s=i*Math.cos(r),o=i*Math.sin(r),a=Math.sin(n);return e.x=s,e.y=o,e.z=a,$(e,e)}var Oe=Object.freeze({__proto__:null,radianToCartesian3:Ee,cartesian3ToDegree:ge,normalizeCartesian:Ne,geodeticSurfaceNormal:Se,geodeticSurfaceNormalCartographic:we});function Me(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 Ce(t,e){let r="";for(let n=0;n<4;n++){const i=t.getUint8(e+n);r+=String.fromCharCode(i)}return r}const Ue="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function xe(t,e,r){const n=new Uint8Array(t,e,r);return Ue?JSON.parse(Ue.decode(n)):JSON.parse(M(n))}function ve(t,e,r){const n=new Uint8Array(t,e,r);return Ue?JSON.parse(Ue.decode(n)):JSON.parse(M(n))}function Be(t,e,r){return{offset:e,byteLength:r}}function Le(t,e,r,n){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=He(s||"UNSIGNED_SHORT"),l=Ge(o);return{byteStride:0,byteOffset:i+r,itemSize:l,count:n*l,componentType:c,array:new a(e,r+i,n*l)}}function Pe(t,e,r,n){const i=Le(t,e,r,n);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}function Fe(t,e,r,n){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a}=He(s||"UNSIGNED_SHORT"),c=Ge(o),l=new a(e,i,r*c);return 1===c?l[n]:l.subarray(n*c,n*c+c)}const De={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Ge(t){return t?De[t]:1}const ke={"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 He(t){return ke[t]}function Ve(t){for(let e in ke)if(t===ke[e].ctor)return ke[e].type;throw new Error("unrecognized ctor:"+t)}function ze(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 Xe(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 c,l,f={},u={};n>0&&(f=xe(a,e,n),e+=n),i>0&&(c=function(t,e,r){return{offset:e,byteLength:r}}(0,e,i),e+=i),s>0&&(u=ve(a,e,s),e+=s);const h=Be(0,e,o);return l=a.slice(h.offset,h.offset+h.byteLength),r.push(l),{featureTable:f,featureTableBin:c,batchTable:u,batchTableBin:l}}var Ye={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},qe={},Ze={east:[],north:[],up:[],west:[],south:[],down:[]},je=[],We=[],Qe=[];const Ke=[0,0,0];function $e(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 Je=(nr={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"}}[tr="east"][er="north"],qe[ir=tr+er]?rr=qe[ir]:(rr=function(t,e,r){if(function(t,e){var r=t[0],n=t[1],i=t[2],s=e[0],o=e[1],a=e[2];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-o)<=1e-6*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))}(t,Ke))q(je,Ye[tr]),q(We,Ye[er]),q(Qe,Ye[nr]);else if(Me(t[0],0,1e-14)&&Me(t[1],0,1e-14)){var n=w(t[2]);q(je,Ye[tr]),"east"!==tr&&"west"!==tr&&K(je,je,n),q(We,Ye[er]),"east"!==er&&"west"!==er&&K(We,We,n),q(Qe,Ye[nr]),"east"!==nr&&"west"!==nr&&K(Qe,Qe,n)}else{Se(t,Ze.up);var i=Ze.up,s=Ze.east;s[0]=-t[1],s[1]=t[0],s[2]=0,$(Ze.east,s),tt(Ze.north,i,s),K(Ze.down,Ze.up,-1),K(Ze.west,Ze.east,-1),K(Ze.south,Ze.north,-1),je=Ze[tr],We=Ze[er],Qe=Ze[nr]}return r[0]=je[0],r[1]=je[1],r[2]=je[2],r[3]=0,r[4]=We[0],r[5]=We[1],r[6]=We[2],r[7]=0,r[8]=Qe[0],r[9]=Qe[1],r[10]=Qe[2],r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r},qe[ir]=rr),rr);var tr,er,rr,nr,ir;const sr=[],or=[],ar=[],cr=[],lr=[],fr=[],ur=[],hr={x:0,y:0},_r={x:0,y:0},dr=Math.PI/180;const Er={"programs":[{"attributes":["aPosition","instanceId","batchId","aTexCoord0","aTexCoord1","aNormal","aColor","uv2","uv3","uv4","secondary_colour","uv6"],"fragmentShader":1,"vertexShader":0}],"shaders":[{"type":35633,"content":"#include <gl2_vert>\n\nuniform mat4 czm_modelViewProjection;\n\nuniform mat4 czm_modelView;\n\nuniform mat3 czm_normal;\n\n\n\nattribute vec4 aPosition;\n\n\n\n#ifdef VertexColor\n\n attribute vec4 aColor;\n\n#endif\n\n#ifdef VertexNormal\n\n attribute vec3 aNormal;\n\n#endif\n\n#ifdef Instance\n\n attribute float instanceId;\n\n#else\n\n attribute float batchId;\n\n#endif\n\n\n\n#ifdef TexCoord\n\n attribute vec4 aTexCoord0;\n\n varying vec4 vTexCoord;\n\n uniform mat4 uTexMatrix;\n\n#ifdef COMPUTE_TEXCOORD\n\n uniform float uTexture0Width;\n\n varying vec4 vTexMatrix;\n\n varying vec4 vTexCoordTransform;\n\n varying vec2 vIsRGBA;\n\n#endif\n\n#endif\n\n\n\n#ifdef TexCoord2\n\n attribute vec4 aTexCoord1;\n\n uniform float uTexture1Width;\n\n varying vec4 vTexMatrix2;\n\n#endif\n\n#ifdef InstanceBim\n\n attribute vec4 uv2;\n\n attribute vec4 uv3;\n\n attribute vec4 uv4;\n\n attribute vec4 secondary_colour;\n\n attribute vec4 uv6;\n\n#endif\n\n\n\n uniform vec4 uFillForeColor;\n\n uniform vec4 uSelectedColor;\n\n varying vec4 vSecondColor;\n\n varying vec4 vPositionMC;\n\n varying vec3 vPositionEC;\n\n#ifdef VertexNormal\n\n varying vec3 vNormalEC;\n\n#endif\n\n varying vec4 vColor;\n\n\n\n const float SHIFT_LEFT8 = 256.0;\n\n const float SHIFT_RIGHT8 = 1.0 / 256.0;\n\n const float SHIFT_RIGHT4 = 1.0 / 16.0;\n\n const float SHIFT_LEFT4 = 16.0;\n\n void getTextureMatrixFromZValue(in float nZ, inout float XTran, inout float YTran, inout float scale, inout float isRGBA)\n\n {\n\n if(nZ <= 0.0)\n\n {\n\n return;\n\n }\n\n float nDel8 = floor(nZ * SHIFT_RIGHT8);\n\n float nDel16 = floor(nDel8 * SHIFT_RIGHT8);\n\n float nDel20 = floor(nDel16 * SHIFT_RIGHT4);\n\n isRGBA = floor(nDel20);\n\n YTran = nZ - nDel8 * SHIFT_LEFT8;\n\n XTran = nDel8 - nDel16 * SHIFT_LEFT8;\n\n float nLevel = nDel16 - nDel20 * SHIFT_LEFT4;\n\n scale = 1.0 / pow(2.0, nLevel);\n\n }\n\n\n\n void operation(vec4 operationType, vec4 color, vec4 selectedColor, inout vec4 vertexColor)\n\n {\n\n float right_2 = operationType.x * 0.5;\n\n float right_4 = right_2 * 0.5;\n\n float right_8 = right_4 * 0.5;\n\n float right_16 = right_8 * 0.5;\n\n float isSetColor = fract(right_2);\n\n if(isSetColor > 0.1)\n\n {\n\n vertexColor *= color;\n\n }\n\n float isPicked = fract(floor(right_2)* 0.5);\n\n if(isPicked > 0.1)\n\n {\n\n vertexColor *= selectedColor;\n\n }\n\n float isHide = fract(floor(right_4)* 0.5);\n\n if(isHide > 0.1)\n\n {\n\n vertexColor.a = 0.0;\n\n }\n\n }\n\n\n\n void main()\n\n {\n\n #ifdef TexCoord\n\n vTexCoord.xy = aTexCoord0.xy;\n\n #ifdef COMPUTE_TEXCOORD\n\n vTexMatrix = vec4(0.0,0.0,1.0,0.0);\n\n vIsRGBA.x = 0.0;\n\n vTexCoordTransform.x = aTexCoord0.z;\n\n if(vTexCoordTransform.x < -90000.0)\n\n {\n\n vTexMatrix.z = -1.0;\n\n }\n\n getTextureMatrixFromZValue(floor(vTexCoordTransform.x), vTexMatrix.x, vTexMatrix.y, vTexMatrix.z, vIsRGBA.x);\n\n vTexMatrix.w = log2(uTexture0Width * vTexMatrix.z);\n\n #endif\n\n #endif\n\n\n\n #ifdef TexCoord2\n\n vTexCoord.zw = aTexCoord1.xy;\n\n vTexMatrix2 = vec4(0.0,0.0,1.0,0.0);\n\n vIsRGBA.y = 0.0;\n\n vTexCoordTransform.y = aTexCoord1.z;\n\n if(vTexCoordTransform.y < -90000.0)\n\n {\n\n vTexMatrix2.z = -1.0;\n\n }\n\n getTextureMatrixFromZValue(floor(vTexCoordTransform.y), vTexMatrix2.x, vTexMatrix2.y, vTexMatrix2.z, vIsRGBA.y);\n\n vTexMatrix2.w = log2(uTexture1Width * vTexMatrix.z);\n\n #endif\n\n\n\n vec4 vertexPos = aPosition;\n\n vec4 vertexColor = uFillForeColor;\n\n#ifdef VertexColor\n\n vertexColor *= aColor / 255.0;\n\n#endif\n\n#ifdef VertexNormal\n\n vec3 normal = aNormal;\n\n#endif\n\n #ifdef InstanceBim\n\n mat4 worldMatrix;\n\n worldMatrix[0] = uv2;\n\n worldMatrix[1] = uv3;\n\n worldMatrix[2] = uv4;\n\n worldMatrix[3] = vec4(0, 0, 0, 1);\n\n vertexPos = vec4(vertexPos.xyz,1.0) * worldMatrix;\n\n vertexColor *= secondary_colour;\n\n #endif\n\n\n\n\n\n #ifdef Instance\n\n float index = instanceId;\n\n #else\n\n float index = batchId;\n\n #endif\n\n vec4 positionMC = vec4(vertexPos.xyz, 1.0);\n\n vColor = vertexColor;\n\n #ifdef VertexNormal\n\n vNormalEC = czm_normal * normal;\n\n #endif\n\n vPositionMC = positionMC;\n\n vPositionEC = (czm_modelView * positionMC).xyz;\n\n gl_Position = czm_modelViewProjection * vec4(vertexPos.xyz, 1.0);\n\n }\n\n"},{"type":35632,"content":"#ifdef GL_OES_standard_derivatives\n\n #extension GL_OES_standard_derivatives : enable\n\n #define support_standard_derivatives 1\n\n#endif\n\n#ifdef GL_EXT_shader_texture_lod\n\n #extension GL_EXT_shader_texture_lod : enable\n\n #define support_shader_texture_lod 1\n\n#endif\n\n\n\nprecision highp float;\n\n\n\n#include <gl2_frag>\n\n\n\n#if __VERSION__ == 300\n\n #define support_standard_derivatives 1\n\n #define support_shader_texture_lod 1\n\n#endif\n\n\n\n uniform vec3 czm_lightDirectionEC;\n\n uniform vec4 uDiffuseColor;\n\n#ifdef TexCoord\n\n varying vec4 vTexCoord;\n\n#ifdef COMPUTE_TEXCOORD\n\n uniform sampler2D uTexture;\n\n uniform highp float uTexture0Width;\n\n varying vec4 vTexCoordTransform;\n\n varying vec4 vTexMatrix;\n\n varying vec2 vIsRGBA;\n\n#endif\n\n#endif\n\n\n\n varying vec4 vColor;\n\n varying vec4 vPositionMC;\n\n varying vec3 vPositionEC;\n\n#ifdef VertexNormal\n\n varying vec3 vNormalEC;\n\n#endif\n\n#ifdef TexCoord2\n\n uniform sampler2D uTexture2;\n\n uniform float uTexture1Width;\n\n varying vec4 vTexMatrix2;\n\n#endif\n\n#ifdef COMPUTE_TEXCOORD\n\n void calculateMipLevel(in vec2 inTexCoord, in float vecTile, in float fMaxMip, inout float mipLevel)\n\n {\n\n vec2 dx = dFdx(inTexCoord * vecTile);\n\n vec2 dy = dFdy(inTexCoord * vecTile);\n\n float dotX = dot(dx, dx);\n\n float dotY = dot(dy, dy);\n\n float dMax = max(dotX, dotY);\n\n float dMin = min(dotX, dotY);\n\n float offset = (dMax - dMin) / (dMax + dMin);\n\n offset = clamp(offset, 0.0, 1.0);\n\n float d = dMax * (1.0 - offset) + dMin * offset;\n\n mipLevel = 0.5 * log2(d);\n\n mipLevel = clamp(mipLevel, 0.0, fMaxMip - 1.62);\n\n }\n\n\n\n void calculateTexCoord(in vec3 inTexCoord, in float scale, in float XTran, in float YTran, in float fTile, in float mipLevel, inout vec2 outTexCoord)\n\n {\n\n if(inTexCoord.z < -9000.0)\n\n {\n\n outTexCoord = inTexCoord.xy;\n\n }\n\n else\n\n {\n\n vec2 fTexCoord = fract(inTexCoord.xy);\n\n float offset = 1.0 * pow(2.0, mipLevel) / fTile;\n\n fTexCoord = clamp(fTexCoord, offset, 1.0 - offset);\n\n outTexCoord.x = (fTexCoord.x + XTran) * scale;\n\n outTexCoord.y = (fTexCoord.y + YTran) * scale;\n\n }\n\n }\n\n\n\n vec4 getTexColorForS3M(sampler2D curTexture, vec3 oriTexCoord, float texTileWidth, float fMaxMipLev, float fTexCoordScale, vec2 vecTexCoordTranslate, float isRGBA)\n\n {\n\n vec4 color = vec4(1.0);\n\n float mipLevel = 0.0;\n\n #ifdef support_standard_derivatives\n\n calculateMipLevel(oriTexCoord.xy, texTileWidth, fMaxMipLev, mipLevel);\n\n #endif\n\n vec2 realTexCoord;\n\n calculateTexCoord(oriTexCoord, fTexCoordScale, vecTexCoordTranslate.x, vecTexCoordTranslate.y, texTileWidth, mipLevel, realTexCoord);\n\n if(isRGBA > 0.5)\n\n {\n\n vec2 rgbTexCoord;\n\n rgbTexCoord.x = (realTexCoord.x + vecTexCoordTranslate.x * fTexCoordScale) * 0.5;\n\n rgbTexCoord.y = (realTexCoord.y + vecTexCoordTranslate.y * fTexCoordScale) * 0.5;\n\n color = texture2D(curTexture, rgbTexCoord.xy, -10.0);\n\n vec2 vecAlphaTexCoord;\n\n vecAlphaTexCoord.x = rgbTexCoord.x;\n\n vecAlphaTexCoord.y = rgbTexCoord.y + fTexCoordScale * 0.5;\n\n color.a = texture2D(curTexture, vecAlphaTexCoord.xy, -10.0).r;\n\n }\n\n else\n\n {\n\n if(oriTexCoord.z < -9000.0)\n\n {\n\n color = texture2D(curTexture, realTexCoord.xy);\n\n }\n\n else\n\n {\n\n #ifdef support_shader_texture_lod\n\n color = texture2DLodEXT(curTexture, realTexCoord.xy, mipLevel);\n\n #else\n\n color = texture2D(curTexture, realTexCoord.xy, mipLevel);\n\n #endif\n\n }\n\n }\n\n\n\n return color;\n\n }\n\n\n\n vec4 getTextureColor()\n\n {\n\n if(vTexMatrix.z < 0.0)\n\n {\n\n return vec4(1.0);\n\n }\n\n float texTileWidth0 = vTexMatrix.z * uTexture0Width;\n\n vec3 realTexCoord = vec3(vTexCoord.xy, vTexCoordTransform.x);\n\n vec4 FColor = getTexColorForS3M(uTexture, realTexCoord, texTileWidth0, vTexMatrix.w, vTexMatrix.z, vTexMatrix.xy, vIsRGBA.x);\n\n #ifdef TexCoord2\n\n float texTileWidth1 = vTexMatrix2.z * uTexture1Width;\n\n realTexCoord = vec3(vTexCoord.zw, vTexCoordTransform.y);\n\n vec4 SColor = getTexColorForS3M(uTexture2, realTexCoord, texTileWidth1, vTexMatrix2.w, vTexMatrix2.z, vTexMatrix2.xy, vIsRGBA.y);\n\n SColor.r = clamp(SColor.r, 0.0, 1.0);\n\n SColor.g = clamp(SColor.g, 0.0, 1.0);\n\n SColor.b = clamp(SColor.b, 0.0, 1.0);\n\n return FColor * SColor;\n\n #else\n\n return FColor;\n\n #endif\n\n }\n\n#endif\n\n vec4 SRGBtoLINEAR4(vec4 srgbIn)\n\n {\n\n #ifndef HDR\n\n vec3 linearOut = pow(srgbIn.rgb, vec3(2.2));\n\n return vec4(linearOut, srgbIn.a);\n\n #else\n\n return srgbIn;\n\n #endif\n\n }\n\n vec3 LINEARtoSRGB(vec3 linearIn)\n\n {\n\n #ifndef HDR\n\n return pow(linearIn, vec3(1.0/2.2));\n\n #else\n\n return linearIn;\n\n #endif\n\n }\n\n\n\n vec3 computeNormal(in vec3 oriVertex)\n\n {\n\n vec3 normal = cross(vec3(dFdx(oriVertex.x), dFdx(oriVertex.y), dFdx(oriVertex.z)), vec3(dFdy(oriVertex.x), dFdy(oriVertex.y), dFdy(oriVertex.z)));\n\n normal = normalize(normal);\n\n return normal;\n\n }\n\n\n\n void main()\n\n {\n\n if(vColor.a < 0.1)\n\n {\n\n discard;\n\n }\n\n vec4 baseColorWithAlpha = vColor;\n\n #ifdef COMPUTE_TEXCOORD\n\n baseColorWithAlpha *= SRGBtoLINEAR4(getTextureColor());\n\n #endif\n\n\n\n if(baseColorWithAlpha.a < 0.1)\n\n {\n\n discard;\n\n }\n\n vec3 normal = vec3(0.0);\n\n #ifdef VertexNormal\n\n normal = normalize(vNormalEC);\n\n #endif\n\n normal = length(normal) > 0.1 ? normal : computeNormal(vPositionMC.xyz);\n\n vec3 color = baseColorWithAlpha.rgb;\n\n vec3 dirVectorEC = normalize(czm_lightDirectionEC);\n\n float dotProduct = dot( normal, dirVectorEC );\n\n float dirDiffuseWeight = max( dotProduct, 0.0 );\n\n dirDiffuseWeight = dirDiffuseWeight * 0.5 + 0.5;\n\n color += color * uDiffuseColor.rgb * dirDiffuseWeight;\n\n #ifdef TexCoord\n\n color = LINEARtoSRGB(color);\n\n #endif\n\n glFragColor = vec4(color, baseColorWithAlpha.a);\n\n#if __VERSION__ == 100\n\n gl_FragColor = glFragColor;\n\n#endif\n\n }\n\n"}],"techniques":[{"attributes":{"aPosition":{"semantic":"POSITION","type":35666},"instanceId":{"semantic":"instanceId","type":5126},"batchId":{"semantic":"_BATCHID","type":5126},"aTexCoord0":{"semantic":"TEXCOORD_0","type":35664},"aTexCoord1":{"semantic":"aTexCoord1","type":35666},"aNormal":{"semantic":"aNormal","type":35665},"aColor":{"semantic":"COLOR_0","type":35666},"uv2":{"semantic":"uv2","type":35666},"uv3":{"semantic":"uv3","type":35666},"uv4":{"semantic":"uv4","type":35666},"secondary_colour":{"semantic":"secondary_colour","type":35666},"uv6":{"semantic":"uv6","type":35666}},"program":0,"uniforms":{"czm_modelView":{"type":35676,"semantic":"MODELVIEW"},"czm_normal":{"type":35675,"semantic":"MODELINVERSETRANSPOSE"},"czm_modelViewProjection":{"type":35676,"semantic":"MODELVIEWPROJECTION"},"uTexMatrix":{"type":35676},"uTexture0Width":{"type":5126},"uFillForeColor":{"type":35666},"uSelectedColor":{"type":35666},"uDiffuseColor":{"type":35666},"uTexture":{"type":35678},"uTexture2":{"type":35678},"uTexture1Width":{"type":5126}}}]},{getTextureMagFilter:Tr,getTextureMinFilter:mr,getTextureWrap:Ar,getMaterialType:pr,getMaterialFormat:yr,getPrimitive:gr,getUniqueREGLBuffer:Rr}=r.REGLHelper,br=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Ir=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:Nr,logoutIBLResOnCanvas:Sr,getIBLResOnCanvas:wr,getPBRUniforms:Or}=r.pbr.PBRUtils,Mr={factor:0,units:0},Cr={specularStrength:0,materialShininess:1},Ur=[1,1,1],xr=n.identity([]),vr=t=>t.material instanceof r.PhongMaterial,Br=t=>t.material instanceof r.pbr.StandardMaterial,Lr=[!0,!0,!0,!0],Pr=[],Fr=new t.Coordinate(0,0),Dr=new t.Point(0,0),Gr=[],kr=[],Hr=[],Vr=[],zr={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"};class Xr{constructor(e,n){this.J=n,this.tt=n.getRenderer().canvas,this.pickingFBO=n.getRenderer().pickingFBO,this.et=new t.SpatialReference,this.rt=e,this.nt=new r.Renderer(e),this.it={},this.st={},this.ot={},this.ct={},this.lt={},this.ft={},this.ut={},this.ht=new r.Scene,this._t=new r.Scene,this.dt=new r.Scene,this.Et=new r.Scene,this.Tt=new r.ResourceLoader(e.texture(2)),this.At=this.yt.bind(this),this.gt=new r.PhongMaterial({"baseColorFactor":[1,1,1,1]}),this.Rt(),this.bt=new r.KHRTechniquesWebglManager(this.rt,this.It(),this.Tt);const i=this.getMap();i.altitudeToPoint&&(this.Nt=i.altitudeToPoint(100,i.getGLRes())/100)}getI3DMMeshes(){return this.lt}getPNTSMeshes(){return this.ct}getB3DMMeshes(){return this.ot}getPaintedMeshes(){return this.St}getMap(){return this.J.getMap()}paint(t,e,r){const n=r&&r.renderTarget,s=r&&r.sceneFilter,o=this.getMap();if(!t.length||!o)return;const a=this.wt(),c=o.projViewMatrix,l=this.J.options.services,f=[],u=[];let h=[];const _=[],E=[],T=this.Ot(t);for(let n=0,s=t.length;n<s;n++){const s=t[n].data.node;let o=this.Mt(s);if(!o)continue;this.ft[s.id]&&(o=this.ft[s.id],o=U(o));let a=l[s.Ct].polygonOffset||Mr;g(a)&&(a=a()),Array.isArray(o)||(f[0]=o,o=f);for(let t=0,n=o.length;t<n;t++){const n=o[t].properties.magic;if("b3dm"===n){if(o[t].getBoundingBox&&!d(c,o[t].getBoundingBox()))continue;const{batchIdData:e,batchIdMap:n}=o[t].geometry.properties;if(e&&n){const e=o[t].properties.node.Ct;this.Ut&&this.Ut[e]&&i.highlightMesh(this.rt,o[t],this.Ut[e],this.xt,n)}r&&r.bloom&&o[t].properties.hlBloomMesh&&(o[t].properties.hlBloomMesh.properties.depthFunc="always",o[t].properties.hlBloomMesh.properties.polygonOffset=a,h.push(o[t].properties.hlBloomMesh)),h.push(o[t])}else"pnts"===n?_.push(o[t]):"i3dm"===n&&E.push(o[t]);o[t].properties.isLeaf=!!e[s.id],o[t].properties.level=T.get(s.vt),o[t].properties.polygonOffset=a,o[t].Bt=s,e[s.id]||u.push(o[t])}}let m=0;const A=this.bt.getExcludeFilter();m+=this.Lt(this.Pt,a,[s,vr,A],n,u,h,E),m+=this.Lt(this.Ft,a,[s,Br,A],n,u,h,E),this.bt.forEachShader(((t,e,r)=>{const i=this.wt(r);m+=this.Lt(t,i,[s,e],n,u,h,E)})),this._t.setMeshes(_);const p=this.Dt();return m+=this.nt.render(this.Gt,p,this._t,n&&n.fbo),this.St={pntsMeshes:_,i3dmMeshes:E,b3dmMeshes:h},m}Lt(t,e,r,n,i,s,o){t.filter=r.filter((t=>!!t)),e.debug=!1,e.stencilEnable=!0,e.debug=!1,e.cullFace="back",e.colorMask=Lr;let a=0;return this.ht.setMeshes(s),a+=this.nt.render(t,e,this.ht,n&&n.fbo),e.stencilEnable=!0,this.dt.setMeshes(o),a+=this.nt.render(t,e,this.dt,n&&n.fbo),a}kt(t,e){return e.Bt.Ht-t.Bt.Ht}paintRegion(t,e,r,n,i){const s=this.getMap();if(!t.length&&!e.length)return;const o=s.projViewMatrix,a=[];for(let r=0,n=(t=t.concat(e)).length;r<n;r++){const e=t[r].node,n=this.Vt(e);n&&(n.getBoundingBox&&!d(o,n.getBoundingBox())||a.push(n))}this.zt.filter=n,this.Et.setMeshes(a);const c=this.Xt(r);this.nt.render(this.zt,c,this.Et,i&&i.fbo)}deleteTile(t){const e=t.node.id;this.Yt(e)}Yt(t){const e=this.st[t];e&&(e.geometry.dispose(),e.dispose(),delete this.st[t]);let r=this.ot[t]||this.ct[t]||this.lt[t]||this.ft[t]||this.it[t];this.ft[t]?this.qt(t):r&&(this.Zt(r),delete this.ot[t],delete this.ct[t],delete this.lt[t],delete this.it[t])}qt(t){let e=this.ft[t];e=U(e);for(let t=0;t<e.length;t++){const{id:r}=e[t].properties;this.Yt(r)}delete this.ft[t]}Zt(t){if(Array.isArray(t))for(let e=0,r=t.length;e<r;e++)this.Zt(t[e]);else{const e=t.geometry.properties.url;if(e){const t=this.ut[e];t&&(t.refCount--,t.refCount<=0&&(t.geometry.dispose(),t.material.dispose(),delete this.ut[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.J;Sr(t.getRenderer().canvas,t.getMap());for(const t in this.ft)this.qt(t);this.ft={};for(const t in this.ot)this.Yt(t);this.ot={};for(const t in this.ct)this.Yt(t);this.ct={};for(const t in this.lt)this.Yt(t);this.lt={};for(const t in this.it)this.Yt(t);this.it={};for(const t in this.st)this.Yt(t);this.st={},this.Pt&&(this.Pt.dispose(),delete this.Pt),this.Ft&&(this.Ft.dispose(),delete this.Ft),this.Gt&&(this.Gt.dispose(),delete this.Gt),this.zt&&(this.zt.dispose(),delete this.zt),this.bt.dispose(),this.picking&&this.picking.dispose()}Vt(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(N(i[0]),N(i[1])),o=new t.Coordinate(N(i[2]),N(i[3]));s=this.jt(s),o=this.jt(o);const a=s.add(o).Wt(.5);s._sub(a),o._sub(a);const c=this.Qt(i[4],i[5]),l=c.x,f=c.y,u=[s.x,s.y,f,o.x,s.y,f,o.x,o.y,f,s.x,o.y,f,s.x,s.y,l,o.x,s.y,l,o.x,o.y,l,s.x,o.y,l],h=new r.Geometry({aPosition:u},[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"});h.generateBuffers(this.rt);const _=new r.Mesh(h),d=n.identity([]);return _.setLocalTransform(n.translate(d,d,[a.x,a.y,0])),this.st[e.id]=_,_}Mt(t){return this.ot[t.id]||this.ct[t.id]||this.lt[t.id]||this.ft[t.id]}has(t){return this.Mt(t)||this.it[t.id]}createPntsMesh(t,e,i,s){if(this.ct[e]){const t=this.ct[e];return console.warn(`pnts mesh with id(${e}) was already created.`),s(null,{id:e,mesh:t}),t}const{pnts:o,featureTable:a,rootIdx:c}=t,l=a.POINTS_LENGTH,f=new r.Geometry(o,null,l,{primitive:"points",positionAttribute:"POSITION"});f.generateBuffers(this.rt);const u={};o.POSITION?u.HAS_POSITION=1:o.POSITION_QUANTIZED&&(u.HAS_POSITION_QUANTIZED=1),o.RGB?u.HAS_RGB=1:o.RGBA?u.HAS_RGBA=1:o.RGB565&&(u.HAS_RGB565=1),(o.NORMAL||o.NORMAL_OCT16P)&&(u.HAS_NORMAL=1,o.NORMAL_OCT16P&&(u.HAS_NORMAL_OCT16P=1)),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:h,rtcCoord:_}=t,d=this.Kt(Hr,_),E=this.$t([],i,h,_);n.multiply(E,E,d);const T=this.J.options.services[c],m=new r.Mesh(f);return m.properties.magic="pnts",m.properties.id=e,m.properties.node=i,m.properties.count=l,m.properties.batchTable=t.batchTable,m.properties.batchTableBin=t.batchTableBin,m.setDefines(u),Object.defineProperty(m.uniforms,"pointColor",{enumerable:!0,get:function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:T&&T.pointColor||[1,1,1,1]}}),Object.defineProperty(m.uniforms,"pointSize",{enumerable:!0,get:function(){return T&&T.pointSize||2}}),Object.defineProperty(m.uniforms,"pointOpacity",{enumerable:!0,get:function(){return T&&T.pointOpacity||1}}),m.setLocalTransform(E),this.ct[e]=m,s(null,{id:e,mesh:[m]}),[m]}createI3DMMesh(t,e,i,o){if(this.lt[e]){const t=this.lt[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.it[e]||o(null,{id:e,mesh:t}),t}const a=this.Jt(i.te),{i3dm:l,featureTable:f,gltf:u,batchTable:h,batchTableBin:_,count:d}=t,E=f.INSTANCES_LENGTH,{rtcCenter:T,rtcCoord:m}=t,A=this.Kt(Hr,m),p=this.$t(Vr,i,T,m);n.multiply(A,p,A);const{POSITION:y,NORMAL_UP:g,NORMAL_RIGHT:R,SCALE:b,SCALE_NON_UNIFORM:I,INSTANCE_ROTATION:N}=l,S={"instance_vectorA":new Float32Array(4*E),"instance_vectorB":new Float32Array(4*E),"instance_vectorC":new Float32Array(4*E)},w=new Float32Array(3),O=new Float32Array(3),M=[],U=new Float32Array(1),x=new Float32Array(3),v=[],B=[],L=[],P=[],F=new Float32Array(9);!function(t,e){let{componentType:r,byteOffset:n,byteStride:i,count:s,itemSize:o}=t;const a=t.array.buffer,c=r?Xt.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*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*o);for(let r=0;r<s*o;r+=o)e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o);return}const l=new Uint8Array(o*c.BYTES_PER_ELEMENT);i||(i=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const r=new Uint8Array(a,i*t+n,o*c.BYTES_PER_ELEMENT);l.set(r),e(new c(l.buffer),t),r.set(l)}}(y,((t,e)=>{g?(fe(O,R,e),fe(w,g,e),s.cross(M,O,w),s.normalize(M,M),C(v,O,0),C(v,w,1),C(v,M,2),c.fromMat3(B,v)):N?(fe(F,N,e),c.fromMat3(B,F)):c.identity(B),b?(fe(U,b,e),s.set(L,U[0],U[0],U[0])):I?(fe(x,I,e),s.set(L,...x)):s.set(L,1,1,1),n.fromRotationTranslationScale(P,B,t,L),ue(S.instance_vectorA,e,P,0),ue(S.instance_vectorB,e,P,1),ue(S.instance_vectorC,e,P,2)}));const D={};for(const t in S)D[t]={buffer:this.rt.buffer({dimension:S[t].length/E,data:S[t]}),divisor:1};const G=this.J.options.services[i.Ct].shader||"phong";let k=0,H=!0;const V=[];return re(u,((t,s,o,c)=>{let{geometry:l,material:f}=this.ee(t,s,o,c,i,!0,G);f&&!f.isReady()&&(H=!1,k++);const u=new r.InstancedMesh(D,E,l,f);u.properties.magic="i3dm",u.properties.id=e,u.properties.count=d,u.properties.batchTable=h,u.properties.batchTableBin=_;const T=this.re(t,l,f,i.Ct,c),m=n.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.multiply(m,m,t.matrices[e]);n.multiply(m,a,m),u.setPositionMatrix(m),u.setLocalTransform(n.copy([],A)),u.setDefines(T),u.properties.polygonOffset={offset:0,factor:0},V.push(u)})),H?(this.lt[e]=V,o(null,{id:e,mesh:V})):(this.it[e]={meshes:V,count:k},V.ne=o),V}createB3DMMesh(e,i,s,o){if(this.ot[i]||this.it[i]){const t=this.ot[i];return console.warn(`mesh with id(${i}) was already created.`),this.it[i]||o(null,{id:i,mesh:t}),t}let a;if(s.maxExtent){const e=new t.Extent(s.maxExtent).convertTo((t=>this._pointToPrj(t)));a=[e.xmin,e.ymin,e.xmax,e.ymax]}const c=e.gltf,{projCenter:l}=c.extensions.MAPTALKS_RTC,{rtcCoord:f,center:u}=c.extensions.CESIUM_RTC,h=this.Jt(s.te);let _;_=c.asset&&c.asset.sharePosition?this.Kt(Hr,f):this.ie(Hr,f,l,s.Ct);const d=this.J.options.services[s.Ct];let E=d.shader||"pbr";if(c.materials)for(let t=0;t<c.materials.length;t++)if(c.materials[t]&&c.materials[t].extensions&&c.materials[t].extensions.KHR_materials_unlit){E=d.shader="phong";break}const T=[];let m=0,A=!0;return re(c,((t,o,c,l)=>{let{geometry:p,material:y}=this.ee(t,o,c,l,s,!1,E);y&&!y.isReady()&&(A=!1,m++);const g=new r.Mesh(p,y);g.properties.magic="b3dm",g.properties.id=i,g.properties.node=s,g.properties.batchTable=e.batchTable,g.properties.batchTableBin=e.batchTableBin,g.properties.count=e.featureTable.BATCH_LENGTH;const R=this.re(t,p,y,s.Ct,l);g.setDefines(R),a&&(R.USE_MAX_EXTENT=1,g.setUniform("maxPrjExtent",a)),Object.prototype.hasOwnProperty.call(g.uniforms,"polygonOpacity")||Object.defineProperty(g.uniforms,"polygonOpacity",{enumerable:!0,get:function(){return b(d.opacity)?d.opacity:1}});let I=n.identity([]);if(l.asset.sharePosition&&t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.multiply(I,I,t.matrices[e]);if(l.asset.sharePosition){const t=this.$t(Vr,s,u,f);n.multiply(I,h,I),n.multiply(I,_,I),n.multiply(I,t,I)}else n.multiply(I,_,I);g.setLocalTransform(I),T.push(g)})),A?(this.ot[i]=T,o(null,{id:i,mesh:T})):(this.it[i]={meshes:T,count:m},T.ne=o),T}$t(e,r,i,o){const a=this.getMap(),c=this.J.options.services[r.Ct].heightOffset||0,l=new t.Coordinate(o);let f;f=a.altitudeToPoint?this.Nt:a.distanceToPointAtRes(100,100,a.getGLRes(),l).y/100;let u=r.matrix?n.copy(e,r.matrix):n.identity(e);if(i){$e(u,s.transformMat4(Pr,i,u),u)}const h=function(t,e,r,n,i,s,o){e=q(sr,e);const a=Ee(sr,e[0]*dr,e[1]*dr,e[2]),c=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(or,r),l=n.ellipsoid;var f;f=0===nt(c)?Z(ar,0,0,-6378137):ge(ar,c),hr.x=f[0],hr.y=f[1];const u=n.project(hr,_r);cr[0]=u.x/i,cr[1]=u.y/i,cr[2]=(f[2]+o)*s;const h=Je(a,l,lr),_=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],f=e[8],u=e[9],h=e[10],_=e[11],d=e[12],E=e[13],T=e[14],m=e[15],A=r*a-n*o,p=r*c-i*o,y=r*l-s*o,g=n*c-i*a,R=n*l-s*a,b=i*l-s*c,I=f*E-u*d,N=f*T-h*d,S=f*m-_*d,w=u*T-h*E,O=u*m-_*E,M=h*m-_*T,C=A*M-p*O+y*w+g*S-R*N+b*I;return C?(C=1/C,t[0]=(a*M-c*O+l*w)*C,t[1]=(i*O-n*M-s*w)*C,t[2]=(E*b-T*R+m*g)*C,t[3]=(h*R-u*b-_*g)*C,t[4]=(c*S-o*M-l*N)*C,t[5]=(r*M-i*S+s*N)*C,t[6]=(T*y-d*b-m*p)*C,t[7]=(f*b-h*y+_*p)*C,t[8]=(o*O-a*S+l*I)*C,t[9]=(n*S-r*O-s*I)*C,t[10]=(d*R-E*y+m*A)*C,t[11]=(u*y-f*R-_*A)*C,t[12]=(a*N-o*w-c*I)*C,t[13]=(r*w-n*N+i*I)*C,t[14]=(E*p-d*g-T*A)*C,t[15]=(f*g-u*p+h*A)*C,t):null}(fr,h),d=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}(ur,r),E=function(t,e,r){var n=t[0],i=t[1],s=t[2],o=t[4],a=t[5],c=t[6],l=t[8],f=t[9],u=t[10],h=e[0],_=e[1],d=e[2],E=e[3],T=e[4],m=e[5],A=e[6],p=e[7],y=e[8],g=n*h+o*_+l*d,R=i*h+a*_+f*d,b=s*h+c*_+u*d,I=n*E+o*T+l*m,N=i*E+a*T+f*m,S=s*E+c*T+u*m,w=n*A+o*p+l*y,O=i*A+a*p+f*y,M=s*A+c*p+u*y;return r[0]=g,r[1]=R,r[2]=b,r[3]=0,r[4]=I,r[5]=N,r[6]=S,r[7]=0,r[8]=w,r[9]=O,r[10]=M,r[11]=0,r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r}(_,d,t);return $e(t,cr,E),t}(u,o,u,a.getProjection(),a.getGLRes(),f,c),_=function(t,e){return Z(t,e[12],e[13],e[14]),t}(kr,h);let d=this.J.options.offset;if(g(d)){d=d(this.J.se(r.id).center)}return s.set(Gr,d[0],d[1],0),s.sub(_,_,Gr),$e(h,_,h),h}createCMPTMesh(t,e,r,n){if(this.ft[e]){const t=this.ft[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],o=e+"."+t;"b3dm"===n?this.createB3DMMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)})):"i3dm"===n?this.createI3DMMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)})):"pnts"===n?this.createPntsMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)})):"cmpt"===n&&this.createCMPTMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)}))}return this.ft[e]=s,n(null,{id:e,mesh:s}),s}re(t,e,r,n,i){const s=("phong"===(this.J.options.services[n].shader||"phong")?this.Pt:this.Ft).getGeometryDefines(e);return i.asset&&"S3M"===i.asset.generator&&this.oe(s,e,i),e.data.uvRegion&&(s.HAS_I3S_UVREGION=1),s}oe(t,e,r){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1),e.data.aTexCoord0&&r.textures.length&&(t.COMPUTE_TEXCOORD=1)}ee(t,e,r,n,i,s,o){let a=!1;n.asset&&"S3M"===n.asset.generator&&(a=!0,n.extensions=n.extensions||{},n.extensions.KHR_techniques_webgl=Er);const c=n.url+"-"+e+"-"+r;if(this.ut[c])return this.ut[c].refCount++,this.ut[c];let l,f;const u=n.materials[t.material];if(n.extensions&&n.extensions.KHR_techniques_webgl&&u.extensions&&u.extensions.KHR_techniques_webgl){const e=this.ae(t,n,s,a);l=e.material,f=e.geometry;this.J.options.services[i.Ct].fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.ce(t,s,zr);const e=this.J.options.services[i.Ct],r=e.ambientLight;let a=e.environmentExposure;const c=e.material,u=this.getMap().getLightManager(),h=u&&u.getAmbientLight();if(r&&(!h||h.color)&&void 0===a){const t=h&&h.color?h.color[0]:.2;a=r[0]/t}l=this.le(t.material,n,o,c||Cr,a||1)}l&&!l.isReady()?l.fe=i.id:l||(l=this.gt);const h={refCount:1,geometry:f,material:l};return f.properties.url=c,this.ut[c]=h,h}ae(t,e,r,n){const{geometry:i,material:s}=this.bt.createMesh(t,e,r,n);return{geometry:i,material:s}}ce(t,e,n){const i=t.attributes;let s=i._BATCHID&&i._BATCHID.array;if(s&&s.byteOffset&&(s=new s.constructor(s)),i.COLOR_0){const t=i.COLOR_0.array||i.COLOR_0;if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let r=0;r<e.length;r++)e[r]=Math.round(255*t[r]);i.COLOR_0.array?(i.COLOR_0.array=e,i.COLOR_0.componentType=5121):i.COLOR_0=e}}const o={};for(const t in i){const e=Rr(this.rt,i[t],{dimension:i[t].itemSize}),r=n[t]||t;o[r]={buffer:e},i[t].quantization&&(o[r].quantization=i[t].quantization),r===n.POSITION&&(o[r].array=i[t].array,o[r].min=i[t].min,o[r].max=i[t].max)}delete t.attributes;const a=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,c=new r.Geometry(o,a,0,{positionAttribute:n.POSITION,normalAttribute:n.NORMAL,uv0Attribute:n.TEXCOORD_0,uv1Attribute:n.TEXCOORD_1,color0Attribute:n.COLOR_0,tangentAttribute:n.TANGENT,pickingIdAttribute:n._BATCHID,primitive:void 0===t.mode?"triangles":gr(t.mode)});return s&&a&&(c.properties.batchIdData=s,c.properties.batchIdMap=function(t,e){if(!e)return null;const r=new Map;for(let n=0;n<e.length;n++){const i=e[n],s=t[i];let o=r.get(s);o||(o=[],r.set(s,o)),o.push(i)}return r}
|
|
18
|
+
let lt=0;function ft(t){return null==t}function ht(t){return!ft(t)}function ut(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 Et(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 Bt(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function _t(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 dt=[],Ct=[],Tt=[],mt=[0,0,0],gt=ot([]),pt=[1,1,1];function yt(t,e,r,n,i,s,o){const a=Et(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}0===i&&(i=n*a.BYTES_PER_ELEMENT);const A=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);A.set(c),r=new a(A.buffer,0,n);for(let e=0;e<n;e++)t[o*n+e]=r[e]}return t}const Rt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function It(t,e,r){const n=new Uint8Array(t,e,r);return Rt.decode(n)}const bt={get:function(t,e={}){e||(e={});const r=new AbortController,n=r.signal,i=ut({},e);i.signal=n,i.method||(i.method="GET");const s=fetch(t,i).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 s.xhr=r,s},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",bt.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?bt.jsonp(t):((e=e||{}).responseType="json",bt.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+lt++;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.A={}}requestImageFromBufferURI(t,e,r){if(this.buffers[t.id]){const n=this.buffers[t.id],i=this.l(e,n);return this.getImageByBuffer(i,r)}if(this.A[t.id])return this.A[t.id].then((()=>{const n=this.buffers[t.id],i=this.l(e,n);return this.getImageByBuffer(i,r)}));if(Bt(t.uri)){const n=this.buffers[t.id]=_t(t.uri),i=this.l(e,n);return this.getImageByBuffer(i,r)}return this.A[t.id]=bt.getArrayBuffer(t.uri,null).then((n=>{const i=this.buffers[t.id]=n.data,s=this.l(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;return this.A[t.id]?this.A[t.id].then((()=>this.images[t.id])):this.A[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 Mt=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16];class Nt{constructor(t,e,r){this.rootPath=t,this.gltf=e,this.u=!1,this.glbBuffer=r,this.buffers={},this.requests={},this.accessors={},this.B()}_(t,e){const r=this.gltf,n=r.accessors[e];if(void 0===n.bufferView)return this.accessors[n.id]=this.C(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.C(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(Bt(e.uri)){const t=this.buffers[e.id]=_t(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const r=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||r?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=bt.getArrayBuffer(t,null).then((n=>(r&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=n.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}C(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,A=this.m(s.type),c=Et(s.componentType),l=o.byteStride||0,f={array:void 0,name:t,accessorName:e,byteLength:s.count*A*c.BYTES_PER_ELEMENT,componentType:s.componentType,count:s.count,type:s.type,itemSize:A};if(s.min&&(f.min=s.min),s.max&&(f.max=s.max),r)if(this.u)f.byteStride=l,f.byteOffset=a+(s.byteOffset||0),!l||l===A*c.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(f.array=this.g(r,s.count,A,a+(s.byteOffset||0),c),f.array.buffer.byteLength===f.byteLength&&(f.byteOffset=0)):f.array=new Uint8Array(r,a,o.byteLength);else if(s.interleaved){f.byteStride=0,f.byteOffset=0;const t=new c(s.count*A);f.array=yt(t,r,s.count,A,l,a+(s.byteOffset||0),s.componentType)}else f.byteStride=0,f.array=this.g(r,s.count,A,a+(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}B(){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)}g(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)}m(t){const e=Mt.indexOf(t);return Mt[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,o=It(i,s+(e.byteOffset||0),r);return t.content=o,t}))}if(t.uri){if(Bt(t.uri)){const e=_t(t.uri),r=It(e,0,e.byteLength);return t.content=r,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return bt.get(e).then((e=>(t.content=e,t)))}}return Promise.resolve(t)}));return Promise.all(r).then((()=>t))}}class St 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 Nt(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(ht(t.name)&&(e.name=t.name),ht(t.children)&&(e.children=t.children),ht(t.jointName)&&(e.jointName=t.jointName),ht(t.matrix)&&(e.matrix=t.matrix),ht(t.rotation)&&(e.rotation=t.rotation),ht(t.scale)&&(e.scale=t.scale),ht(t.translation)&&(e.translation=t.translation),ht(t.extras)&&(e.extras=t.extras),ht(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=H(dt,e.translation||mt),n=V(Ct,e.rotation||gt),i=K(Tt,e.scale||pt);return G(i,n,i),G(t,r,i)}return U(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}p(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}R(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)}I(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.R(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 Lt 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 Nt(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 ut(e,t),!ht(t.weights)&&this.gltf.meshes&&ht(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}I(t){const e=this.gltf.textures[t];if(!e)return null;const r=this.gltf.images[e.source];return this.R(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}};ut(n,e);const i=ht(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return i&&(n.sampler=i),t.format&&(n.format=t.format),n}))}R(t){if(!ht(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.P(e,t)}return null}P(t,e){const r=this.l(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(r,e)}l(t,e,r){r=r||0;const n=t.byteOffset+r,i=t.byteLength;return new Uint8Array(e,n,i)}M(t,e){const r=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)r[e]=String.fromCharCode(t[e]);return r.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(r)))}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++)(ht(t[r].input)||ht(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 Dt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class Ot{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 Ot.readV1(n,e);if(2===i)return Ot.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=Ft(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 A=s.getUint32(o,!0);if(o+=4,1313821514===A)r=Ft(t,e+12+o,a);else if(5130562===A){i=e+12+o,n=a;break}o+=a}return{json:JSON.parse(r),glbBuffer:{byteOffset:i,buffer:t,byteLength:n}}}}function Ft(t,e,r){if(Dt){const n=new Uint8Array(t,e,r);return Dt.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=xt[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 xt=[1,1,1,1,2,2,3,0],wt=[0,0,0],vt=[0,0,0,1],Ut=[1,1,1],Gt={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},Ht={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},Kt={N(t,e,r,n,i,s,o,a){const A=ht(t)?e.animations:[e.animations[0]],c={};for(let e=0;e<A.length;e++){const l=A[e],f=l.name||e;if(ht(t)&&f!==t)continue;const h=l.channelsMap[r];if(h)for(let t=0;t<h.length;t++){const e=h[t];"translation"===e.target.path?(this.S(i,l.samplers[e.sampler],n,1),c.translation=J(wt,i)):"rotation"===e.target.path?(this.L(s,l.samplers[e.sampler],n,1),c.rotation=ct(vt,s)):"scale"===e.target.path?(this.S(o,l.samplers[e.sampler],n,1),c.scale=J(Ut,o)):"weights"===e.target.path&&a&&(this.S(a,l.samplers[e.sampler],n,a.length),c.weights=a)}}return c},S(t,e,r,n){switch(e.interpolation){case"LINEAR":{const i=this.D(Ht,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.D(Ht,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.D(Ht,e,r,3*n);i&&(t=this.O(t,i,e.input.array,3*n));break}}return t},L(t,e,r){switch(e.interpolation){case"LINEAR":{const n=this.D(Ht,e,r,1);n&&at(t,n.PREVIOUS,n.NEXT,n.INTERPOLATION);break}case"STEP":{const n=this.D(Ht,e,r,1);n&&(t=it(t,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this.D(Ht,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.O(t,n,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},F(t,e){const r=t.length;let n,i,s,o=0,a=r-1,A=Math.floor((o+a)/2);for(;o<=r-1&&a>=0;){if(o===a)return null;if(t[A]<=e&&e<=t[A+1]){const r=t[A];return n=A,i=A+1,s=(e-r)/(t[A+1]-r),{preIndx:n,nextIndex:i,interpolation:s}}e<t[A]?(a=A,A=Math.floor((o+a)/2)):t[A+1]<e&&(o=A,A=Math.floor((o+a)/2))}return null},D(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.F(i,r);if(!a||!a.nextIndex)return null;const{preIndx:A,nextIndex:c,interpolation:l}=a;t.PREINDEX=A,t.NEXTINDEX=c,t.INTERPOLATION=l;const f=o*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},O(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],A=(o-s)*e.PREVIOUS[2*n+r],c=e.NEXT[3+r],l=(o-s)*e.NEXT[r],f=(2*Math.pow(i,3)-3*Math.pow(i,2)+1)*a+(Math.pow(i,3)-2*Math.pow(i,2)+i)*A+(2*-Math.pow(i,3)+3*Math.pow(i,2))*c+(Math.pow(i,3)-Math.pow(i,2))*l;t[r]=f}return t},getAnimationClip(t,e,r,n){const i=t.nodes[e]&&t.nodes[e].weights;return z(wt,...Gt.TRANSLATION),it(vt,...Gt.ROTATION),z(Ut,...Gt.SCALE),this.N(n,t,e,r,wt,vt,Ut,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?ht(e)?r[e]:r[Object.keys(r)[0]]:null}};let Vt=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Wr){}t&&"undefined"!=typeof createImageBitmap&&(Vt=!0)}const kt="undefined"==typeof document?null:document.createElement("canvas");class Xt{constructor(t,e,r){if(this.options=r||{},this.options.decoders||(this.options.decoders={}),e.buffer instanceof ArrayBuffer){const{json:r,glbBuffer:n}=Ot.read(e.buffer,e.byteOffset,e.byteLength);this.v(t,r,n)}else this.v(t,e);this.U=new Nt(this.rootPath,this.gltf,this.glbBuffer),this.G()}G(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}H(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.U.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then((e=>(t.KHR_techniques_webgl=e,t))):Promise.resolve(t)}load(t){t=t||{};const e=this.K(t),r=this.V(),n=this.k(),i=this.H();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 Kt.getAnimationClip(t,e,r,n)}static getAnimationTimeSpan(t,e){return Kt.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return Et(t)}static readInterleavedArray(t,e,r,n,i,s,o){return yt(t,e,r,n,i,s,o)}v(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=Vt?Zt.bind(this):this.options.requestImage||Yt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new Lt(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 St(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"))}X(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(r=t.children[0])&&isFinite(r)||function(t){return!ft(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.X(r,e)}));t.children=n}var r;return t}K(t){return this.Y(t).then((t=>{const e=this.scenes=[];let r;for(const e in t)t[e]=this.X(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.p(this.gltf.materials);n.materials=t}return n}))}Y(t){return this.J(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}))}Z(){this.skins=[];const t=[];return this.adapter.iterate(((e,r,n)=>{t.push(this.W(r).then((t=>{t.index=n,this.skins.push(t)})))}),"skins"),t}W(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 ht(t)?this.adapter.getAnimations(t):null}J(t){this.meshes={};let e=[];return this.adapter.iterate(((r,n,i)=>{e.push(this.j(n,t).then((t=>{t.index=i,this.meshes[r]=t})))}),"meshes"),e=e.concat(this.Z()),Promise.all(e)}j(t,e){const r=t.primitives.map((t=>this.q(t,e))).filter((t=>!!t));return Promise.all(r).then((e=>{const r={};return ut(r,t),r.primitives=e,r}))}k(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const r in t)e.push(this.adapter.I(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}))}q(t,e){let r;const n=[],i=t.extensions;if(ht(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:o}=i.KHR_draco_mesh_compression,a=this.gltf.bufferViews[s],A=this.U.T(a).then((r=>{const{buffer:n,byteOffset:i}=r;let{byteOffset:s,byteLength:A}=a;s||(s=0);const c=new DataView(n,i+s,A),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(A),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(ht(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={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;Q(t,t,i),Z(t,t,s),Q(r,r,i),Z(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=ht(t.mode)?t.mode:4,ht(t.extras)&&(s.extras=t.extras),s}))}}function Yt(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",{willReadFrequently:!0});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 Jt,zt;function Zt(t,e){Jt||(Jt=new OffscreenCanvas(2,2),zt=Jt.getContext("2d",{willReadFrequently:!0})),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;Wt(r)||(r=jt(r)),Wt(n)||(n=jt(n));const i=this.options.maxTextureSize;i&&(r=Math.min(i,r),n=Math.min(i,n)),Jt.width=r,Jt.height=n,zt.drawImage(t,0,0,r,n),t.close();const s=zt.getImageData(0,0,r,n);e(null,{width:r,height:n,data:new Uint8Array(s.data)})})).catch((t=>{console.warn(t),e(t)}))}function Wt(t){return 0==(t&t-1)&&0!==t}function jt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}const Qt="undefined"==typeof document?null:document.createElement("canvas");class qt 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(!Qt)return void e(new Error("There is no canvas to draw image!"));const t=function(t){if($t(t.width)&&$t(t.height))return t;let e=t.width,r=t.height;$t(e)||(e=te(e));$t(r)||(r=te(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,o=i.substring(s);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${r})`),n}(r);Qt.width=t.width,Qt.height=t.height;const n=Qt.getContext("2d",{willReadFrequently:!0});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 $t(t){return 0==(t&t-1)&&0!==t}function te(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}class ee{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 re(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=[];ce(n[r],i,t,e)}}}const ne=[],ie=[],se=[],oe=[0,0,0],ae=ot([]),Ae=[1,1,1];function ce(t,e,r,n){const i=e.slice(0);if(t.matrix)i.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=H(ne,t.translation||oe),r=V(ie,t.rotation||ae),n=K(se,t.scale||Ae);G(n,r,n);const s=G([],e,n);i.push(s)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)ce(t.children[e],i,r,n);if(void 0!==t.mesh){const e=t.mesh,s=r.meshes[e];if(s){const t=i.slice(0),o=s.primitives;for(let i=0,s=o.length;i<s;i++){const s=o[i];s&&(s.matrices=t,n(s,e,i,r))}}}}function le(t,e,r){let{componentType:n,byteOffset:i,byteStride:s,itemSize:o}=e;const a=e.array.buffer,A=n?Xt.getTypedArrayCtor(n):e.array.constructor;if(i=void 0===i?e.array.byteOffset:i,s=s||0,!s||s===o*A.BYTES_PER_ELEMENT&&i%A.BYTES_PER_ELEMENT==0){const e=new A(a,i+r*o*A.BYTES_PER_ELEMENT,o);return t.set(e),t}s||(s=o*A.BYTES_PER_ELEMENT);const c=new Uint8Array(a,s*r+i,o*A.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(c),t}function fe(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 he=new Array(3),ue=new Array(3),Ee=[40680631590769,40680631590769,40408299984661.445];function Be(t,e,r,n){const i=Ee,s=Math.cos(r);he[0]=s*Math.cos(e),he[1]=s*Math.sin(e),he[2]=Math.sin(r),Ie(he,he),j(ue,i,he);const o=Math.sqrt($(he,ue));var a,A,c;return A=ue,c=o,(a=ue)[0]=A[0]/c,a[1]=A[1]/c,a[2]=A[2]/c,Q(he,he,n),Z(t,ue,he)}const _e=[1/6378137,1/6378137,1/6356752.314245179],de=[1/40680631590769,1/40680631590769,1/40408299984661.445],Ce=new Array(3),Te=new Array(3),me=new Array(3);function ge(t,e){const r=de,n=function(t,e,r,n,i){const s=e[0],o=e[1],a=e[2],A=r[0],c=r[1],l=r[2],f=s*s*A*A,h=o*o*c*c,u=a*a*l*l,E=f+h+u,B=Math.sqrt(1/E),_=Q(pe,e,B);if(E<i)return isFinite(B)?_:void 0;const d=n[0],C=n[1],T=n[2],m=ye;m[0]=_[0]*d*2,m[1]=_[1]*C*2,m[2]=_[2]*T*2;let g,p,y,R,I,b,P,M,N,S,L,D=(1-B)*Re(e)/(.5*Re(m)),O=0;do{D-=O,y=1/(1+D*d),R=1/(1+D*C),I=1/(1+D*T),b=y*y,P=R*R,M=I*I,N=b*y,S=P*R,L=M*I,g=f*b+h*P+u*M-1,p=f*N*d+h*S*C+u*L*T;O=g/(-2*p)}while(Math.abs(g)>1e-12);return t[0]=s*y,t[1]=o*R,t[2]=a*I,t}(Ce,e,_e,r,.1);let i=rt(Te,n,r);i=Ie(i,i);const s=et(me,e,n),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),A=P($(s,e))*Re(s);return t[0]=I(o),t[1]=I(a),t[2]=A,t}const pe=new Array(3),ye=new Array(3);function Re(t){return X(t)}function Ie(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 be(t,e){return j(e,t,de),q(e,e)}function Pe(t,e){var r=t[0],n=t[1],i=Math.cos(n),s=i*Math.cos(r),o=i*Math.sin(r),a=Math.sin(n);return e.x=s,e.y=o,e.z=a,q(e,e)}var Me=Object.freeze({__proto__:null,radianToCartesian3:Be,cartesian3ToDegree:ge,normalizeCartesian:Ie,geodeticSurfaceNormal:be,geodeticSurfaceNormalCartographic:Pe});function Ne(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 Se(t,e){let r="";for(let n=0;n<4;n++){const i=t.getUint8(e+n);r+=String.fromCharCode(i)}return r}const Le="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function De(t,e,r){const n=new Uint8Array(t,e,r);return Le?JSON.parse(Le.decode(n)):JSON.parse(N(n))}function Oe(t,e,r){const n=new Uint8Array(t,e,r);return Le?JSON.parse(Le.decode(n)):JSON.parse(N(n))}function Fe(t,e,r){return{offset:e,byteLength:r}}function xe(t,e,r,n){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:A}=Ke(s||"UNSIGNED_SHORT"),c=Ge(o);return{byteStride:0,byteOffset:i+r,itemSize:c,count:n*c,componentType:A,array:new a(e,r+i,n*c)}}function we(t,e,r,n){const i=xe(t,e,r,n);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}function ve(t,e,r,n){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a}=Ke(s||"UNSIGNED_SHORT"),A=Ge(o),c=new a(e,i,r*A);return 1===A?c[n]:c.subarray(n*A,n*A+A)}const Ue={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Ge(t){return t?Ue[t]:1}const He={"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 Ke(t){return He[t]}function Ve(t){for(let e in He)if(t===He[e].ctor)return He[e].type;throw new Error("unrecognized ctor:"+t)}function ke(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 Xe(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 A,c,l={},f={};n>0&&(l=De(a,e,n),e+=n),i>0&&(A=function(t,e,r){return{offset:e,byteLength:r}}(0,e,i),e+=i),s>0&&(f=Oe(a,e,s),e+=s);const h=Fe(0,e,o);return c=a.slice(h.offset,h.offset+h.byteLength),r.push(c),{featureTable:l,featureTableBin:A,batchTable:f,batchTableBin:c}}var Ye={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Je={},ze={east:[],north:[],up:[],west:[],south:[],down:[]},Ze=[],We=[],je=[];const Qe=[0,0,0];function qe(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 $e=(nr={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"}}[tr="east"][er="north"],Je[ir=tr+er]?rr=Je[ir]:(rr=function(t,e,r){if(function(t,e){var r=t[0],n=t[1],i=t[2],s=e[0],o=e[1],a=e[2];return Math.abs(r-s)<=1e-6*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(n-o)<=1e-6*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=1e-6*Math.max(1,Math.abs(i),Math.abs(a))}(t,Qe))J(Ze,Ye[tr]),J(We,Ye[er]),J(je,Ye[nr]);else if(Ne(t[0],0,1e-14)&&Ne(t[1],0,1e-14)){var n=P(t[2]);J(Ze,Ye[tr]),"east"!==tr&&"west"!==tr&&Q(Ze,Ze,n),J(We,Ye[er]),"east"!==er&&"west"!==er&&Q(We,We,n),J(je,Ye[nr]),"east"!==nr&&"west"!==nr&&Q(je,je,n)}else{be(t,ze.up);var i=ze.up,s=ze.east;s[0]=-t[1],s[1]=t[0],s[2]=0,q(ze.east,s),tt(ze.north,i,s),Q(ze.down,ze.up,-1),Q(ze.west,ze.east,-1),Q(ze.south,ze.north,-1),Ze=ze[tr],We=ze[er],je=ze[nr]}return r[0]=Ze[0],r[1]=Ze[1],r[2]=Ze[2],r[3]=0,r[4]=We[0],r[5]=We[1],r[6]=We[2],r[7]=0,r[8]=je[0],r[9]=je[1],r[10]=je[2],r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r},Je[ir]=rr),rr);var tr,er,rr,nr,ir;const sr=[],or=[],ar=[],Ar=[],cr=[],lr=[],fr=[],hr={x:0,y:0},ur={x:0,y:0},Er=Math.PI/180;const Br={"programs":[{"attributes":["aPosition","instanceId","batchId","aTexCoord0","aTexCoord1","aNormal","aColor","uv2","uv3","uv4","secondary_colour","uv6"],"fragmentShader":1,"vertexShader":0}],"shaders":[{"type":35633,"content":"precision highp float;\n\n#include <gl2_vert>\n\n attribute vec4 aPosition;\n\n#ifdef VertexColor\n\n attribute vec4 aColor0;\n\n#endif\n\n#ifdef VertexNormal\n\n attribute vec3 aNormal;\n\n#endif\n\n#ifdef Instance\n\n attribute float instanceId;\n\n#else\n\n attribute float batchId;\n\n#endif \n\n\n\n#ifdef HAS_VertexWeight\n\n attribute float aVertexWeight;\n\n#endif\n\n\n\n#ifdef HAS_TextureCoordMatrix\n\n attribute vec2 aTextureCoordMatrix;\n\n#endif\n\n\n\n#ifdef TexCoord\n\n attribute vec4 aTexCoord;\n\n varying vec4 vTexCoord;\n\n uniform mat4 uTexMatrix;\n\n#ifdef COMPUTE_TEXCOORD\n\n uniform float uTexture0Width;\n\n varying vec4 vTexMatrix;\n\n varying vec4 vTexCoordTransform;\n\n varying vec2 vIsRGBA;\n\n#endif\n\n#endif\n\n\n\n#ifdef TexCoord2\n\n attribute vec4 aTexCoord1;\n\n uniform float uTexture1Width;\n\n varying vec4 vTexMatrix2;\n\n#endif\n\n#ifdef InstanceBim\n\n attribute vec4 uv2;\n\n attribute vec4 uv3;\n\n attribute vec4 uv4;\n\n attribute vec4 secondary_colour;\n\n attribute vec4 uv6; \n\n#endif\n\n\n\n#ifdef InstancePipe\n\n attribute vec4 uv1;\n\n attribute vec4 uv2;\n\n attribute vec4 uv3;\n\n attribute vec4 uv4;\n\n attribute vec4 uv5;\n\n attribute vec4 uv6;\n\n attribute vec4 uv7;\n\n attribute vec4 secondary_colour;\n\n attribute vec4 uv9;\n\n#endif\n\n uniform vec4 uFillForeColor;\n\n uniform vec4 uSelectedColor;\n\n varying vec4 vPositionMC;\n\n varying vec3 vPositionEC;\n\n#ifdef VertexNormal\n\n varying vec3 vNormalEC;\n\n#endif\n\n varying vec4 vColor;\n\n const float SHIFT_LEFT8 = 256.0;\n\n const float SHIFT_RIGHT8 = 1.0 / 256.0;\n\n const float SHIFT_RIGHT4 = 1.0 / 16.0;\n\n const float SHIFT_LEFT4 = 16.0;\n\n void getTextureMatrixFromZValue(in float nZ, inout float XTran, inout float YTran, inout float scale, inout float isRGBA)\n\n {\n\n if(nZ <= 0.0)\n\n {\n\n return;\n\n }\n\n float nDel8 = floor(nZ * SHIFT_RIGHT8);\n\n float nDel16 = floor(nDel8 * SHIFT_RIGHT8);\n\n float nDel20 = floor(nDel16 * SHIFT_RIGHT4);\n\n isRGBA = floor(nDel20);\n\n YTran = nZ - nDel8 * SHIFT_LEFT8;\n\n XTran = nDel8 - nDel16 * SHIFT_LEFT8;\n\n float nLevel = nDel16 - nDel20 * SHIFT_LEFT4;\n\n scale = 1.0 / pow(2.0, nLevel);\n\n }\n\n \n\n void operation(vec4 operationType, vec4 color, vec4 selectedColor, inout vec4 vertexColor)\n\n {\n\n float right_2 = operationType.x * 0.5;\n\n float right_4 = right_2 * 0.5;\n\n float right_8 = right_4 * 0.5;\n\n float right_16 = right_8 * 0.5;\n\n float isSetColor = fract(right_2);\n\n if(isSetColor > 0.1)\n\n {\n\n vertexColor *= color;\n\n }\n\n float isPicked = fract(floor(right_2)* 0.5);\n\n if(isPicked > 0.1)\n\n {\n\n vertexColor *= selectedColor;\n\n }\n\n float isHide = fract(floor(right_4)* 0.5);\n\n if(isHide > 0.1)\n\n {\n\n vertexColor.a = 0.0;\n\n }\n\n }\n\n \n\n#ifdef COMPRESS_TEXCOORD\n\n#ifdef TexCoord\n\n uniform vec2 decode_texCoord0_min;\n\n#endif\n\n#ifdef TexCoord2\n\n uniform vec2 decode_texCoord1_min;\n\n#endif\n\n#ifdef MeshOPT_Compress\n\n uniform vec3 decode_texCoord0_vNormConstant;\n\n uniform vec3 decode_texCoord1_vNormConstant;\n\n#else\n\n uniform float decode_texCoord0_normConstant;\n\n uniform float decode_texCoord1_normConstant;\n\n#endif\n\n#endif\n\n\n\n#ifdef COMPRESS_VERTEX\n\n uniform vec4 decode_position_min;\n\n uniform float decode_position_normConstant;\n\n#endif\n\n\n\n#ifdef COMPRESS_NORMAL\n\n uniform float normal_rangeConstant;\n\n#endif\n\n\n\nuniform mat4 modelMatrix;\n\nuniform mat4 modelViewMatrix;\n\nuniform mat4 projMatrix;\n\nuniform mat3 modelNormalMatrix;\n\n\n\n\n\n\n\nfloat czm_signNotZero(float value) {\n\n return value >= 0.0 ? 1.0 : -1.0;\n\n}\n\nvec2 czm_signNotZero(vec2 value) {\n\n return vec2(czm_signNotZero(value.x), czm_signNotZero(value.y));\n\n}\n\n\n\nvec3 czm_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)) * czm_signNotZero(v.xy);\n\n }\n\n return normalize(v);\n\n}\n\n\n\nvec4 czm_updatePositionDepth(vec4 coords) {\n\n coords.z = clamp(coords.z / coords.w, -1.0, 1.0) * coords.w;\n\n return coords;\n\n}\n\n\n\nvoid main()\n\n{\n\n#ifdef COMPRESS_VERTEX\n\n vec4 vertexPos = vec4(1.0);\n\n vertexPos = vec4(aPosition.xyz, 1.0);\n\n#else\n\n vec4 vertexPos = aPosition;\n\n#endif\n\n#ifdef TexCoord\n\n\n\n#ifdef COMPRESS_TEXCOORD\n\n#ifdef MeshOPT_Compress\n\n vec2 texCoord0;\n\n texCoord0.x = aTexCoord.x * decode_texCoord0_vNormConstant.x;\n\n texCoord0.y = aTexCoord.y * decode_texCoord0_vNormConstant.y;\n\n vTexCoord.xy = decode_texCoord0_min + texCoord0.xy;\n\n#else\n\n vTexCoord.xy = decode_texCoord0_min.xy + aTexCoord.xy * decode_texCoord0_normConstant;\n\n#endif\n\n#else\n\n vTexCoord.xy = aTexCoord.xy;\n\n#endif\n\n\n\n#ifdef COMPUTE_TEXCOORD\n\n vTexMatrix = vec4(0.0,0.0,1.0,0.0);\n\n vIsRGBA.x = 0.0;\n\n vTexCoordTransform.x = aTexCoord.z;\n\n #ifdef HAS_TextureCoordMatrix\n\n vTexCoordTransform.x = aTextureCoordMatrix.x;\n\n #endif\n\n if(vTexCoordTransform.x < -90000.0)\n\n {\n\n vTexMatrix.z = -1.0;\n\n }\n\n getTextureMatrixFromZValue(floor(vTexCoordTransform.x), vTexMatrix.x, vTexMatrix.y, vTexMatrix.z, vIsRGBA.x);\n\n vTexMatrix.w = log2(uTexture0Width * vTexMatrix.z);\n\n#endif\n\n#endif\n\n\n\n#ifdef TexCoord2\n\n\n\n #ifdef COMPRESS_TEXCOORD\n\n #ifdef MeshOPT_Compress\n\n vec2 texCoord1;\n\n texCoord1.x = aTexCoord1.x * decode_texCoord1_vNormConstant.x;\n\n texCoord1.y = aTexCoord1.y * decode_texCoord1_vNormConstant.y;\n\n vTexCoord.zw = decode_texCoord1_min + texCoord1.xy;\n\n #else\n\n vTexCoord.zw = decode_texCoord1_min.xy + aTexCoord1.xy * decode_texCoord1_normConstant;\n\n #endif\n\n #else\n\n vTexCoord.zw = aTexCoord1.xy;\n\n #endif\n\n\n\n vTexMatrix2 = vec4(0.0,0.0,1.0,0.0);\n\n vIsRGBA.y = 0.0;\n\n vTexCoordTransform.y = aTexCoord1.z;\n\n #ifdef HAS_TextureCoordMatrix\n\n vTexCoordTransform.y = aTextureCoordMatrix.y;\n\n #endif\n\n if(vTexCoordTransform.y < -90000.0)\n\n {\n\n vTexMatrix2.z = -1.0;\n\n }\n\n getTextureMatrixFromZValue(floor(vTexCoordTransform.y), vTexMatrix2.x, vTexMatrix2.y, vTexMatrix2.z, vIsRGBA.y);\n\n vTexMatrix2.w = log2(uTexture1Width * vTexMatrix.z);\n\n#endif\n\n\n\n vec4 vertexColor = uFillForeColor;\n\n#ifdef VertexColor\n\n vertexColor *= aColor0 / 255.0;\n\n#endif\n\n#ifdef VertexNormal\n\n vec3 normal = aNormal;\n\n #ifdef COMPRESS_NORMAL\n\n #ifdef MeshOPT_Compress\n\n normal.x = aNormal.x / 127.0;\n\n normal.y = aNormal.y / 127.0;\n\n normal.z = 1.0 - abs(normal.x) - abs(normal.y);\n\n normal = normalize(normal);\n\n #else\n\n normal = czm_octDecode(aNormal.xy, normal_rangeConstant).zxy;\n\n #endif\n\n #endif\n\n#endif\n\n#ifdef InstanceBim\n\n mat4 worldMatrix;\n\n worldMatrix[0] = uv2;\n\n worldMatrix[1] = uv3;\n\n worldMatrix[2] = uv4;\n\n worldMatrix[3] = vec4(0, 0, 0, 1);\n\n vertexPos = vec4(vertexPos.xyz,1.0) * worldMatrix;\n\n vertexColor *= secondary_colour; \n\n#endif\n\n#ifdef InstancePipe\n\n mat4 worldMatrix;\n\n mat4 worldMatrix0;\n\n mat4 worldMatrix1;\n\n vec4 worldPos0;\n\n vec4 worldPos1;\n\n worldMatrix0[0] = uv1;\n\n worldMatrix0[1] = uv2;\n\n worldMatrix0[2] = uv3;\n\n worldMatrix0[3] = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n worldMatrix1[0] = uv4;\n\n worldMatrix1[1] = uv5;\n\n worldMatrix1[2] = uv6;\n\n worldMatrix1[3] = vec4( 0.0, 0.0, 0.0, 1.0 );\n\n vec4 realVertex = vec4(vertexPos.xyz, 1.0);\n\n realVertex.x = realVertex.x * uv7.z;\n\n worldPos0 = realVertex * worldMatrix0;\n\n worldPos1 = realVertex * worldMatrix1;\n\n vertexColor *= secondary_colour; \n\n #ifdef TexCoord\n\n if(aTexCoord.y > 0.5)\n\n {\n\n vec4 tex4Vec = uTexMatrix * vec4(uv7.y, aTexCoord.x, 0.0, 1.0);\n\n vTexCoord.xy = tex4Vec.xy;\n\n vertexPos = worldPos1;\n\n worldMatrix = worldMatrix1;\n\n }\n\n else\n\n {\n\n vec4 tex4Vec = uTexMatrix * vec4(uv7.x, aTexCoord.x, 0.0, 1.0);\n\n vTexCoord.xy = tex4Vec.xy;\n\n vertexPos = worldPos0;\n\n worldMatrix = worldMatrix0;\n\n }\n\n #endif\n\n #ifdef VertexNormal\n\n normal.x = normal.x * uv7.z;\n\n #endif\n\n#endif\n\n#ifdef Instance \n\n float index = instanceId;\n\n#else\n\n float index = batchId;\n\n#endif \n\n vec4 positionMC = vec4(vertexPos.xyz, 1.0);\n\n vColor = vertexColor;\n\n#ifdef VertexNormal\n\n vNormalEC = modelNormalMatrix * normal;\n\n#endif\n\n vPositionMC = positionMC;\n\n vPositionEC = (modelViewMatrix * positionMC).xyz;\n\n gl_Position = projMatrix * modelViewMatrix * vec4(vertexPos.xyz, 1.0);\n\n}\n\n"},{"type":35632,"content":"#ifdef GL_OES_standard_derivatives\n\n #extension GL_OES_standard_derivatives : enable\n\n#endif\n\n#ifdef GL_EXT_shader_texture_lod\n\n #extension GL_EXT_shader_texture_lod : enable\n\n#endif\n\nprecision highp float;\n\n#include <gl2_frag>\n\n uniform vec4 uDiffuseColor;\n\n#ifdef TexCoord\n\n varying vec4 vTexCoord;\n\n #ifdef COMPUTE_TEXCOORD\n\n uniform sampler2D uTexture;\n\n uniform float uTexture0Width;\n\n varying vec4 vTexCoordTransform;\n\n varying vec4 vTexMatrix;\n\n varying vec2 vIsRGBA;\n\n #endif\n\n#endif\n\n\n\n varying vec4 vPositionMC;\n\n varying vec3 vPositionEC;\n\n varying vec4 vColor;\n\n#ifdef VertexNormal\n\n varying vec3 vNormalEC;\n\n#endif\n\n#ifdef TexCoord2\n\n uniform sampler2D uTexture2;\n\n uniform float uTexture1Width;\n\n varying vec4 vTexMatrix2;\n\n#endif\n\n#ifdef COMPUTE_TEXCOORD\n\n void calculateMipLevel(in vec2 inTexCoord, in float vecTile, in float fMaxMip, inout float mipLevel)\n\n {\n\n vec2 dx = dFdx(inTexCoord * vecTile);\n\n vec2 dy = dFdy(inTexCoord * vecTile);\n\n float dotX = dot(dx, dx);\n\n float dotY = dot(dy, dy);\n\n float dMax = max(dotX, dotY);\n\n float dMin = min(dotX, dotY);\n\n float offset = (dMax - dMin) / (dMax + dMin);\n\n offset = clamp(offset, 0.0, 1.0);\n\n float d = dMax * (1.0 - offset) + dMin * offset;\n\n mipLevel = 0.5 * log2(d);\n\n mipLevel = clamp(mipLevel, 0.0, fMaxMip - 1.62);\n\n }\n\n \n\n void calculateTexCoord(in vec3 inTexCoord, in float scale, in float XTran, in float YTran, in float fTile, in float mipLevel, inout vec2 outTexCoord)\n\n {\n\n if(inTexCoord.z < -9000.0)\n\n {\n\n outTexCoord = inTexCoord.xy;\n\n }\n\n else\n\n {\n\n vec2 fTexCoord = fract(inTexCoord.xy);\n\n float offset = 1.0 * pow(2.0, mipLevel) / fTile;\n\n fTexCoord = clamp(fTexCoord, offset, 1.0 - offset);\n\n outTexCoord.x = (fTexCoord.x + XTran) * scale;\n\n outTexCoord.y = (fTexCoord.y + YTran) * scale;\n\n }\n\n }\n\n \n\n vec4 getTexColorForS3M(sampler2D curTexture, vec3 oriTexCoord, float texTileWidth, float fMaxMipLev, float fTexCoordScale, vec2 vecTexCoordTranslate, float isRGBA)\n\n {\n\n vec4 color = vec4(1.0);\n\n float mipLevel = 0.0;\n\n #ifdef GL_OES_standard_derivatives\n\n calculateMipLevel(oriTexCoord.xy, texTileWidth, fMaxMipLev, mipLevel);\n\n #endif\n\n vec2 realTexCoord;\n\n calculateTexCoord(oriTexCoord, fTexCoordScale, vecTexCoordTranslate.x, vecTexCoordTranslate.y, texTileWidth, mipLevel, realTexCoord);\n\n if(isRGBA > 0.5)\n\n {\n\n vec2 rgbTexCoord;\n\n rgbTexCoord.x = (realTexCoord.x + vecTexCoordTranslate.x * fTexCoordScale) * 0.5;\n\n rgbTexCoord.y = (realTexCoord.y + vecTexCoordTranslate.y * fTexCoordScale) * 0.5;\n\n color = texture2D(curTexture, rgbTexCoord.xy, -10.0);\n\n vec2 vecAlphaTexCoord;\n\n vecAlphaTexCoord.x = rgbTexCoord.x;\n\n vecAlphaTexCoord.y = rgbTexCoord.y + fTexCoordScale * 0.5;\n\n color.a = texture2D(curTexture, vecAlphaTexCoord.xy, -10.0).r;\n\n }\n\n else\n\n {\n\n if(oriTexCoord.z < -9000.0)\n\n {\n\n color = texture2D(curTexture, realTexCoord.xy);\n\n }\n\n else\n\n {\n\n color = texture2DLodEXT(curTexture, realTexCoord.xy, mipLevel);\n\n }\n\n }\n\n \n\n return color;\n\n }\n\n \n\n vec4 getTextureColor()\n\n {\n\n if(vTexMatrix.z < 0.0)\n\n {\n\n return vec4(1.0);\n\n }\n\n float texTileWidth0 = vTexMatrix.z * uTexture0Width;\n\n vec3 realTexCoord = vec3(vTexCoord.xy, vTexCoordTransform.x);\n\n vec4 FColor = getTexColorForS3M(uTexture, realTexCoord, texTileWidth0, vTexMatrix.w, vTexMatrix.z, vTexMatrix.xy, vIsRGBA.x);\n\n #ifdef TexCoord2\n\n float texTileWidth1 = vTexMatrix2.z * uTexture1Width;\n\n realTexCoord = vec3(vTexCoord.zw, vTexCoordTransform.y);\n\n vec4 SColor = getTexColorForS3M(uTexture2, realTexCoord, texTileWidth1, vTexMatrix2.w, vTexMatrix2.z, vTexMatrix2.xy, vIsRGBA.y);\n\n SColor.r = clamp(SColor.r, 0.0, 1.0);\n\n SColor.g = clamp(SColor.g, 0.0, 1.0);\n\n SColor.b = clamp(SColor.b, 0.0, 1.0);\n\n return FColor * SColor;\n\n #else\n\n return FColor;\n\n #endif\n\n }\n\n#endif\n\n\n\n vec3 czm_acesTonemapping(vec3 color) {\n\n float g = 0.985;\n\n float a = 0.065;\n\n float b = 0.0001;\n\n float c = 0.433;\n\n float d = 0.238;\n\n\n\n color = (color * (color + a) - b) / (color * (g * color + c) + d);\n\n\n\n color = clamp(color, 0.0, 1.0);\n\n\n\n return color;\n\n }\n\n vec4 SRGBtoLINEAR4(vec4 srgbIn) {\n\n #ifndef HDR \n\n vec3 linearOut = pow(srgbIn.rgb, vec3(2.2));\n\n return vec4(linearOut, srgbIn.a);\n\n #else\n\n return srgbIn;\n\n #endif\n\n }\n\n vec3 LINEARtoSRGB(vec3 linearIn) {\n\n #ifndef HDR \n\n return pow(linearIn, vec3(1.0/2.2));\n\n #else\n\n return linearIn;\n\n #endif\n\n }\n\n vec3 applyTonemapping(vec3 linearIn) {\n\n #ifndef HDR\n\n return czm_acesTonemapping(linearIn);\n\n #else\n\n return linearIn;\n\n #endif\n\n }\n\n \n\n vec3 computeNormal(in vec3 oriVertex)\n\n {\n\n vec3 normal = cross(vec3(dFdx(oriVertex.x), dFdx(oriVertex.y), dFdx(oriVertex.z)), vec3(dFdy(oriVertex.x), dFdy(oriVertex.y), dFdy(oriVertex.z)));\n\n normal = normalize(normal);\n\n return normal;\n\n }\n\n \n\n uniform vec3 light0_viewDirection;\n\n void main()\n\n {\n\n if(vColor.a < 0.1)\n\n {\n\n discard;\n\n } \n\n vec4 baseColorWithAlpha = vColor;\n\n #ifdef COMPUTE_TEXCOORD\n\n baseColorWithAlpha *= SRGBtoLINEAR4(getTextureColor());\n\n #endif\n\n \n\n if(baseColorWithAlpha.a < 0.1)\n\n {\n\n discard;\n\n }\n\n vec3 normal = vec3(0.0);\n\n #ifdef VertexNormal\n\n normal = normalize(vNormalEC);\n\n #endif\n\n normal = length(normal) > 0.1 ? normal : computeNormal(vPositionMC.xyz);\n\n vec3 color = baseColorWithAlpha.rgb;\n\n vec3 dirVectorEC = normalize(light0_viewDirection);\n\n float dotProduct = dot( normal, dirVectorEC );\n\n float dirDiffuseWeight = max( dotProduct, 0.0 );\n\n dirDiffuseWeight = dirDiffuseWeight * 0.5 + 0.5;\n\n color += color * uDiffuseColor.rgb * dirDiffuseWeight;\n\n #ifdef TexCoord\n\n color = LINEARtoSRGB(color);\n\n #endif\n\n glFragColor = vec4(color, baseColorWithAlpha.a);\n\n#if __VERSION__ == 100\n\n gl_FragColor = glFragColor;\n\n#endif\n\n }"}],"techniques":[{"attributes":{"aPosition":{"semantic":"POSITION","type":35666},"instanceId":{"semantic":"instanceId","type":5126},"batchId":{"semantic":"_BATCHID","type":5126},"aTexCoord0":{"semantic":"TEXCOORD_0","type":35664},"aTexCoord1":{"semantic":"aTexCoord1","type":35666},"aNormal":{"semantic":"aNormal","type":35665},"aColor":{"semantic":"COLOR_0","type":35666},"uv2":{"semantic":"uv2","type":35666},"uv3":{"semantic":"uv3","type":35666},"uv4":{"semantic":"uv4","type":35666},"secondary_colour":{"semantic":"secondary_colour","type":35666},"uv6":{"semantic":"uv6","type":35666},"TextureCoordMatrix":{"semantic":"TextureCoordMatrix","type":35664}},"program":0,"uniforms":{"czm_modelView":{"type":35676,"semantic":"MODELVIEW"},"czm_normal":{"type":35675,"semantic":"MODELINVERSETRANSPOSE"},"czm_modelViewProjection":{"type":35676,"semantic":"MODELVIEWPROJECTION"},"uTexMatrix":{"type":35676},"uTexture0Width":{"type":5126},"uFillForeColor":{"type":35666},"uSelectedColor":{"type":35666},"uDiffuseColor":{"type":35666},"uTexture":{"type":35678},"uTexture2":{"type":35678},"uTexture1Width":{"type":5126}}}]},{getTextureMagFilter:_r,getTextureMinFilter:dr,getTextureWrap:Cr,getMaterialType:Tr,getMaterialFormat:mr,getPrimitive:gr,getUniqueREGLBuffer:pr}=r.REGLHelper,yr=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Rr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:Ir,logoutIBLResOnCanvas:br,getIBLResOnCanvas:Pr,getPBRUniforms:Mr}=r.pbr.PBRUtils,Nr={factor:0,units:0},Sr={specularStrength:0,materialShininess:1},Lr=[1,1,1],Dr=n.identity([]),Or=t=>t.material instanceof r.PhongMaterial,Fr=t=>t.material instanceof r.pbr.StandardMaterial,xr=[!0,!0,!0,!0],wr=[],vr=new t.Coordinate(0,0),Ur=new t.Point(0,0),Gr=new t.Point(0,0),Hr=new t.Point(0,0),Kr=[],Vr=[],kr=[],Xr=[],Yr={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"};class Jr{constructor(e,n){this.$=n,this.tt=n.getRenderer().canvas,this.pickingFBO=n.getRenderer().pickingFBO,this.et=new t.SpatialReference,this.rt=e,this.nt=new r.Renderer(e),this.it={},this.st={},this.ot={},this.At={},this.ct={},this.lt={},this.ft={},this.ht=new r.Scene,this.ut=new r.Scene,this.Et=new r.Scene,this.Bt=new r.Scene,this._t=new r.ResourceLoader(e.texture(2)),this.dt=this.Ct.bind(this),this.Tt=new r.PhongMaterial({"baseColorFactor":[1,1,1,1]}),this.gt(),this.yt=new r.KHRTechniquesWebglManager(this.rt,this.Rt(),this._t);const i=this.getMap();i.altitudeToPoint&&(this.It=i.altitudeToPoint(100,i.getGLRes())/100)}getI3DMMeshes(){return this.ct}getPNTSMeshes(){return this.At}getB3DMMeshes(){return this.ot}getPaintedMeshes(){return this.bt}getMap(){return this.$.getMap()}paint(t,e,r){const n=r&&r.renderTarget,s=r&&r.sceneFilter,o=this.getMap();if(!t.length||!o)return;const a=this.Pt(),A=o.projViewMatrix,c=this.$.options.services,l=[],f=[];let h=[];const u=[],B=[],_=this.Mt(t);for(let n=0,s=t.length;n<s;n++){const s=t[n].data.node;let o=this.Nt(s);if(!o)continue;this.lt[s.id]&&(o=this.lt[s.id],o=L(o));let a=c[s.St].polygonOffset||Nr;g(a)&&(a=a()),Array.isArray(o)||(l[0]=o,o=l);for(let t=0,n=o.length;t<n;t++){const n=o[t].properties.magic;if("b3dm"===n){if(o[t].getBoundingBox&&!E(A,o[t].getBoundingBox()))continue;const{batchIdData:e,batchIdMap:n}=o[t].geometry.properties;if(e&&n){const e=o[t].properties.node.St;this.Lt&&this.Lt[e]&&i.highlightMesh(this.rt,o[t],this.Lt[e],this.Dt,n)}r&&r.bloom&&o[t].properties.hlBloomMesh&&(o[t].properties.hlBloomMesh.properties.depthFunc="always",o[t].properties.hlBloomMesh.properties.polygonOffset=a,h.push(o[t].properties.hlBloomMesh)),h.push(o[t])}else"pnts"===n?u.push(o[t]):"i3dm"===n&&B.push(o[t]);o[t].properties.isLeaf=!!e[s.id],o[t].properties.level=_.get(s.Ot),o[t].properties.polygonOffset=a,o[t].Ft=s,e[s.id]||f.push(o[t])}}let d=0;const C=this.yt.getExcludeFilter();d+=this.xt(this.wt,a,[s,Or,C],n,f,h,B),d+=this.xt(this.vt,a,[s,Fr,C],n,f,h,B),this.yt.forEachShader(((t,e,r)=>{const i=this.Pt(r);d+=this.xt(t,i,[s,e],n,f,h,B)})),this.ut.setMeshes(u);const T=this.Ut();return d+=this.nt.render(this.Gt,T,this.ut,n&&n.fbo),this.bt={pntsMeshes:u,i3dmMeshes:B,b3dmMeshes:h},d}xt(t,e,r,n,i,s,o){t.filter=r.filter((t=>!!t)),e.debug=!1,e.stencilEnable=!0,e.debug=!1,e.cullFace="back",e.colorMask=xr;let a=0;return this.ht.setMeshes(s),a+=this.nt.render(t,e,this.ht,n&&n.fbo),e.stencilEnable=!0,this.Et.setMeshes(o),a+=this.nt.render(t,e,this.Et,n&&n.fbo),a}Ht(t,e){return e.Ft.Kt-t.Ft.Kt}paintRegion(t,e,r,n,i){const s=this.getMap();if(!t.length&&!e.length)return;const o=s.projViewMatrix,a=[];for(let r=0,n=(t=t.concat(e)).length;r<n;r++){const e=t[r].node,n=this.Vt(e);n&&(n.getBoundingBox&&!E(o,n.getBoundingBox())||a.push(n))}this.kt.filter=n,this.Bt.setMeshes(a);const A=this.Xt(r);this.nt.render(this.kt,A,this.Bt,i&&i.fbo)}deleteTile(t){const e=t.node.id;this.Yt(e)}Yt(t){const e=this.st[t];e&&(e.geometry.dispose(),e.dispose(),delete this.st[t]);let r=this.ot[t]||this.At[t]||this.ct[t]||this.lt[t]||this.it[t];this.lt[t]?this.Jt(t):r&&(this.zt(r),delete this.ot[t],delete this.At[t],delete this.ct[t],delete this.it[t])}Jt(t){let e=this.lt[t];e=L(e);for(let t=0;t<e.length;t++){const{id:r}=e[t].properties;this.Yt(r)}delete this.lt[t]}zt(t){if(Array.isArray(t))for(let e=0,r=t.length;e<r;e++)this.zt(t[e]);else{const e=t.geometry.properties.url;if(e){const t=this.ft[e];t&&(t.refCount--,t.refCount<=0&&(t.geometry.dispose(),t.material.dispose(),delete this.ft[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.$;br(t.getRenderer().canvas,t.getMap());for(const t in this.lt)this.Jt(t);this.lt={};for(const t in this.ot)this.Yt(t);this.ot={};for(const t in this.At)this.Yt(t);this.At={};for(const t in this.ct)this.Yt(t);this.ct={};for(const t in this.it)this.Yt(t);this.it={};for(const t in this.st)this.Yt(t);this.st={},this.wt&&(this.wt.dispose(),delete this.wt),this.vt&&(this.vt.dispose(),delete this.vt),this.Gt&&(this.Gt.dispose(),delete this.Gt),this.kt&&(this.kt.dispose(),delete this.kt),this.yt.dispose(),this.picking&&this.picking.dispose()}Vt(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(I(i[0]),I(i[1])),o=new t.Coordinate(I(i[2]),I(i[3]));s=this.Zt(s),o=this.Zt(o);const a=s.add(o).Wt(.5);s._sub(a),o._sub(a);const A=this.jt(i[4],i[5]),c=A.x,l=A.y,f=[s.x,s.y,l,o.x,s.y,l,o.x,o.y,l,s.x,o.y,l,s.x,s.y,c,o.x,s.y,c,o.x,o.y,c,s.x,o.y,c],h=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"});h.generateBuffers(this.rt);const u=new r.Mesh(h),E=n.identity([]);return u.setLocalTransform(n.translate(E,E,[a.x,a.y,0])),this.st[e.id]=u,u}Nt(t){return this.ot[t.id]||this.At[t.id]||this.ct[t.id]||this.lt[t.id]}has(t){return this.Nt(t)||this.it[t.id]}createPntsMesh(t,e,i,s){if(this.At[e]){const t=this.At[e];return console.warn(`pnts mesh with id(${e}) was already created.`),s(null,{id:e,mesh:t}),t}const{pnts:o,featureTable:a,rootIdx:A}=t,c=this.$.options.services[A],l=a.POINTS_LENGTH,f=new r.Geometry(o,null,l,{primitive:"points",positionAttribute:"POSITION"});f.generateBuffers(this.rt);const h={};o.POSITION?h.HAS_POSITION=1:o.POSITION_QUANTIZED&&(h.HAS_POSITION_QUANTIZED=1),o.RGB?h.HAS_RGB=1:o.RGBA?h.HAS_RGBA=1:o.RGB565&&(h.HAS_RGB565=1),(o.NORMAL||o.NORMAL_OCT16P)&&(h.HAS_NORMAL=1,o.NORMAL_OCT16P&&(h.HAS_NORMAL_OCT16P=1)),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:u,rtcCoord:E}=t,B=this.Qt(kr,E),_=this.qt([],i,u,E);n.multiply(_,_,B);const d=this.$.options.services[A],C=new r.Mesh(f);if(C.properties.magic="pnts",C.properties.id=e,C.properties.node=i,C.properties.count=l,C.properties.batchTable=t.batchTable,C.properties.batchTableBin=t.batchTableBin,C.properties.serviceIndex=A,C.setDefines(h),Object.defineProperty(C.uniforms,"pointColor",{enumerable:!0,get:function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:d&&d.pointColor||[1,1,1,1]}}),Object.defineProperty(C.uniforms,"pointSize",{enumerable:!0,get:function(){return d&&d.pointSize||2}}),Object.defineProperty(C.uniforms,"pointOpacity",{enumerable:!0,get:function(){return d&&d.pointOpacity||1}}),c.coordOffset){const t=this.$t(i.St,E);n.multiply(_,t,_)}return C.setLocalTransform(_),this.At[e]=C,s(null,{id:e,mesh:[C]}),[C]}createI3DMMesh(t,e,i,o){if(this.ct[e]){const t=this.ct[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.it[e]||o(null,{id:e,mesh:t}),t}const a=this.$.options.services[i.St],c=this.te(i.ee),{i3dm:l,featureTable:f,gltf:h,batchTable:u,batchTableBin:E,count:B}=t,_=f.INSTANCES_LENGTH,{rtcCenter:d,rtcCoord:C}=t,T=this.Qt(kr,C),m=this.qt(Xr,i,d,C);n.multiply(T,m,T);const{POSITION:g,NORMAL_UP:p,NORMAL_RIGHT:y,SCALE:R,SCALE_NON_UNIFORM:I,INSTANCE_ROTATION:b}=l,P={"instance_vectorA":new Float32Array(4*_),"instance_vectorB":new Float32Array(4*_),"instance_vectorC":new Float32Array(4*_)},M=new Float32Array(3),N=new Float32Array(3),L=[],D=new Float32Array(1),O=new Float32Array(3),F=[],x=[],w=[],v=[],U=new Float32Array(9);!function(t,e){let{componentType:r,byteOffset:n,byteStride:i,count:s,itemSize:o}=t;const a=t.array.buffer,A=r?Xt.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*A.BYTES_PER_ELEMENT)&&n%A.BYTES_PER_ELEMENT==0){const t=new A(a,n,s*o);for(let r=0;r<s*o;r+=o)e(new A(t.buffer,n+r*A.BYTES_PER_ELEMENT,o),r/o);return}const c=new Uint8Array(o*A.BYTES_PER_ELEMENT);i||(i=o*A.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const r=new Uint8Array(a,i*t+n,o*A.BYTES_PER_ELEMENT);c.set(r),e(new A(c.buffer),t),r.set(c)}}(g,((t,e)=>{p?(le(N,y,e),le(M,p,e),s.cross(L,N,M),s.normalize(L,L),S(F,N,0),S(F,M,1),S(F,L,2),A.fromMat3(x,F)):b?(le(U,b,e),A.fromMat3(x,U)):A.identity(x),R?(le(D,R,e),s.set(w,D[0],D[0],D[0])):I?(le(O,I,e),s.set(w,...O)):s.set(w,1,1,1),n.fromRotationTranslationScale(v,x,t,w),fe(P.instance_vectorA,e,v,0),fe(P.instance_vectorB,e,v,1),fe(P.instance_vectorC,e,v,2)}));const G={};for(const t in P)G[t]={buffer:this.rt.buffer({dimension:P[t].length/_,data:P[t]}),divisor:1};const H=a.shader||"phong";let K=0,V=!0;const k=[];return re(h,((t,s,o,A)=>{let{geometry:l,material:f}=this.re(t,s,o,A,i,!0,H);f&&!f.isReady()&&(V=!1,K++);const h=new r.InstancedMesh(G,_,l,f);h.properties.magic="i3dm",h.properties.id=e,h.properties.count=B,h.properties.batchTable=u,h.properties.batchTableBin=E,h.properties.serviceIndex=i.St;const d=this.ne(t,l,f,i.St,A),m=n.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.multiply(m,m,t.matrices[e]);let g;if(n.multiply(m,c,m),h.setPositionMatrix(m),a.coordOffset){const t=this.$t(i.St,C);g=n.multiply([],t,T)}else g=n.copy([],T);h.setLocalTransform(g),h.setDefines(d),h.properties.polygonOffset={offset:0,factor:0},k.push(h)})),V?(this.ct[e]=k,o(null,{id:e,mesh:k})):(this.it[e]={meshes:k,count:K},k.ie=o),k}createB3DMMesh(e,i,s,o){if(this.ot[i]||this.it[i]){const t=this.ot[i];return console.warn(`mesh with id(${i}) was already created.`),this.it[i]||o(null,{id:i,mesh:t}),t}let a;if(s.maxExtent){const e=new t.Extent(s.maxExtent).convertTo((t=>this._pointToPrj(t)));a=[e.xmin,e.ymin,e.xmax,e.ymax]}const A=e.gltf,{projCenter:c}=A.extensions.MAPTALKS_RTC,{rtcCoord:l,center:f}=A.extensions.CESIUM_RTC,h=this.te(s.ee);let u;u=A.asset&&A.asset.sharePosition?this.Qt(kr,l):this.se(kr,l,c,s.St);const E=this.$.options.services[s.St];let B=E.shader||"pbr";if(A.materials)for(let t=0;t<A.materials.length;t++)if(A.materials[t]&&A.materials[t].extensions&&A.materials[t].extensions.KHR_materials_unlit){B=E.shader="phong";break}const _=[];let d=0,C=!0;return re(A,((t,o,A,c)=>{let{geometry:T,material:m}=this.re(t,o,A,c,s,!1,B);m&&!m.isReady()&&(C=!1,d++);const g=new r.Mesh(T,m);g.properties.magic="b3dm",g.properties.id=i,g.properties.node=s,g.properties.batchTable=e.batchTable,g.properties.batchTableBin=e.batchTableBin,g.properties.count=e.featureTable.BATCH_LENGTH,g.properties.serviceIndex=s.St;const p=this.ne(t,T,m,s.St,c);g.setDefines(p);const R=t.compressUniforms;if(R)for(const t in R)g.setUniform(t,R[t]);a&&(p.USE_MAX_EXTENT=1,g.setUniform("maxPrjExtent",a)),Object.prototype.hasOwnProperty.call(g.uniforms,"polygonOpacity")||Object.defineProperty(g.uniforms,"polygonOpacity",{enumerable:!0,get:function(){return y(E.opacity)?E.opacity:1}});let I=n.identity([]);if(c.asset.sharePosition&&t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.multiply(I,I,t.matrices[e]);if(c.asset.sharePosition){const t=this.qt(Xr,s,f,l);n.multiply(I,h,I),n.multiply(I,u,I),n.multiply(I,t,I)}else n.multiply(I,u,I);if(E.coordOffset){const t=this.$t([],s.St,l);n.multiply(I,t,I)}g.setLocalTransform(I),_.push(g)})),C?(this.ot[i]=_,o(null,{id:i,mesh:_})):(this.it[i]={meshes:_,count:d},_.ie=o),_}qt(e,r,i,o){const a=this.getMap(),A=this.$.options.services[r.St].heightOffset||0,c=new t.Coordinate(o);let l;l=a.altitudeToPoint?this.It:a.distanceToPointAtRes(100,100,a.getGLRes(),c).y/100;let f=r.matrix?n.copy(e,r.matrix):n.identity(e);if(i){qe(f,s.transformMat4(wr,i,f),f)}const h=function(t,e,r,n,i,s,o){e=J(sr,e);const a=Be(sr,e[0]*Er,e[1]*Er,e[2]),A=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(or,r),c=n.ellipsoid;var l;l=0===nt(A)?z(ar,0,0,-6378137):ge(ar,A),hr.x=l[0],hr.y=l[1];const f=n.project(hr,ur);Ar[0]=f.x/i,Ar[1]=f.y/i,Ar[2]=(l[2]+o)*s;const h=$e(a,c,cr),u=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=e[4],a=e[5],A=e[6],c=e[7],l=e[8],f=e[9],h=e[10],u=e[11],E=e[12],B=e[13],_=e[14],d=e[15],C=r*a-n*o,T=r*A-i*o,m=r*c-s*o,g=n*A-i*a,p=n*c-s*a,y=i*c-s*A,R=l*B-f*E,I=l*_-h*E,b=l*d-u*E,P=f*_-h*B,M=f*d-u*B,N=h*d-u*_,S=C*N-T*M+m*P+g*b-p*I+y*R;return S?(S=1/S,t[0]=(a*N-A*M+c*P)*S,t[1]=(i*M-n*N-s*P)*S,t[2]=(B*y-_*p+d*g)*S,t[3]=(h*p-f*y-u*g)*S,t[4]=(A*b-o*N-c*I)*S,t[5]=(r*N-i*b+s*I)*S,t[6]=(_*m-E*y-d*T)*S,t[7]=(l*y-h*m+u*T)*S,t[8]=(o*M-a*b+c*R)*S,t[9]=(n*b-r*M-s*R)*S,t[10]=(E*p-B*m+d*C)*S,t[11]=(f*m-l*p-u*C)*S,t[12]=(a*I-o*P-A*R)*S,t[13]=(r*P-n*I+i*R)*S,t[14]=(B*T-E*g-_*C)*S,t[15]=(l*g-f*T+h*C)*S,t):null}(lr,h),E=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}(fr,r),B=function(t,e,r){var n=t[0],i=t[1],s=t[2],o=t[4],a=t[5],A=t[6],c=t[8],l=t[9],f=t[10],h=e[0],u=e[1],E=e[2],B=e[3],_=e[4],d=e[5],C=e[6],T=e[7],m=e[8],g=n*h+o*u+c*E,p=i*h+a*u+l*E,y=s*h+A*u+f*E,R=n*B+o*_+c*d,I=i*B+a*_+l*d,b=s*B+A*_+f*d,P=n*C+o*T+c*m,M=i*C+a*T+l*m,N=s*C+A*T+f*m;return r[0]=g,r[1]=p,r[2]=y,r[3]=0,r[4]=R,r[5]=I,r[6]=b,r[7]=0,r[8]=P,r[9]=M,r[10]=N,r[11]=0,r[12]=t[12],r[13]=t[13],r[14]=t[14],r[15]=t[15],r}(u,E,t);return qe(t,Ar,B),t}(f,o,f,a.getProjection(),a.getGLRes(),l,A),u=function(t,e){return z(t,e[12],e[13],e[14]),t}(Vr,h);let E=this.$.options.offset;if(g(E)){E=E(this.$.oe(r.id).center)}return s.set(Kr,E[0],E[1],0),s.sub(u,u,Kr),qe(h,u,h),h}$t(t,e,r){const i=this.$.options.services[e];if(!i.coordOffset)return null;const o=this.getMap(),a=o.getGLRes();vr.set(r[0],r[1]);const A=o.coordToPointAtRes(vr,a,Gr),c=i.coordOffset,l=vr.set(r[0]+c[0],r[1]+c[1]),f=o.coordToPointAtRes(l,a,Hr),h=f.x-A.x,u=f.y-A.y,E=this.ae(),B=s.set(Kr,h,u,(c[2]||0)*E);return n.fromTranslation(t,B)}ae(){const t=this.getMap();let e;return e=t.altitudeToPoint?this.It:t.distanceToPointAtRes(100,100,t.getGLRes(),vr).y/100,e}createCMPTMesh(t,e,r,n){if(this.lt[e]){const t=this.lt[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],o=e+"."+t;"b3dm"===n?this.createB3DMMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)})):"i3dm"===n?this.createI3DMMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)})):"pnts"===n?this.createPntsMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)})):"cmpt"===n&&this.createCMPTMesh(i[t],o,r,((t,{mesh:e})=>{s.push(e)}))}return this.lt[e]=s,n(null,{id:e,mesh:s}),s}ne(t,e,r,n,i){const s=("phong"===(this.$.options.services[n].shader||"phong")?this.wt:this.vt).getGeometryDefines(e);i.asset&&"S3M"===i.asset.generator&&this.Ae(s,e,i),e.data.uvRegion&&(s.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(s.VertexNormal=1),e.data[e.desc.color0Attribute]&&(s.VertexColor=1),e.data[e.desc.uv0Attribute]&&(s.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(s.HAS_TextureCoordMatrix=1),r.get("uTexture")&&(s.COMPUTE_TEXCOORD=1),r.get("uTexture2")&&(s.TexCoord2=1),"MESHOPT"===this.$.ce&&(s.MeshOPT_Compress=1);return m(s,t.compressDefines),s}Ae(t,e,r){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1),e.data.aTexCoord0&&r.textures.length&&(t.COMPUTE_TEXCOORD=1)}re(t,e,r,n,i,s,o){let a=!1;n.asset&&"S3M"===n.asset.generator&&(a=!0,n.extensions=n.extensions||{},n.extensions.KHR_techniques_webgl=Br);const A=n.url+"-"+e+"-"+r;if(this.ft[A])return this.ft[A].refCount++,this.ft[A];let c,l;const f=n.materials[t.material];if(n.extensions&&n.extensions.KHR_techniques_webgl&&f.extensions&&f.extensions.KHR_techniques_webgl){const e=this.le(t,n,s,a);c=e.material,l=e.geometry;this.$.options.services[i.St].fillEmptyDataInMissingAttribute&&(l.desc.fillEmptyDataInMissingAttribute=!0)}else{l=this.fe(t,s,Yr);const e=this.$.options.services[i.St],r=e.ambientLight;let a=e.environmentExposure;const A=e.material,f=this.getMap().getLightManager(),h=f&&f.getAmbientLight();if(r&&(!h||h.color)&&void 0===a){const t=h&&h.color?h.color[0]:.2;a=r[0]/t}c=this.he(t.material,n,o,A||Sr,a||1)}c&&!c.isReady()?c.ue=i.id:c||(c=this.Tt);const h={refCount:1,geometry:l,material:c};return l.properties.url=A,this.ft[A]=h,h}le(t,e,r,n){const{geometry:i,material:s}=this.yt.createMesh(t,e,r,n);return{geometry:i,material:s}}fe(t,e,n){const i=t.attributes;let s=i._BATCHID&&i._BATCHID.array;if(s&&s.byteOffset&&(s=new s.constructor(s)),i.COLOR_0){const t=i.COLOR_0.array||i.COLOR_0;if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let r=0;r<e.length;r++)e[r]=Math.round(255*t[r]);i.COLOR_0.array?(i.COLOR_0.array=e,i.COLOR_0.componentType=5121):i.COLOR_0=e}}const o={};for(const t in i){const e=pr(this.rt,i[t],{dimension:i[t].itemSize}),r=n[t]||t;o[r]={buffer:e},i[t].quantization&&(o[r].quantization=i[t].quantization),r===n.POSITION&&(o[r].array=i[t].array,o[r].min=i[t].min,o[r].max=i[t].max)}delete t.attributes;const a=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,A=new r.Geometry(o,a,0,{positionAttribute:n.POSITION,normalAttribute:n.NORMAL,uv0Attribute:n.TEXCOORD_0,uv1Attribute:n.TEXCOORD_1,color0Attribute:n.COLOR_0,tangentAttribute:n.TANGENT,pickingIdAttribute:n._BATCHID,primitive:void 0===t.mode?"triangles":gr(t.mode)});return s&&a&&(A.properties.batchIdData=s,A.properties.batchIdMap=function(t,e){if(!e)return null;const r=new Map;for(let n=0;n<e.length;n++){const i=e[n],s=t[i];let o=r.get(s);o||(o=[],r.set(s,o)),o.push(i)}return r}
|
|
19
19
|
/*!
|
|
20
|
-
* @maptalks/gl v0.
|
|
20
|
+
* @maptalks/gl v0.81.0
|
|
21
21
|
* LICENSE : UNLICENSED
|
|
22
|
-
* (c) 2016-
|
|
23
|
-
*/(s,a)),c.generateBuffers(this.rt,{excludeElementsInVAO:e}),c}ie(t,e,r,i){const o=n.identity(t),a=this.getMap();Fr.x=r[0],Fr.y=r[1];const c=this._prjToPoint(Fr),l=this.ue(),f=1/(a.getGLZoom?a.getResolution(a.getGLZoom()):a.getGLRes());let u;Fr.x=e[0],Fr.y=e[1],u=a.altitudeToPoint?this.Nt:a.distanceToPointAtRes(100,100,a.getGLRes(),Fr).y/100;let h=this.J.options.offset;g(h)&&(h=h(Fr));const _=this.J.options.services[i].heightOffset||0;return s.set(kr,c.x-h[0],c.y-h[1],u*r[2]+u*_),n.translate(o,o,kr),s.set(l,f,f,u),n.scale(o,o,l),o}Kt(t,e){const r=n.identity(t),i=this.getMap(),o=this.ue();Fr.x=e[0],Fr.y=e[1];const a=i.distanceToPointAtRes(100,100,i.getGLRes(),Fr);let c;return c=i.altitudeToPoint?this.Nt:a.y/100,s.set(o,a.x/100*1.01,a.y/100*1.01,c),n.scale(r,r,o),r}Rt(){const t={x:0,y:0,width:()=>this.tt?this.tt.width:1,height:()=>this.tt?this.tt.height:1};this.zt=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.Gt=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)=>o.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 s=this.It();this.Pt=new r.PhongShader({extraCommandProps:s}),this.Ft=new r.pbr.StandardShader({extraCommandProps:s});const a=this.J;Nr(a.getRenderer().canvas,this.rt,a.getMap()),this.picking=new r.FBORayPicking(this.nt,{vert:this.Ft.vert,extraCommandProps:s,uniforms:this.Ft.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}It(){return{viewport:{x:0,y:0,width:()=>this.tt?this.tt.width:1,height:()=>this.tt?this.tt.height:1},colorMask:(t,e)=>e.colorMask||Lr,cull:{enable:!0,face:(t,e)=>e.cullFace||"back"},stencil:{enable:(t,e)=>!0===e.stencilEnable,func:{cmp:(t,e)=>e.meshProperties.isLeaf?"always":">=",ref:(t,e)=>e.meshProperties.level},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,range:[0,1],func:(t,e)=>e.meshProperties.depthFunc||"<"},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}Xt(t){return{projViewMatrix:this.getMap().projViewMatrix,color:t&&t.color||[0,1,0]}}Dt(t){const e=this.getMap(),r=e.getLightManager(),n=(r&&r.getDirectionalLight()||{}).direction||[1,1,-1],i=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:i,lightDir:s.normalize(n,n)}}wt(){const t=this.getMap(),e=this.J.getRenderer().canvas,{iblTexes:r,dfgLUT:n}=wr(e),i=Or(t,r,n);return y(i,{czm_lightDirectionEC:i.light0_viewDirection,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}le(t,e,n,i,s){const o=e.materials[t];if(!o||!o.baseColorTexture&&!o.pbrMetallicRoughness)return null;const c=y({},i);if(o.baseColorTexture){const t=e.textures[o.baseColorTexture.index];let r;t&&!t.image.color&&(r=this.S(t)),c.baseColorFactor=t&&t.image.color||o.baseColorFactor||[1,1,1,1],r&&(c.baseColorTexture=r)}else{if(o.normalTexture){const t=this.S(e.textures[o.normalTexture.index]),r=o.normalTexture.scale||1;c.normalTexture=t,c.normalMapFactor=r}if(o.occlusionTexture){const t=this.S(e.textures[o.occlusionTexture.index]),r=o.occlusionTexture.strength||1;c.occlusionTexture=t,c.occlusionFactor=r}if(o.emissiveTexture){const t=this.S(e.textures[o.emissiveTexture.index]);c.emissiveTexture=t}o.emissiveFactor&&(c.emissiveFactor=o.emissiveFactor);const t=o.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(c.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const r=e.textures[t.baseColorTexture.index];r.image&&r.image.color?c.baseColorFactor=c.baseColorFactor?a.multiply(c.baseColorFactor,c.baseColorFactor,r.image.color):r.image.color:(c.baseColorTexture=this.S(r),c.baseColorTexture.getREGLTexture(this.rt))}if(p(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),p(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),o.metallicRoughnessTexture){const t=this.S(e.textures[o.metallicRoughnessTexture.index]);c.metallicRoughnessTexture=t}}}if(o.s3mMaterial)return new r.Material(c);if(c.environmentExposure=s,o.extensions&&o.extensions.KHR_materials_unlit)return c.environmentExposure=1,c.ambientColor=[1,1,1],c.light0_diffuse=[0,0,0,0],c.lightSpecular=[0,0,0],new r.PhongMaterial(c);let l=new r.pbr.StandardMaterial(c);"phong"===n&&(l=r.PhongMaterial.convertFrom(l));const f=o.pbrMetallicRoughness,u=f&&f.baseColorTexture&&f.baseColorTexture.extensions;return u&&u.KHR_texture_transform&&(l.set("khr_offset",u.KHR_texture_transform.offset||[0,0]),l.set("khr_rotation",u.KHR_texture_transform.rotation||0),l.set("khr_scale",u.KHR_texture_transform.scale||[1,1])),l.once("complete",this.At),l}S(t){const e={type:t.type?pr(t.type):"uint8",format:t.format?yr(t.format):"rgba",flipY:!!t.flipY},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&&t.texture.sampler;return i&&(i.magFilter&&(e.mag=Tr(i.magFilter)),i.minFilter&&(e.min=mr(i.minFilter)),i.wrapS&&(e.wrapS=Ar(i.wrapS)),i.wrapT&&(e.wrapT=Ar(i.wrapT))),new r.Texture2D(e,this.Tt)}he(t){const e=t.image,r=window.URL||window.webkitURL,n=new Blob([e.array],{type:e.mimeType});return r.createObjectURL(n)}yt({target:t}){const e=t.fe,r=this.it[e];if(r.count--,!r.count){const t=r.meshes;this.ot[e]=t,delete this.it[e];const n=t.ne;delete t.ne,n(null,{mesh:r.meshes,id:e})}}ue(){return Ur}jt(t){return this.J.jt(t)}Qt(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(),Dr)}Jt(t){return"Y"===t?br:"X"===t?Ir:xr}pick(t,e,r=3){const n=this.J;if(!n||!n.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const i=this.getMap(),s=this.wt(),o=this.picking;o.render(this.ht.getMeshes().filter((t=>!t.bloom)),s,!0);let a={};o.getRenderedMeshes().length&&(a=o.pick(t,e,r,s,{viewMatrix:i.viewMatrix,projMatrix:i.projMatrix,returnPoint:n.options.pickingPoint}));const{meshId:c,pickingId:l,point:f,coordinate:u}=a,h=(0===c||c)&&o.getMeshAt(c);if(!h||!h.geometry)return[];const _=h.properties;f&&f.length&&(f[0]=Math.round(1e5*f[0])/1e5,f[1]=Math.round(1e5*f[1])/1e5,f[2]=Math.round(1e5*f[2])/1e5);const d={batchId:l};if(n.options.debug&&(d.debugInfo=_),_&&_.batchTable){const{batchTable:t,batchTableBin:e,count:r}=_,n=l;for(const i in t)void 0!==t[i].byteOffset?d[i]=Fe(t[i],e,r,n):d[i]=t[i][n]}return[{data:d,point:f,coordinate:u}]}Ot(t){let e=new Set;for(let r=0,n=t.length;r<n;r++){const n=t[r].data.node;this.Mt(n)&&e.add(n.vt)}e=Array.from(e),e.sort();const r=new Map,n=e.length;for(let t=0;t<n;t++)r.set(e[t],t);return r}highlight(t){this.Ut=t;const e=this.J.getRenderer();this.xt=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.Ut=null;const t=this.J.getRenderer();this.xt=t.getFrameTimestamp(),t.setToRedraw(!0)}}const Yr=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")},qr=Yr(),Zr=qr.gl_trans__coders=qr.gl_trans__coders||{};function jr(t,e){if(e)for(let r=0;r<e.length;r++){t[e[r].id||e[r].index]=e[r]}}Zr.inject=function(t){const e=t.toString(),r=e.indexOf("{")+1,n=e.substring(0,r),i=qr.gl_trans__coders=qr.gl_trans__coders||{};let s=`${n}\n const _____getGlobal = ${Yr.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},Zr.registerTranscoder=function(t,e){Zr[t]=e},Zr.getTranscoder=function(t){return Zr[t]};const Wr=[];class Qr{constructor(t,e,r,n){this._e=t,this.Ct=e,this.de=n,this.Ee=r.version,t.indexOf("i3s:tileset:")<0?(this.Ee<=1.6?this.Te="root":this.Te=0,r.version=this.Ee):(this.Te=t.substring("i3s:tileset:".length),this.Ee>1.6&&(this.Te=parseInt(this.Te))),this._e=t,this.me=r}load(){const t=this.me,e=t.layerScene.baseUrl;if(this.Ee<=1.6)return t[this.Te]&&t[this.Te].lodSelection?(this.Ae=t[this.Te],this.pe()):new Promise((r=>{let n=e+"/nodes/"+this.Te;t.layerScene.eslpk&&(n+="/3dNodeIndexDocument.json"),this.de(this.Ct,n,(()=>{this.Ae=t[this.Te],r(this.pe())}))}));if(this.Ee>=1.7){if(t[this.Te])return this.Ae=t[this.Te],this.pe();const r=Math.floor(this.Te/t.nodesPerPage);return new Promise((n=>{let i=e+"/nodepages/"+r;t.layerScene.eslpk&&(i+=".json"),this.de(this.Ct,i,(()=>{this.Ae=t[this.Te],n(this.pe())}))}))}return null}getTileset(){return this.ye}getChildrenURL(){return this.ge}pe(){const t=this.me,e=t.layerScene.baseUrl,r=this.Ae.children,n=[],i={};if(r)for(let s=0;s<r.length;s++)if(this.Ee<=1.6){const o=r[s].id;if(t[o])continue;const a=o;i[a]||(i[a]=new Promise((r=>{let n=e+"/nodes/"+a;t.layerScene.eslpk&&(n+="/3dNodeIndexDocument.json"),this.de(this.Ct,n,(()=>{r()}))})),n.push(i[a]))}else{const o=r[s];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);i[a]||(i[a]=new Promise((r=>{let n=e+"/nodepages/"+a;t.layerScene.eslpk&&(n+=".json"),this.de(this.Ct,n,(()=>{r()}))})),n.push(i[a]))}return n.length?Promise.all(n).then((()=>this.Re())):this.Re()}Re(){return Promise.resolve(this.be())}Ie(t){jr(this.me,t)}be(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.Ne(this.Ae,!0)}}Ne(t){const e=this.Ee,r=this.me,n=t;var i,s=n.obb,o=n.mbs,a={};if(o)i=Kr([],o[0],o[1],o[2]),a.sphere=[...i,o[3]];else if(s){const t=function(t,e,r){const n=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,c=i+i,l=r*o,f=n*o,u=n*a,h=i*o,_=i*a,d=i*c,E=s*o,T=s*a,m=s*c;return t[0]=1-u-d,t[3]=f-m,t[6]=h+T,t[1]=f+m,t[4]=1-l-d,t[7]=_-E,t[2]=h-T,t[5]=_+E,t[8]=1-l-u,t}([],r);return n[0]=n[0]*e[0],n[1]=n[1]*e[0],n[2]=n[2]*e[0],n[3]=n[3]*e[1],n[4]=n[4]*e[1],n[5]=n[5]*e[1],n[6]=n[6]*e[2],n[7]=n[7]*e[2],n[8]=n[8]*e[2],[...t,...n]}(i=Kr([],s.center[0],s.center[1],s.center[2]),s.halfSize,s.quaternion),e=t[3]+t[6]+t[9],r=t[4]+t[7]+t[10],n=t[5]+t[8]+t[11];Z(Wr,e,r,n);const o=nt(Wr);a.sphere=[...i,o]}var c=1/0,l=0;if(n.mbs?l=n.mbs[3]:n.obb&&(l=Math.max(Math.max(n.obb.halfSize[0],n.obb.halfSize[1]),n.obb.halfSize[2])),void 0!==n.lodThreshold)"maxScreenThresholdSQ"===r.lodSelectionMetricType?c=l/(Math.sqrt(n.lodThreshold)/(.25*Math.PI)):console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==n.lodSelection)for(var f=0;f<n.lodSelection.length;f++)"maxScreenThreshold"===n.lodSelection[f].metricType&&(c=l/n.lodSelection[f].maxError);(c===1/0||isNaN(c))&&(c=1e5);var u=16*c;const h=D([]),_=n.children;var d;if(_){d=[];const t=this.me;for(let r=0;r<_.length;r++){const n=e<=1.6?_[r].id:_[r];if(!t[n]){d=null;break}d.push(this.Ne(t[n]))}}var E={refine:"REPLACE",boundingVolume:a,transform:h,geometricError:u};return e<=1.6?t.lodSelection?t.geometryData&&(E.content={uri:"i3s:mesh:"+(t.id||t.index)}):E.content={uri:"i3s:tileset:"+(t.id||t.index)}:_&&_.length&&!d?E.content={uri:"i3s:tileset:"+(t.id||t.index)}:n.mesh&&(E.content={uri:"i3s:mesh:"+(t.id||t.index)}),d&&d.length&&(E.children=d),E}getJSON(){return this.Ae}}function Kr(t,e,r,n){return Ee(t,I(e),I(r),n)}const $r=!!Zr.ktx2,Jr=n.identity([]),tn=(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1})();function en(t){return t.indexOf("i3s:mesh")>=0}const rn="i3s:mesh:".length;function nn(t,e,r,n,i){const s=e.layerScene.eslpk,o=function(t,e){const r=e.substring(rn);return t>=1.7?parseInt(r):r}(e.version,t),a=e[o],c=e.layerScene.baseUrl,l=[];let f=!1;const u=Jr;let h,_;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;let r=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;s&&(r+=".bin");const n={geometry:{url:r,info:e.layerScene.store.defaultGeometrySchema}};let i=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(i){const t=e.layerScene.store.textureEncoding[0];let r;r="image/jpeg"===t?"jpg":"png",s&&(i+="."+r);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+i,factor:1,format:r,mimeType:t},metallicFactor:0}};n.material=o}l.push(n)}else{h=a.mesh.geometry,_=a.mesh.material;const t=e.layerScene.geometryDefinitions[h.definition],{geometryBuffers:o}=t;f=n&&2===o.length;const u=Zr.draco&&f?o[1]:o[0],d=Zr.draco&&f?1:0;let E=c+`/nodes/${h.resource}/geometries/`+d;s&&(E+=".bin");const T={geometry:{url:E,info:u}};if(i&&tn&&f&&!Zr.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const m=e.layerScene.materialDefinitions,A=e.layerScene.textureSetDefinitions;let p,y=0;if(_&&(y=m[_.definition]),m){p=function(t,e,r,n,i,s){const o=JSON.parse(JSON.stringify(t));return sn(o,e,r,n,i,s),o}(y,A,c,_.resource,r,e.layerScene.eslpk)}else p={pbrMetallicRoughness:{metallicFactor:0}};T.material=p,l.push(T)}return{dracoCompression:f,meshes:l,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:u}}function sn(t,e,r,n,i,s){for(const o in t)if(t[o]&&t[o].textureSetDefinitionId>=0){const a=e[t[o].textureSetDefinitionId],c="images/"+a.formats[0].format,l=on(a.formats,i),f={url:r+`/nodes/${n}/textures/${l.name}`,factor:void 0===t[o].factor?1:t[o].factor,format:l.format,mimeType:c};if(s){let t="";switch(l.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=l.format}f.url+="."+t}t[o]=f}else R(t[o])&&sn(t[o],e,r,n,i,s)}function on(t,e){for(let r=0;r<=t.length;r++){const n=t[r].format;if("dds"===n&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[r];if("jpg"===n||"png"===n)return t[r];if("ktx2"===n&&$r)return t[r]}return null}const an=[];class cn extends t.renderer.CanvasRenderer{constructor(t){super(t),this.prepareWorker(),this.tilesLoading={},this.tileCache=new ee(1024*t.options.maxGPUMemory*1024,this.deleteTile.bind(this)),this.Se={},this.we=[],this.de=this.Oe.bind(this)}getAnalysisMeshes(){if(!this.painter)return an;const t=this.painter.getPaintedMeshes();if(!t)return an;const e=[],{b3dmMeshes:r,pntsMeshes:n,i3dmMeshes:i}=t;return r.length&&L(e,r),n.length&&L(e,n),i.length&&L(e,i),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.we.length||super.needToRedraw())}getFrameTimestamp(){return this.Me}drawOnInteracting(t,e,r){this.draw(e,r)}draw(t,e){this.Me=t;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.Ce(),this.Ue();const{selectedTiles:o,leaves:a,requests:c}=this.xe(n,i);c.length&&this.loadTiles(c),this.ve(o,a,e),this.Be(),c.length||this.completeRender()}xe(t,e){let r=[];this.Le();let n=0;const i=this.Pe(),s={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const i=e[t],c=i.node;if(s[c.id])continue;s[c.id]=1;let l=!1;const f=this.getCachedTile(c.id);if(this.Fe(c.id)?(n++,l=a=!0,this.tilesLoading[c.id].current=!0):f?(this.getTileOpacity(f)<1&&(l=a=!0),(!i.node.De||i.node.De<=500)&&(o=!0,i.selected=!0,i.data=f)):this.painter.has(c)||(l=a=!0,r.push(c)),!l)continue;if(this.Ge(i))o=!0;else{this.ke(i).length&&(o=!0)}}let c=[],l={};if(o&&({selectedTiles:c,leaves:l}=this.He(t)),r.length>1&&(r.sort(ln),i)){const t=i-n;r=t>0?r.slice(0,t):[]}return{loading:a,requests:r,selectedTiles:c,leaves:l}}He(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.Ve===i.length){s.pop(),t===n&&(t.leave=!0,r[t.node.id]=1),e.push(t);continue}}const t=i.pop(),o=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===o.length){t.leave=!0,r[t.node.id]=1,e.push(t);continue}s.push(t),t.Ve=i.length}for(let t=0;t<o.length;t++)i.push(o[t])}return{selectedTiles:e,leaves:r}}Ge(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}ke(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const r=t.vt+1,n=[t.node];for(;n.length>0;){const i=n.pop().children;for(let s=0,o=i.length;s<o;s++){if((!i[s].content||!i[s].content.url)&&i[s].children&&i[s].children.length){n.push(i[s]);continue}const o=i[s].id;if(this.tileCache.has(o)){const r=this.layer.ze(i[s],t);r.selected=!0,r.data=this.tileCache.get(o),t.children.push(r),e.push(r)}else i[s].vt<=r&&n.push(i[s])}}return e}ve(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=this.painter.paint(t,e,r);this.onDrawTileEnd(n),i&&this.layer.fire("canvasisdirty",{renderCount:i})}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(v(e)){const r=B(e);return void this.Xe(e,r,t)}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const r=t.Ct,n=this.Ye[r];return new Qr(e,r,n,this.de).load().then((r=>{this.onTilesetLoad(r,t,e)}))}t&&-1===e.indexOf("http://")&&-1===e.indexOf("https://")&&!en(e)&&(e=t.baseUrl+e);const r=this.layer.options.services[t.Ct];if(r.ajaxInMainThread){let n=r.urlParams;n&&(n=(e.indexOf("?")>0?"&":"?")+n);let i=St.getArrayBuffer(e+(n||""),r.fetchOptions);const s=i.xhr;i=i.then((r=>{delete this.Se[e],r?this.Xe(e,r.data,t):this.onTileError(null,t)})).catch((r=>{delete this.Se[e],this.onTileError(r,t)})),this.Se[e]=s}else this.Xe(e,null,t)}Xe(t,e,n){let i=this.o;i||(i=r.Util.getSupportedFormats(this.gl.gl||this.gl),this.o=i);const s=this.layer.options.services[n.Ct];s.isSuperMapiServer&&(t=function(t,e){const r=t.substring(e.length).split("/"),n=[];for(let t=0;t<r.length;t++)n.push(encodeURIComponent(r[t]));return e+n.join("/")}(t,n.baseUrl));const o={url:t=this.layer.getTileUrl(t,n.baseUrl,s),arraybuffer:e,rootIdx:n.Ct,upAxis:n.te,transform:n.matrix,supportedFormats:i};if(en(t)){const e=this.Ye[n.Ct];if(o.i3sInfo=nn(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},n)}this.workerConn.loadTile(this.layer.getId(),o,((e,r)=>{if(e)return void this.onTileError(e,n);const{magic:i}=r;"b3dm"===i||"pnts"===i||"i3dm"===i||"cmpt"===i?this.we.push({data:r,tile:n}):this.onTilesetLoad(r,n,t)}))}Ue(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let r=0;for(;this.we.length&&(r<e||!t.isInteracting());){const{data:t,tile:e}=this.we.shift(),{magic:n}=t;"b3dm"===n?this.painter.createB3DMMesh(t,e.id,e,((r,{mesh:n})=>{this.qe(t,e,r,n)})):"pnts"===n?this.painter.createPntsMesh(t,e.id,e,((r,{mesh:n})=>{this.qe(t,e,r,n)})):"i3dm"===n?this.painter.createI3DMMesh(t,e.id,e,((r,{mesh:n})=>{this.qe(t,e,r,n)})):"cmpt"===n&&this.painter.createCMPTMesh(t,e.id,e,((r,{mesh:n})=>{this.qe(t,e,r,n)})),r++}}qe(t,e,r,n){if(r)this.onTileError(r,e);else{const r=this.Ze(n);e.memorySize=r,this.onTileLoad(t,e)}}Ze(t){let e=0;if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]&&(e+=this.Ze(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.je(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,r){this.layer&&(t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.We(t,e,r):(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.Qe(e,t),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}Qe(e,r){const n={loadTime:t.Util.now(),current:!0,error:r,node:e};this.tileCache.add(e.id,n)}je(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.Ct].ajaxInMainThread){const t=this.Se[e];t&&t.abort()}else this.workerConn.abortTileLoading(this.layer.getId(),e);delete this.Se[e]}Le(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}createContext(){const t=this.layer,e=t.options.glOptions||{alpha:!0,depth:!0,stencil:!0,preserveDrawingBuffer:!0,antialias:t.options.antialias},r=this.canvas.gl&&this.canvas.gl.wrap;r?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.Ke(this.canvas,e)),this.regl=this.regl||l({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),r&&(this.canvas.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height)),this.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height),this.painter=new Xr(this.regl,t),this.layer.$e()}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new $t("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=y({},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.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.Be(!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}Be(t){this.Je||(this.Je=Date.now());const e=Date.now();if(t||!(e-this.Je<this.layer.options.retireInterval)){this.Je=e;for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||this.abortTileLoading(r)}}}Pe(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}Ke(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}Fe(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 Le(t,e,0,r)}Ce(){if(!this.tr)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const r=[];for(const n in this.tr){const i=this.tr[n];if("pending"===i.status)continue;i.status="pending";const s=i.rootIdx;if(r.push(St.getJSON(n).then((t=>{delete this.tr[n];const e=this.Ye[s];if(e){t.nodes?jr(e,t.nodes):(e[t.id]=t,jr(e,t.children));for(let t=0;t<i.length;t++)i[t]();this.setToRedraw()}else this.setToRedraw()}))),e++,e>=t)break}r.length&&Promise.all(r)}Oe(t,e,r){this.tr||(this.tr={}),this.tr[e]=this.tr[e]||[],this.tr[e].rootIdx=t,this.tr[e].push(r),this.setToRedraw()}We(t,e,r){this.Ye||(this.Ye=[]);const n=e.Ct;this.Ye[n]||(this.Ye[n]={});const i=this.Ye[n],s=this.layer.options.services[n];t.layers&&(t=t.layers[0],"/"!==r[r.length-1]&&(r+="/"),r+="layers/0"),i.version=+(s.i3sVersion||t.store.version),function(t,e,r,n,i,s){if(!i.layerScene){i.layerScene=t,i.nodesPerPage=t.nodePages&&t.nodePages.nodesPerPage||64,i.lodSelectionMetricType=t.nodePages&&t.nodePages.lodSelectionMetricType;let e=n;if(i.layerScene.eslpk=e.indexOf("3dSceneLayer.json")>=0,e.endsWith(".json")){const t=n.lastIndexOf("/");e=t<0?"./":n.substring(0,t)}i.layerScene.baseUrl=function(t){return t.split("?")[0]}(e)}return new Qr(n,e,i,s).load()}(t,n,0,r,i,this.de).then((t=>{this.onTilesetLoad(t,e,r)}))}pick(t,e,r){return this.painter?this.painter.pick(t,e,r&&r.tolerance):[]}highlight(t){if(this.Ut||(this.Ut=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const r=t[e].service||0;let n=this.Ut[r];n||(n=this.Ut[r]=new Map),n.set(t[e].id,t[e])}else{const e=t.service||0;let r=this.Ut[e];r||(r=this.Ut[e]=new Map),r.set(t.id,t)}this.painter.highlight(this.Ut)}cancelHighlight(t,e){if(!this.Ut)return;const r=this.Ut[t];if(r){if(Array.isArray(e))for(let t=0;t<e.length;t++)r.delete(e[t]);else r.delete(e);this.painter.highlight(this.Ut)}}cancelAllHighlight(){delete this.Ut,this.painter.cancelAllHighlight()}}function ln(t,e){return t.Ht-e.Ht}function fn(t,e,r){return t[0]=e[r],t[1]=e[r+3],t[2]=e[r+6],t}function un(t,e,r){return Math.sqrt(function(t,e,r){var n=W(hn,r,t),i=fn(_n,e,0),s=fn(dn,e,1),o=fn(En,e,2),a=nt(i),c=nt(s),l=nt(o);$(i,i),$(s,s),$(o,o);var f=Tn;f[0]=J(n,i),f[1]=J(n,s),f[2]=J(n,o);var u,h=0;f[0]<-a?h+=(u=f[0]+a)*u:f[0]>a&&(h+=(u=f[0]-a)*u);f[1]<-c?h+=(u=f[1]+c)*u:f[1]>c&&(h+=(u=f[1]-c)*u);f[2]<-l?h+=(u=f[2]+l)*u:f[2]>l&&(h+=(u=f[2]-l)*u);return h}(t,e,r))}const hn=[],_n=[],dn=[],En=[],Tn=[];const mn=2*Math.PI;class An{constructor(t,e,r,n){this.west=t,this.south=e,this.east=r,this.north=n}static contains(t,e){var r=e[0],n=e[1],i=t.west,s=t.east;return s<i&&(s+=mn,r<0&&(r+=mn)),(r>i||Me(r,i,1e-14))&&(r<s||Me(r,s,1e-14))&&n>=t.south&&n<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const pn=[0,0,1];function yn(t,e){return Ee(e,t[0],t[1],t[2])}class gn{constructor(t,e){this.normal=s.copy([],t),this.distance=e}static fromPointNormal(t,e,r){var n=-s.dot(e,t);return s.copy(r.normal,e),r.distance=n,r}}const Rn=[],bn=[],In=[],Nn=[],Sn=[],wn=[],On=[],Mn=[],Cn=[],Un=[],xn=new gn([1,0,0],0),vn=[];class Bn{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new An(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){var r,n,i,o=0;if(!An.contains(this.rectangle,e)){var a=this.southwestCornerCartesian,c=this.northeastCornerCartesian,l=this.westNormal,f=this.southNormal,u=this.eastNormal,h=this.northNormal,_=s.subtract(vn,t,a),d=s.dot(_,l),E=s.dot(_,f),T=s.subtract(vn,t,c),m=s.dot(T,u),A=s.dot(T,h);d>0?o+=d*d:m>0&&(o+=m*m),E>0?o+=E*E:A>0&&(o+=A*A)}if(r=e[2],n=this.minimumHeight,r>(i=this.maximumHeight)){var p=r-i;o+=p*p}else if(r<n){var y=n-r;o+=y*y}return Math.sqrt(o)}computeBox(t){const e=this;yn(An.southwest(t,bn),e.southwestCornerCartesian),yn(An.northeast(t,bn),e.northeastCornerCartesian),Rn[0]=t.west,Rn[1]=.5*(t.south+t.north),Rn[2]=0;var r=yn(Rn,In),n=s.cross(Sn,r,pn);s.normalize(e.westNormal,n),Rn[0]=t.east;var i=yn(Rn,Mn),o=s.cross(Sn,pn,i);s.normalize(e.eastNormal,o);var a,c=s.subtract(Sn,r,i),l=s.normalize(Nn,c),f=t.south;if(f>0){Rn[0]=.5*(t.west+t.east),Rn[1]=f;var u=yn(Rn,Cn);s.copy(Un,l);var h=gn.fromPointNormal(e.southwestCornerCartesian,e.westNormal,xn);Ln(Cn,Un,h,e.southwestCornerCartesian),a=Se(u,wn)}else a=we(An.southeast(t,bn),wn);var _=s.cross(On,a,c);s.normalize(e.southNormal,_);var d,E=t.north;if(E<0){Rn[0]=.5*(t.west+t.east),Rn[1]=E;var T=yn(Rn,Cn);s.scale(Un,l,-1);var m=gn.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,xn);Ln(Cn,Un,m,e.northeastCornerCartesian),d=Se(T,wn)}else d=we(An.northwest(t,bn),wn);var A=s.cross(On,c,d);s.normalize(e.northNormal,A)}}function Ln(t,e,r,n){var i=t,o=e,a=r.normal,c=s.dot(a,o);if(!(Math.abs(c)<1e-15)){var l=(-r.distance-s.dot(a,i))/c;if(!(l<0))return n=s.scale(n,o,l),s.add(n,i,n)}}const Pn=new t.Extent(0,0,0,0),Fn=new t.Extent(0,0,0,0),Dn=[],Gn=[],kn=[],Hn=[],Vn=new t.Point(0,0),zn=[],Xn=new t.Coordinate(0,0),Yn=n.identity([]);class qn extends t.Layer{constructor(t,e){super(t,e),this.er(),this.Se={},this.rr=[]}er(){let t=this.options.services.map((t=>t.url));this.nr=t.map(((t,e)=>function(t,e){t=S(t);return{visible:1,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:n.identity([]),Ct:e,vt:0}}(t,e))),this.fire("rootready",{roots:this.nr.slice(0)})}showService(t){return this.ir(t,1),this}hideService(t){return this.ir(t,0),this}setToRedraw(){const t=this.getRenderer();t&&t.setToRedraw()}ir(t,e){const r=this.nr[t];if(!r)return;r.visible=e;const n=this.getRenderer();n&&n.setToRedraw()}getTileUrl(t){return t}getExtent(e){if(!e&&0!==e){const e=new t.Extent;for(let t=0;t<this.nr.length;t++)if(this.nr[t].boundingVolume){const r=this.boundingVolumeToExtent(this.nr[t]);e._combine(r)}return e}return this.nr[e]&&this.nr[e].boundingVolume?this.boundingVolumeToExtent(this.nr[e]):null}boundingVolumeToExtent(e){const r=e.boundingVolume.sr?Yn:e.matrix,n=this.getMap();if(e.boundingVolume.region){const r=e.boundingVolume.region;return new t.Extent(N(r[0]),N(r[1]),N(r[2]),N(r[3]))}if(e.boundingVolume.sphere){const i=e.boundingVolume.sphere,o=ge([],s.transformMat4([],i,r)),a=i[3],c=n.locate(o,-a,a),l=n.locate(o,a,-a);return new t.Extent(c,l)}if(e.boundingVolume.box){const i=e.boundingVolume.box,a=s.transformMat4([],i,r),c=new t.Coordinate(ge([],a)),l=i.slice(3);o.multiply(l,o.fromMat4([],e.matrix),l);const f=s.length(l.slice(0,3)),u=s.length(l.slice(3,6)),h=s.length(l.slice(6,9)),_=Math.max(f,u,h),d=n.locate(c,-_,_),E=n.locate(c,_,-_);return new t.Extent(d,E)}return null}getRootTiles(){return this.nr}getTiles(){const t=this.getRenderer();if(!t.ready)return this.ar(),{tiles:Hn};const e=this.getMap(),r=e.cameraPosition;let n,i;if(e.getGLZoom)i=e.pointToDistance(r[2],0,e.getGLZoom()),Xn.set(r[0],r[1]),n=e.pointToCoord(Xn,e.getGLZoom());else{const t=e.getGLRes();i=e.pointAtResToDistance(r[2],0,t),Xn.set(r[0],r[1]),n=e.pointAtResToCoord(Xn,t)}this.cr=this.cr||[],s.set(this.cr,I(n.x),I(n.y),i),this.lr=Ee(this.lr||[],this.cr[0],this.cr[1],this.cr[2]),this.ur=2*Math.tan(.5*I(e.getFov()));const o=e.projViewMatrix,a={children:[],level:-1};let c=a;const l=[];for(let e=0;e<this.nr.length;e++){const r=this.nr[e];if(!r.visible)continue;let n=1/0;const i=[r],s=this.hr(e);for(;i.length>0;){const e=i.pop();for(e.id||this._r(e);c.level>=e.vt;)c=c.parent;const r=this.dr(e,s,o);if(r<1){let t=c;for(;t&&!t.content;)t=t.parent;0===r&&t&&t.content&&this.Er(l,t);if(!1===this.options.services[e.Ct].alwaysShow)continue;if(!(0===r&&e.vt<=n))continue;e.content&&(n=e.vt)}e.Ht<1/0&&this.Tr(e);const a=this.ze(e,c);c.children.push(a);const f=e.children,u=f&&f.length,h=a.content;if(!u&&h&&this.Er(l,a),u){h&&"add"===e.refine&&this.Er(l,a),c=a;const r=f[0].parent;let n=!1;for(let s=0,o=f.length;s<o;s++){if(r){const e=t.getCachedTile(f[s].id);if(e&&e.error&&404!==e.error.status)continue;n=!0}else{n=!0,f[s].parent=e,f[s].te=e.te,f[s].baseUrl=e.baseUrl;const t=f[s].content&&(f[s].content.url||f[s].content.uri);t&&(v(t)||t.indexOf("i3s:")>=0?f[s].baseUrl=e.baseUrl:-1===t.indexOf("http://")&&-1===t.indexOf("https://")?f[s].content.url=e.baseUrl+t:f[s].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}i.push(f[s])}!n&&h&&this.Er(l,a)}}}return{root:a,tiles:l}}Er(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 Zn(r,e);if(r.box)return 0===jn(r,e)}return!1}(this.cr,this.lr,r)||t.push(e)}ze(t,e){return{id:t.id,node:t,children:[],level:t.vt,parent:e,content:t.content&&t.content.url}}_r(e){e.id=t.Util.GUID(),e.matrix=e.transform||n.identity([]),e.mr=this.Ar(e),e.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(e)||(e.matrix=n.multiply(e.matrix,e.parent.matrix,e.matrix)),e.Ct=e.parent.Ct,void 0===e.vt&&(e.vt=e.parent.vt+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.pr(e)}pr(t){const e=t.boundingVolume;if(!e||e.sr)return;const r=this.options.services[t.Ct].heightOffset||0,i=this.options.offset,o=g(i)||i[0]||i[1];if(!t.boundingVolume||!r&&n.exactEquals(t.matrix,Yn)&&!o)return;const{region:a,box:c,sphere:l}=e;if(a){const t=this.yr([N(a[0]),N(a[1])]);a[0]=I(t.x),a[1]=I(t.y);const e=this.yr([N(a[2]),N(a[3])]);a[2]=I(e.x),a[3]=I(e.y),a[4]+=r,a[5]+=r}else if(c||l){const e=c||l,n=s.transformMat4(Dn,e,t.matrix),i=ge(Gn,n),o=this.yr([i[0],i[1]]);i[0]=o.x,i[1]=o.y,i[2]+=r,Ee(e,I(i[0]),I(i[1]),i[2])}e.sr=!0}Ar(t){return void 0===t.geometricError||!t.boundingVolume}Tr(t){let e=t.parent;for(;e&&e.mr&&!(e.Ht<=t.Ht);)e.Ht=t.Ht,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=this.options.services[e.Ct],s=(t.asset&&t.asset.gltfUpAxis||e&&e.te||i.upAxis||"Y").toUpperCase();t.root.baseUrl=r.substring(0,r.lastIndexOf("/")+1);const o=r.indexOf("realspace/")>-1;0===e.vt&&(t.asset&&t.asset.s3mType&&o||i.isSuperMapiServer)&&(t.root.baseUrl+="data/path/");const a=t.asset.i3s;if(t.root.te=s,e){const r=e.boundingVolume;y(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",r&&(e.boundingVolume=r);const i=t.root.transform;i&&(e.parent?a||(e.matrix=n.multiply([],e.parent.matrix,i)):e.matrix=i),this.pr(e),e.gr=e.content,delete e.content,t.root.content&&(e.content=t.root.content),e.mr=this.Ar(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),a||!s||v(s)||-1!==s.indexOf("http://")||-1!==s.indexOf("https://")||(e.content.url=e.baseUrl+s)}this.ar(),this.fire("loadtileset",{tileset:t,index:e.Ct,url:r})}dr(t,e,r){if(t.Ht=1/0,0===t.vt||t.mr)return 1;if(!this.Rr(t,e,r))return-1;if(0===t.geometricError)return 1;let n=this.options.services[t.Ct].maximumScreenSpaceError;null==n&&(n=8);let i=this.br(t);return 0===i&&t.parent&&(i=.5*(t.parent.De||0)),i>=n?1:0}jt(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)}Rr(e,r,i){const a=e.id;let c=this.rr[a];const{boundingVolume:l}=e,f=l.sphere;let h=l.region;const _=l.box;if(!c){let r,i,u;if(_&&(h=function(t,e){for(let e=0;e<9;e++)ii[e]=t[e+3];const r=ii;n.exactEquals(e,Yn)||o.multiply(r,o.fromMat4(zn,e),r);const i=s.copy(Wn,t),a=s.set(Qn,r[0],r[1],r[2]),c=s.set(Kn,r[3],r[4],r[5]),l=s.set($n,r[6],r[7],r[8]);Jn[0]=Jn[0]||[];const f=s.copy(Jn[0],i);s.sub(f,f,a),s.sub(f,f,c),s.sub(f,f,l),Jn[1]=Jn[1]||[];const u=s.copy(Jn[1],i);s.sub(u,u,a),s.sub(u,u,c),s.add(u,u,l),Jn[2]=Jn[2]||[];const h=s.copy(Jn[2],i);s.sub(h,h,a),s.add(h,h,c),s.sub(h,h,l),Jn[3]=Jn[3]||[];const _=s.copy(Jn[3],i);s.sub(_,_,a),s.add(_,_,c),s.add(_,_,l),Jn[4]=Jn[4]||[];const d=s.copy(Jn[4],i);s.add(d,d,a),s.sub(d,d,c),s.sub(d,d,l),Jn[5]=Jn[5]||[];const E=s.copy(Jn[5],i);s.add(E,E,a),s.sub(E,E,c),s.add(E,E,l),Jn[6]=Jn[6]||[];const T=s.copy(Jn[6],i);s.add(T,T,a),s.add(T,T,c),s.sub(T,T,l),Jn[7]=Jn[7]||[];const m=s.copy(Jn[7],i);s.add(m,m,a),s.add(m,m,c),s.add(m,m,l);for(let t=0;t<Jn.length;t++)ti[t]=ti[t]||[],ge(ti[t],Jn[t]),ei[t]=ti[t][0],ri[t]=ti[t][1],ni[t]=ti[t][2];return[I(Math.min(...ei)),I(Math.min(...ri)),I(Math.max(...ei)),I(Math.max(...ri)),Math.min(...ni),Math.max(...ni)]}(_,e.matrix),l.region=h),h){r=Pn.set(N(h[0]),N(h[1]),N(h[2]),N(h[3]));const t=r.getCenter(),e=this.Ir(t);r=r.convertTo((t=>this.jt(t,Vn)),Fn),u=h[4],i=h[5],c=this.rr[a]=[[r.xmin,r.ymin,u*e[2]],[r.xmax,r.ymax,i*e[2]]],c.center=t}else if(f){const e=ge(Dn,f),r=new t.Coordinate(e),n=this.jt(r,Vn).toArray(),i=this.Ir(r);n.push(e[2]*i[2]),c=this.rr[a]=[n,f[3]*i[2]],c.center=r}}if(r){if(h)Pn.xmin=c[0][0],Pn.ymin=c[0][1],Pn.xmax=c[1][0],Pn.ymax=c[1][1];else if(f){const t=c[2];Pn.xmin=c[0][0]-t,Pn.ymin=c[0][1]-t,Pn.xmax=c[0][0]+t,Pn.ymax=c[0][1]+t}else if(_){const t=c[1],e=c[2];Pn.xmin=c[0][0]-t,Pn.ymin=c[0][1]-e,Pn.xmax=c[0][0]+t,Pn.ymax=c[0][1]+e}if(!r.intersects(Pn))return!1}return h?d(i,c):f?function(t,e,r){T(t);for(var n=e[0],i=-e[1],s=0;s<6;s++)if((!r||"0"!==r.charAt(s))&&A(u[s],n)<i)return!1;return!0}(i,c):!!_&&function(t,e,r){T(t);for(var n=0;n<6;n++)if(!(r&&"0"===r.charAt(n)||E(u[n],e)))return!1;return!0}(i,c)}Ir(t){const e=this.getMap(),r=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let n;return n=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:r.y/100,s.set(kn,r.x/100*1.01,r.y/100*1.01,n),kn}yr(e){Array.isArray(e)&&(e=new t.Coordinate(e));let r=this.options.offset;if(g(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}hr(e){const r=this.options.services[e].maxExtent;if(!r)return null;const n=this.nr[e];return n.maxExtent||(n.maxExtent=new t.Extent(r).convertTo((t=>this.jt(t)))),n.maxExtent}br(t){const e=this.ur,r=t.geometricError;if(0===r)return t.De=0,0;const n=this.getMap();let i;t.boundingVolume.region?i=function(t,e,r){t.Nr||(t.Nr=new Bn(t.boundingVolume.region));return t.Nr.distanceToCamera(e,r)}(t,this.lr,this.cr):t.boundingVolume.sphere?i=Zn(t.boundingVolume,this.lr):t.boundingVolume.box&&(i=jn(t.boundingVolume,this.lr));const s=Math.max(Math.abs(i),1e-7),o=r*n.height/(s*e);return t.Ht=i,t.De=o,o}ar(){const t=this.getRenderer();t&&t.setToRedraw()}se(t){return this.rr[t]}identify(e,r={}){const n=this.getMap(),i=this.getRenderer();if(!n||!i)return[];const s=n.coordToContainerPoint(new t.Coordinate(e));return this.identifyAtPoint(s,r)}identifyAtPoint(t,e={}){const r=this.getMap(),n=this.getRenderer();if(!r||!n)return[];const i=r.getDevicePixelRatio();return n.pick(t.x*i,t.y*i,e)}highlight(t){const e=this.getRenderer();return e?(e.highlight(t),this):(this.Ut||(this.Ut=[]),this.Ut.push(t),this)}$e(){if(this.Ut){for(let t=0;t<this.Ut.length;t++)this.highlight(this.Ut[t]);delete this.Ut}}cancelHighlight(t,e){const r=this.getRenderer();return r?(r.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}}function Zn(t,e){const r=t.sphere,n=s.dist(r,e),i=t.sphere[3];return n<i?0:n-i}function jn(t,e){const r=t.box;return un(s.set(Dn,r[0],r[1],r[2]),o.set(zn,r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11]),e)}qn.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,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!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]}),qn.registerRenderer("gl",cn),qn.registerJSONType("Geo3DTilesLayer");const Wn=[],Qn=[],Kn=[],$n=[],Jn=[],ti=[],ei=[],ri=[],ni=[],ii=[];let si=null;function oi(){return si||(si={"image/crn":Zr.crn&&Zr.crn(),"image/ktx2":Zr.ktx2&&Zr.ktx2(),"image/cttf":Zr.ktx2&&Zr.ktx2(),"draco":Zr.draco&&Zr.draco()}),si}class ai{constructor(t,e,r){this.i=t,this.Sr=e||Xt,this.o=r,this.wr=oi()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.Or(t,e,r,n,i)):St.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.Or(t,i,r,n)}))}Or(t,e,r,n,i){const s=i&&i.maxTextureSize,o=this.Mr(e,r,n,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.Sr(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.wr,supportedFormats:this.o,maxTextureSize:s});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${r}-${n}`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}Mr(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),c=i.getUint32(16,!0),l=i.getUint32(20,!0),f=i.getUint32(24,!0),u=28+e;l>=570425344?(u-=8,o=a,l=c,f=0,a=0,c=0):f>=570425344&&(u-=4,o=l,l=a,f=c,a=0,c=0);const h=[t];let _,d,E;if(a>0?(_=xe(t,u,a),u+=a,o=_.BATCH_LENGTH):_={"BATCH_LENGTH":o},c>0&&(u+=c),l>0&&(d=ve(t,u,l),u+=l,f>0)){const e=Be(0,u,f);E=t.slice(e.offset,e.offset+e.byteLength),u+=f,h.push(E)}const T=_.BATCH_LENGTH,m={};if(_&&_.BATCH_ID){m.BATCH_ID=Pe(_.BATCH_ID,t,undefined.offset,T);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:_,batchTable:d,batchTableBin:E,b3dm:m,glb:{buffer:t,byteOffset:u,byteLength:i.byteLength+i.byteOffset-u}}}Cr(){return null}}class ci{constructor(t,e,r,n){this.i=t,this.Sr=e||Xt,this.o=r,this.wr=oi(),this.Ur=n}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.Or(t,e,r,n,i)):St.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.Or(t,i,r,n)}))}Or(t,e,r,n,i){return this.vr(t,e,r,n,i).then((({gltf:i,transferables:s})=>{const o=this.Br(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})}))}vr(t,e,r,n,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.wr,supportedFormats:this.o,maxTextureSize:s},a=new DataView(e,r,n),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let n=M(new Uint8Array(e,c+r,a.byteLength-c));-1==n.indexOf("://")&&(n=t.substring(0,t.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?St.getArrayBuffer(n,{}).then((t=>this.Lr(n,{buffer:t.data,byteOffset:0},o))):St.getJSON(n,{}).then((t=>this.Lr(n,t,o)))}{const n={buffer:e,byteOffset:c+r,byteLength:a.byteLength-c};return this.Lr(t,n,o)}}Lr(t,e,r){const n=t.substring(0,t.lastIndexOf("/")),i=new this.Sr(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}}))}Br(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:c,batchTable:l,batchTableBin:f}=Xe(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+c.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.Pr(new Uint16Array(t,n+c.offset,3*h),e,r)},o.push(u.POSITION.array.buffer)}if(a.BATCH_ID){u.BATCH_ID=Pe(a.BATCH_ID,t,c.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+c.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+c.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.Fr(new Uint16Array(t,e+c.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.Fr(new Uint16Array(t,e+c.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+c.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+c.offset,3*h).slice()},o.push(u.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:l,batchTableBin:f,featureTable:a,i3dm:u,transferables:o}}Fr(t){const e=t.length/2,r=new Float32Array(3*e),n=[];for(let i=0;i<e;i++)li(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}Pr(t,e,r){return ze(new Float32Array(t.length),t,e,r)}Cr(){return null}}function li(t,e,r,n){if(t[0]=fi(e,n),t[1]=fi(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]))*ui(e),t[1]=(1-Math.abs(e))*ui(t[1])}return $(t,t)}function fi(t,e){return e=function(t,e){if(null!=t)return t;return e}(e,255),function(t,e,r){return t<e?e:t>r?r:t}(t,0,e)/e*2-1}function ui(t){return t<0?-1:1}class hi{constructor(){}load(t,e,r=0,n=0){return e?(n||(n=e.byteLength),this.Or(t,e,r,n)):St.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.Or(t,i,r,n)}))}Or(t,e,r,n){return this.Dr(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}))}Dr(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:c,batchTable:l,batchTableBin:f}=Xe(i,e+28,o),u=a.QUANTIZED_VOLUME_OFFSET,h=a.QUANTIZED_VOLUME_SCALE,_=a.POINTS_LENGTH;let d,E={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){E=a.extensions["3DTILES_draco_point_compression"],d=new DataView(t,E.byteOffset+c.offset,E.byteLength);const e={attributes:E.properties,useUniqueIDs:!1};return this.Gr||(this.Gr=oi().draco),this.Gr(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.kr(t,e.attributes,c.offset,_,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:Ve(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?n.BATCH_ID=Pe(a.BATCH_ID,t,c.offset,_):n.BATCH_ID=_i(_);const e=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:_,batchTable:l,batchTableBin:f,featureTable:a,pnts:n,transferables:o}}))}const T=this.kr(t,a,c.offset,_,o,u,h);if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?T.BATCH_ID=Pe(a.BATCH_ID,t,c.offset,_):T.BATCH_ID=_i(_);const e=T.BATCH_ID.array&&T.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:_,batchTable:l,batchTableBin:f,featureTable:a,pnts:T,transferables:o})}kr(t,e,r,n,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+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:c,array:l}=e.POSITION_QUANTIZED;c=c||0;const f=l?0:r;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this.Pr(l||new Uint16Array(t,c+f,3*n),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:r;if(!o){const e=t.slice(s+c,s+c+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 c=o?0:r;if(!o){const e=t.slice(s+c,s+c+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 c=o?0:r;if(!o){const e=t.slice(s+c,s+c+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 c=o?0:r;if(!o){const e=t.slice(s+c,s+c+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 c=o?0:r;if(!o){const e=t.slice(s+c,s+c+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}Pr(t,e,r){return ze(new Float32Array(t.length),t,e,r)}Cr(){return null}}function _i(t){const e=x(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 di{constructor(t,e,r,n){this.o=r,this.i=t,this.Sr=e||Xt,this.Ur=n}load(t,e,r=0,n=0,i){return e?this.Or(t,e,r,n,i):St.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.Or(t,i,r,n)}))}Or(t,e,r,n,i){n||(n=e.byteLength);const s=this.Hr(e,t,r,n),o=[];for(let r=0;r<s.length;r++){let n;if("b3dm"===s[r].magic)n=new ai(this.i,this.Sr,this.o);else if("i3dm"===s[r].magic)n=new ci(this.i,this.Sr,this.o,this.Ur);else if("pnts"===s[r].magic)n=new hi;else{if("cmpt"!==s[r].magic){console.warn("Unsupported magic in CMPT tile:",s[r].magic);continue}n=new di(this.i,this.Sr,this.o,this.Ur)}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})))}Hr(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 c=16;for(let e=0;e<a;e++){const e=Ce(i,c),n=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+r,byteLength:n}),c+=n}return o}}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(f);t.registerWorkerAdapter("@maptalks/3dtiles",r)}else t.registerWorkerAdapter("@maptalks/3dtiles",(function(){return e.transcoders.inject(f)}))}else t.registerWorkerAdapter("@maptalks/3dtiles",f);export{ai as B3DMLoader,di as CMPTLoader,qn as Geo3DTilesLayer,P as Geo3DTilesUtil,Oe as Geo3DTransform};"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.22.0");
|
|
22
|
+
* (c) 2016-2023 maptalks.com
|
|
23
|
+
*/(s,a)),A.generateBuffers(this.rt,{excludeElementsInVAO:e}),A}se(t,e,r,i){const o=n.identity(t),a=this.getMap();vr.x=r[0],vr.y=r[1];const A=this._prjToPoint(vr),c=this.Ee(),l=1/(a.getGLZoom?a.getResolution(a.getGLZoom()):a.getGLRes());vr.x=e[0],vr.y=e[1];const f=this.ae();let h=this.$.options.offset;g(h)&&(h=h(vr));const u=this.$.options.services[i].heightOffset||0;return s.set(Vr,A.x-h[0],A.y-h[1],f*r[2]+f*u),n.translate(o,o,Vr),s.set(c,l,l,f),n.scale(o,o,c),o}Qt(t,e){const r=n.identity(t),i=this.getMap(),o=this.Ee();vr.x=e[0],vr.y=e[1];const a=i.distanceToPointAtRes(100,100,i.getGLRes(),vr);let A;return A=i.altitudeToPoint?this.It:a.y/100,s.set(o,a.x/100*1.01,a.y/100*1.01,A),n.scale(r,r,o),r}gt(){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.Gt=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)=>o.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 s=this.Rt();this.wt=new r.PhongShader({extraCommandProps:s}),this.vt=new r.pbr.StandardShader({extraCommandProps:s});const a=this.$;Ir(a.getRenderer().canvas,this.rt,a.getMap()),this.picking=new r.FBORayPicking(this.nt,{vert:this.vt.vert,extraCommandProps:s,uniforms:this.vt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}Rt(){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||xr,cull:{enable:!0,face:(t,e)=>e.cullFace||"back"},stencil:{enable:(t,e)=>!0===e.stencilEnable,func:{cmp:(t,e)=>e.meshProperties.isLeaf?"always":">=",ref:(t,e)=>e.meshProperties.level},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,range:[0,1],func:(t,e)=>e.meshProperties.depthFunc||"<"},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}Xt(t){return{projViewMatrix:this.getMap().projViewMatrix,color:t&&t.color||[0,1,0]}}Ut(t){const e=this.getMap(),r=e.getLightManager(),n=(r&&r.getDirectionalLight()||{}).direction||[1,1,-1],i=t&&t.pointOpacity||1;return{projViewMatrix:e.projViewMatrix,pointOpacity:i,lightDir:s.normalize(n,n)}}Pt(){const t=this.getMap(),e=this.$.getRenderer().canvas,{iblTexes:r,dfgLUT:n}=Pr(e),i=Mr(t,r,n);return m(i,{czm_lightDirectionEC:i.light0_viewDirection,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}he(t,e,n,i,s){const o=e.materials[t];if(!o||!o.baseColorTexture&&!o.pbrMetallicRoughness)return null;const A=m({},i);if(o.baseColorTexture){const t=e.textures[o.baseColorTexture.index];let r;t&&!t.image.color&&(r=this.I(t)),A.baseColorFactor=t&&t.image.color||o.baseColorFactor||[1,1,1,1],r&&(A.baseColorTexture=r)}else{if(o.normalTexture){const t=this.I(e.textures[o.normalTexture.index]),r=o.normalTexture.scale||1;A.normalTexture=t,A.normalMapFactor=r}if(o.occlusionTexture){const t=this.I(e.textures[o.occlusionTexture.index]),r=o.occlusionTexture.strength||1;A.occlusionTexture=t,A.occlusionFactor=r}if(o.emissiveTexture){const t=this.I(e.textures[o.emissiveTexture.index]);A.emissiveTexture=t}o.emissiveFactor&&(A.emissiveFactor=o.emissiveFactor);const t=o.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(A.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const r=e.textures[t.baseColorTexture.index];r.image&&r.image.color?A.baseColorFactor=A.baseColorFactor?a.multiply(A.baseColorFactor,A.baseColorFactor,r.image.color):r.image.color:(A.baseColorTexture=this.I(r),A.baseColorTexture.getREGLTexture(this.rt))}if(T(t.metallicFactor)||(A.metallicFactor=t.metallicFactor),T(t.roughnessFactor)||(A.roughnessFactor=t.roughnessFactor),o.metallicRoughnessTexture){const t=this.I(e.textures[o.metallicRoughnessTexture.index]);A.metallicRoughnessTexture=t}}}if(o.s3mMaterial)return new r.Material(A);if(A.environmentExposure=s,o.extensions&&o.extensions.KHR_materials_unlit)return A.environmentExposure=1,A.ambientColor=[1,1,1],A.light0_diffuse=[0,0,0,0],A.lightSpecular=[0,0,0],new r.PhongMaterial(A);let c=new r.pbr.StandardMaterial(A);"phong"===n&&(c=r.PhongMaterial.convertFrom(c));const l=o.pbrMetallicRoughness,f=l&&l.baseColorTexture&&l.baseColorTexture.extensions;return f&&f.KHR_texture_transform&&(c.set("khr_offset",f.KHR_texture_transform.offset||[0,0]),c.set("khr_rotation",f.KHR_texture_transform.rotation||0),c.set("khr_scale",f.KHR_texture_transform.scale||[1,1])),c.once("complete",this.dt),c}I(t){const e={type:t.type?Tr(t.type):"uint8",format:t.format?mr(t.format):"rgba",flipY:!!t.flipY},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&&t.texture.sampler;return i&&(i.magFilter&&(e.mag=_r(i.magFilter)),i.minFilter&&(e.min=dr(i.minFilter)),i.wrapS&&(e.wrapS=Cr(i.wrapS)),i.wrapT&&(e.wrapT=Cr(i.wrapT))),new r.Texture2D(e,this._t)}Be(t){const e=t.image,r=window.URL||window.webkitURL,n=new Blob([e.array],{type:e.mimeType});return r.createObjectURL(n)}Ct({target:t}){const e=t.ue,r=this.it[e];if(r.count--,!r.count){const t=r.meshes;this.ot[e]=t,delete this.it[e];const n=t.ie;delete t.ie,n(null,{mesh:r.meshes,id:e})}}Ee(){return Lr}Zt(t){return this.$.Zt(t)}jt(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(),Ur)}te(t){return"Y"===t?yr:"X"===t?Rr:Dr}pick(t,e,r=3){const n=this.$;if(!n||!n.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const i=this.getMap(),s=this.Pt(),o=this.picking;o.render(this.ht.getMeshes().filter((t=>!t.bloom)),s,!0);let a={};o.getRenderedMeshes().length&&(a=o.pick(t,e,r,s,{viewMatrix:i.viewMatrix,projMatrix:i.projMatrix,returnPoint:n.options.pickingPoint}));const{meshId:A,pickingId:c,point:l,coordinate:f}=a,h=(0===A||A)&&o.getMeshAt(A);if(!h||!h.geometry)return[];const u=h.properties;l&&l.length&&(l[0]=Math.round(1e5*l[0])/1e5,l[1]=Math.round(1e5*l[1])/1e5,l[2]=Math.round(1e5*l[2])/1e5);const E={batchId:c};if(n.options.debug&&(E.debugInfo=u),u&&u.batchTable){const{batchTable:t,batchTableBin:e,count:r}=u,n=c;for(const i in t)void 0!==t[i].byteOffset?E[i]=ve(t[i],e,r,n):E[i]=t[i][n]}return[{service:h.properties.serviceIndex,data:E,point:l,coordinate:f}]}Mt(t){let e=new Set;for(let r=0,n=t.length;r<n;r++){const n=t[r].data.node;this.Nt(n)&&e.add(n.Ot)}e=Array.from(e),e.sort();const r=new Map,n=e.length;for(let t=0;t<n;t++)r.set(e[t],t);return r}highlight(t){this.Lt=t;const e=this.$.getRenderer();this.Dt=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.Lt=null;const t=this.$.getRenderer();this.Dt=t.getFrameTimestamp(),t.setToRedraw(!0)}_e(){if(!this.bt)return[];const t={},e=[];for(const r in this.bt){const n=this.bt[r];if(n)for(let r=0;r<n.length;r++){const i=n[r],s=i&&i.geometry;if(!i||!s)continue;const o=i.properties.serviceIndex;t[o]||(t[o]=new Set);const a=s.properties.batchIdData;if(a)for(let r=0;r<a.length;r++)t[o].has(a[r])||(e.push({id:a[r],service:o}),t[o].add(a[r]))}}return e}}const zr=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")},Zr=zr(),Wr=Zr.gl_trans__coders=Zr.gl_trans__coders||{};function jr(t,e){if(e)for(let r=0;r<e.length;r++){t[e[r].id||e[r].index]=e[r]}}Wr.inject=function(t){const e=t.toString(),r=e.indexOf("{")+1,n=e.substring(0,r),i=Zr.gl_trans__coders=Zr.gl_trans__coders||{};let s=`${n}\n const _____getGlobal = ${zr.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]};const Qr=[];class qr{constructor(t,e,r,n){this.de=t,this.St=e,this.Ce=n,this.Te=r.version,t.indexOf("i3s:tileset:")<0?(this.Te<=1.6?this.me="root":this.me=0,r.version=this.Te):(this.me=t.substring("i3s:tileset:".length),this.Te>1.6&&(this.me=parseInt(this.me))),this.de=t,this.ge=r}load(){const t=this.ge,e=t.layerScene.baseUrl;if(this.Te<=1.6)return t[this.me]&&t[this.me].lodSelection?(this.pe=t[this.me],this.ye()):new Promise((r=>{let n=e+"/nodes/"+this.me;t.layerScene.eslpk&&(n+="/3dNodeIndexDocument.json"),this.Ce(this.St,n,(()=>{this.pe=t[this.me],r(this.ye())}))}));if(this.Te>=1.7){if(t[this.me])return this.pe=t[this.me],this.ye();const r=Math.floor(this.me/t.nodesPerPage);return new Promise((n=>{let i=e+"/nodepages/"+r;t.layerScene.eslpk&&(i+=".json"),this.Ce(this.St,i,(()=>{this.pe=t[this.me],n(this.ye())}))}))}return null}getTileset(){return this.Re}getChildrenURL(){return this.Ie}ye(){const t=this.ge,e=t.layerScene.baseUrl,r=this.pe.children,n=[],i={};if(r)for(let s=0;s<r.length;s++)if(this.Te<=1.6){const o=r[s].id;if(t[o])continue;const a=o;i[a]||(i[a]=new Promise((r=>{let n=e+"/nodes/"+a;t.layerScene.eslpk&&(n+="/3dNodeIndexDocument.json"),this.Ce(this.St,n,(()=>{r()}))})),n.push(i[a]))}else{const o=r[s];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);i[a]||(i[a]=new Promise((r=>{let n=e+"/nodepages/"+a;t.layerScene.eslpk&&(n+=".json"),this.Ce(this.St,n,(()=>{r()}))})),n.push(i[a]))}return n.length?Promise.all(n).then((()=>this.be())):this.be()}be(){return Promise.resolve(this.Pe())}Me(t){jr(this.ge,t)}Pe(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.Ne(this.pe,!0)}}Ne(t){const e=this.Te,r=this.ge,n=t;var i,s=n.obb,o=n.mbs,a={};if(o)i=$r([],o[0],o[1],o[2]),a.sphere=[...i,o[3]];else if(s){const t=function(t,e,r){const n=function(t,e){var r=e[0],n=e[1],i=e[2],s=e[3],o=r+r,a=n+n,A=i+i,c=r*o,l=n*o,f=n*a,h=i*o,u=i*a,E=i*A,B=s*o,_=s*a,d=s*A;return t[0]=1-f-E,t[3]=l-d,t[6]=h+_,t[1]=l+d,t[4]=1-c-E,t[7]=u-B,t[2]=h-_,t[5]=u+B,t[8]=1-c-f,t}([],r);return n[0]=n[0]*e[0],n[1]=n[1]*e[0],n[2]=n[2]*e[0],n[3]=n[3]*e[1],n[4]=n[4]*e[1],n[5]=n[5]*e[1],n[6]=n[6]*e[2],n[7]=n[7]*e[2],n[8]=n[8]*e[2],[...t,...n]}(i=$r([],s.center[0],s.center[1],s.center[2]),s.halfSize,s.quaternion),e=t[3]+t[6]+t[9],r=t[4]+t[7]+t[10],n=t[5]+t[8]+t[11];z(Qr,e,r,n);const o=nt(Qr);a.sphere=[...i,o]}var A=1/0,c=0;if(n.mbs?c=n.mbs[3]:n.obb&&(c=Math.max(Math.max(n.obb.halfSize[0],n.obb.halfSize[1]),n.obb.halfSize[2])),void 0!==n.lodThreshold)"maxScreenThresholdSQ"===r.lodSelectionMetricType?A=c/(Math.sqrt(n.lodThreshold)/(.25*Math.PI)):console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==n.lodSelection)for(var l=0;l<n.lodSelection.length;l++)"maxScreenThreshold"===n.lodSelection[l].metricType&&(A=c/n.lodSelection[l].maxError);(A===1/0||isNaN(A))&&(A=1e5);var f=16*A;const h=U([]),u=n.children;var E;if(u){E=[];const t=this.ge;for(let r=0;r<u.length;r++){const n=e<=1.6?u[r].id:u[r];if(!t[n]){E=null;break}E.push(this.Ne(t[n]))}}var B={refine:"REPLACE",boundingVolume:a,transform:h,geometricError:f};return e<=1.6?t.lodSelection?t.geometryData&&(B.content={uri:"i3s:mesh:"+(t.id||t.index)}):B.content={uri:"i3s:tileset:"+(t.id||t.index)}:u&&u.length&&!E?B.content={uri:"i3s:tileset:"+(t.id||t.index)}:n.mesh&&(B.content={uri:"i3s:mesh:"+(t.id||t.index)}),E&&E.length&&(B.children=E),B}getJSON(){return this.pe}}function $r(t,e,r,n){return Be(t,R(e),R(r),n)}const tn=!!Wr.ktx2,en=n.identity([]),rn=(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1})();function nn(t){return t.indexOf("i3s:mesh")>=0}const sn="i3s:mesh:".length;function on(t,e,r,n,i){const s=e.layerScene.eslpk,o=function(t,e){const r=e.substring(sn);return t>=1.7?parseInt(r):r}(e.version,t),a=e[o],A=e.layerScene.baseUrl,c=[];let l=!1;const f=en;let h,u;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;if(!t)return null;let r=A+`/nodes/${a.id}/`+a.geometryData[t-1].href;s&&(r+=".bin");const n={geometry:{url:r,info:e.layerScene.store.defaultGeometrySchema}};let i=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(i){const t=e.layerScene.store.textureEncoding[0];let r;r="image/jpeg"===t?"jpg":"png",s&&(i+="."+r);const o={pbrMetallicRoughness:{baseColorTexture:{url:A+`/nodes/${a.id}/`+i,factor:1,format:r,mimeType:t},metallicFactor:0}};n.material=o}c.push(n)}else{h=a.mesh.geometry,u=a.mesh.material;const t=e.layerScene.geometryDefinitions[h.definition],{geometryBuffers:o}=t;l=n&&2===o.length;const f=Wr.draco&&l?o[1]:o[0],E=Wr.draco&&l?1:0;let B=A+`/nodes/${h.resource}/geometries/`+E;s&&(B+=".bin");const _={geometry:{url:B,info:f}};if(i&&rn&&l&&!Wr.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const d=e.layerScene.materialDefinitions,C=e.layerScene.textureSetDefinitions;let T,m=0;if(u&&(m=d[u.definition]),d){T=function(t,e,r,n,i,s){const o=JSON.parse(JSON.stringify(t));return an(o,e,r,n,i,s),o}(m,C,A,u.resource,r,e.layerScene.eslpk)}else T={pbrMetallicRoughness:{metallicFactor:0}};_.material=T,c.push(_)}return{dracoCompression:l,meshes:c,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:f}}function an(t,e,r,n,i,s){for(const o in t)if(t[o]&&t[o].textureSetDefinitionId>=0){const a=e[t[o].textureSetDefinitionId],A="images/"+a.formats[0].format,c=An(a.formats,i),l={url:r+`/nodes/${n}/textures/${c.name}`,factor:void 0===t[o].factor?1:t[o].factor,format:c.format,mimeType:A};if(s){let t="";switch(c.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=c.format}l.url+="."+t}t[o]=l}else p(t[o])&&an(t[o],e,r,n,i,s)}function An(t,e){for(let r=0;r<=t.length;r++){const n=t[r].format;if("dds"===n&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[r];if("jpg"===n||"png"===n)return t[r];if("ktx2"===n&&tn)return t[r]}return null}const cn=[];class ln extends t.renderer.CanvasRenderer{constructor(t){super(t),this.prepareWorker(),this.tilesLoading={},this.tileCache=new ee(1024*t.options.maxGPUMemory*1024,this.deleteTile.bind(this)),this.Se={},this.Le=[],this.Ce=this.De.bind(this)}getAnalysisMeshes(){if(!this.painter)return cn;const t=this.painter.getPaintedMeshes();if(!t)return cn;const e=[],{b3dmMeshes:r,pntsMeshes:n,i3dmMeshes:i}=t;return r.length&&x(e,r),n.length&&x(e,n),i.length&&x(e,i),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.Le.length||super.needToRedraw())}getFrameTimestamp(){return this.Oe}drawOnInteracting(t,e,r){this.draw(e,r)}draw(t,e){this.Oe=t;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.Fe(),this.xe();const{selectedTiles:o,leaves:a,requests:A}=this.we(n,i);A.length&&this.loadTiles(A),this.ve(o,a,e),this.Ue(),A.length||this.completeRender()}we(t,e){const r=this.layer.getRootTiles();let n=[];this.Ge();let i=0;const s=this.He(),o={};let a=!1,A=!1;for(let t=0;t<e.length;t++){const s=e[t],c=s.node;if(o[c.id])continue;const l=r[c.St];o[c.id]=1;let f=!1;const h=this.getCachedTile(c.id);if(this.Ke(c.id)?(i++,f=A=!0,this.tilesLoading[c.id].current=!0):h?(this.getTileOpacity(h)<1&&(f=A=!0),(!s.node.Ve||l.isS3M||!s.node.children||s.node.Ve<=500)&&(a=!0,s.selected=!0,s.data=h)):this.painter.has(c)||(f=A=!0,n.push(c)),!f)continue;if(this.ke(s))a=!0;else{this.Xe(s).length&&(a=!0)}}let c=[],l={};if(a&&({selectedTiles:c,leaves:l}=this.Ye(t)),n.length>1&&(n.sort(fn),s)){const t=s-i;n=t>0?n.slice(0,t):[]}return{loading:A,requests:n,selectedTiles:c,leaves:l}}Ye(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.Je===i.length){s.pop(),t===n&&(t.leave=!0,r[t.node.id]=1),e.push(t);continue}}const t=i.pop(),o=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===o.length){t.leave=!0,r[t.node.id]=1,e.push(t);continue}s.push(t),t.Je=i.length}for(let t=0;t<o.length;t++)i.push(o[t])}return{selectedTiles:e,leaves:r}}ke(t){if(!t.parent)return null;let e=t.parent;for(;e&&e.level>=0;){const t=e.node.id;if(this.tileCache.has(t))return e.selected=!0,e.data=this.tileCache.get(t),e;e=e.parent}return null}Xe(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const r=t.Ot+1,n=[t.node];for(;n.length>0;){const i=n.pop().children;for(let s=0,o=i.length;s<o;s++){if((!i[s].content||!i[s].content.url)&&i[s].children&&i[s].children.length){n.push(i[s]);continue}const o=i[s].id;if(this.tileCache.has(o)){const r=this.layer.ze(i[s],t);r.selected=!0,r.data=this.tileCache.get(o),t.children.push(r),e.push(r)}else i[s].Ot<=r&&n.push(i[s])}}return e}ve(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=this.painter.paint(t,e,r);this.onDrawTileEnd(n),i&&this.layer.fire("canvasisdirty",{renderCount:i})}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(O(e)){const r=F(e);return void this.Ze(e,r,t)}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const r=t.St,n=this.We[r];return new qr(e,r,n,this.Ce).load().then((r=>{this.onTilesetLoad(r,t,e)}))}t&&-1===e.indexOf("http://")&&-1===e.indexOf("https://")&&!nn(e)&&(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=bt.getArrayBuffer(e+(n||""),r.fetchOptions);const s=i.xhr;i=i.then((r=>{delete this.Se[e],r?this.Ze(e,r.data,t):this.onTileError(null,t)})).catch((r=>{delete this.Se[e],this.onTileError(r,t)})),this.Se[e]=s}else this.Ze(e,null,t)}Ze(t,e,n){let i=this.o;i||(i=r.Util.getSupportedFormats(this.gl.gl||this.gl),this.o=i);const s=this.layer.options.services[n.St];s.isSuperMapiServer&&(t=function(t,e){const r=t.substring(e.length).split("/"),n=[];for(let t=0;t<r.length;t++)n.push(encodeURIComponent(r[t]));return e+n.join("/")}(t,n.baseUrl));const o={url:t=this.layer.getTileUrl(t,n.baseUrl,s),arraybuffer:e,rootIdx:n.St,upAxis:n.ee,transform:n.matrix,supportedFormats:i};if(nn(t)){const e=this.We[n.St];if(o.i3sInfo=on(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},n)}this.workerConn.loadTile(this.layer.getId(),o,((e,r)=>{if(e)return void this.onTileError(e,n);const{magic:i}=r;"b3dm"===i||"pnts"===i||"i3dm"===i||"cmpt"===i?this.Le.push({data:r,tile:n}):this.onTilesetLoad(r,n,t)}))}xe(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let r=0;for(;this.Le.length&&(r<e||!t.isInteracting());){const{data:t,tile:e}=this.Le.shift(),{magic:n}=t;"b3dm"===n?this.painter.createB3DMMesh(t,e.id,e,((r,{mesh:n})=>{this.je(t,e,r,n)})):"pnts"===n?this.painter.createPntsMesh(t,e.id,e,((r,{mesh:n})=>{this.je(t,e,r,n)})):"i3dm"===n?this.painter.createI3DMMesh(t,e.id,e,((r,{mesh:n})=>{this.je(t,e,r,n)})):"cmpt"===n&&this.painter.createCMPTMesh(t,e.id,e,((r,{mesh:n})=>{this.je(t,e,r,n)})),r++}}je(t,e,r,n){if(r)this.onTileError(r,e);else{const r=this.Qe(n);e.memorySize=r,this.onTileLoad(t,e)}}Qe(t){let e=0;if(Array.isArray(t))for(let r=0;r<t.length;r++)t[r]&&(e+=this.Qe(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.qe(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,r){this.layer&&(this.layer.ce=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.$e(t,e,r):(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.tr(e,t),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}tr(e,r){const n={loadTime:t.Util.now(),current:!0,error:r,node:e};this.tileCache.add(e.id,n)}qe(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.Se[e];t&&t.abort()}else this.workerConn.abortTileLoading(this.layer.getId(),e);delete this.Se[e]}Ge(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}createContext(){const t=this.layer,e=t.options.glOptions||{alpha:!0,depth:!0,stencil:!0,preserveDrawingBuffer:!0,antialias:t.options.antialias},r=this.canvas.gl&&this.canvas.gl.wrap;r?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.er(this.canvas,e)),this.regl=this.regl||c({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),r&&(this.canvas.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height)),this.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height),this.painter=new Jr(this.regl,t),this.layer.rr()}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new qt("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=m({},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.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.Ue(!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}Ue(t){this.nr||(this.nr=Date.now());const e=Date.now();if(t||!(e-this.nr<this.layer.options.retireInterval)){this.nr=e;for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||this.abortTileLoading(r)}}}He(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}er(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}Ke(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 xe(t,e,0,r)}Fe(){if(!this.ir)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const r=[];for(const n in this.ir){const i=this.ir[n];if("pending"===i.status)continue;i.status="pending";const s=i.rootIdx;if(r.push(bt.getJSON(n).then((t=>{delete this.ir[n];const e=this.We[s];if(e){t.nodes?jr(e,t.nodes):(e[t.id]=t,jr(e,t.children));for(let t=0;t<i.length;t++)i[t]();this.setToRedraw()}else this.setToRedraw()}))),e++,e>=t)break}r.length&&Promise.all(r)}De(t,e,r){this.ir||(this.ir={}),this.ir[e]=this.ir[e]||[],this.ir[e].rootIdx=t,this.ir[e].push(r),this.setToRedraw()}$e(t,e,r){this.We||(this.We=[]);const n=e.St;this.We[n]||(this.We[n]={});const i=this.We[n],s=this.layer.options.services[n];t.layers&&(t=t.layers[0],"/"!==r[r.length-1]&&(r+="/"),r+="layers/0"),i.version=+(s.i3sVersion||t.store.version),function(t,e,r,n,i,s){if(!i.layerScene){i.layerScene=t,i.nodesPerPage=t.nodePages&&t.nodePages.nodesPerPage||64,i.lodSelectionMetricType=t.nodePages&&t.nodePages.lodSelectionMetricType;let e=n;if(i.layerScene.eslpk=e.indexOf("3dSceneLayer.json")>=0,e.endsWith(".json")){const t=n.lastIndexOf("/");e=t<0?"./":n.substring(0,t)}i.layerScene.baseUrl=function(t){return t.split("?")[0]}(e)}return new qr(n,e,i,s).load()}(t,n,0,r,i,this.Ce).then((t=>{this.onTilesetLoad(t,e,r)}))}pick(t,e,r){return this.painter?this.painter.pick(t,e,r&&r.tolerance):[]}highlight(t){if(this.Lt||(this.Lt=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const r=t[e].service||0;let n=this.Lt[r];n||(n=this.Lt[r]=new Map),n.set(t[e].id,t[e])}else{const e=t.service||0;let r=this.Lt[e];r||(r=this.Lt[e]=new Map),r.set(t.id,t)}this.painter.highlight(this.Lt)}cancelHighlight(t,e){if(!this.Lt)return;const r=this.Lt[t];if(r){if(Array.isArray(e))for(let t=0;t<e.length;t++)r.delete(e[t]);else r.delete(e);this.painter.highlight(this.Lt)}}cancelAllHighlight(){delete this.Lt,this.painter.cancelAllHighlight()}_e(){return this.painter?this.painter._e():[]}}function fn(t,e){return t.Kt-e.Kt}function hn(t,e,r){return t[0]=e[r],t[1]=e[r+3],t[2]=e[r+6],t}function un(t,e,r){return Math.sqrt(function(t,e,r){var n=W(En,r,t),i=hn(Bn,e,0),s=hn(_n,e,1),o=hn(dn,e,2),a=nt(i),A=nt(s),c=nt(o);q(i,i),q(s,s),q(o,o);var l=Cn;l[0]=$(n,i),l[1]=$(n,s),l[2]=$(n,o);var f,h=0;l[0]<-a?h+=(f=l[0]+a)*f:l[0]>a&&(h+=(f=l[0]-a)*f);l[1]<-A?h+=(f=l[1]+A)*f:l[1]>A&&(h+=(f=l[1]-A)*f);l[2]<-c?h+=(f=l[2]+c)*f:l[2]>c&&(h+=(f=l[2]-c)*f);return h}(t,e,r))}const En=[],Bn=[],_n=[],dn=[],Cn=[];const Tn=2*Math.PI;class mn{constructor(t,e,r,n){this.west=t,this.south=e,this.east=r,this.north=n}static contains(t,e){var r=e[0],n=e[1],i=t.west,s=t.east;return s<i&&(s+=Tn,r<0&&(r+=Tn)),(r>i||Ne(r,i,1e-14))&&(r<s||Ne(r,s,1e-14))&&n>=t.south&&n<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const gn=[0,0,1];function pn(t,e){return Be(e,t[0],t[1],t[2])}class yn{constructor(t,e){this.normal=s.copy([],t),this.distance=e}static fromPointNormal(t,e,r){var n=-s.dot(e,t);return s.copy(r.normal,e),r.distance=n,r}}const Rn=[],In=[],bn=[],Pn=[],Mn=[],Nn=[],Sn=[],Ln=[],Dn=[],On=[],Fn=new yn([1,0,0],0),xn=[];class wn{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new mn(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){var r,n,i,o=0;if(!mn.contains(this.rectangle,e)){var a=this.southwestCornerCartesian,A=this.northeastCornerCartesian,c=this.westNormal,l=this.southNormal,f=this.eastNormal,h=this.northNormal,u=s.subtract(xn,t,a),E=s.dot(u,c),B=s.dot(u,l),_=s.subtract(xn,t,A),d=s.dot(_,f),C=s.dot(_,h);E>0?o+=E*E:d>0&&(o+=d*d),B>0?o+=B*B:C>0&&(o+=C*C)}if(r=e[2],n=this.minimumHeight,r>(i=this.maximumHeight)){var T=r-i;o+=T*T}else if(r<n){var m=n-r;o+=m*m}return Math.sqrt(o)}computeBox(t){const e=this;pn(mn.southwest(t,In),e.southwestCornerCartesian),pn(mn.northeast(t,In),e.northeastCornerCartesian),Rn[0]=t.west,Rn[1]=.5*(t.south+t.north),Rn[2]=0;var r=pn(Rn,bn),n=s.cross(Mn,r,gn);s.normalize(e.westNormal,n),Rn[0]=t.east;var i=pn(Rn,Ln),o=s.cross(Mn,gn,i);s.normalize(e.eastNormal,o);var a,A=s.subtract(Mn,r,i),c=s.normalize(Pn,A),l=t.south;if(l>0){Rn[0]=.5*(t.west+t.east),Rn[1]=l;var f=pn(Rn,Dn);s.copy(On,c);var h=yn.fromPointNormal(e.southwestCornerCartesian,e.westNormal,Fn);vn(Dn,On,h,e.southwestCornerCartesian),a=be(f,Nn)}else a=Pe(mn.southeast(t,In),Nn);var u=s.cross(Sn,a,A);s.normalize(e.southNormal,u);var E,B=t.north;if(B<0){Rn[0]=.5*(t.west+t.east),Rn[1]=B;var _=pn(Rn,Dn);s.scale(On,c,-1);var d=yn.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,Fn);vn(Dn,On,d,e.northeastCornerCartesian),E=be(_,Nn)}else E=Pe(mn.northwest(t,In),Nn);var C=s.cross(Sn,A,E);s.normalize(e.northNormal,C)}}function vn(t,e,r,n){var i=t,o=e,a=r.normal,A=s.dot(a,o);if(!(Math.abs(A)<1e-15)){var c=(-r.distance-s.dot(a,i))/A;if(!(c<0))return n=s.scale(n,o,c),s.add(n,i,n)}}const Un=new t.Extent(0,0,0,0),Gn=new t.Extent(0,0,0,0),Hn=[],Kn=[],Vn=[],kn=[],Xn=new t.Point(0,0),Yn=[],Jn=new t.Coordinate(0,0),zn=n.identity([]),Zn=[0,0];class Wn extends t.Layer{constructor(t,e){super(t,e),this.sr(),this.Se={},this.ar=[]}sr(){let t=this.options.services.map((t=>t.url));this.Ar=t.map(((t,e)=>function(t,e){t=b(t);return{visible:1,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:n.identity([]),St:e,Ot:0}}(t,e))),this.fire("rootready",{roots:this.Ar.slice(0)})}showService(t){return this.cr(t,1),this}hideService(t){return this.cr(t,0),this}setToRedraw(){const t=this.getRenderer();t&&t.setToRedraw()}cr(t,e){const r=this.Ar[t];if(!r)return;r.visible=e;const n=this.getRenderer();n&&n.setToRedraw()}getTileUrl(t){return t}getExtent(e){if(!e&&0!==e){const e=new t.Extent;for(let t=0;t<this.Ar.length;t++)if(this.Ar[t].boundingVolume){const r=this.boundingVolumeToExtent(this.Ar[t]);e._combine(r)}return e}return this.Ar[e]&&this.Ar[e].boundingVolume?this.boundingVolumeToExtent(this.Ar[e]):null}boundingVolumeToExtent(e){const r=e.boundingVolume.lr?zn:e.matrix,n=this.getMap();if(e.boundingVolume.region){const r=e.boundingVolume.region;return new t.Extent(I(r[0]),I(r[1]),I(r[2]),I(r[3]))}if(e.boundingVolume.sphere){const i=e.boundingVolume.sphere,o=ge([],s.transformMat4([],i,r)),a=i[3],A=n.locate(o,-a,a),c=n.locate(o,a,-a);return new t.Extent(A,c)}if(e.boundingVolume.box){const i=e.boundingVolume.box,a=s.transformMat4([],i,r),A=new t.Coordinate(ge([],a)),c=i.slice(3);o.multiply(c,o.fromMat4([],e.matrix),c);const l=s.length(c.slice(0,3)),f=s.length(c.slice(3,6)),h=s.length(c.slice(6,9)),u=Math.max(l,f,h),E=n.locate(A,-u,u),B=n.locate(A,u,-u);return new t.Extent(E,B)}return null}getRootTiles(){return this.Ar}getTiles(){const t=this.getRenderer();if(!t.ready)return this.hr(),{tiles:kn};const e=this.getMap(),r=e.cameraPosition;let n,i;if(e.getGLZoom)i=e.pointToDistance(r[2],0,e.getGLZoom()),Jn.set(r[0],r[1]),n=e.pointToCoord(Jn,e.getGLZoom());else{const t=e.getGLRes();i=e.pointAtResToDistance(r[2],0,t),Jn.set(r[0],r[1]),n=e.pointAtResToCoord(Jn,t)}this.ur=this.ur||[],s.set(this.ur,R(n.x),R(n.y),i),this.Er=Be(this.Er||[],this.ur[0],this.ur[1],this.ur[2]),this.Br=2*Math.tan(.5*R(e.getFov()));const o=e.projViewMatrix,a={children:[],level:-1};let A=a;const c=[];for(let e=0;e<this.Ar.length;e++){const r=this.Ar[e];if(!r.visible)continue;let n=1/0;const i=[r],s=this._r(e);for(;i.length>0;){const e=i.pop();for(e.id||this.dr(e);A.level>=e.Ot;)A=A.parent;const r=this.Cr(e,s,o);if(r<1){let t=A;for(;t&&!t.content;)t=t.parent;0===r&&t&&t.content&&this.Tr(c,t);if(!1===this.options.services[e.St].alwaysShow)continue;if(!(0===r&&e.Ot<=n))continue;e.content&&(n=e.Ot)}e.Kt<1/0&&this.mr(e);const a=this.ze(e,A);A.children.push(a);const l=e.children,f=l&&l.length,h=a.content;if(!f&&h&&this.Tr(c,a),f){h&&"add"===e.refine&&this.Tr(c,a),A=a;const r=l[0].parent;let n=!1;for(let s=0,o=l.length;s<o;s++){if(r){const e=t.getCachedTile(l[s].id);if(e&&e.error&&404!==e.error.status)continue;n=!0}else{n=!0,l[s].parent=e,l[s].ee=e.ee,l[s].baseUrl=e.baseUrl;const t=l[s].content&&(l[s].content.url||l[s].content.uri);t&&(O(t)||t.indexOf("i3s:")>=0?l[s].baseUrl=e.baseUrl:-1===t.indexOf("http://")&&-1===t.indexOf("https://")?l[s].content.url=e.baseUrl+t:l[s].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}i.push(l[s])}!n&&h&&this.Tr(c,a)}}}return{root:a,tiles:c}}Tr(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 jn(r,e);if(r.box)return 0===Qn(r,e)}return!1}(this.ur,this.Er,r)||t.push(e)}ze(t,e){return{id:t.id,node:t,children:[],level:t.Ot,parent:e,content:t.content&&t.content.url}}dr(e){e.id=t.Util.GUID(),e.matrix=e.transform||n.identity([]),e.gr=this.pr(e),e.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(e)||(e.matrix=n.multiply(e.matrix,e.parent.matrix,e.matrix)),e.St=e.parent.St,void 0===e.Ot&&(e.Ot=e.parent.Ot+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.yr(e)}yr(t){const e=t.boundingVolume;if(!e||e.lr)return;const r=this.options.services[t.St],i=r.heightOffset||0,o=this.options.offset,a=g(o)||o[0]||o[1],A=r.coordOffset||Zn;if(!Array.isArray(A))throw new Error("service.coordOffset must be an array");if(!t.boundingVolume||!i&&n.exactEquals(t.matrix,zn)&&!a&&A===Zn)return;const{region:c,box:l,sphere:f}=e;if(c){const t=this.Rr([I(c[0]),I(c[1])]);c[0]=R(t.x+A[0]),c[1]=R(t.y+A[1]);const e=this.Rr([I(c[2]),I(c[3])]);c[2]=R(e.x+A[0]),c[3]=R(e.y+A[1]),c[4]+=i+(A[2]||0),c[5]+=i+(A[2]||0)}else if(l||f){const e=l||f,r=s.transformMat4(Hn,e,t.matrix),n=ge(Kn,r),o=this.Rr([n[0]+A[0],n[1]+A[1]]);n[0]=o.x,n[1]=o.y,n[2]+=i+(A[2]||0),Be(e,R(n[0]),R(n[1]),n[2])}e.lr=!0}pr(t){return void 0===t.geometricError||!t.boundingVolume}mr(t){let e=t.parent;for(;e&&e.gr&&!(e.Kt<=t.Kt);)e.Kt=t.Kt,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=this.options.services[e.St],s=(t.asset&&t.asset.gltfUpAxis||e&&e.ee||i.upAxis||"Y").toUpperCase();t.root.baseUrl=r.substring(0,r.lastIndexOf("/")+1);const o=r.indexOf("realspace/")>-1;0===e.Ot&&(t.asset&&t.asset.s3mType&&o||i.isSuperMapiServer)&&(t.root.baseUrl+="data/path/");const a=t.asset.i3s,A=!!t.asset.s3mType;if(t.root.ee=s,e){const r=e.St,i=this.Ar[r];A&&!i.isS3M&&(i.isS3M=A);const s=e.boundingVolume;m(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",s&&(e.boundingVolume=s);const o=t.root.transform;o&&(e.parent?a||(e.matrix=n.multiply([],e.parent.matrix,o)):e.matrix=o),this.yr(e),e.Ir=e.content,delete e.content,t.root.content&&(e.content=t.root.content),e.gr=this.pr(e);const c=e.content&&(e.content.url||e.content.uri);c&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),a||!c||O(c)||-1!==c.indexOf("http://")||-1!==c.indexOf("https://")||(e.content.url=e.baseUrl+c)}this.hr(),this.fire("loadtileset",{tileset:t,index:e&&e.St,url:r})}Cr(t,e,r){if(t.Kt=1/0,0===t.Ot||t.gr)return 1;if(!this.br(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.Pr(t);return 0===i&&t.parent&&(i=.5*(t.parent.Ve||0)),i>=n?1:0}Zt(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)}br(e,r,i){const a=e.id;let A=this.ar[a];const{boundingVolume:c}=e,l=c.sphere;let h=c.region;const u=c.box;if(!A){let r,i,f;if(u&&(h=function(t,e){for(let e=0;e<9;e++)ai[e]=t[e+3];const r=ai;n.exactEquals(e,zn)||o.multiply(r,o.fromMat4(Yn,e),r);const i=s.copy(qn,t),a=s.set($n,r[0],r[1],r[2]),A=s.set(ti,r[3],r[4],r[5]),c=s.set(ei,r[6],r[7],r[8]);ri[0]=ri[0]||[];const l=s.copy(ri[0],i);s.sub(l,l,a),s.sub(l,l,A),s.sub(l,l,c),ri[1]=ri[1]||[];const f=s.copy(ri[1],i);s.sub(f,f,a),s.sub(f,f,A),s.add(f,f,c),ri[2]=ri[2]||[];const h=s.copy(ri[2],i);s.sub(h,h,a),s.add(h,h,A),s.sub(h,h,c),ri[3]=ri[3]||[];const u=s.copy(ri[3],i);s.sub(u,u,a),s.add(u,u,A),s.add(u,u,c),ri[4]=ri[4]||[];const E=s.copy(ri[4],i);s.add(E,E,a),s.sub(E,E,A),s.sub(E,E,c),ri[5]=ri[5]||[];const B=s.copy(ri[5],i);s.add(B,B,a),s.sub(B,B,A),s.add(B,B,c),ri[6]=ri[6]||[];const _=s.copy(ri[6],i);s.add(_,_,a),s.add(_,_,A),s.sub(_,_,c),ri[7]=ri[7]||[];const d=s.copy(ri[7],i);s.add(d,d,a),s.add(d,d,A),s.add(d,d,c);for(let t=0;t<ri.length;t++)ni[t]=ni[t]||[],ge(ni[t],ri[t]),ii[t]=ni[t][0],si[t]=ni[t][1],oi[t]=ni[t][2];return[R(Math.min(...ii)),R(Math.min(...si)),R(Math.max(...ii)),R(Math.max(...si)),Math.min(...oi),Math.max(...oi)]}(u,e.matrix),c.region=h),h){r=Un.set(I(h[0]),I(h[1]),I(h[2]),I(h[3]));const t=r.getCenter(),e=this.Mr(t);r=r.convertTo((t=>this.Zt(t,Xn)),Gn),f=h[4],i=h[5],A=this.ar[a]=[[r.xmin,r.ymin,f*e[2]],[r.xmax,r.ymax,i*e[2]]],A.center=t}else if(l){const e=ge(Hn,l),r=new t.Coordinate(e),n=this.Zt(r,Xn).toArray(),i=this.Mr(r);n.push(e[2]*i[2]),A=this.ar[a]=[n,l[3]*i[2]],A.center=r}}if(r){if(h)Un.xmin=A[0][0],Un.ymin=A[0][1],Un.xmax=A[1][0],Un.ymax=A[1][1];else if(l){const t=A[2];Un.xmin=A[0][0]-t,Un.ymin=A[0][1]-t,Un.xmax=A[0][0]+t,Un.ymax=A[0][1]+t}else if(u){const t=A[1],e=A[2];Un.xmin=A[0][0]-t,Un.ymin=A[0][1]-e,Un.xmax=A[0][0]+t,Un.ymax=A[0][1]+e}if(!r.intersects(Un))return!1}return h?E(i,A):l?function(t,e,r){_(t);for(var n=e[0],i=-e[1],s=0;s<6;s++)if((!r||"0"!==r.charAt(s))&&C(f[s],n)<i)return!1;return!0}(i,A):!!u&&function(t,e,r){_(t);for(var n=0;n<6;n++)if(!(r&&"0"===r.charAt(n)||B(f[n],e)))return!1;return!0}(i,A)}Mr(t){const e=this.getMap(),r=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let n;return n=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:r.y/100,s.set(Vn,r.x/100*1.01,r.y/100*1.01,n),Vn}Rr(e){Array.isArray(e)&&(e=new t.Coordinate(e));let r=this.options.offset;if(g(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}_r(e){const r=this.options.services[e].maxExtent;if(!r)return null;const n=this.Ar[e];return n.maxExtent||(n.maxExtent=new t.Extent(r).convertTo((t=>this.Zt(t)))),n.maxExtent}Pr(t){const e=this.Br,r=t.geometricError;if(0===r)return t.Ve=0,0;const n=this.getMap();let i;t.boundingVolume.region?i=function(t,e,r){t.Nr||(t.Nr=new wn(t.boundingVolume.region));return t.Nr.distanceToCamera(e,r)}(t,this.Er,this.ur):t.boundingVolume.sphere?i=jn(t.boundingVolume,this.Er):t.boundingVolume.box&&(i=Qn(t.boundingVolume,this.Er));const s=Math.max(Math.abs(i),1e-7),o=r*n.height/(s*e);return t.Kt=i,t.Ve=o,o}hr(){const t=this.getRenderer();t&&t.setToRedraw()}oe(t){return this.ar[t]}identify(e,r={}){const n=this.getMap(),i=this.getRenderer();if(!n||!i)return[];const s=n.coordToContainerPoint(new t.Coordinate(e));return this.identifyAtPoint(s,r)}identifyAtPoint(t,e={}){const r=this.getMap(),n=this.getRenderer();if(!r||!n)return[];const i=r.getDevicePixelRatio();return n.pick(t.x*i,t.y*i,e)}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e._e():[]}highlight(t){const e=this.getRenderer();return e?(e.highlight(t),this):(this.Lt||(this.Lt=[]),this.Lt.push(t),this)}rr(){if(this.Lt){for(let t=0;t<this.Lt.length;t++)this.highlight(this.Lt[t]);delete this.Lt}}cancelHighlight(t,e){const r=this.getRenderer();return r?(r.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}}function jn(t,e){const r=t.sphere,n=s.dist(r,e),i=t.sphere[3];return n<i?0:n-i}function Qn(t,e){const r=t.box;return un(s.set(Hn,r[0],r[1],r[2]),o.set(Yn,r[3],r[4],r[5],r[6],r[7],r[8],r[9],r[10],r[11]),e)}Wn.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,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!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]}),Wn.registerRenderer("gl",ln),Wn.registerJSONType("Geo3DTilesLayer");const qn=[],$n=[],ti=[],ei=[],ri=[],ni=[],ii=[],si=[],oi=[],ai=[];let Ai=null;function ci(){return Ai||(Ai={"image/crn":Wr.crn&&Wr.crn(),"image/ktx2":Wr.ktx2&&Wr.ktx2(),"image/cttf":Wr.ktx2&&Wr.ktx2(),"draco":Wr.draco&&Wr.draco()}),Ai}class li{constructor(t,e,r){this.i=t,this.Sr=e||Xt,this.o=r,this.Lr=ci()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.Dr(t,e,r,n,i)):bt.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.Dr(t,i,r,n)}))}Dr(t,e,r,n,i){const s=i&&i.maxTextureSize,o=this.Or(e,r,n,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),A=new this.Sr(a,o.glb,{transferable:!0,requestImage:this.i,decoders:this.Lr,supportedFormats:this.o,maxTextureSize:s});return A.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${r}-${n}`;const i=A.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}}))}Or(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),A=i.getUint32(16,!0),c=i.getUint32(20,!0),l=i.getUint32(24,!0),f=28+e;c>=570425344?(f-=8,o=a,c=A,l=0,a=0,A=0):l>=570425344&&(f-=4,o=c,c=a,l=A,a=0,A=0);const h=[t];let u,E,B;if(a>0?(u=De(t,f,a),f+=a,o=u.BATCH_LENGTH):u={"BATCH_LENGTH":o},A>0&&(f+=A),c>0&&(E=Oe(t,f,c),f+=c,l>0)){const e=Fe(0,f,l);B=t.slice(e.offset,e.offset+e.byteLength),f+=l,h.push(B)}const _=u.BATCH_LENGTH,d={};if(u&&u.BATCH_ID){d.BATCH_ID=we(u.BATCH_ID,t,undefined.offset,_);const e=d.BATCH_ID.array&&d.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:o,transferables:h,featureTable:u,batchTable:E,batchTableBin:B,b3dm:d,glb:{buffer:t,byteOffset:f,byteLength:i.byteLength+i.byteOffset-f}}}Fr(){return null}}class fi{constructor(t,e,r,n){this.i=t,this.Sr=e||Xt,this.o=r,this.Lr=ci(),this.wr=n}load(t,e,r=0,n=0,i){return e?(n||(n=e.byteLength),this.Dr(t,e,r,n,i)):bt.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.Dr(t,i,r,n)}))}Dr(t,e,r,n,i){return this.vr(t,e,r,n,i).then((({gltf:i,transferables:s})=>{const o=this.Ur(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})}))}vr(t,e,r,n,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.i,decoders:this.Lr,supportedFormats:this.o,maxTextureSize:s},a=new DataView(e,r,n),A=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=N(new Uint8Array(e,A+r,a.byteLength-A));-1==n.indexOf("://")&&(n=t.substring(0,t.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?bt.getArrayBuffer(n,{}).then((t=>this.Gr(n,{buffer:t.data,byteOffset:0},o))):bt.getJSON(n,{}).then((t=>this.Gr(n,t,o)))}{const n={buffer:e,byteOffset:A+r,byteLength:a.byteLength-A};return this.Gr(t,n,o)}}Gr(t,e,r){const n=t.substring(0,t.lastIndexOf("/")),i=new this.Sr(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}}))}Ur(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:A,batchTable:c,batchTableBin:l}=Xe(i,32+e,o),f={},h=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+A.offset,3*h).slice()},o.push(f.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,r=a.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=a.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.Hr(new Uint16Array(t,n+A.offset,3*h),e,r)},o.push(f.POSITION.array.buffer)}if(a.BATCH_ID){f.BATCH_ID=we(a.BATCH_ID,t,A.offset,h);const e=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+A.offset,3*h).slice()},o.push(f.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+A.offset,3*h).slice()},o.push(f.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.Kr(new Uint16Array(t,e+A.offset,2*h))},o.push(f.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.Kr(new Uint16Array(t,e+A.offset,2*h))},o.push(f.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+A.offset,h).slice()},o.push(f.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;f.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+A.offset,3*h).slice()},o.push(f.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:c,batchTableBin:l,featureTable:a,i3dm:f,transferables:o}}Kr(t){const e=t.length/2,r=new Float32Array(3*e),n=[];for(let i=0;i<e;i++)hi(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}Hr(t,e,r){return ke(new Float32Array(t.length),t,e,r)}Fr(){return null}}function hi(t,e,r,n){if(t[0]=ui(e,n),t[1]=ui(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]))*Ei(e),t[1]=(1-Math.abs(e))*Ei(t[1])}return q(t,t)}function ui(t,e){return e=function(t,e){if(null!=t)return t;return e}(e,255),function(t,e,r){return t<e?e:t>r?r:t}(t,0,e)/e*2-1}function Ei(t){return t<0?-1:1}class Bi{constructor(){}load(t,e,r=0,n=0){return e?(n||(n=e.byteLength),this.Dr(t,e,r,n)):bt.getArrayBuffer(t,{}).then((e=>{const i=e.data;return n||(n=i.byteLength),this.Dr(t,i,r,n)}))}Dr(t,e,r,n){return this.Vr(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}))}Vr(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:A,batchTable:c,batchTableBin:l}=Xe(i,e+28,o),f=a.QUANTIZED_VOLUME_OFFSET,h=a.QUANTIZED_VOLUME_SCALE,u=a.POINTS_LENGTH;let E,B={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){B=a.extensions["3DTILES_draco_point_compression"],E=new DataView(t,B.byteOffset+A.offset,B.byteLength);const e={attributes:B.properties,useUniqueIDs:!1};return this.kr||(this.kr=ci().draco),this.kr(E,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.Xr(t,e.attributes,A.offset,u,o,f,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:Ve(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(c).length){a.BATCH_ID?n.BATCH_ID=we(a.BATCH_ID,t,A.offset,u):n.BATCH_ID=_i(u);const e=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:u,batchTable:c,batchTableBin:l,featureTable:a,pnts:n,transferables:o}}))}const _=this.Xr(t,a,A.offset,u,o,f,h);if(a.BATCH_ID||Object.keys(c).length){a.BATCH_ID?_.BATCH_ID=we(a.BATCH_ID,t,A.offset,u):_.BATCH_ID=_i(u);const e=_.BATCH_ID.array&&_.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:u,batchTable:c,batchTableBin:l,featureTable:a,pnts:_,transferables:o})}Xr(t,e,r,n,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const A=o?0:r;if(!o){const e=t.slice(s+A,s+A+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:A,array:c}=e.POSITION_QUANTIZED;A=A||0;const l=c?0:r;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this.Hr(c||new Uint16Array(t,A+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 A=o?0:r;if(!o){const e=t.slice(s+A,s+A+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 A=o?0:r;if(!o){const e=t.slice(s+A,s+A+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 A=o?0:r;if(!o){const e=t.slice(s+A,s+A+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 A=o?0:r;if(!o){const e=t.slice(s+A,s+A+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 A=o?0:r;if(!o){const e=t.slice(s+A,s+A+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}Hr(t,e,r){return ke(new Float32Array(t.length),t,e,r)}Fr(){return null}}function _i(t){const e=D(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 di{constructor(t,e,r,n){this.o=r,this.i=t,this.Sr=e||Xt,this.wr=n}load(t,e,r=0,n=0,i){return e?this.Dr(t,e,r,n,i):bt.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.Dr(t,i,r,n)}))}Dr(t,e,r,n,i){n||(n=e.byteLength);const s=this.Yr(e,t,r,n),o=[];for(let r=0;r<s.length;r++){let n;if("b3dm"===s[r].magic)n=new li(this.i,this.Sr,this.o);else if("i3dm"===s[r].magic)n=new fi(this.i,this.Sr,this.o,this.wr);else if("pnts"===s[r].magic)n=new Bi;else{if("cmpt"!==s[r].magic){console.warn("Unsupported magic in CMPT tile:",s[r].magic);continue}n=new di(this.i,this.Sr,this.o,this.wr)}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})))}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 o=[],a=i.getUint32(12,!0);let A=16;for(let e=0;e<a;e++){const e=Se(i,A),n=i.getUint32(A+8,!0);o.push({magic:e,buffer:t,offset:A+r,byteLength:n}),A+=n}return o}}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(l);t.registerWorkerAdapter("@maptalks/3dtiles",r)}else t.registerWorkerAdapter("@maptalks/3dtiles",(function(){return e.transcoders.inject(l)}))}else t.registerWorkerAdapter("@maptalks/3dtiles",l);export{li as B3DMLoader,di as CMPTLoader,Wn as Geo3DTilesLayer,w as Geo3DTilesUtil,Me as Geo3DTransform};"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.23.0");
|